def __init__(self, obj_device, str_id): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI self.resource_name = str_id CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type # If str_id is 'active', this workflow shoud be a # downstream resource of Node if str_id.lower() == 'active': self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) # If str_id is a 24 width hash code, this workflow # should be a downstream resource of Monorail root elif p_hash.findall(str_id): str_root = '/'.join(self.obj_parent.uri.split('/', 5)[0:5]) self.uri = '{}/workflows/{}'.format(str_root, str_id) # If str_id is 'library', which is specified by a static # library workflow definition, this workflow shall have no # upstream resource, but only maintain a static data. # It can't be udpated. elif str_id == 'library': self.uri = '' # Else, it's not valid else: raise Exception( 'Invalid workflow resource name: {}'.format(str_id)) self.mon_data = {}
def __init__(self, cpu_id, obj_xmlnode_cpu, obj_device_parent): CDevice.__init__(self, cpu_id, obj_xmlnode_cpu, obj_device_parent) processor_file_path=os.path.join(os.path.abspath('.'), \ 'pub', 'processor.xml') root=et.parse(processor_file_path) processor_list=root.findall('processor') for i in processor_list: if cpu_id == i.find('id').text: self.cpu_detail_xmlnode=i break self.obj_xmlnode_cpu = obj_xmlnode_cpu self.device_type = 'cpu' self.socket = 0 self.brand_string = '' self.codename = '' self.core_num = 0 self.core_freq = 0 self.ht_enable = False self.qpi_freq = 0 self.qpi_freq_reg = 0 #0x7:9.6GT/s self.ucode = 0 self.stepping = 0 self.por = [] self.ha_num = 0
def build_upon_spec(self): ''' Load slic hw info from pub/slic.xml ''' CDevice.build_upon_spec(self) # Read spec str_spec_file = os.path.join('pub', 'slic.xml') try: root = ET.parse(str_spec_file).getroot() except: msg='specification file not found or not interpretable' msg+=traceback.format_exc() raise Exception(msg) lst_slic = root.findall('slic') obj_xmlnode_spec = None for i in lst_slic: ffid='%04x%04x'%(int(i.find('family_id').text, 16), int(i.find('fru_id').text, 16)) if ffid == self.str_ffid: obj_xmlnode_spec = i break if obj_xmlnode_spec is None: raise Exception('No spec found for SLIC 0x%s'%self.str_ffid) # parse config str_smi_support = obj_xmlnode_spec.find('smi_support').text.lower() if str_smi_support not in ('0', 'false', 'no'): self.b_smi_supported = True else: self.b_smi_supported = False self.str_name = obj_xmlnode_spec.find('name').text #firmare file character string: try: self.fw_id = obj_xmlnode_spec.find('fw_id').text except: self.log('WARNING', 'fw_id not found in SLIC spec.') #fw name in resume try: self.fw_name_resume = obj_xmlnode_spec.find('fw_name_resume').text except: self.log('WARNING', 'fw_name_resume not found in SLIC spec.') #for Rockslide/RockslideX try: self.spirom_id = obj_xmlnode_spec.find('spirom_id').text except: self.log('WARNING', 'spirom_id not found in SLIC spec.') try: self.cmd_fw_id = obj_xmlnode_spec.find('cmd_fw_id').text except: self.log('WARNING', 'cmd_fw_id not found in SLIC spec.') try: self.protocol = obj_xmlnode_spec.find('protocol').text except: self.log('WARNING', 'protocol not found in SLIC spec.') return 0
def __init__(self, str_fan_type, obj_xmlnode_fan, obj_device_parent): CDevice.__init__(self, str_fan_type, obj_xmlnode_fan, obj_device_parent) self.obj_xmlnode_fan = obj_xmlnode_fan self.str_device_type = 'fan' self.int_slot = -1 self.str_name = self.str_sub_type self.b_valid = True
def __init__(self, dict_rack): CDevice.__init__(self, 'vRack') self.dict_config = dict_rack self.name = self.dict_config.get('name', '') self.nodes = {} self.pdus = {} self.switchs = {} # vPDU for pdu_info in self.dict_config['vPDU']: obj_pdu = CPDU(pdu_info) self.add_pdu(obj_pdu) # vSwitch for switch_info in self.dict_config['vSwitch']: obj_switch = CSwitch(switch_info) self.add_switch(obj_switch) # vNode for node_info in self.dict_config['vNode']: obj_node = CNode(node_info) self.add_node(obj_node) # Bind Node to PDU outlet for dict_power in obj_node.get_config().get('power', {}): str_pdu_name = dict_power['vPDU'] str_outlet = dict_power['outlet'] obj_pdu = self.pdus.get(str_pdu_name, None) if (obj_pdu, str_outlet) not in obj_node.power: obj_node.power.append((obj_pdu, str_outlet)) obj_pdu.outlet[str_outlet]['node'] = obj_node
def __init__(self, dict_rack): CDevice.__init__(self, 'vRack') self.dict_config = dict_rack self.name = self.dict_config.get('name', '') self.hypervisor = self.dict_config.get('hypervisor', '') self.nodes = {} self.pdus = {} self.switchs = {} # vPDU for pdu_info in self.dict_config['vPDU']: obj_pdu = CPDU(pdu_info) self.add_pdu(obj_pdu) # vSwitch for switch_info in self.dict_config['vSwitch']: obj_switch = CSwitch(switch_info) self.add_switch(obj_switch) # vNode for node_info in self.dict_config['vNode']: obj_node = CNode(node_info) self.add_node(obj_node) # Bind Node to PDU outlet for dict_power in obj_node.get_config().get('power', {}): str_pdu_name = dict_power['vPDU'] str_outlet = dict_power['outlet'] obj_pdu = self.pdus.get(str_pdu_name, None) if (obj_pdu, str_outlet) not in obj_node.power: obj_node.power.append((obj_pdu, str_outlet)) obj_pdu.outlet[str_outlet]['node'] = obj_node
def __init__(self, dict_stack): CDevice.__init__(self, 'vStack') self.dict_config = dict_stack # HyperVisor self.hypervisors = {} for hypervisor_info in self.dict_config['available_HyperVisor']: obj_hypervisor = CHypervisor(hypervisor_info) self.hypervisors[obj_hypervisor.get_name()] = obj_hypervisor # vRacks self.racks = {} for rack_info in self.dict_config['vRacks']: obj_rack = CRack(rack_info) self.racks[obj_rack.get_name()] = obj_rack # vRackSystem REST agent self.dict_vracksystem = self.dict_config['vRackSystem'] self.rest = APIClient(username=self.dict_vracksystem['username'], password=self.dict_vracksystem['password'], session_log=True) self.rest_root = '{}://{}:{}{}'.format(self.dict_vracksystem['protocol'], self.dict_vracksystem['ip'], self.dict_vracksystem['port'], self.dict_vracksystem['root']) self.b_valid = True
def __init__(self, obj_device, str_id): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI self.resource_name = str_id CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type # If str_id is 'active', this workflow shoud be a # downstream resource of Node if str_id.lower() == 'active': self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) # If str_id is a 24 width hash code, this workflow # should be a downstream resource of Monorail root elif p_hash.findall(str_id): str_root = '/'.join(self.obj_parent.uri.split('/', 5)[0:5]) self.uri = '{}/workflows/{}'.format(str_root, str_id) # If str_id is 'library', which is specified by a static # library workflow definition, this workflow shall have no # upstream resource, but only maintain a static data. # It can't be udpated. elif str_id == 'library': self.uri = '' # Else, it's not valid else: raise Exception('Invalid workflow resource name: {}'.format(str_id)) self.mon_data = {}
def load_runtime_config(self): CDevice.load_runtime_config(self) if self.obj_xmlnode_runtime == None: self.b_valid = False return self.load_enclosure_id() self.load_sn() self.load_enclosure_status()
def build_sensors(self): CDevice.build_sensors(self) if not self.b_valid: return -1 self._build_sensor_status() self._build_sensor_CMD() self._build_sensor_temp() return 0
def __init__(self, dict_node): """ dict_node example: { "name": "vnode_a_20160126114700", "power": [ {"vPDU": "vpdu_1", "outlet": "1.1"} ], "admin":{ "ip": "192.168.134.114", "username": "******", "password": "******" }, "bmc": { "ip": "172.31.128.2", "username": "******", "password": "******" } } """ CDevice.__init__(self, 'vNode') self.dict_config = dict_node # vBMC obj_bmc = CBMC(self.dict_config.get('bmc', {})) self.bmc = obj_bmc # Power, a tuple of PDU information: # (obj_pdu, str_outlet) self.power = [] self.name = self.dict_config.get('name', '') if 'admin' not in self.dict_config: raise Exception('No "admin" network defined for node {}'.format( self.name)) self.ip = self.dict_config['admin'].get('ip', '') self.username = self.dict_config['admin'].get('username', '') self.password = self.dict_config['admin'].get('password', '') if self.dict_config.get('guest_os'): self.guest_ip = self.dict_config['guest_os'].get('ip', '') self.guest_user = self.dict_config['guest_os'].get('username', '') self.guest_password = self.dict_config['guest_os'].get( 'password', '') self.port_ipmi_console = self.dict_config.get('ipmi-console', 9300) self.ssh_ipmi_console = CSSH(self.ip, username='', password='', port=self.port_ipmi_console) self.ssh = CSSH(self.ip, username=self.username, password=self.password, port=22) self.b_sol = False
def load_runtime_config(self): CDevice.load_runtime_config(self) self._load_socket_number() self._load_brand_string() self._load_codename() self._load_core_number() self._load_core_freq() self._load_qpi_freq() self._load_ucode() self._load_stepping() self._load_por_platform() self._check_hyper_threading()
def __init__(self, dict_bmc): CDevice.__init__(self, 'vBMC') self.dict_config = dict_bmc self.ip = self.dict_config.get('ip', '') self.username = self.dict_config.get('username', '') self.password = self.dict_config.get('password', '') self.ipmi = CIOL(str_ip=self.ip, str_user=self.username, str_password=self.password)
def __init__(self, dict_stack): CDevice.__init__(self, 'vStack') self.dict_config = dict_stack # vRacks self.racks = {} for rack_info in self.dict_config['vRacks']: obj_rack = CRack(rack_info) self.racks[obj_rack.get_name()] = obj_rack self.b_valid = True
def __init__(self, str_platform, obj_xmlnode_enclosure, obj_device_parent = None): CDevice.__init__(self, str_platform, obj_xmlnode_enclosure, obj_device_parent) self.str_device_type = 'enslosure' self.str_platform = str_platform self.spa = CSP self.spb = CSP self.spc = CSP self.spd = CSP self.sp = CSP self.lst_sp = list() self.b_dual_sp = False self.str_sp_side_available = '' self.dict_device_children['sp'] = []
def __init__(self, dict_node): """ dict_node example: { "name": "vnode_a_20160126114700", "power": [ {"vPDU": "vpdu_1", "outlet": "1.1"} ], "admin":{ "ip": "192.168.134.114", "username": "******", "password": "******" }, "bmc": { "ip": "172.31.128.2", "username": "******", "password": "******" } } """ CDevice.__init__(self, 'vNode') self.dict_config = dict_node # vBMC obj_bmc = CBMC(self.dict_config.get('bmc', {})) self.bmc = obj_bmc # Power, a tuple of PDU information: # (obj_pdu, str_outlet) self.power = [] self.name = self.dict_config.get('name', '') if 'admin' not in self.dict_config: raise Exception('No "admin" network defined for node {}'.format(self.name)) self.ip = self.dict_config['admin'].get('ip', '') self.username = self.dict_config['admin'].get('username', '') self.password = self.dict_config['admin'].get('password', '') if self.dict_config.get('guest_os'): self.guest_ip = self.dict_config['guest_os'].get('ip', '') self.guest_user = self.dict_config['guest_os'].get('username', '') self.guest_password = self.dict_config['guest_os'].get('password', '') self.port_ipmi_console = self.dict_config.get('ipmi-console', 9300) self.ssh_ipmi_console = CSSH(self.ip, username='', password='', port=self.port_ipmi_console) self.ssh = CSSH(self.ip, username=self.username, password=self.password, port=22) self.b_sol = False
def __init__(self, dict_node): CDevice.__init__(self, 'vNode') self.dict_config = dict_node # vBMC obj_bmc = CBMC(self.dict_config.get('bmc', {})) self.bmc = obj_bmc # Power, a tuple of PDU information: # (obj_pdu, str_outlet) self.power = [] self.name = self.dict_config.get('name', '') self.datastore = self.dict_config.get('datastore', '') self.hypervisor = self.dict_config.get('hypervisor', '')
def __init__(self, obj_device): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI self.resource_name = "lookups" CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) self.log('INFO', 'URI {}'.format(self.uri)) self.mon_data = {} self.look_up = {}
def __init__(self, dict_pdu): CDevice.__init__(self, 'vPDU') self.dict_config = dict_pdu self.ip = self.dict_config.get('ip', '') self.name = self.dict_config.get('name', '') self.community = self.dict_config.get('community', '') # Build outlet mapping self.outlet = {} for str_outlet, str_password in self.dict_config.get('outlet', {}).items(): self.outlet[str_outlet] = {'node': None, 'password': str_password} self.snmp = CSNMP(self.ip, self.community) self.ssh_vpdu = CSSH(ip=self.ip, username='', password='', port=20022)
def __init__(self, obj_device, str_id): """ @param obj_device: Parent device that init this one @type obj_device: CDevice @param str_id: id of this poller @type str_id: string """ # Initialize resource name, parents and URI self.resource_name = str_id CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) self.mon_data = {}
def __init__(self, ffid, obj_xmlnode_slic, obj_device_parent): CDevice.__init__(self, ffid, obj_xmlnode_slic, obj_device_parent) self.str_family_id='' self.str_fru_id='' self.str_ffid='' self.obj_xmlnode_slic = obj_xmlnode_slic self.load_ffid() self.obj_device_parent = obj_device_parent self.str_device_type = 'slic' self.int_slot = -1 self.str_name = '' self.b_smi_supported = '' self.str_pci_bus_number = '' self.b_valid = True self.fw_id = None self.spirom_id = None self.cmd_fw_id = None self.protocol = None self.fw_name_resume = None
def __init__(self, str_sensor_number, obj_xmlnode_runtime = None, obj_device_parent = None): CDevice.__init__(self, str_sensor_number.lower(), obj_xmlnode_runtime, obj_device_parent) self.str_sensor_number = str_sensor_number.lower() self.str_lun = '' self.str_description = '' self.str_sensor_type = '' self.str_event_type = '' self.str_assert_mask = '' self.str_deassert_mask = '' self.str_reading_mask = '' self.str_unr_thresh = '' self.str_uc_thresh = '' self.str_unc_thresh = '' self.str_lnr_thresh = '' self.str_lc_thresh = '' self.str_lnc_thresh = '' self.str_type = '' self.str_device_type = 'sensor'
def __init__(self, obj_device, str_attr): """ @param obj_device: Parent device that init this one @type obj_device: CDevice @param str_attr: attribute of this catalog, could be: - id for catalog in catalogs - source for catalog in nodes @type str_attr: string """ # Initialize resource name, parents and URI self.resource_name = str_attr CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) self.mon_data = {}
def __init__(self, dict_pdu): CDevice.__init__(self, 'vPDU') self.dict_config = dict_pdu self.ip = self.dict_config.get('ip', '') self.name = self.dict_config.get('name', '') self.community = self.dict_config.get('community', '') # Build outlet mapping self.outlet = {} for str_outlet, str_password in self.dict_config.get('outlet', {}).items(): self.outlet[str_outlet] = { 'node': None, 'password': str_password } self.snmp = CSNMP(self.ip, self.community) self.ssh_vpdu = CSSH(ip=self.ip, username='', password='', port=20022)
def __init__(self, obj_device): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI self.resource_name = 'pollers' CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) # Pre-defined next level object self.dict_pollers = {} self.list_poller_id = [] self.mon_data = {}
def __init__(self, obj_device): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI self.resource_name = "workflows" CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) # Pre-defined downstream resource self.dict_workflows = {} self.list_workflow_id = [] self.mon_data = {}
def __init__(self, obj_device): """ @param obj_device: Parent device that init this one @type obj_device: CDevice """ # Initialize resource name, parents and URI # If this is obm for nodes, its resource name should be: # obm # If this is obm managed by monorail, its resource name should be: # obms/library self.obj_parent = obj_device self.resource_name = 'obms' CDevice.__init__(self, self.resource_name) self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) self.dict_obm = {} self.list_obm_service = [] self.mon_data = {}
def __init__(self, obj_device, str_id): """ @param obj_device: Parent device that init this one @type obj_device: CDevice @param str_id: id of this poller @type str_id: string """ # Initialize resource name, parents and URI self.resource_name = str_id CDevice.__init__(self, self.resource_name) self.obj_parent = obj_device self.set_logger(self.obj_parent.obj_logger) self.set_rest_agent(self.obj_parent.obj_rest_agent) self.str_device_type = self.obj_parent.str_device_type self.uri = '{}/{}'.format(self.obj_parent.uri, self.resource_name) self.mon_data = {} self.list_sku_id = [] # dict_names is a mapping from id to SKU name self.dict_names = {} # dict_skus is a mapping from id to SKU instance self.dict_skus = {}
def __init__(self, str_platform, obj_xmlnode_bmc, obj_device_parent): CDevice.__init__(self, str_platform, obj_xmlnode_bmc, obj_device_parent) self.obj_xmlnode_bmc = obj_xmlnode_bmc self.str_device_type = 'bmc' self.str_platform = str_platform
def __init__(self, dict_switch): CDevice.__init__(self, 'vSwitch') self.dict_config = dict_switch
def __init__(self, dict_chassis): """ dict_chassis example: { "name": "chassis", "ip": "192.168.132.144", "username": "******", "password": "******", "chassis_node_a": [{ "admin": { "ip": "10.62.83.141", "username": "******", "password": "******", "port": "18022" }, "guest_os": { "ip": "10.62.83.132", "username": "******", "password": "******", "port": "22" }, "bmc": { "ip": "10.62.83.141", "username": "******", "password": "******" } }], "chassis_node_b": [{ "admin": { "ip": "10.62.83.145", "username": "******", "password": "******", "port": "28022" }, "guest_os": { "ip": "10.62.83.136", "username": "******", "password": "******", "port": "22" }, "bmc": { "ip": "10.62.83.145", "username": "******", "password": "******" } }] } """ CDevice.__init__(self, 'vChassis') self.dict_config = dict_chassis # Power, a tuple of PDU information: # (obj_pdu, str_outlet) self.power = [] self.name = self.dict_config.get('name', '') self.node_a_name = '{}_a'.format(self.name) self.node_b_name = '{}_b'.format(self.name) self.ip = self.dict_config.get('ip', '') self.dict_node_a = self.dict_config.get(self.node_a_name) self.dict_node_b = self.dict_config.get(self.node_b_name) self.username = self.dict_config.get('username', '') self.password = self.dict_config.get('password', '') self.port_ipmi_console = self.dict_config.get('ipmi-console', 9300) self.ssh_ipmi_console = CSSH(self.ip, username='', password='', port=self.port_ipmi_console) self.ssh = CSSH(self.ip, username=self.username, password=self.password, port=22)
def __init__(self, str_sub_type = 'cmos', obj_xmlnode_runtime = None, obj_device_parent = None): CDevice.__init__(self, str_sub_type, obj_xmlnode_runtime, obj_device_parent) self.str_device_type = 'cmos'
def __init__(self, dict_hwimo): ''' Init Monorail instance :param dict_hwimo: a dict includes HWIMO information, e.g. { "ip": "192.168.128.1" "platform": "RackHD", "monorail_rest_rev": "1.1", "monorail_rest_protocol": "http", "monorail_rest_port": 8080, "username": "", "password": "" } ''' CDevice.__init__(self, 'Monorail', None, None) try: self.str_device_type = 'monorail' self.str_sub_type = 'Root' # Monorail IP self.ip = dict_hwimo['ip'] self.username = dict_hwimo['username'] self.password = dict_hwimo['password'] self.rest_username = dict_hwimo['rest_username'] self.rest_password = dict_hwimo['rest_password'] # Monorail REST info self.str_mon_rev = dict_hwimo['rest_rev'] self.str_mon_protocol = dict_hwimo['rest_protocol'] self.str_mon_port = dict_hwimo['rest_port'] self.uri = '{0}://{1}:{2}/api/{3}'.format(self.str_mon_protocol, self.ip, self.str_mon_port, self.str_mon_rev) except Exception: self.log('ERROR', 'Fail to build {}\n{}'\ .format(self.str_sub_type, traceback.format_exc())) self.obj_rest_agent = APIClient() self.set_rest_agent(self.obj_rest_agent) self.set_rackhd_rest_auth() self.obj_ssh_agent = CSSH(self.ip, self.username, self.password) self.b_valid = True # Pre-defined next level object self.catalogs = None self.config = None self.files = None self.obj_lookups = None self.nodes = None self.obms = None self.pollers = None self.profiles = None self.schemas = None self.skus = None self.tasks = None self.templates = None self.versions = None self.workflowtasks = None self.workflows = None self.workflow_library = None self.mon_data = {}
def load_runtime_config(self): CDevice.load_runtime_config(self)
def __init__(self, str_name = 'nvram', \ obj_xmlnode_runtime = None, \ obj_device_parent = None): CDevice.__init__(self, str_name, obj_xmlnode_runtime, obj_device_parent) self.str_device_type = 'nvram'
def set_interface(self): return CDevice.set_interface(self, self.sp)
def load_runtime_config(self): CDevice.load_runtime_config(self) self.load_slot_number()
def __init__(self, str_type, obj_xmlnode_psu, obj_device_parent): CDevice.__init__(self, str_type, obj_xmlnode_psu, obj_device_parent) self.obj_xmlnode_psu = obj_xmlnode_psu self.str_type = str_type self.str_device_type = 'plx'