@@ -2255,6 +2255,7 @@ def attach_managed_data_disk(cmd, resource_group_name, vm_name,
22552255 vm_dict = vm if isinstance (vm , dict ) else getattr (vm , 'result' , vm )
22562256 data_disks = vm_dict .get ('storageProfile' , {}).get ('dataDisks' , []) or []
22572257 used_luns = {d .get ('lun' ) for d in data_disks if isinstance (d , dict ) and d .get ('lun' ) is not None }
2258+
22582259 def _next_lun (start = 0 ):
22592260 i = start
22602261 while i in used_luns :
@@ -2288,6 +2289,7 @@ def _next_lun(start=0):
22882289 # new / copy / restore
22892290 from azure .mgmt .core .tools import parse_resource_id
22902291 from .operations .vm import VMUpdate as _VMUpdate
2292+
22912293 class VMUpdate (_VMUpdate ):
22922294 def pre_instance_update (self , instance ):
22932295 storage_profile = instance .properties .storage_profile
@@ -2298,6 +2300,7 @@ def pre_instance_update(self, instance):
22982300 for d in data_disks_list :
22992301 if isinstance (d , dict ) and 'lun' in d and d ['lun' ] is not None :
23002302 used_luns .add (d ['lun' ])
2303+
23012304 def _next_lun (start = 0 ):
23022305 i = start
23032306 while i in used_luns :
@@ -2389,6 +2392,7 @@ def _next_lun(start=0):
23892392 }
23902393 return VMUpdate (cli_ctx = cmd .cli_ctx )(command_args = args )
23912394
2395+
23922396def detach_unmanaged_data_disk (cmd , resource_group_name , vm_name , disk_name ):
23932397 # here we handle unmanaged disk
23942398 vm = get_vm_to_update (cmd , resource_group_name , vm_name )
0 commit comments