def fill_blanks(self): if not self.storage_controllers: if "disks_slots" in self.json_file: # Fill blank for disks slots disks_slots = [ *range(1, len(self.json_file["disks_slots"]) + 1) ] disks_slots = set(disks_slots) - set(self.disk_slots_used) for slot_id in disks_slots: blank_name = None orientation = "horizontal" disk_format = None for disk_slot in self.json_file["disks_slots"]: if disk_slot['id'] == slot_id: orientation = disk_slot['orientation'] disk_format = disk_slot['format'] for model in self.json_file["disks_models"]: if "type" in model and not blank_name: if model["type"] == "blank" and model[ "format"] == disk_format: blank_name = model["name"] img = Image.open( "catalog/drives/img/" + blank_name + ".png", 'r') if orientation == "vertical": img = GenericUcsDrawEquipment.rotate_object( picture=img) if blank_name: for slot in self.json_file["disks_slots"]: if slot["id"] == slot_id: coord = slot["coord"] coord_offset = self.picture_offset[0] + coord[ 0], self.picture_offset[1] + coord[1] self.parent_draw.paste_layer(img, coord_offset)
def fill_blanks(self): if "disks_slots" in self.parent_draw.json_file: # For rack front or blade only if "Front" in self.parent_draw.__class__.__name__ or "Blade" in self.parent_draw.__class__.__name__: if len(self.disks) < len( self.parent_draw.json_file["disks_slots"] ): # Fill blank for disks slots used_slot = [] potential_slot = [] unused_slot = [] for disk in self.disks: used_slot.append(int(disk._parent.id)) # We add to the list of used slots, the slot of potential other Storage Controllers used_slot = list( set(used_slot + self.parent_draw.disk_slots_used)) for disk in self.parent_draw.json_file["disks_slots"]: potential_slot.append(disk["id"]) for blank_id in set(potential_slot) - set(used_slot): unused_slot.append(blank_id) for slot_id in unused_slot: blank_name = None orientation = "horizontal" disk_format = None for disk_slot in self.parent_draw.json_file[ 'disks_slots']: if disk_slot['id'] == slot_id: orientation = disk_slot['orientation'] disk_format = disk_slot['format'] for model in self.parent_draw.json_file[ "disks_models"]: if "type" in model and not blank_name: if model["type"] == "blank" and model[ "format"] == disk_format: blank_name = model["name"] img = Image.open( "catalog/drives/img/" + blank_name + ".png", 'r') if orientation == "vertical": img = GenericUcsDrawEquipment.rotate_object( picture=img) if blank_name: for slot in self.parent_draw.json_file[ "disks_slots"]: if slot["id"] == int(slot_id): coord = slot["coord"] coord_offset = self.parent_draw.picture_offset[0] + coord[0],\ self.parent_draw.picture_offset[1] + coord[1] if self.parent_draw.__class__.__name__ == "GenericUcsDrawBlade": self.parent_draw.parent_draw.paste_layer( img, coord_offset) else: self.parent_draw.paste_layer(img, coord_offset) if "disks_slots_rear" in self.parent_draw.json_file: # For rack rear only if "Rear" in self.parent_draw.__class__.__name__: if len(self.disks) < len( self.parent_draw.json_file["disks_slots_rear"] ): # Fill blank for disks slots used_slot = [] potential_slot = [] unused_slot = [] for disk in self.disks: disk_id = int(disk._parent.id) used_slot.append(disk_id) for disk in self.parent_draw.json_file["disks_slots_rear"]: potential_slot.append(disk["id"]) for blank_id in set(potential_slot) - set(used_slot): unused_slot.append(blank_id) for slot_id in unused_slot: blank_name = None orientation = "horizontal" disk_format = None for disk_slot in self.parent_draw.json_file[ 'disks_slots_rear']: if disk_slot['id'] == slot_id: orientation = disk_slot['orientation'] disk_format = disk_slot['format'] for model in self.parent_draw.json_file[ "disks_models"]: if "type" in model and not blank_name: if model["type"] == "blank" and model[ "format"] == disk_format: blank_name = model["name"] img = Image.open( "catalog/drives/img/" + blank_name + ".png", 'r') if orientation == "vertical": img = GenericUcsDrawEquipment.rotate_object( picture=img) if blank_name: for slot in self.parent_draw.json_file[ "disks_slots_rear"]: if slot["id"] == int(slot_id): coord = slot["coord"] coord_offset = self.parent_draw.picture_offset[0] + coord[0],\ self.parent_draw.picture_offset[1] + coord[1] self.parent_draw.paste_layer(img, coord_offset)