Skip to content

Commit b7ac2f9

Browse files
{Compute} az vmss diagnostics: Migrate command group to aaz-based implementation (#32921)
1 parent 1bb89c5 commit b7ac2f9

File tree

4 files changed

+959
-1071
lines changed

4 files changed

+959
-1071
lines changed

src/azure-cli/azure/cli/command_modules/vm/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def load_command_table(self, _):
420420
from .operations.vmss_vms import VMSSGetResiliencyView
421421
self.command_table['vmss get-resiliency-view'] = VMSSGetResiliencyView(loader=self)
422422

423-
with self.command_group('vmss diagnostics', compute_vmss_sdk) as g:
423+
with self.command_group('vmss diagnostics') as g:
424424
g.custom_command('set', 'set_vmss_diagnostics_extension')
425425
g.custom_command('get-default-config', 'show_default_diagnostics_configuration')
426426

src/azure-cli/azure/cli/command_modules/vm/custom.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5082,16 +5082,15 @@ def _output(self, *args, **kwargs):
50825082

50835083

50845084
# region VirtualMachineScaleSets Diagnostics
5085-
def set_vmss_diagnostics_extension(
5086-
cmd, resource_group_name, vmss_name, settings, protected_settings=None, version=None,
5087-
no_auto_upgrade=False):
5088-
client = _compute_client_factory(cmd.cli_ctx)
5089-
vmss = client.virtual_machine_scale_sets.get(resource_group_name, vmss_name)
5085+
def set_vmss_diagnostics_extension(cmd, resource_group_name, vmss_name, settings, protected_settings=None,
5086+
version=None, no_auto_upgrade=False):
5087+
from ._vm_utils import UpgradeMode
5088+
vmss = get_vmss_by_aaz(cmd, resource_group_name, vmss_name)
50905089
# pylint: disable=no-member
5091-
is_linux_os = _is_linux_os(vmss.virtual_machine_profile)
5090+
is_linux_os = _is_linux_os_aaz(vmss['virtualMachineProfile'])
50925091
vm_extension_name = _LINUX_DIAG_EXT if is_linux_os else _WINDOWS_DIAG_EXT
5093-
if is_linux_os and vmss.virtual_machine_profile.extension_profile: # check incompatibles
5094-
exts = vmss.virtual_machine_profile.extension_profile.extensions or []
5092+
if is_linux_os and vmss.get('virtualMachineProfile', {}).get('extensionProfile'): # check incompatibles
5093+
exts = vmss.get('virtualMachineProfile', {}).get('extensionProfile', {}).get('extensions', [])
50955094
major_ver = extension_mappings[_LINUX_DIAG_EXT]['version'].split('.', maxsplit=1)[0]
50965095
# For VMSS, we don't do auto-removal like VM because there is no reliable API to wait for
50975096
# the removal done before we can install the newer one
@@ -5111,8 +5110,7 @@ def set_vmss_diagnostics_extension(
51115110
no_auto_upgrade)
51125111

51135112
result = LongRunningOperation(cmd.cli_ctx)(poller)
5114-
UpgradeMode = cmd.get_models('UpgradeMode')
5115-
if vmss.upgrade_policy.mode == UpgradeMode.manual:
5113+
if vmss.get('upgradePolicy', {}).get('mode') == UpgradeMode.MANUAL.value:
51165114
poller2 = update_vmss_instances(cmd, resource_group_name, vmss_name, ['*'])
51175115
LongRunningOperation(cmd.cli_ctx)(poller2)
51185116
return result

0 commit comments

Comments
 (0)