Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] BREAKING CHANGE: az snapshot: Migrate commands using Code Gen V2 #30486

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 0 additions & 40 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,46 +1287,6 @@
text: az snapshot create -g MyResourceGroup -n MySnapshot --size-gb 10 --network-access-policy AllowPrivate --disk-access MyDiskAccessID
"""

helps['snapshot grant-access'] = """
type: command
short-summary: Grant read access to a snapshot.
examples:
- name: Grant read access to a snapshot. (autogenerated)
text: |
az snapshot grant-access --duration-in-seconds 3600 --name MySnapshot --resource-group MyResourceGroup
crafted: true
- name: Grant read access to a snapshot with specifying the file format.
text: |
az snapshot grant-access --duration-in-seconds 3600 --name MySnapshot --resource-group MyResourceGroup --file-format VHDX
"""

helps['snapshot update'] = """
type: command
short-summary: Update a snapshot.
examples:
- name: Update a snapshot and associate it with a disk access resource.
text: |
az snapshot update --name MySnapshot --resource-group MyResourceGroup --network-access-policy AllowPrivate --disk-access MyDiskAccessID
- name: Update a snapshot. (autogenerated)
text: |
az snapshot update --name MySnapshot --resource-group MyResourceGroup --subscription MySubscription
crafted: true
"""

helps['snapshot wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of a snapshot is met.
examples:
- name: Place the CLI in a waiting state until a condition of a snapshot is met. (autogenerated)
text: |
az snapshot wait --exists --name MySnapshot --resource-group MyResourceGroup
crafted: true
- name: Place the CLI in a waiting state until a condition of a snapshot is met. (autogenerated)
text: |
az snapshot wait --created --name MySnapshot --resource-group MyResourceGroup
crafted: true
"""

helps['vm'] = """
type: group
short-summary: Manage Linux or Windows virtual machines.
Expand Down
12 changes: 1 addition & 11 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from azure.cli.command_modules.vm._validators import (
validate_nsg_name, validate_vm_nics, validate_vm_nic, validate_vmss_disk,
validate_asg_names_or_ids, validate_keyvault, _validate_proximity_placement_group,
validate_vm_name_for_monitor_metrics, validate_secure_vm_guest_state_sas)
validate_vm_name_for_monitor_metrics)

from azure.cli.command_modules.vm._vm_utils import MSI_LOCAL_ID
from azure.cli.command_modules.vm._image_builder import ScriptType
Expand Down Expand Up @@ -175,13 +175,6 @@ def load_arguments(self, _):
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.')
# endregion

# region Disks
with self.argument_context('disk grant-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disks') as c:
c.argument('secure_vm_guest_state_sas', options_list=['--secure-vm-guest-state-sas', '-s'], min_api='2022-03-02',
action='store_true', validator=validate_secure_vm_guest_state_sas,
help="Get SAS on managed disk with VM guest state. It will be used by default when the create option of disk is 'secureOSUpload'")
# endregion

# region Disks
with self.argument_context('disk', resource_type=ResourceType.MGMT_COMPUTE, operation_group='disks') as c:
# 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.
Expand Down Expand Up @@ -246,9 +239,6 @@ def load_arguments(self, _):
c.argument('bandwidth_copy_speed', min_api='2023-10-02',
help='If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied at a quicker speed.',
arg_type=get_enum_type(["None", "Enhanced"]))

with self.argument_context('snapshot grant-access', resource_type=ResourceType.MGMT_COMPUTE, operation_group='snapshots') as c:
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.')
# endregion

# region Images
Expand Down
9 changes: 0 additions & 9 deletions src/azure-cli/azure/cli/command_modules/vm/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2658,12 +2658,3 @@ def _validate_community_gallery_legal_agreement_acceptance(cmd, namespace):
if not prompt_y_n(msg, default="y"):
import sys
sys.exit(0)


def validate_secure_vm_guest_state_sas(cmd, namespace):
compute_client = _compute_client_factory(cmd.cli_ctx)
disk_info = compute_client.disks.get(namespace.resource_group_name, namespace.disk_name)
DiskCreateOption = cmd.get_models('DiskCreateOption')

if disk_info.creation_data and disk_info.creation_data.create_option == DiskCreateOption.upload_prepared_secure:
namespace.secure_vm_guest_state_sas = True
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._grant_access import *
from ._list import *
from ._revoke_access import *
from ._show import *
from ._update import *
from ._wait import *
Loading