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: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,12 +1454,12 @@ def load_arguments(self, _):
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') 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('ppg_type', options_list=['--type', '-t'], arg_type=get_enum_type(self.get_models('ProximityPlacementGroupType')), min_api='2018-04-01', help="The type of the proximity placement group.")
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.")

for scope, item in [('vm create', 'VM'), ('vmss create', 'VMSS'),
Expand Down
13 changes: 4 additions & 9 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4944,16 +4944,9 @@ 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, zone=None, intent_vm_sizes=None):
from knack.arguments import CaseInsensitiveList

location = location or _get_resource_group_location(cmd.cli_ctx, resource_group_name)

ProximityPlacementGroup, PPGType = cmd.get_models('ProximityPlacementGroup', 'ProximityPlacementGroupType')
choices = CaseInsensitiveList([x.value for x in PPGType])

if ppg_type and ppg_type not in choices:
logger.info("Valid choices: %s", str(choices))
raise CLIError("Usage error: invalid value for --type/-t")
ProximityPlacementGroup = cmd.get_models('ProximityPlacementGroup')

ppg_params = ProximityPlacementGroup(name=proximity_placement_group_name, proximity_placement_group_type=ppg_type,
location=location, tags=(tags or {}), zones=zone)
Expand All @@ -4967,11 +4960,13 @@ def create_proximity_placement_group(cmd, client, proximity_placement_group_name
proximity_placement_group_name=proximity_placement_group_name, parameters=ppg_params)


def update_ppg(cmd, instance, intent_vm_sizes=None):
def update_ppg(cmd, instance, intent_vm_sizes=None, ppg_type=None):
if intent_vm_sizes:
Intent = cmd.get_models('ProximityPlacementGroupPropertiesIntent')
intent = Intent(vm_sizes=intent_vm_sizes)
instance.intent = intent
if ppg_type:
instance.proximity_placement_group_type = ppg_type
return instance


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2065,9 +2065,6 @@ def test_proximity_placement_group(self, resource_group, resource_group_location
'loc': resource_group_location
})

# fails because not a valid type
self.cmd('ppg create -n fail_ppg -g {rg} -t notAvalidType', expect_failure=True)

self.cmd('ppg create -n {ppg1} -t StandarD -g {rg}', checks=[
self.check('name', '{ppg1}'),
self.check('location', '{loc}'),
Expand Down
Loading