@@ -703,16 +703,16 @@ def _build_disk_capacity(self, host):
703703 }
704704
705705 def _build_used_dstores (self , vm ):
706- _ , _ , host_ds = self . get_ds_map ()
707- vm_hist = vm . history_records . history
708- last_rec = max ( vm_hist , key = lambda item : item . seq )
709- ds_id = last_rec . ds_id
710- # Host DS
711- if ds_id in host_ds .keys ():
712- self .used_host_dstores [vm .id , 0 ] = ds_id
713- # Shared system ds or image ds
714- else :
715- self .used_shared_dstores [vm .id , 0 ] = ds_id
706+ if vm_hist := vm . history_records . history :
707+ last_rec = max ( vm_hist , key = lambda item : item . seq )
708+ ds_id = last_rec . ds_id
709+ # Host DS
710+ _ , _ , host_ds = self . get_ds_map ()
711+ if ds_id in host_ds .keys ():
712+ self .used_host_dstores [vm .id , 0 ] = ds_id
713+ # Shared system ds or image ds
714+ else :
715+ self .used_shared_dstores [vm .id , 0 ] = ds_id
716716
717717 def get_ds_map (self ) -> tuple [set [int ], set [int ], dict [int , int ]]:
718718 shared_ds , image_ds = set (), set ()
@@ -723,8 +723,7 @@ def get_ds_map(self) -> tuple[set[int], set[int], dict[int, int]]:
723723 }
724724 if ds_attrs .get ("TYPE" ) == "IMAGE_DS" :
725725 image_ds .add (int (ds .id ))
726- # elif ds_attrs.get("SHARED") == "YES":
727- else :
726+ elif ds_attrs .get ("SHARED" ) == "YES" :
728727 shared_ds .add (int (ds .id ))
729728 host_ds_dict = {
730729 int (host_ds .id ): int (host .id )
0 commit comments