當前位置: 首頁>>代碼示例>>Python>>正文


Python Device.CDevice類代碼示例

本文整理匯總了Python中lib.Device.CDevice的典型用法代碼示例。如果您正苦於以下問題:Python CDevice類的具體用法?Python CDevice怎麽用?Python CDevice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CDevice類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    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
開發者ID:PaynePei,項目名稱:test,代碼行數:29,代碼來源:Stack.py

示例2: build_upon_spec

    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
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:60,代碼來源:SLIC.py

示例3: __init__

    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 = {}
開發者ID:JuneZhou19,項目名稱:test,代碼行數:34,代碼來源:Workflow.py

示例4: __init__

 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
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:7,代碼來源:Fan.py

示例5: __init__

    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
開發者ID:PaynePei,項目名稱:test,代碼行數:35,代碼來源:Rack.py

示例6: __init__

    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
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:26,代碼來源:CPU.py

示例7: build_sensors

 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
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:8,代碼來源:SLIC.py

示例8: load_runtime_config

 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()
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:8,代碼來源:Enclosure.py

示例9: __init__

    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)
開發者ID:InfraSIM,項目名稱:test,代碼行數:12,代碼來源:BMC.py

示例10: load_runtime_config

 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()
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:12,代碼來源:CPU.py

示例11: __init__

    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
開發者ID:InfraSIM,項目名稱:test,代碼行數:13,代碼來源:Stack.py

示例12: __init__

 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'] = []
開發者ID:zhang-martin,項目名稱:atom2,代碼行數:13,代碼來源:Enclosure.py

示例13: __init__

    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": "infrasim",
                "password": "infrasim"
            },
            "bmc": {
                "ip": "172.31.128.2",
                "username": "admin",
                "password": "admin"
            }
        }
        """

        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
開發者ID:InfraSIM,項目名稱:test,代碼行數:49,代碼來源:Node.py

示例14: __init__

    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', '')
開發者ID:PaynePei,項目名稱:test,代碼行數:17,代碼來源:Node.py

示例15: __init__

    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 = {}
開發者ID:InfraSIM,項目名稱:test,代碼行數:18,代碼來源:Poller.py


注:本文中的lib.Device.CDevice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。