def __init__(self, request, *args, **kwargs): super(RegisterForm, self).__init__(request, *args, **kwargs) self._node = kwargs['initial'].get('node', None) if self._node is not None: self._drivers = kwargs['initial']['drivers'] self._ramdisk = kwargs['initial']['images'] self._macaddress = kwargs['initial']['ports'] self.fields['name'].initial = shovel.get_catalog_data_by_source(self._node['id'],'dmi')['System Information']['Product Name'] self.fields['uuid'].initial = self._node['id'] self.fields['driver'].choices = [ (elem,_(elem)) for elem in self._drivers ] self.fields['kernel'].choices = [ (elem,_(elem)) for elem in self._ramdisk ] self.fields['ramdisk'].choices = [ (elem,_(elem)) for elem in self._ramdisk ] self.fields['port'].choices = [ (elem,_(elem)) for elem in self._macaddress] # BMC information initials bmc = shovel.get_catalog_data_by_source(self._node['id'], 'bmc') bmcuser = shovel.get_catalog_data_by_source(self._node['id'], 'ipmi-user-list-1') self.fields['ipmihost'].initial = bmc['IP Address'] self.fields['ipmiuser'].initial = bmcuser['2'][''] # Host network initials host = shovel.get_catalog_data_by_source(self._node['id'], 'ohai') self.fields['sshuser'].initial = host['current_user'] self.fields['sshhost'].initial = host['ipaddress'] self.fields['sshport'].initial = '22' # Failover node initials nodes = shovel.request_nodes_get() self.fields['failovernode'].choices = [ (n['id'],_(n['id'])) for n in nodes if n['id'] != self._node['id'] ] else: redirect = reverse('horizon:admin:rackhd:index') msg = 'Invalid node ID specified' messages.error(request, _(msg)) raise ValueError(msg)
def get_data(self): data = [] try: nodes = shovel.request_nodes_get() i = 0 for n in nodes: dmi = shovel.get_catalog_data_by_source(n['id'],'dmi') name = dmi['System Information']['Product Name'] hwaddr = n['name'] id = n['id'] events = '0' n = self._find_ironic_node(id) if n is not None: events = n['extra'].get('eventcnt','0') state = 'Registered' else: state = 'Unregistered' i += i +1 data.append(self.NodeData(id, name, hwaddr, events, state)) return data except Exception, e: print LOG.error("Excepton in get_baremetal_data(): {0}".format(e)) return data
def get_data(self): data = [] try: nodes = shovel.request_nodes_get() i = 0 for n in nodes: dmi = shovel.get_catalog_data_by_source(n['id'], 'dmi') name = dmi['System Information']['Product Name'] hwaddr = n['name'] id = n['id'] events = '0' n = self._find_ironic_node(id) if n is not None: events = n['extra'].get('eventcnt', '0') state = 'Registered' else: state = 'Unregistered' i += i + 1 data.append(self.NodeData(id, name, hwaddr, events, state)) return data except Exception, e: print LOG.error("Excepton in get_baremetal_data(): {0}".format(e)) return data