Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def load_arguments(self, _):
c.argument('logical_sector_size', type=int, help='Logical sector size in bytes for Ultra disks. Supported values are 512 ad 4096. 4096 is the default.')
c.argument('tier', help='Performance tier of the disk (e.g, P4, S10) as described here: https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra disks.')
c.argument('edge_zone', edge_zone_type)
c.argument('security_type', choices=['TrustedLaunch'], help='The security type of the VM. Applicable for OS disks only.', min_api='2020-12-01')
c.argument('support_hibernation', arg_type=get_three_state_flag(), help='Indicate the OS on a disk supports hibernation.', min_api='2020-12-01')
# endregion

# region Snapshots
Expand Down
12 changes: 8 additions & 4 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
image_reference=None, image_reference_lun=None,
gallery_image_reference=None, gallery_image_reference_lun=None,
network_access_policy=None, disk_access=None, logical_sector_size=None,
tier=None, enable_bursting=None, edge_zone=None):
tier=None, enable_bursting=None, edge_zone=None, security_type=None, support_hibernation=None):
from msrestazure.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id

Expand Down Expand Up @@ -376,7 +376,7 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
sku=_get_sku_object(cmd, sku), disk_size_gb=size_gb, os_type=os_type, encryption=encryption)

if hyper_v_generation:
disk.hyper_vgeneration = hyper_v_generation
disk.hyper_v_generation = hyper_v_generation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there are still many unnoticed but ubiquitous attribute/model/function-name error caused by track2 upgrading.
Is it necessary to check them thoroughly in advance rather than fix them after issues raising?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. It is a disadvantage of dynamic language. We can't detect the error until runtime.


if zone:
disk.zones = zone
Expand All @@ -398,8 +398,12 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
disk.tier = tier
if enable_bursting is not None:
disk.bursting_enabled = enable_bursting
if edge_zone:
if edge_zone is not None:
disk.extended_location = edge_zone
if security_type is not None:
disk.security_profile = {'securityType': security_type}
if support_hibernation is not None:
disk.supports_hibernation = support_hibernation

client = _compute_client_factory(cmd.cli_ctx)
return sdk_no_wait(no_wait, client.disks.begin_create_or_update, resource_group_name, disk_name, disk)
Expand Down Expand Up @@ -585,7 +589,7 @@ def create_snapshot(cmd, resource_group_name, snapshot_name, location=None, size
sku=_get_sku_object(cmd, sku), disk_size_gb=size_gb, incremental=incremental,
encryption=encryption)
if hyper_v_generation:
snapshot.hyper_vgeneration = hyper_v_generation
snapshot.hyper_v_generation = hyper_v_generation
if network_access_policy is not None:
snapshot.network_access_policy = network_access_policy
if disk_access is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- disk create
Connection:
- keep-alive
ParameterSetName:
- -g -n --size-gb --support-hibernation
User-Agent:
- python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.3
azure-mgmt-resource/12.1.0 Azure-SDK-For-Python AZURECLI/2.22.0
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_disk_hibernation_000001?api-version=2020-10-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_hibernation_000001","name":"cli_test_disk_hibernation_000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2021-04-20T05:39:09Z"},"properties":{"provisioningState":"Succeeded"}}'
headers:
cache-control:
- no-cache
content-length:
- '428'
content-type:
- application/json; charset=utf-8
date:
- Tue, 20 Apr 2021 05:39:12 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
- request:
body: '{"location": "westus", "tags": {}, "sku": {"name": "Premium_LRS"}, "properties":
{"creationData": {"createOption": "Empty"}, "diskSizeGB": 10, "supportsHibernation":
true}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- disk create
Connection:
- keep-alive
Content-Length:
- '172'
Content-Type:
- application/json
ParameterSetName:
- -g -n --size-gb --support-hibernation
User-Agent:
- AZURECLI/2.22.0 azsdk-python-azure-mgmt-compute/20.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_hibernation_000001/providers/Microsoft.Compute/disks/d1?api-version=2020-12-01
response:
body:
string: "{\r\n \"name\": \"d1\",\r\n \"location\": \"westus\",\r\n \"tags\":
{},\r\n \"sku\": {\r\n \"name\": \"Premium_LRS\"\r\n },\r\n \"properties\":
{\r\n \"supportsHibernation\": true,\r\n \"creationData\": {\r\n \"createOption\":
\"Empty\"\r\n },\r\n \"diskSizeGB\": 10,\r\n \"provisioningState\":
\"Updating\",\r\n \"isArmResource\": true\r\n }\r\n}"
headers:
azure-asyncoperation:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/9504fd49-3f8b-48f4-b1d8-d97d3f8d71e0?api-version=2020-12-01
cache-control:
- no-cache
content-length:
- '314'
content-type:
- application/json; charset=utf-8
date:
- Tue, 20 Apr 2021 05:39:16 GMT
expires:
- '-1'
location:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/9504fd49-3f8b-48f4-b1d8-d97d3f8d71e0?monitor=true&api-version=2020-12-01
pragma:
- no-cache
server:
- Microsoft-HTTPAPI/2.0
- Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-resource:
- Microsoft.Compute/CreateUpdateDisks3Min;999,Microsoft.Compute/CreateUpdateDisks30Min;7992
x-ms-ratelimit-remaining-subscription-writes:
- '1199'
status:
code: 202
message: Accepted
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
CommandName:
- disk create
Connection:
- keep-alive
ParameterSetName:
- -g -n --size-gb --support-hibernation
User-Agent:
- AZURECLI/2.22.0 azsdk-python-azure-mgmt-compute/20.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/DiskOperations/9504fd49-3f8b-48f4-b1d8-d97d3f8d71e0?api-version=2020-12-01
response:
body:
string: "{\r\n \"startTime\": \"2021-04-20T05:39:17.2214047+00:00\",\r\n \"endTime\":
\"2021-04-20T05:39:17.3620232+00:00\",\r\n \"status\": \"Succeeded\",\r\n
\ \"properties\": {\r\n \"output\": {\r\n \"name\": \"d1\",\r\n \"id\":
\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_hibernation_000001/providers/Microsoft.Compute/disks/d1\",\r\n
\ \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"westus\",\r\n
\ \"tags\": {},\r\n \"sku\": {\r\n \"name\": \"Premium_LRS\",\r\n \"tier\":
\"Premium\"\r\n },\r\n \"properties\": {\r\n \"supportsHibernation\":
true,\r\n \"creationData\": {\r\n \"createOption\": \"Empty\"\r\n
\ },\r\n \"diskSizeGB\": 10,\r\n \"diskIOPSReadWrite\": 120,\r\n \"diskMBpsReadWrite\":
25,\r\n \"encryption\": {\r\n \"type\": \"EncryptionAtRestWithPlatformKey\"\r\n
\ },\r\n \"timeCreated\": \"2021-04-20T05:39:17.2214047+00:00\",\r\n
\ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"Unattached\",\r\n
\ \"diskSizeBytes\": 10737418240,\r\n \"uniqueId\": \"67ccf1b4-0154-4ba5-a4d9-26494bb0c221\",\r\n
\ \"networkAccessPolicy\": \"AllowAll\",\r\n \"tier\": \"P3\"\r\n }\r\n}\r\n
\ },\r\n \"name\": \"9504fd49-3f8b-48f4-b1d8-d97d3f8d71e0\"\r\n}"
headers:
cache-control:
- no-cache
content-length:
- '1145'
content-type:
- application/json; charset=utf-8
date:
- Tue, 20 Apr 2021 05:39:19 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-HTTPAPI/2.0
- Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-resource:
- Microsoft.Compute/GetOperation3Min;49996,Microsoft.Compute/GetOperation30Min;399964
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
CommandName:
- disk create
Connection:
- keep-alive
ParameterSetName:
- -g -n --size-gb --support-hibernation
User-Agent:
- AZURECLI/2.22.0 azsdk-python-azure-mgmt-compute/20.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_hibernation_000001/providers/Microsoft.Compute/disks/d1?api-version=2020-12-01
response:
body:
string: "{\r\n \"name\": \"d1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_hibernation_000001/providers/Microsoft.Compute/disks/d1\",\r\n
\ \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"westus\",\r\n
\ \"tags\": {},\r\n \"sku\": {\r\n \"name\": \"Premium_LRS\",\r\n \"tier\":
\"Premium\"\r\n },\r\n \"properties\": {\r\n \"supportsHibernation\":
true,\r\n \"creationData\": {\r\n \"createOption\": \"Empty\"\r\n
\ },\r\n \"diskSizeGB\": 10,\r\n \"diskIOPSReadWrite\": 120,\r\n \"diskMBpsReadWrite\":
25,\r\n \"encryption\": {\r\n \"type\": \"EncryptionAtRestWithPlatformKey\"\r\n
\ },\r\n \"timeCreated\": \"2021-04-20T05:39:17.2214047+00:00\",\r\n
\ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"Unattached\",\r\n
\ \"diskSizeBytes\": 10737418240,\r\n \"uniqueId\": \"67ccf1b4-0154-4ba5-a4d9-26494bb0c221\",\r\n
\ \"networkAccessPolicy\": \"AllowAll\",\r\n \"tier\": \"P3\"\r\n }\r\n}"
headers:
cache-control:
- no-cache
content-length:
- '920'
content-type:
- application/json; charset=utf-8
date:
- Tue, 20 Apr 2021 05:39:19 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-HTTPAPI/2.0
- Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-resource:
- Microsoft.Compute/LowCostGet3Min;4998,Microsoft.Compute/LowCostGet30Min;39968
status:
code: 200
message: OK
version: 1
Loading