Skip to content

Commit 4d80a6a

Browse files
committed
aaz update vm/vmss
1 parent 01ab8ae commit 4d80a6a

File tree

1 file changed

+23
-23
lines changed
  • src/azure-cli/azure/cli/command_modules/vm

1 file changed

+23
-23
lines changed

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,9 +1835,10 @@ def _output(self, *args, **kwargs):
18351835
os_type = vm.storage_profile.os_disk.os_type if vm.storage_profile.os_disk.os_type else None
18361836
_set_data_source_for_workspace(cmd, os_type, resource_group_name, workspace_name)
18371837

1838-
aux_subscriptions = None
1839-
if vm and vm.storage_profile and vm.storage_profile.image_reference and 'id' in vm.storage_profile.image_reference:
1840-
aux_subscriptions = _parse_aux_subscriptions(vm.storage_profile.image_reference['id'])
1838+
# aux_subscriptions = None
1839+
# if (vm and vm.storage_profile and vm.storage_profile.image_reference
1840+
# and 'id' in vm.storage_profile.image_reference):
1841+
# aux_subscriptions = _parse_aux_subscriptions(vm.storage_profile.image_reference['id'])
18411842

18421843
if size is not None:
18431844
if vm.hardware_profile.vm_size == size:
@@ -1902,7 +1903,7 @@ def _output(self, *args, **kwargs):
19021903
# ==============================================================================
19031904
# All SDK modifications to 'vm' object have already happened above (storage, security, etc.)
19041905
# Now we just need to apply those changes using AAZ's Update command
1905-
1906+
19061907
class VMUpdateCustom(UpdateVM):
19071908
def pre_instance_update(self, instance):
19081909
"""
@@ -1911,13 +1912,13 @@ def pre_instance_update(self, instance):
19111912
"""
19121913
vm_dict = vm.serialize()
19131914
vm_dict.pop('resources', None) # Remove conflicting resources
1914-
1915+
19151916
for key, value in vm_dict.items():
19161917
try:
19171918
instance[key] = value
19181919
except Exception as e:
1919-
logger.debug(f"Could not set {key}: {e}")
1920-
1920+
logger.debug("Could not set %s: %s", key, e)
1921+
19211922
def post_instance_update(self, instance):
19221923
"""
19231924
Set AAZ-only fields after AAZ processes command_args.
@@ -1927,35 +1928,34 @@ def post_instance_update(self, instance):
19271928
props = getattr(instance, 'properties', None)
19281929
sp = getattr(props, 'security_profile', None) if props else None
19291930
pas = getattr(sp, 'proxy_agent_settings', None) if sp else None
1930-
1931+
19311932
if pas:
19321933
pas.add_proxy_agent_extension = add_proxy_agent_extension
19331934
else:
19341935
logger.debug("Cannot set add_proxy_agent_extension - proxy_agent_settings does not exist")
1935-
1936+
19361937
def _output(self, *args, **kwargs):
19371938
"""
19381939
Remove resources before flattening to avoid KeyError issues during output serialization.
19391940
"""
19401941
self.ctx.vars.instance.resources = None
19411942
return self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
1942-
1943+
19431944
args = {
19441945
'resource_group': resource_group_name,
19451946
'vm_name': vm_name,
19461947
'no_wait': no_wait
19471948
}
1948-
1949-
return VMUpdateCustom(cli_ctx=cmd.cli_ctx)(command_args=args)
1950-
19511949

1950+
return VMUpdateCustom(cli_ctx=cmd.cli_ctx)(command_args=args)
19521951

19531952
# client = _compute_client_factory(cmd.cli_ctx, aux_subscriptions=aux_subscriptions)
19541953
# if wire_server_access_control_profile_reference_id is not None or \
19551954
# imds_access_control_profile_reference_id is not None or \
19561955
# add_proxy_agent_extension is not None:
19571956
# kwargs['parameters'] = vm
1958-
# return sdk_no_wait(no_wait, client.virtual_machines.begin_create_or_update, resource_group_name, vm_name, **kwargs)
1957+
# return sdk_no_wait(no_wait, client.virtual_machines.begin_create_or_update, resource_group_name, vm_name
1958+
# , **kwargs)
19591959
# endregion
19601960

19611961

@@ -4598,34 +4598,34 @@ def _output(self, *args, **kwargs):
45984598

45994599
if zone_balance is not None:
46004600
vmss.zone_balance = zone_balance
4601-
4601+
46024602
# if wire_server_access_control_profile_reference_id is not None or \
46034603
# imds_access_control_profile_reference_id is not None or \
46044604
# add_proxy_agent_extension is not None:
46054605
# kwargs['parameters'] = vmss
46064606

46074607
# return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.begin_create_or_update,
4608-
# resource_group_name, name, **kwargs)
4608+
# resource_group_name, name, **kwargs)
46094609

46104610
# ==============================================================================
46114611
# AAZ Update: Use SDK for complex logic, then apply via AAZ (same pattern as update_vm)
46124612
# ==============================================================================
46134613
from .aaz.latest.vmss import Update as UpdateVMSS
4614-
4614+
46154615
class VMSSUpdateCustom(UpdateVMSS):
46164616
def pre_instance_update(self, instance):
46174617
"""
46184618
Copy SDK VMSS object properties into the AAZ instance before the update.
46194619
This ensures AAZ sees the current state, but does NOT override user args.
46204620
"""
46214621
vmss_dict = vmss.serialize()
4622-
4622+
46234623
for key, value in vmss_dict.items():
46244624
try:
46254625
instance[key] = value
46264626
except Exception as e:
4627-
logger.debug(f"Could not set {key}: {e}")
4628-
4627+
logger.debug("Could not set %s: %s", key, e)
4628+
46294629
def post_instance_update(self, instance):
46304630
"""
46314631
Set AAZ-only fields after AAZ processes command_args.
@@ -4637,18 +4637,18 @@ def post_instance_update(self, instance):
46374637
vm_profile = getattr(props, 'virtual_machine_profile', None) if props else None
46384638
sp = getattr(vm_profile, 'security_profile', None) if vm_profile else None
46394639
pas = getattr(sp, 'proxy_agent_settings', None) if sp else None
4640-
4640+
46414641
if pas:
46424642
pas.add_proxy_agent_extension = add_proxy_agent_extension
46434643
else:
46444644
logger.debug("Cannot set add_proxy_agent_extension - proxy_agent_settings does not exist")
4645-
4645+
46464646
args = {
46474647
'resource_group': resource_group_name,
46484648
'vm_scale_set_name': name,
46494649
'no_wait': no_wait
46504650
}
4651-
4651+
46524652
return VMSSUpdateCustom(cli_ctx=cmd.cli_ctx)(command_args=args)
46534653

46544654
# endregion

0 commit comments

Comments
 (0)