88
99from azure .cli .core .aaz import has_value , register_command , register_command_group , AAZCommandGroup
1010from ..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
1214logger = 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