Skip to content

Commit dd424b8

Browse files
authored
[Compute] BREAKING CHANGE: az snapshot: Migrate commands using Code Gen V2 (#30486)
1 parent 025ac6c commit dd424b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+8682
-2770
lines changed

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,46 +1287,6 @@
12871287
text: az snapshot create -g MyResourceGroup -n MySnapshot --size-gb 10 --network-access-policy AllowPrivate --disk-access MyDiskAccessID
12881288
"""
12891289

1290-
helps['snapshot grant-access'] = """
1291-
type: command
1292-
short-summary: Grant read access to a snapshot.
1293-
examples:
1294-
- name: Grant read access to a snapshot. (autogenerated)
1295-
text: |
1296-
az snapshot grant-access --duration-in-seconds 3600 --name MySnapshot --resource-group MyResourceGroup
1297-
crafted: true
1298-
- name: Grant read access to a snapshot with specifying the file format.
1299-
text: |
1300-
az snapshot grant-access --duration-in-seconds 3600 --name MySnapshot --resource-group MyResourceGroup --file-format VHDX
1301-
"""
1302-
1303-
helps['snapshot update'] = """
1304-
type: command
1305-
short-summary: Update a snapshot.
1306-
examples:
1307-
- name: Update a snapshot and associate it with a disk access resource.
1308-
text: |
1309-
az snapshot update --name MySnapshot --resource-group MyResourceGroup --network-access-policy AllowPrivate --disk-access MyDiskAccessID
1310-
- name: Update a snapshot. (autogenerated)
1311-
text: |
1312-
az snapshot update --name MySnapshot --resource-group MyResourceGroup --subscription MySubscription
1313-
crafted: true
1314-
"""
1315-
1316-
helps['snapshot wait'] = """
1317-
type: command
1318-
short-summary: Place the CLI in a waiting state until a condition of a snapshot is met.
1319-
examples:
1320-
- name: Place the CLI in a waiting state until a condition of a snapshot is met. (autogenerated)
1321-
text: |
1322-
az snapshot wait --exists --name MySnapshot --resource-group MyResourceGroup
1323-
crafted: true
1324-
- name: Place the CLI in a waiting state until a condition of a snapshot is met. (autogenerated)
1325-
text: |
1326-
az snapshot wait --created --name MySnapshot --resource-group MyResourceGroup
1327-
crafted: true
1328-
"""
1329-
13301290
helps['vm'] = """
13311291
type: group
13321292
short-summary: Manage Linux or Windows virtual machines.

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from azure.cli.command_modules.vm._validators import (
2424
validate_nsg_name, validate_vm_nics, validate_vm_nic, validate_vmss_disk,
2525
validate_asg_names_or_ids, validate_keyvault, _validate_proximity_placement_group,
26-
validate_vm_name_for_monitor_metrics, validate_secure_vm_guest_state_sas)
26+
validate_vm_name_for_monitor_metrics)
2727

2828
from azure.cli.command_modules.vm._vm_utils import MSI_LOCAL_ID
2929
from azure.cli.command_modules.vm._image_builder import ScriptType
@@ -175,13 +175,6 @@ def load_arguments(self, _):
175175
c.argument('secure_vm_disk_encryption_set', min_api='2021-08-01', help='Name or ID of disk encryption set created with ConfidentialVmEncryptedWithCustomerKey encryption type.')
176176
# endregion
177177

178-
# region Disks
179-
with self.argument_context('disk grant-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disks') as c:
180-
c.argument('secure_vm_guest_state_sas', options_list=['--secure-vm-guest-state-sas', '-s'], min_api='2022-03-02',
181-
action='store_true', validator=validate_secure_vm_guest_state_sas,
182-
help="Get SAS on managed disk with VM guest state. It will be used by default when the create option of disk is 'secureOSUpload'")
183-
# endregion
184-
185178
# region Disks
186179
with self.argument_context('disk', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disks') as c:
187180
# The `Standard` is used for backward compatibility to allow customers to keep their current behavior after changing the default values to Trusted Launch VMs in the future.
@@ -246,9 +239,6 @@ def load_arguments(self, _):
246239
c.argument('bandwidth_copy_speed', min_api='2023-10-02',
247240
help='If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied at a quicker speed.',
248241
arg_type=get_enum_type(["None", "Enhanced"]))
249-
250-
with self.argument_context('snapshot grant-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='snapshots') as c:
251-
c.argument('file_format', arg_type=get_enum_type(self.get_models('FileFormat', operation_group='snapshots')), help='Used to specify the file format when making request for SAS on a VHDX file format snapshot.')
252242
# endregion
253243

254244
# region Images

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,12 +2655,3 @@ def _validate_community_gallery_legal_agreement_acceptance(cmd, namespace):
26552655
if not prompt_y_n(msg, default="y"):
26562656
import sys
26572657
sys.exit(0)
2658-
2659-
2660-
def validate_secure_vm_guest_state_sas(cmd, namespace):
2661-
compute_client = _compute_client_factory(cmd.cli_ctx)
2662-
disk_info = compute_client.disks.get(namespace.resource_group_name, namespace.disk_name)
2663-
DiskCreateOption = cmd.get_models('DiskCreateOption')
2664-
2665-
if disk_info.creation_data and disk_info.creation_data.create_option == DiskCreateOption.upload_prepared_secure:
2666-
namespace.secure_vm_guest_state_sas = True

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/snapshot/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
# flake8: noqa
1010

1111
from .__cmd_group import *
12+
from ._create import *
1213
from ._delete import *
14+
from ._grant_access import *
1315
from ._list import *
1416
from ._revoke_access import *
1517
from ._show import *
18+
from ._update import *
1619
from ._wait import *

0 commit comments

Comments
 (0)