def get_hostname(self, host_uuid): try: host = sysinv.host_get(self.request, host_uuid) except Exception: host = {} msg = _('Unable to retrieve hostname details.') exceptions.handle(self.request, msg) return host.hostname
def get_initial(self): initial = super(AddDiskProfileView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['personality'] = host._personality return initial
def handle(self, request, data): host_id = data['host_id'] del data['host_id'] del data['host'] try: host = sysinv.host_get(self.request, host_id) cpudata = {} sharedcpudata = {} platformcpudata = {} for key, val in data.items(): if 'num_cores_on_processor' in key or 'function' in key: if key not in self.fields: cpudata[key] = val elif not type(self.fields[key].widget) is\ forms.widgets.HiddenInput: cpudata[key] = val if 'platform_processor' in key: update_key = 'num_cores_on_processor' + key[-1:] if key not in self.fields: platformcpudata[update_key] = val elif not type(self.fields[key].widget) is\ forms.widgets.HiddenInput: platformcpudata[update_key] = val if 'num_shared_on_processor' in key: key2 = key.replace('shared', 'cores') if key not in self.fields: sharedcpudata[key2] = val elif not type(self.fields[key].widget) is\ forms.widgets.HiddenInput: sharedcpudata[key2] = val sharedcpudata['function'] = 'shared' platformcpudata['function'] = 'platform' sysinv.host_cpus_modify(request, host.uuid, platformcpudata, cpudata, sharedcpudata) msg = _('CPU Assignments were successfully updated.') LOG.debug(msg) messages.success(request, msg) return self.host.cpus except exc.ClientException as ce: # Display REST API error message on UI messages.error(request, ce) LOG.error(ce) # Redirect to failure pg redirect = reverse(self.failure_url, args=[host_id]) return shortcuts.redirect(redirect) except Exception as e: LOG.exception(e) msg = _('Failed to update CPU Assignments.') LOG.info(msg) redirect = reverse(self.failure_url, args=[host_id]) exceptions.handle(request, msg, redirect=redirect)
def get_initial(self): initial = super(AddStorageVolumeView, self).get_initial() initial['host_id'] = self.kwargs['host_id'] try: host = sysinv.host_get(self.request, initial['host_id']) except Exception: exceptions.handle(self.request, _('Unable to retrieve host.')) initial['ihost_uuid'] = host.uuid initial['hostname'] = host.hostname return initial
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) host.nodes = sysinv.host_node_list(self.request, host.uuid) host.cpus = sysinv.host_cpu_list(self.request, host.uuid) icpu_utils.restructure_host_cpu_data(host) 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
def _get_object(self, *args, **kwargs): if not hasattr(self, "_object"): host_id = self.kwargs['host_id'] try: host = sysinv.host_get(self.request, host_id) host.nodes = sysinv.host_node_list(self.request, host.uuid) host.cpus = sysinv.host_cpu_list(self.request, host.uuid) icpu_utils.restructure_host_cpu_data(host) self._object = host self._object.host_id = host_id except Exception as e: LOG.exception(e) redirect = reverse("horizon:project:networks:detail", args=(host_id)) msg = _('Unable to retrieve port details') exceptions.handle(self.request, msg, redirect=redirect) return self._object
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