def allowed(self, request, partition=None): host = self.table.kwargs['host'] PARTITION_IN_USE_STATUS = sysinv.PARTITION_IN_USE_STATUS PARTITION_STATUS_MSG = sysinv.PARTITION_STATUS_MSG if partition: if partition.type_guid != sysinv.USER_PARTITION_PHYS_VOL: return False if (partition.status == PARTITION_STATUS_MSG[PARTITION_IN_USE_STATUS]): return False if partition.ipv_uuid: return False # Get all the partitions from the same disk. disk_partitions = \ sysinv.host_disk_partition_list(request, host.uuid, partition.idisk_uuid) if partition.device_path: partition_number = re.match('.*?([0-9]+)$', partition.device_path).group(1) for dpart in disk_partitions: dpart_number = re.match('.*?([0-9]+)$', dpart.device_path).group(1) if int(dpart_number) > int(partition_number): return False return True
def allowed(self, request, partition=None): host = self.table.kwargs['host'] PARTITION_IN_USE_STATUS = sysinv.PARTITION_IN_USE_STATUS PARTITION_STATUS_MSG = sysinv.PARTITION_STATUS_MSG if partition: pv = None if partition.type_guid != sysinv.USER_PARTITION_PHYS_VOL: return False if partition.ipv_uuid: pv = sysinv.host_pv_get(request, partition.ipv_uuid) if pv.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES: if (host.personality == "Controller-Active" and host._administrative == 'unlocked'): return False else: return False if (partition.status == PARTITION_STATUS_MSG[PARTITION_IN_USE_STATUS]): if not (pv and pv.lvm_vg_name == sysinv.LVG_CINDER_VOLUMES): return False # Get all the partitions from the same disk. disk_partitions = \ sysinv.host_disk_partition_list(request, host.uuid, partition.idisk_uuid) if partition.device_path: partition_number = re.match('.*?([0-9]+)$', partition.device_path).group(1) for dpart in disk_partitions: dpart_number = re.match('.*?([0-9]+)$', dpart.device_path).group(1) if int(dpart_number) > int(partition_number): return False return True
def get_myhost_data(self): if not hasattr(self, "_host"): host_id = self.kwargs['host_id'] try: host = sysinv.host_get(self.request, host_id) all_disks = sysinv.host_disk_list(self.request, host.uuid) host.disks = [d for d in all_disks if (d.istor_uuid or d.ipv_uuid)] host.partitions = sysinv.host_disk_partition_list( self.request, host.uuid) host.stors = sysinv.host_stor_list(self.request, host.uuid) all_lvgs = sysinv.host_lvg_list(self.request, host.uuid) host.lvgs = [l for l in all_lvgs if l.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] all_pvs = sysinv.host_pv_list(self.request, host.uuid) host.pvs = [p for p in all_pvs if p.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] journals = {} count = 0 for s in host.stors: # count journals if s.function == 'journal': count += 1 journals.update({s.uuid: count}) for s in host.stors: if s.function == 'journal' and count > 1: setattr(s, "count", journals[s.uuid]) if s.function == 'osd': if s.journal_location != s.uuid: if count > 1: setattr(s, "count", journals[s.journal_location]) setattr(s, "tier_name", s.tier_name) s.disks = [d.device_path for d in all_disks if d.istor_uuid and d.istor_uuid == s.uuid] s.disks = ", ".join(s.disks) for l in host.lvgs: l.instance_backing = l.capabilities.get( sysinv.LVG_NOVA_PARAM_BACKING) l.concurrent_disk_operations = l.capabilities.get( sysinv.LVG_NOVA_PARAM_DISK_OPS) l.lvm_type = l.capabilities.get( sysinv.LVG_CINDER_PARAM_LVM_TYPE) l.dev_paths = [p.disk_or_part_device_path for p in all_pvs if p.lvm_vg_name and p.lvm_vg_name == sysinv.LVG_NOVA_LOCAL] l.dev_paths = ", ".join(l.dev_paths) except Exception: redirect = reverse('horizon:admin:inventory:index') exceptions.handle(self.request, _('Unable to retrieve details for ' 'host "%s".') % host_id, redirect=redirect) self._host = host return self._host