Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] vm/vmss/availability-set update: add --ppg to allowing updating ProximityPlacementGroup #12002

Merged
merged 5 commits into from
Feb 5, 2020
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
5 changes: 4 additions & 1 deletion src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,10 @@ def load_arguments(self, _):
c.argument('ppg_type', options_list=['--type', '-t'], help="The type of the proximity placement group. Allowed values: Standard.")
c.argument('tags', tags_type)

for scope, item in [('vm create', 'VM'), ('vmss create', 'VMSS'), ('vm availability-set create', 'availability set')]:
for scope, item in [('vm create', 'VM'), ('vmss create', 'VMSS'),
('vm availability-set create', 'availability set'),
('vm update', 'VM'), ('vmss update', 'VMSS'),
('vm availability-set update', 'availability set')]:
with self.argument_context(scope, min_api='2018-04-01') as c:
c.argument('proximity_placement_group', options_list=['--ppg'], help="The name or ID of the proximity placement group the {} should be associated with.".format(item),
validator=_validate_proximity_placement_group) # only availability set does not have a command level validator, so this should be added.
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def load_command_table(self, _):
g.custom_command('list', 'list_av_sets')
g.command('list-sizes', 'list_available_sizes')
g.show_command('show', 'get')
g.generic_update_command('update')
g.generic_update_command('update', custom_func_name='update_av_set')

with self.command_group('vm boot-diagnostics', compute_vm_sdk) as g:
g.custom_command('disable', 'disable_boot_diagnostics')
Expand Down
16 changes: 14 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ def show_vm(cmd, resource_group_name, vm_name, show_details=False):

def update_vm(cmd, resource_group_name, vm_name, os_disk=None, disk_caching=None,
write_accelerator=None, license_type=None, no_wait=False, ultra_ssd_enabled=None,
priority=None, max_price=None, **kwargs):
priority=None, max_price=None, proximity_placement_group=None, **kwargs):
from msrestazure.tools import parse_resource_id, resource_id, is_valid_resource_id
from ._vm_utils import update_write_accelerator_settings, update_disk_caching
vm = kwargs['parameters']
Expand Down Expand Up @@ -1098,6 +1098,9 @@ def update_vm(cmd, resource_group_name, vm_name, os_disk=None, disk_caching=None
else:
vm.billing_profile.max_price = max_price

if proximity_placement_group is not None:
vm.proximity_placement_group = {'id': proximity_placement_group}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a model for proximity_placement_group?

Copy link
Member Author

Choose a reason for hiding this comment

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

in params.py:
with self.argument_context(scope, min_api='2018-04-01')


return sdk_no_wait(no_wait, _compute_client_factory(cmd.cli_ctx).virtual_machines.create_or_update,
resource_group_name, vm_name, **kwargs)

Expand Down Expand Up @@ -1243,6 +1246,12 @@ def create_av_set(cmd, availability_set_name, resource_group_name, platform_faul
return compute_client.availability_sets.get(resource_group_name, availability_set_name)


def update_av_set(instance, resource_group_name, proximity_placement_group=None):
if proximity_placement_group is not None:
instance.proximity_placement_group = {'id': proximity_placement_group}
return instance


def list_av_sets(cmd, resource_group_name=None):
op_group = _compute_client_factory(cmd.cli_ctx).availability_sets
if resource_group_name:
Expand Down Expand Up @@ -2617,7 +2626,7 @@ def update_vmss_instances(cmd, resource_group_name, vm_scale_set_name, instance_
def update_vmss(cmd, resource_group_name, name, license_type=None, no_wait=False, instance_id=None,
protect_from_scale_in=None, protect_from_scale_set_actions=None,
enable_terminate_notification=None, terminate_notification_time=None, ultra_ssd_enabled=None,
scale_in_policy=None, priority=None, max_price=None, **kwargs):
scale_in_policy=None, priority=None, max_price=None, proximity_placement_group=None, **kwargs):
vmss = kwargs['parameters']
client = _compute_client_factory(cmd.cli_ctx)

Expand Down Expand Up @@ -2679,6 +2688,9 @@ def update_vmss(cmd, resource_group_name, name, license_type=None, no_wait=False
else:
vmss.virtual_machine_profile.billing_profile.max_price = max_price

if proximity_placement_group is not None:
vmss.proximity_placement_group = {'id': proximity_placement_group}

return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.create_or_update,
resource_group_name, name, **kwargs)

Expand Down
Loading