{Compute} Clean up code#33297
Conversation
❌AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Refactors the VM command module registration and client factory usage in command_modules/vm to simplify code and reduce unused SDK command type scaffolding.
Changes:
- Simplified
list_vm_extension_imagesformatting incustom.py. - Removed multiple
CliCommandTypedeclarations and updated severalcommand_group(...)registrations incommands.py. - Deleted a large set of unused client factory helpers in
_client_factory.py.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/vm/custom.py |
Minor formatting refactor of a helper command implementation. |
src/azure-cli/azure/cli/command_modules/vm/commands.py |
Reworked imports and command group registrations to reduce SDK command type usage. |
src/azure-cli/azure/cli/command_modules/vm/_client_factory.py |
Removed unused client factory functions to simplify the module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cf_gallery_images, cf_gallery_image_versions, | ||
| cf_proximity_placement_groups, | ||
| cf_dedicated_hosts, | ||
| cf_vm_image, cf_vm_image_term, cf_usage, | ||
| cf_vmss, cf_images, | ||
| cf_dedicated_hosts, cf_dedicated_host_groups, |
There was a problem hiding this comment.
The _client_factory module no longer defines several names imported here (e.g., cf_vm_ext, cf_vm_ext_image, cf_gallery_images, cf_gallery_image_versions, cf_proximity_placement_groups, cf_images, cf_dedicated_host_groups). As-is, this will raise an ImportError when az loads the VM command module. Remove these imports or reintroduce the corresponding factory functions, and also deduplicate the repeated imports in this block.
| g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}') | ||
| g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception) | ||
| g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False)) | ||
| g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop) | ||
| g.generic_update_command('update', getter_name='get_vmss_modified_by_aaz', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace) |
There was a problem hiding this comment.
vmss commands like get-instance-view, create, show, stop, and update are being registered in two separate with self.command_group('vmss', ...) blocks (one without compute_vmss_sdk above, and this one). This will overwrite earlier registrations and can change behavior depending on load order. Consolidate these commands into a single vmss command group, or ensure each block registers distinct command names.
| g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}') | |
| g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception) | |
| g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False)) | |
| g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop) | |
| g.generic_update_command('update', getter_name='get_vmss_modified_by_aaz', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace) |
Related command
Description
Refactored several lines of code to simplify future maintenance.
Testing Guide
History Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.