Skip to content

Commit

Permalink
[Compute] az vmss create: Add new parameter --max-surge to support en…
Browse files Browse the repository at this point in the history
…abling rolling upgrade policy max surge (#25333)
  • Loading branch information
Jing-song authored Feb 2, 2023
1 parent c80909a commit b86f82c
Show file tree
Hide file tree
Showing 5 changed files with 892 additions and 3 deletions.
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 @@ -722,6 +722,8 @@ def load_arguments(self, _):
c.argument('enable_vtpm', enable_vtpm_type)
c.argument('os_disk_delete_option', arg_type=get_enum_type(self.get_models('DiskDeleteOptionTypes')), min_api='2022-03-01', arg_group='Storage', help='Specify whether OS disk should be deleted or detached upon VMSS Flex deletion (This feature is only for VMSS with flexible orchestration mode).')
c.argument('data_disk_delete_option', arg_type=get_enum_type(self.get_models('DiskDeleteOptionTypes')), min_api='2022-03-01', arg_group='Storage', help='Specify whether data disk should be deleted or detached upon VMSS Flex deletion (This feature is only for VMSS with flexible orchestration mode)')
c.argument('max_surge', arg_type=get_three_state_flag(), min_api='2022-11-01', is_preview=True,
help='Specify it to create new virtual machines to upgrade the scale set, rather than updating the existing virtual machines.')

with self.argument_context('vmss create', arg_group='Network Balancer') as c:
LoadBalancerSkuName = self.get_models('LoadBalancerSkuName', resource_type=ResourceType.MGMT_NETWORK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
v_cpus_per_core=None, os_disk_security_encryption_type=None,
os_disk_secure_vm_disk_encryption_set=None, os_disk_delete_option=None,
regular_priority_count=None, regular_priority_percentage=None, disk_controller_type=None,
enable_osimage_notification=None):
enable_osimage_notification=None, max_surge=None):

# Build IP configuration
ip_configuration = {}
Expand Down Expand Up @@ -1284,6 +1284,9 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
if prioritize_unhealthy_instances is not None:
rolling_upgrade_policy['prioritizeUnhealthyInstances'] = prioritize_unhealthy_instances

if max_surge is not None:
rolling_upgrade_policy['maxSurge'] = max_surge

if not rolling_upgrade_policy:
del rolling_upgrade_policy

Expand Down
4 changes: 2 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 @@ -3086,7 +3086,7 @@ def create_vmss(cmd, vmss_name, resource_group_name, image=None,
os_disk_security_encryption_type=None, os_disk_secure_vm_disk_encryption_set=None,
os_disk_delete_option=None, data_disk_delete_option=None, regular_priority_count=None,
regular_priority_percentage=None, disk_controller_type=None, nat_rule_name=None,
enable_osimage_notification=None):
enable_osimage_notification=None, max_surge=None):

from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import random_string, hash_string
Expand Down Expand Up @@ -3396,7 +3396,7 @@ def _get_public_ip_address_allocation(value, sku):
os_disk_secure_vm_disk_encryption_set=os_disk_secure_vm_disk_encryption_set,
os_disk_delete_option=os_disk_delete_option, regular_priority_count=regular_priority_count,
regular_priority_percentage=regular_priority_percentage, disk_controller_type=disk_controller_type,
enable_osimage_notification=enable_osimage_notification)
enable_osimage_notification=enable_osimage_notification, max_surge=max_surge)

vmss_resource['dependsOn'] = vmss_dependencies

Expand Down
Loading

0 comments on commit b86f82c

Please sign in to comment.