diff --git a/src/azure-cli/azure/cli/command_modules/vm/_help.py b/src/azure-cli/azure/cli/command_modules/vm/_help.py index cded0161af2..941a2301e5e 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_help.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_help.py @@ -629,6 +629,14 @@ text: | az ppg create --name MyProximityPlacementGroup --resource-group MyResourceGroup crafted: true + - name: Create a proximity placement group with specifying VM sizes that can be created. + text: | + az ppg create --name MyProximityPlacementGroup --resource-group MyResourceGroup \\ + --intent-vm-sizes Standard_E64s_v4 Standard_M416ms_v2 + - name: Create a proximity placement group with specifying VM sizes that can be created and availability zone. + text: | + az ppg create --name MyProximityPlacementGroup --resource-group MyResourceGroup \\ + --intent-vm-sizes Standard_E64s_v4 Standard_M416ms_v2 --zone 1 """ helps['ppg list'] = """ @@ -654,6 +662,11 @@ helps['ppg update'] = """ type: command short-summary: Update a proximity placement group +examples: + - name: Update a proximity placement group with specifying VM sizes that can be created. + text: | + az ppg update --name MyProximityPlacementGroup --resource-group MyResourceGroup \\ + --intent-vm-sizes Standard_E64s_v4 Standard_M416ms_v2 """ helps['sig'] = """ 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 93f279802a9..31d3da37e8c 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_params.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_params.py @@ -1408,9 +1408,14 @@ def load_arguments(self, _): with self.argument_context('ppg', min_api='2018-04-01') as c: c.argument('proximity_placement_group_name', arg_type=name_arg_type, help="The name of the proximity placement group.") - with self.argument_context('ppg create', min_api='2018-04-01') as c: - c.argument('ppg_type', options_list=['--type', '-t'], help="The type of the proximity placement group. Allowed values: Standard.") - c.argument('tags', tags_type) + with self.argument_context('ppg create') as c: + c.argument('ppg_type', options_list=['--type', '-t'], min_api='2018-04-01', help="The type of the proximity placement group. Allowed values: Standard.") + c.argument('tags', tags_type, min_api='2018-04-01') + c.argument('zone', zone_type, min_api='2021-11-01') + + for scope in ['ppg create', 'ppg update']: + with self.argument_context(scope) as c: + c.argument('intent_vm_sizes', nargs='*', min_api='2021-11-01', help="Specify possible sizes of virtual machines that can be created in the proximity placement group.") with self.argument_context('ppg show', min_api='2019-07-01') as c: c.argument('include_colocation_status', action='store_true', help='Enable fetching the colocation status of all the resources in the proximity placement group.') diff --git a/src/azure-cli/azure/cli/command_modules/vm/_validators.py b/src/azure-cli/azure/cli/command_modules/vm/_validators.py index 68c09ba6d8e..76bfcc6cacd 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_validators.py @@ -2129,6 +2129,17 @@ def _disk_encryption_set_format(cmd, namespace, name): # endregion +def process_ppg_create_namespace(namespace): + """ + The availability zone can be provided only when an intent is provided + """ + if namespace.zone and not namespace.intent_vm_sizes: + raise RequiredArgumentMissingError('The --zone can be provided only when an intent is provided. ' + 'Please use parameter --intent-vm-sizes to specify possible sizes of ' + 'virtual machines that can be created in the proximity placement group.') +# endregion + + def process_image_version_create_namespace(cmd, namespace): process_gallery_image_version_namespace(cmd, namespace) process_image_resource_id_namespace(namespace) diff --git a/src/azure-cli/azure/cli/command_modules/vm/commands.py b/src/azure-cli/azure/cli/command_modules/vm/commands.py index 214e4d1a151..f0d38518536 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/commands.py @@ -33,7 +33,7 @@ process_disk_encryption_namespace, process_assign_identity_namespace, process_remove_identity_namespace, process_vm_secret_format, process_vm_vmss_stop, validate_vmss_update_namespace, process_vm_update_namespace, process_set_applications_namespace, process_vm_disk_attach_namespace, - process_image_version_create_namespace, process_image_version_update_namespace) + process_image_version_create_namespace, process_image_version_update_namespace, process_ppg_create_namespace) from azure.cli.command_modules.vm._image_builder import ( process_image_template_create_namespace, process_img_tmpl_output_add_namespace, @@ -641,9 +641,9 @@ def load_command_table(self, _): with self.command_group('ppg', compute_proximity_placement_groups_sdk, min_api='2018-04-01', client_factory=cf_proximity_placement_groups) as g: g.show_command('show', 'get') - g.custom_command('create', 'create_proximity_placement_group') + g.custom_command('create', 'create_proximity_placement_group', validator=process_ppg_create_namespace) g.custom_command('list', 'list_proximity_placement_groups') - g.generic_update_command('update') + g.generic_update_command('update', setter_name='create_or_update', custom_func_name='update_ppg') g.command('delete', 'delete') with self.command_group('vm monitor log', client_factory=cf_log_analytics_data_plane) as g: 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 fe1963f87df..09d32864402 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -4496,7 +4496,7 @@ def update_image_version(cmd, resource_group_name, gallery_name, gallery_image_n # region proximity placement groups def create_proximity_placement_group(cmd, client, proximity_placement_group_name, resource_group_name, - ppg_type=None, location=None, tags=None): + ppg_type=None, location=None, tags=None, zone=None, intent_vm_sizes=None): from knack.arguments import CaseInsensitiveList location = location or _get_resource_group_location(cmd.cli_ctx, resource_group_name) @@ -4509,12 +4509,25 @@ def create_proximity_placement_group(cmd, client, proximity_placement_group_name raise CLIError("Usage error: invalid value for --type/-t") ppg_params = ProximityPlacementGroup(name=proximity_placement_group_name, proximity_placement_group_type=ppg_type, - location=location, tags=(tags or {})) + location=location, tags=(tags or {}), zones=zone) + + if intent_vm_sizes: + Intent = cmd.get_models('ProximityPlacementGroupPropertiesIntent') + intent = Intent(vm_sizes=intent_vm_sizes) + ppg_params.intent = intent return client.create_or_update(resource_group_name=resource_group_name, proximity_placement_group_name=proximity_placement_group_name, parameters=ppg_params) +def update_ppg(cmd, instance, intent_vm_sizes=None): + if intent_vm_sizes: + Intent = cmd.get_models('ProximityPlacementGroupPropertiesIntent') + intent = Intent(vm_sizes=intent_vm_sizes) + instance.intent = intent + return instance + + def list_proximity_placement_groups(client, resource_group_name=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intent_vm_sizes_and_zone.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intent_vm_sizes_and_zone.yaml new file mode 100644 index 00000000000..d63e3a45e5b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intent_vm_sizes_and_zone.yaml @@ -0,0 +1,369 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + ParameterSetName: + - -n -g --intent-vm-sizes --zone + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_ppg_intent_vm_sizes_and_zone_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001","name":"cli_test_ppg_intent_vm_sizes_and_zone_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2","tags":{"product":"azurecli","cause":"automation","date":"2022-07-12T08:32:24Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '367' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:36 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": "eastus2", "tags": {}, "zones": ["2"], "properties": {"intent": + {"vmSizes": ["Standard_E64s_v4", "Standard_M416ms_v2"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + Content-Length: + - '134' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intent-vm-sizes --zone + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n }\r\n },\r\n \"zones\": + [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '524' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:43 GMT + expires: + - '-1' + 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/PutDeletePPG3Min;99,Microsoft.Compute/PutDeletePPG30Min;499 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + ParameterSetName: + - -n -g --intent-vm-sizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_ppg_intent_vm_sizes_and_zone_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001","name":"cli_test_ppg_intent_vm_sizes_and_zone_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2","tags":{"product":"azurecli","cause":"automation","date":"2022-07-12T08:32:24Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '367' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:44 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": "eastus2", "tags": {}, "properties": {"intent": {"vmSizes": + ["Standard_E64s_v4", "Standard_M416ms_v2"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + Content-Length: + - '118' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intent-vm-sizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_2?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_2\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_2\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n }\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '495' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:52 GMT + expires: + - '-1' + 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/PutDeletePPG3Min;98,Microsoft.Compute/PutDeletePPG30Min;498 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg update + Connection: + - keep-alive + ParameterSetName: + - -n -g --intent-vm-sizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n },\r\n \"virtualMachines\": + [],\r\n \"virtualMachineScaleSets\": [],\r\n \"availabilitySets\": []\r\n + \ },\r\n \"zones\": [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '617' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:53 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/HighCostGet3Min;139,Microsoft.Compute/HighCostGet30Min;699 + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2", "tags": {}, "zones": ["2"], "properties": {"proximityPlacementGroupType": + "Standard", "intent": {"vmSizes": ["Standard_E64s_v4"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg update + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intent-vm-sizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\"\r\n + \ ]\r\n }\r\n },\r\n \"zones\": [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '493' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:57 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/PutDeletePPG3Min;97,Microsoft.Compute/PutDeletePPG30Min;497 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg show + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intent_vm_sizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\"\r\n + \ ]\r\n },\r\n \"virtualMachines\": [],\r\n \"virtualMachineScaleSets\": + [],\r\n \"availabilitySets\": []\r\n },\r\n \"zones\": [\r\n \"2\"\r\n + \ ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '586' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 12 Jul 2022 08:32:58 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/HighCostGet3Min;138,Microsoft.Compute/HighCostGet30Min;698 + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intentvmsizes_and_zone.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intentvmsizes_and_zone.yaml new file mode 100644 index 00000000000..1d5203e8489 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_ppg_intentvmsizes_and_zone.yaml @@ -0,0 +1,369 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + ParameterSetName: + - -n -g --intentvmsizes --zone + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_ppg_intentvmsizes_and_zone_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001","name":"cli_test_ppg_intentvmsizes_and_zone_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2","tags":{"product":"azurecli","cause":"automation","date":"2022-07-11T07:59:38Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:39 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": "eastus2", "tags": {}, "zones": ["2"], "properties": {"intent": + {"vmSizes": ["Standard_E64s_v4", "Standard_M416ms_v2"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + Content-Length: + - '134' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intentvmsizes --zone + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n }\r\n },\r\n \"zones\": + [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '522' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:43 GMT + expires: + - '-1' + 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/PutDeletePPG3Min;99,Microsoft.Compute/PutDeletePPG30Min;474 + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + ParameterSetName: + - -n -g --intentvmsizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-resource/21.1.0b1 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_ppg_intentvmsizes_and_zone_000001?api-version=2021-04-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001","name":"cli_test_ppg_intentvmsizes_and_zone_000001","type":"Microsoft.Resources/resourceGroups","location":"eastus2","tags":{"product":"azurecli","cause":"automation","date":"2022-07-11T07:59:38Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:44 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": "eastus2", "tags": {}, "properties": {"intent": {"vmSizes": + ["Standard_E64s_v4", "Standard_M416ms_v2"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg create + Connection: + - keep-alive + Content-Length: + - '118' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intentvmsizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_2?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_2\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_2\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n }\r\n }\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '493' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:49 GMT + expires: + - '-1' + 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/PutDeletePPG3Min;98,Microsoft.Compute/PutDeletePPG30Min;473 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg update + Connection: + - keep-alive + ParameterSetName: + - -n -g --intentvmsizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\",\r\n + \ \"Standard_M416ms_v2\"\r\n ]\r\n },\r\n \"virtualMachines\": + [],\r\n \"virtualMachineScaleSets\": [],\r\n \"availabilitySets\": []\r\n + \ },\r\n \"zones\": [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '615' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:50 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/HighCostGet3Min;129,Microsoft.Compute/HighCostGet30Min;666 + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus2", "tags": {}, "zones": ["2"], "properties": {"proximityPlacementGroupType": + "Standard", "intent": {"vmSizes": ["Standard_E64s_v4"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg update + Connection: + - keep-alive + Content-Length: + - '155' + Content-Type: + - application/json + ParameterSetName: + - -n -g --intentvmsizes + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\"\r\n + \ ]\r\n }\r\n },\r\n \"zones\": [\r\n \"2\"\r\n ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '491' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:53 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/PutDeletePPG3Min;97,Microsoft.Compute/PutDeletePPG30Min;472 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - ppg show + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.38.0 azsdk-python-azure-mgmt-compute/27.1.0 Python/3.8.0 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1?api-version=2022-03-01 + response: + body: + string: "{\r\n \"name\": \"my_ppg_1\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_ppg_intentvmsizes_and_zone_000001/providers/Microsoft.Compute/proximityPlacementGroups/my_ppg_1\",\r\n + \ \"type\": \"Microsoft.Compute/proximityPlacementGroups\",\r\n \"location\": + \"eastus2\",\r\n \"tags\": {},\r\n \"properties\": {\r\n \"proximityPlacementGroupType\": + \"Standard\",\r\n \"intent\": {\r\n \"vmSizes\": [\r\n \"Standard_E64s_v4\"\r\n + \ ]\r\n },\r\n \"virtualMachines\": [],\r\n \"virtualMachineScaleSets\": + [],\r\n \"availabilitySets\": []\r\n },\r\n \"zones\": [\r\n \"2\"\r\n + \ ]\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '584' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jul 2022 07:59:54 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/HighCostGet3Min;128,Microsoft.Compute/HighCostGet30Min;665 + 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 1fc3fab30d4..d91ab47fd32 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 @@ -5988,6 +5988,47 @@ def test_proximity_placement_group(self, resource_group, resource_group_location self.check('tags.foo', 'bar') ]) + @ResourceGroupPreparer(name_prefix="cli_test_ppg_intent_vm_sizes_and_zone_", location='eastus2') + def test_ppg_intent_vm_sizes_and_zone(self): + self.kwargs.update({ + 'ppg1': 'my_ppg_1', + 'ppg2': 'my_ppg_2', + 'vm_size1': 'Standard_E64s_v4', + 'vm_size2': 'Standard_M416ms_v2', + 'zone': '2' + }) + + # test creating proximity placement group with intent vm size and available zone + self.cmd('ppg create -n {ppg1} -g {rg} --intent-vm-sizes {vm_size1} {vm_size2} --zone {zone}', + checks=[ + self.check('name', '{ppg1}'), + self.check('length(intent.vmSizes)', '2'), + self.check('zones[0]', '{zone}') + ]) + + # test creating proximity placement group with intent vm size + self.cmd('ppg create -n {ppg2} -g {rg} --intent-vm-sizes {vm_size1} {vm_size2}', + checks=[ + self.check('name', '{ppg2}'), + self.check('length(intent.vmSizes)', '2') + ]) + + # the availability zone can be provided only when an intent is provided + from azure.cli.core.azclierror import RequiredArgumentMissingError + with self.assertRaises(RequiredArgumentMissingError): + self.cmd('ppg create -n {ppg1} -g {rg} --zone {zone}') + + # test updating proximity placement group with intent vm size + self.cmd('ppg update -n {ppg1} -g {rg} --intent-vm-sizes {vm_size1}', checks=[ + self.check('name', '{ppg1}'), + self.check('length(intent.vmSizes)', '1') + ]) + + self.cmd('ppg show -n {ppg1} -g {rg}', checks=[ + self.check('name', '{ppg1}'), + self.check('length(intent.vmSizes)', '1') + ]) + @ResourceGroupPreparer(name_prefix='cli_test_ppg_vm_vmss_') def test_ppg_with_related_resources(self, resource_group):