Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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: 3 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ def load_command_table(self, _):
g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}')
g.custom_command('list-instance-connection-info', 'list_vmss_instance_connection_info')
g.custom_command('list-instance-public-ips', 'list_vmss_instance_public_ips')
g.custom_command('list-instances', 'get_instances_list')
g.custom_command('reimage', 'reimage_vmss', supports_no_wait=True, min_api='2017-03-30')
g.custom_command('restart', 'restart_vmss', supports_no_wait=True)
g.custom_command('scale', 'scale_vmss', supports_no_wait=True)
Expand All @@ -432,8 +433,8 @@ def load_command_table(self, _):
self.command_table['vmss list'] = VMSSList(loader=self,
table_transformer=transform_vmss_list_with_zones_table_output)

from .operations.vmss import VMSSListInstances
self.command_table['vmss list-instances'] = VMSSListInstances(loader=self)
from .operations.vmss_vms import VMSSGetResiliencyView
self.command_table['vmss get-resiliency-view'] = VMSSGetResiliencyView(loader=self)

with self.command_group('vmss diagnostics', compute_vmss_sdk) as g:
g.custom_command('set', 'set_vmss_diagnostics_extension')
Expand Down
19 changes: 19 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# the urlopen is imported for automation purpose
from urllib.request import urlopen # noqa, pylint: disable=import-error,unused-import,ungrouped-imports

from azdev.operations.statistics import command_args_express
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

This import appears to be incorrect. command_args_express from azdev.operations.statistics doesn't seem to be used anywhere in the file and shouldn't be imported from azdev (which is a development tool package) in production code.

Suggested change
from azdev.operations.statistics import command_args_express

Copilot uses AI. Check for mistakes.
from knack.log import get_logger
from knack.util import CLIError
from azure.cli.core.azclierror import (
Expand Down Expand Up @@ -4108,6 +4109,24 @@ def get_vmss_modified_by_aaz(cmd, resource_group_name, name, instance_id=None, s
vmss["virtualMachineProfile"]["storageProfile"]["imageReference"] = None
return vmss

def get_instances_list(cmd, resource_group_name, vm_scale_set_name, resiliency_view=False):
from .operations.vmss import VMSSListInstances
instances = VMSSListInstances(cli_ctx=cmd.cli_ctx)(command_args={
'resource_group': resource_group_name,
'virtual_machine_scale_set_name': vm_scale_set_name,
})

if not resiliency_view:
return instances

instances_id = [instance['instanceId'] for instance in instances]

from .operations.vmss_vms import VMSSGetResiliencyView
return [VMSSGetResiliencyView(cli_ctx=cmd.cli_ctx)(command_args={
'instance_id': id,
'resource_group': resource_group_name,
'vm_scale_set_name': vm_scale_set_name,
}) for id in instances_id]

def get_vmss_instance_view(cmd, resource_group_name, vm_scale_set_name, instance_id=None):
client = _compute_client_factory(cmd.cli_ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ def _output(self, *args, **kwargs):
return result


from azure.cli.core.aaz import register_command
@register_command(
"vmss get-resiliency-view",
)
class VMSSGetResiliencyView(_VMSSVMSShow):
"""View the resiliency status of an VMSS
"""
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.instance_id._options = ["--instance"]
args_schema.vm_scale_set_name._options = ["-n", "--name"]
args_schema.expand._registered = False
return args_schema

def pre_operations(self):
self.ctx.args.expand='resiliencyView'
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing space after = in the assignment. Should be self.ctx.args.expand = 'resiliencyView' to follow PEP 8 style guidelines.

Suggested change
self.ctx.args.expand='resiliencyView'
self.ctx.args.expand = 'resiliencyView'

Copilot uses AI. Check for mistakes.

def convert_show_result_to_snake_case(result):
new_result = {}
if "instanceId" in result:
Expand Down
Loading
Loading