def allowed(self, request, datum): host = self.table.kwargs['host'] self.verbose_name = _("Add Physical Volume") classes = [c for c in self.classes if c != "disabled"] self.classes = classes # cgts-vg, cinder-volumes: Allow adding to any controller if host._personality == sysinv.PERSONALITY_CONTROLLER: return True # nova-local: Allow adding to any locked host with a worker # subfunction. On an AIO, the previous check superceeds this. if host._administrative != 'locked': if 'worker' in host._subfunctions and \ host.worker_config_required is False: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] self.verbose_name = string_concat(self.verbose_name, ' ', _("(Node Unlocked)")) elif "nova-local" not in [ lvg.lvm_vg_name for lvg in sysinv.host_lvg_list(request, host.uuid) ]: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] self.verbose_name = string_concat(self.verbose_name, ' ', _("(No nova-local LVG)")) return True # The action should always be displayed
def allowed(self, request, datum): host = self.table.kwargs['host'] self.verbose_name = _("Add Local Volume Group") classes = [c for c in self.classes if c != "disabled"] self.classes = classes if not host._administrative == 'locked': if 'worker' in host._subfunctions and \ host.worker_config_required is False: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] self.verbose_name = string_concat(self.verbose_name, ' ', _("(Node Unlocked)")) # LVGs that are considered as "present" in the system are those # in an adding or provisioned state. current_lvg_states = [sysinv.LVG_ADD, sysinv.LVG_PROV] ilvg_list = sysinv.host_lvg_list(request, host.uuid) current_lvgs = [ lvg.lvm_vg_name for lvg in ilvg_list if lvg.vg_state in current_lvg_states ] compatible_lvgs = [] if host._personality == 'controller': compatible_lvgs += [sysinv.LVG_CINDER_VOLUMES] if 'worker' in host._subfunctions: compatible_lvgs += [sysinv.LVG_NOVA_LOCAL] allowed_lvgs = set(compatible_lvgs) - set(current_lvgs) if not any(allowed_lvgs): if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] self.verbose_name = string_concat(self.verbose_name, ' ', _("(All Added)")) return True # The action should always be displayed
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