diff --git a/src/azure-cli/azure/cli/command_modules/vm/_params.py b/src/azure-cli/azure/cli/command_modules/vm/_params.py index 9eaacfc82ec..63093f4a57d 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_params.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_params.py @@ -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 diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index c49171dea08..d24e8685b2a 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -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 @@ -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 if zone: disk.zones = zone @@ -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) @@ -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: diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_hibernation.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_hibernation.yaml new file mode 100644 index 00000000000..28afc492351 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_hibernation.yaml @@ -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 diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_trusted_launch.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_trusted_launch.yaml new file mode 100644 index 00000000000..fb5d911625e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_disk_trusted_launch.yaml @@ -0,0 +1,303 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - disk create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image-reference --hyper-v-generation --security-type + 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.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_disk_trusted_launch_000001?api-version=2020-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_disk_trusted_launch_000001","name":"cli_test_disk_trusted_launch_000001","type":"Microsoft.Resources/resourceGroups","location":"southcentralus","tags":{"product":"azurecli","cause":"automation","date":"2021-04-21T08:56:28Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '436' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 21 Apr 2021 08:56:32 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: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - disk create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image-reference --hyper-v-generation --security-type + User-Agent: + - AZURECLI/2.22.1 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/southcentralus/publishers/Canonical/artifacttypes/vmimage/offers/UbuntuServer/skus/18_04-lts-gen2/versions/18.04.202004290?api-version=2020-12-01 + response: + body: + string: "{\r\n \"properties\": {\r\n \"hyperVGeneration\": \"V2\",\r\n \"replicaType\": + \"Unmanaged\",\r\n \"disallowed\": {\r\n \"vmDiskType\": \"Unmanaged\"\r\n + \ },\r\n \"automaticOSUpgradeProperties\": {\r\n \"automaticOSUpgradeSupported\": + false\r\n },\r\n \"imageAttributes\": [\r\n {\r\n \"Key\": + \"SecurityType\",\r\n \"Value\": \"TrustedLaunchSupported\"\r\n }\r\n + \ ],\r\n \"features\": [\r\n {\r\n \"name\": \"SecurityType\",\r\n + \ \"value\": \"TrustedLaunchSupported\"\r\n }\r\n ],\r\n \"osDiskImage\": + {\r\n \"operatingSystem\": \"Linux\",\r\n \"sizeInGb\": 31,\r\n + \ \"sizeInBytes\": 32213303808\r\n },\r\n \"dataDiskImages\": []\r\n + \ },\r\n \"location\": \"southcentralus\",\r\n \"name\": \"18.04.202004290\",\r\n + \ \"id\": \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/southcentralus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18_04-lts-gen2/Versions/18.04.202004290\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '929' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 21 Apr 2021 08:56:33 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/GetVMImageFromLocation3Min;12999,Microsoft.Compute/GetVMImageFromLocation30Min;73997 + status: + code: 200 + message: OK +- request: + body: '{"location": "southcentralus", "tags": {}, "sku": {"name": "Premium_LRS"}, + "properties": {"hyperVGeneration": "V2", "creationData": {"createOption": "FromImage", + "imageReference": {"id": "/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/southcentralus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18_04-lts-gen2/Versions/18.04.202004290"}}, + "securityProfile": {"securityType": "TrustedLaunch"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - disk create + Connection: + - keep-alive + Content-Length: + - '459' + Content-Type: + - application/json + ParameterSetName: + - -g -n --image-reference --hyper-v-generation --security-type + User-Agent: + - AZURECLI/2.22.1 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_trusted_launch_000001/providers/Microsoft.Compute/disks/d1?api-version=2020-12-01 + response: + body: + string: "{\r\n \"name\": \"d1\",\r\n \"location\": \"southcentralus\",\r\n + \ \"tags\": {},\r\n \"associatedXStoreEntities\": [\r\n {\r\n \"id\": + \"7d4839714527437cb0bedd2c1ab5c19b\",\r\n \"type\": \"VmgsBlob\",\r\n + \ \"name\": \"7d4839714527437cb0bedd2c1ab5c19b_vmgs\",\r\n \"accessibleExternally\": + false,\r\n \"alignWithDisk\": true,\r\n \"deleteOnDetach\": false,\r\n + \ \"pseudoSubscriptionId\": \"00000000-0000-0000-0000-000000000000\",\r\n + \ \"sizeInBytes\": 0\r\n }\r\n ],\r\n \"sku\": {\r\n \"name\": + \"Premium_LRS\"\r\n },\r\n \"properties\": {\r\n \"osType\": \"Linux\",\r\n + \ \"hyperVGeneration\": \"V2\",\r\n \"creationData\": {\r\n \"createOption\": + \"FromImage\",\r\n \"imageReference\": {\r\n \"id\": \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/southcentralus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18_04-lts-gen2/Versions/18.04.202004290\"\r\n + \ }\r\n },\r\n \"provisioningState\": \"Updating\",\r\n \"isArmResource\": + true,\r\n \"securityProfile\": {\r\n \"securityType\": \"TrustedLaunch\"\r\n + \ }\r\n }\r\n}" + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/southcentralus/DiskOperations/99df7577-7738-4c63-a84e-510d44890088?api-version=2020-12-01 + cache-control: + - no-cache + content-length: + - '1044' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 21 Apr 2021 08:56:38 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/southcentralus/DiskOperations/99df7577-7738-4c63-a84e-510d44890088?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;7998 + x-ms-ratelimit-remaining-subscription-writes: + - '1196' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - disk create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image-reference --hyper-v-generation --security-type + User-Agent: + - AZURECLI/2.22.1 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/southcentralus/DiskOperations/99df7577-7738-4c63-a84e-510d44890088?api-version=2020-12-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-04-21T08:56:38.8230894+00:00\",\r\n \"endTime\": + \"2021-04-21T08:56:39.9168044+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_trusted_launch_000001/providers/Microsoft.Compute/disks/d1\",\r\n + \ \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"southcentralus\",\r\n + \ \"tags\": {},\r\n \"sku\": {\r\n \"name\": \"Premium_LRS\",\r\n \"tier\": + \"Premium\"\r\n },\r\n \"properties\": {\r\n \"osType\": \"Linux\",\r\n + \ \"hyperVGeneration\": \"V2\",\r\n \"creationData\": {\r\n \"createOption\": + \"FromImage\",\r\n \"imageReference\": {\r\n \"id\": \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/southcentralus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18_04-lts-gen2/Versions/18.04.202004290\"\r\n + \ }\r\n },\r\n \"diskSizeGB\": 30,\r\n \"diskIOPSReadWrite\": + 120,\r\n \"diskMBpsReadWrite\": 25,\r\n \"encryption\": {\r\n \"type\": + \"EncryptionAtRestWithPlatformKey\"\r\n },\r\n \"timeCreated\": \"2021-04-21T08:56:38.8387077+00:00\",\r\n + \ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"Unattached\",\r\n + \ \"diskSizeBytes\": 32213303296,\r\n \"uniqueId\": \"229bde8b-af41-4fce-92f8-960d2e37d48b\",\r\n + \ \"networkAccessPolicy\": \"AllowAll\",\r\n \"securityProfile\": {\r\n + \ \"securityType\": \"TrustedLaunch\"\r\n },\r\n \"tier\": \"P4\"\r\n + \ }\r\n}\r\n },\r\n \"name\": \"99df7577-7738-4c63-a84e-510d44890088\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1518' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 21 Apr 2021 08:56:41 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;49999,Microsoft.Compute/GetOperation30Min;399989 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - disk create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image-reference --hyper-v-generation --security-type + User-Agent: + - AZURECLI/2.22.1 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_trusted_launch_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_trusted_launch_000001/providers/Microsoft.Compute/disks/d1\",\r\n + \ \"type\": \"Microsoft.Compute/disks\",\r\n \"location\": \"southcentralus\",\r\n + \ \"tags\": {},\r\n \"sku\": {\r\n \"name\": \"Premium_LRS\",\r\n \"tier\": + \"Premium\"\r\n },\r\n \"properties\": {\r\n \"osType\": \"Linux\",\r\n + \ \"hyperVGeneration\": \"V2\",\r\n \"creationData\": {\r\n \"createOption\": + \"FromImage\",\r\n \"imageReference\": {\r\n \"id\": \"/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/southcentralus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18_04-lts-gen2/Versions/18.04.202004290\"\r\n + \ }\r\n },\r\n \"diskSizeGB\": 30,\r\n \"diskIOPSReadWrite\": + 120,\r\n \"diskMBpsReadWrite\": 25,\r\n \"encryption\": {\r\n \"type\": + \"EncryptionAtRestWithPlatformKey\"\r\n },\r\n \"timeCreated\": \"2021-04-21T08:56:38.8387077+00:00\",\r\n + \ \"provisioningState\": \"Succeeded\",\r\n \"diskState\": \"Unattached\",\r\n + \ \"diskSizeBytes\": 32213303296,\r\n \"uniqueId\": \"229bde8b-af41-4fce-92f8-960d2e37d48b\",\r\n + \ \"networkAccessPolicy\": \"AllowAll\",\r\n \"securityProfile\": {\r\n + \ \"securityType\": \"TrustedLaunch\"\r\n },\r\n \"tier\": \"P4\"\r\n + \ }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1293' + content-type: + - application/json; charset=utf-8 + date: + - Wed, 21 Apr 2021 08:56:41 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;14999,Microsoft.Compute/LowCostGet30Min;119989 + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py index f8ad41bc0be..69c1eb871a6 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py @@ -5156,7 +5156,7 @@ class VMTrustedLaunchScenarioTest(ScenarioTest): @unittest.skip('Not supported') @ResourceGroupPreparer(name_prefix='cli_test_vm_trusted_launch_', location='southcentralus') def test_vm_trusted_launch(self, resource_group): - self.cmd('vm create -g {rg} -n vm --image Win2019Datacenter --security-type TrustedLaunch --enable-secure-boot true --enable-vtpm true --admin-username azureuser --admin-password testPassword0 --nsg-rule None') + self.cmd('vm create -g {rg} -n vm --image Canonical:UbuntuServer:18_04-lts-gen2:18.04.202004290 --security-type TrustedLaunch --enable-secure-boot true --enable-vtpm true --admin-username azureuser --admin-password testPassword0 --nsg-rule None') self.cmd('vm show -g {rg} -n vm', checks=[ self.check('securityProfile.securityType', 'TrustedLaunch'), self.check('securityProfile.UefiSettings.secureBootEnabled', True), @@ -5166,7 +5166,7 @@ def test_vm_trusted_launch(self, resource_group): @unittest.skip('Not supported') @ResourceGroupPreparer(name_prefix='cli_test_vm_trusted_launch_update_', location='southcentralus') def test_vm_trusted_launch_update(self, resource_group): - self.cmd('vm create -g {rg} -n vm --image Win2019Datacenter --security-type TrustedLaunch --admin-username azureuser --admin-password testPassword0 --nsg-rule None') + self.cmd('vm create -g {rg} -n vm --image Canonical:UbuntuServer:18_04-lts-gen2:18.04.202004290 --security-type TrustedLaunch --admin-username azureuser --admin-password testPassword0 --nsg-rule None') self.cmd('vm update -g {rg} -n vm --enable-secure-boot true --enable-vtpm true') self.cmd('vm show -g {rg} -n vm', checks=[ self.check('securityProfile.securityType', 'TrustedLaunch'), @@ -5174,6 +5174,21 @@ def test_vm_trusted_launch_update(self, resource_group): self.check('securityProfile.UefiSettings.vTpmEnabled', True) ]) + # @unittest.skip('Service does not work') + @ResourceGroupPreparer(name_prefix='cli_test_disk_trusted_launch_', location='southcentralus') + def test_disk_trusted_launch(self): + self.cmd('disk create -g {rg} -n d1 --image-reference Canonical:UbuntuServer:18_04-lts-gen2:18.04.202004290 --hyper-v-generation V2 --security-type TrustedLaunch', checks=[ + self.check('securityProfile.securityType', 'TrustedLaunch') + ]) + + +class DiskHibernationScenarioTest(ScenarioTest): + @ResourceGroupPreparer(name_prefix='cli_test_disk_hibernation_') + def test_disk_hibernation(self): + self.cmd('disk create -g {rg} -n d1 --size-gb 10 --support-hibernation true', checks=[ + self.check('supportsHibernation', True) + ]) + class VMCreateCountScenarioTest(ScenarioTest): @ResourceGroupPreparer(name_prefix='cli_test_vm_create_count_', location='eastus')