Skip to content

Commit fba0f90

Browse files
committed
Migrated disk update
1 parent 1dcddb3 commit fba0f90

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def load_command_table(self, _):
208208
from .operations.ppg import PPGShow
209209
self.command_table["ppg show"] = PPGShow(loader=self)
210210

211-
with self.command_group('disk', compute_disk_sdk, operation_group='disks') as g:
211+
with self.command_group('disk', operation_group='disks') as g:
212212
g.custom_command('create', 'create_managed_disk', supports_no_wait=True, table_transformer=transform_disk_create_table_output, validator=process_disk_create_namespace)
213213
from .operations.disk import DiskUpdate, DiskGrantAccess
214214
self.command_table["disk grant-access"] = DiskGrantAccess(loader=self)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
580580
'disk_encryption_set_name': secure_vm_disk_encryption_set
581581
})
582582

583-
584583
if secure_vm_disk_encryption_set:
585584
secure_vm_disk_encryption_set = secure_vm_disk_encryption_set['id']
586585
else:

src/azure-cli/azure/cli/command_modules/vm/operations/disk.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from azure.cli.core.aaz import has_value, register_command, register_command_group, AAZCommandGroup
1010
from ..aaz.latest.disk import Update as _DiskUpdate, GrantAccess as _DiskGrantAccess, Show, UpdatePatch as _UpdatePatch
11+
from ..aaz.latest.disk_encryption_set import Show as DiskEncryptionSetShow
12+
from ..aaz.latest.disk_access import Show as DiskAccessShow
1113

1214
logger = get_logger(__name__)
1315

@@ -45,9 +47,15 @@ def pre_instance_update(self, instance):
4547

4648
disk_encryption_set = args.disk_encryption_set
4749
if not is_valid_resource_id(disk_encryption_set.to_serialized_data()):
48-
disk_encryption_set = resource_id(
49-
subscription=get_subscription_id(self.cli_ctx), resource_group=args.resource_group,
50-
namespace='Microsoft.Compute', type='diskEncryptionSets', name=disk_encryption_set)
50+
disk_encryption_set = DiskEncryptionSetShow(cli_ctx=self.cli_ctx)(command_args={
51+
'resource_group': args.resource_group,
52+
'disk_encryption_set_name': disk_encryption_set
53+
})
54+
55+
if disk_encryption_set:
56+
disk_encryption_set = disk_encryption_set['id']
57+
else:
58+
disk_encryption_set = None
5159

5260
instance.properties.encryption.disk_encryption_set_id = disk_encryption_set
5361

@@ -58,9 +66,16 @@ def pre_instance_update(self, instance):
5866
if has_value(args.disk_access):
5967
disk_access = args.disk_access
6068
if not is_valid_resource_id(disk_access.to_serialized_data()):
61-
disk_access = resource_id(
62-
subscription=get_subscription_id(self.cli_ctx), resource_group=args.resource_group,
63-
namespace='Microsoft.Compute', type='diskAccesses', name=disk_access)
69+
disk_access = DiskAccessShow(cli_ctx=self.cli_ctx)(command_args={
70+
'resource_group': args.resource_group,
71+
'disk_access_name': disk_access
72+
})
73+
74+
if disk_access:
75+
disk_access = disk_access['id']
76+
else:
77+
disk_access = None
78+
6479
instance.properties.disk_access_id = disk_access
6580

6681

0 commit comments

Comments
 (0)