{Compute} az disk create: Migrate command to aaz-based implementation#32932
{Compute} az disk create: Migrate command to aaz-based implementation#32932william051200 wants to merge 1 commit intoAzure:devfrom
az disk create: Migrate command to aaz-based implementation#32932Conversation
❌AzureCLI-FullTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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>
|
There was a problem hiding this comment.
Pull request overview
Migrates az disk create argument validation away from mgmt SDK lookups by resolving --source using AAZ-based disk show / snapshot show, aligning the validator path with the AAZ-backed disk create implementation.
Changes:
- Switched
process_disk_create_namespaceto use an AAZ-based source resolver. - Added
_figure_out_storage_source_by_aazand_get_disk_or_snapshot_info_by_aazto resolve disk/snapshot sources via AAZ.
Comments suppressed due to low confidence (1)
src/azure-cli/azure/cli/command_modules/vm/_validators.py:2057
process_disk_create_namespacenow routes--sourcename resolution through_figure_out_storage_source_by_aaz, which makes live ARM calls via AAZsnapshot show/disk show. There are existing unit tests forprocess_disk_create_namespace, but none cover the new name-resolution path (snapshot vs disk fallback). Please add tests that mock AAZShowto verify: (1) snapshot name setsnamespace.source_snapshot, (2) disk name falls back to setnamespace.source_disk, and (3) errors propagate as the expectedArgumentUsageError.
if namespace.source:
usage_error = 'usage error: --source {SNAPSHOT | DISK | RESTOREPOINT} | ' \
'--source VHD_BLOB_URI [--source-storage-account-id ID]'
try:
namespace.source_blob_uri, namespace.source_disk, namespace.source_snapshot, \
namespace.source_restore_point, _ = _figure_out_storage_source_by_aaz(
cmd.cli_ctx, namespace.resource_group_name, namespace.source)
if not namespace.source_blob_uri and namespace.source_storage_account_id:
raise ArgumentUsageError(usage_error)
except HttpResponseError:
raise ArgumentUsageError(usage_error)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _figure_out_storage_source_by_aaz(cli_ctx, resource_group_name, source): | ||
| source_blob_uri = None | ||
| source_disk = None | ||
| source_snapshot = None | ||
| source_info = None | ||
| source_restore_point = None | ||
| if urlparse(source).scheme: # a uri? | ||
| source_blob_uri = source | ||
| elif '/disks/' in source.lower(): | ||
| source_disk = source | ||
| elif '/snapshots/' in source.lower(): | ||
| source_snapshot = source | ||
| elif '/restorepoints/' in source.lower(): | ||
| source_restore_point = source | ||
| else: | ||
| source_info, is_snapshot = _get_disk_or_snapshot_info_by_aaz(cli_ctx, resource_group_name, source) | ||
| if is_snapshot: | ||
| source_snapshot = source_info.get('id') | ||
| else: | ||
| source_disk = source_info.get('id') | ||
|
|
||
| return (source_blob_uri, source_disk, source_snapshot, source_restore_point, source_info) |
There was a problem hiding this comment.
_figure_out_storage_source_by_aaz largely duplicates _figure_out_storage_source, differing mainly in how it resolves a bare name (AAZ show) and how it reads the resource id (dict.get('id') vs .id). To reduce divergence risk (future fixes landing in only one path), consider factoring the shared parsing logic into a single helper and injecting the "name -> (info,is_snapshot)" resolver and an "extract_id" helper that supports both SDK objects and dict outputs.
️✔️AzureCLI-BreakingChangeTest
|
Related command
az disk createDescription
Migration from mgmt.compute to aaz-based
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.