示例#1
0
 def _parseMemoryParameters(self, output):
     """
     This procedure parses and sets the values of the Memory Configuration for the Managed System
     @param output: output of 'lshwres -r mem --level sys <Managed System>' command
     @type output: String
     @param managedSysDo: data object of ManagedSystemDo
     @type managedSysDo: ManagedSystemDo class instace 
     """
     if output:
         propertiesDict = self.buildPropertiesDict(output)
         memoryParameters = ibm_hmc_lib.ManagedSystemMemoryParameters()
         memoryParameters.configurableSysMem = ibm_hmc_lib.toLong(
             propertiesDict.get('configurable_sys_mem'))
         memoryParameters.memRegSize = ibm_hmc_lib.toInteger(
             propertiesDict.get('mem_region_size'))
         memoryParameters.currAvailMem = ibm_hmc_lib.toLong(
             propertiesDict.get('curr_avail_sys_mem'))
         memoryParameters.installedMem = ibm_hmc_lib.toLong(
             propertiesDict.get('installed_sys_mem'))
         memoryParameters.reqHugePagesNum = ibm_hmc_lib.toLong(
             propertiesDict.get('requested_num_sys_huge_pages'))
         memoryParameters.pendingAvailMem = ibm_hmc_lib.toLong(
             propertiesDict.get('pend_avail_sys_mem'))
         memoryParameters.firmwareMem = ibm_hmc_lib.toLong(
             propertiesDict.get('sys_firmware_mem'))
         memoryParameters.hugePageSize = ibm_hmc_lib.toLong(
             propertiesDict.get('huge_page_size'))
         memoryParameters.maxNumberHugePages = ibm_hmc_lib.toInteger(
             propertiesDict.get('max_num_sys_huge_pages'))
         return memoryParameters
示例#2
0
 def _parseCpuParameters(self, output):
     """
     This procedure parses and sets the values of the Processor Configuration for the Managed System
     @param output: output of 'lshwres -r proc --level sys <Managed System>' command
     @type output: String
     @param managedSysDo: data object of ManagedSystemDo
     @type managedSysDo: ManagedSystemDo class instace 
     """
     if output:
         propertiesDict = self.buildPropertiesDict(output)
         cpuParameters = ibm_hmc_lib.ManagedSystemProcessorParameters()
         cpuParameters.minCpuPerVirtualCpu = ibm_hmc_lib.toFloat(
             propertiesDict.get('min_proc_units_per_virtual_proc'))
         cpuParameters.curCpuAvail = ibm_hmc_lib.toFloat(
             propertiesDict.get('curr_avail_sys_proc_units'))
         cpuParameters.maxCpuPerLpar = ibm_hmc_lib.toInteger(
             propertiesDict.get('max_procs_per_lpar'))
         cpuParameters.maxVirtCpuPerLpar = ibm_hmc_lib.toInteger(
             propertiesDict.get('max_virtual_procs_per_lpar'))
         cpuParameters.instCpuUnits = ibm_hmc_lib.toFloat(
             propertiesDict.get('installed_sys_proc_units'))
         cpuParameters.pendingAvailCpuUnits = ibm_hmc_lib.toFloat(
             propertiesDict.get('pend_avail_sys_proc_units'))
         cpuParameters.maxSharedCpuPools = ibm_hmc_lib.toInteger(
             propertiesDict.get('max_shared_proc_pools'))
         cpuParameters.maxOs400CpuUnits = ibm_hmc_lib.toInteger(
             propertiesDict.get('max_curr_procs_per_os400_lpar'))
         cpuParameters.configurableCpuUnits = ibm_hmc_lib.toFloat(
             propertiesDict.get('configurable_sys_proc_units'))
         return cpuParameters
示例#3
0
    def _parseEth(self, buffer):
        """
        Created NIC DO from the output of the lshwres -r virtualio --rsubtype eth --level lpar -m '<Managed System Name>'
        @param buffer: command output
        @type buffer: String 
        @return: instance of NetworkInterfaceDo
        """
        if buffer:
            propertiesDict = self.buildPropertiesDict(buffer)
            vEth = ibm_hmc_lib.LparNetworkInterface()
            vEth.macAddress = propertiesDict.get('mac_addr')
            if not vEth.macAddress and not netutils.isValidMac(
                    vEth.macAddress):
                raise ValueError, "Failed parsing MAC addres of Virtual Ethernet Card from buffer: %s" % buffer
            vEth.macAddress = netutils.parseMac(vEth.macAddress)
            vEth.portVlanId = ibm_hmc_lib.toInteger(
                propertiesDict.get('port_vlan_id'))
            vEth.lparName = propertiesDict.get('lpar_name')
            vEth.slotNum = propertiesDict.get('slot_num')
            if not vEth.lparName:
                raise ValueError, "Failed parsing LPar Name for Virtual Ethernet Card from buffer: %s" % buffer
            vEth.lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
            vEth.isVirtual = 1

            return vEth
def parseEthernetAdapterSpeedAndRelation(output, adapter):
    if output:
        mediaSpeed = re.search("media_speed\s+(\w+)\s+", output)
        if mediaSpeed:
            mediaSpeed = mediaSpeed.group(1).strip()
            speed = re.match("(\d+)", mediaSpeed)
            if speed:
                adapter.speed = ibm_hmc_lib.toInteger(speed.group(1)) * 1000
        usedAdapters = re.search("adapter_names\s+([\w\,]+)\s+EtherChannel", output)
        if usedAdapters:
            adapter.usedAdapters.extend(usedAdapters.group(1).strip().split(","))

        # determine link aggr operation status
        if adapter.interfaceType == ibm_hmc_lib.LINK_AGGREGATION_ADAPTER:
            aggrMode = re.search("mode\s+(\w+)\s+EtherChannel\s+mode", output)
            failOverInterface = re.search("backup_adapter\s+(\w+)", output)
            if aggrMode:
                if (aggrMode.group(1) == "netif_backup") or (
                    failOverInterface
                    and failOverInterface.group(1).strip()
                    and failOverInterface.group(1).strip().upper() != "NONE"
                ):
                    adapter.operatingMode = ibm_hmc_lib.AGGREGATED_FAILOVER
                    adapter.backupAdapter = failOverInterface.group(1).strip()
                else:
                    adapter.operatingMode = ibm_hmc_lib.AGGREGATED_BAND

    return adapter
示例#5
0
def parseIoSlot(buffer):
    """
    Parses and sets the values for the Physical I/O Slots Do
    @param buffer: output of the command ''
    @type buffer: String
    @return: IoSlotDo instance
    """
    if buffer:
        ioSlot = ibm_hmc_lib.IoSlot()
        propertiesDict = ibm_hmc_lib.buildPropertiesDict(buffer)
        ioSlot.drcName = propertiesDict.get('drc_name')
        if not ioSlot.drcName:
            raise ValueError, "Failed parsing I/O Slot for %s" % buffer
        ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName)
        ioSlot.name = propertiesDict.get('description')
        ioSlot.busId = propertiesDict.get('bus_id')
        ioSlot.physLoc = propertiesDict.get('unit_phys_loc')
        ioSlot.pciRevId = propertiesDict.get('pci_revision_id')
        ioSlot.busGrouping = propertiesDict.get('bus_grouping')
        ioSlot.pciDeviceId = propertiesDict.get('pci_device_id')
        ioSlot.physLocOnBus = propertiesDict.get('phys_loc')
        ioSlot.parentDrcIndex = propertiesDict.get('parent_slot_drc_index')
        ioSlot.drcIndex = propertiesDict.get('drc_index')
        ioSlot.subSlotVendorId = propertiesDict.get('pci_subs_vendor_id')
        ioSlot.pciClass = propertiesDict.get('pci_class')
        ioSlot.ioPoolId = propertiesDict.get('slot_io_pool_id')
        ioSlot.vendorId = propertiesDict.get('pci_vendor_id')
        ioSlot.featureCodes = propertiesDict.get('feature_codes')
        ioSlot.subslotDeviceId = propertiesDict.get('pci_subs_device_id')
        ioSlot.lpar_name = propertiesDict.get('lpar_name')
        ioSlot.lpar_id = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
        return ioSlot
示例#6
0
def parseIoSlot(buffer):
    """
    Parses and sets the values for the Physical I/O Slots Do
    @param buffer: output of the command ''
    @type buffer: String
    @return: IoSlotDo instance
    """
    if buffer:
        ioSlot = ibm_hmc_lib.IoSlot()
        propertiesDict = ibm_hmc_lib.buildPropertiesDict(buffer)
        ioSlot.drcName = propertiesDict.get('drc_name')
        if not ioSlot.drcName:
            raise ValueError, "Failed parsing I/O Slot for %s" % buffer
        ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(
            ioSlot.drcName)
        ioSlot.name = propertiesDict.get('description')
        ioSlot.busId = propertiesDict.get('bus_id')
        ioSlot.physLoc = propertiesDict.get('unit_phys_loc')
        ioSlot.pciRevId = propertiesDict.get('pci_revision_id')
        ioSlot.busGrouping = propertiesDict.get('bus_grouping')
        ioSlot.pciDeviceId = propertiesDict.get('pci_device_id')
        ioSlot.physLocOnBus = propertiesDict.get('phys_loc')
        ioSlot.parentDrcIndex = propertiesDict.get('parent_slot_drc_index')
        ioSlot.drcIndex = propertiesDict.get('drc_index')
        ioSlot.subSlotVendorId = propertiesDict.get('pci_subs_vendor_id')
        ioSlot.pciClass = propertiesDict.get('pci_class')
        ioSlot.ioPoolId = propertiesDict.get('slot_io_pool_id')
        ioSlot.vendorId = propertiesDict.get('pci_vendor_id')
        ioSlot.featureCodes = propertiesDict.get('feature_codes')
        ioSlot.subslotDeviceId = propertiesDict.get('pci_subs_device_id')
        ioSlot.lpar_name = propertiesDict.get('lpar_name')
        ioSlot.lpar_id = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
        return ioSlot
def parseEthernetAdapterSpeedAndRelation(output, adapter):
    if output:
        mediaSpeed = re.search('media_speed\s+(\w+)\s+', output)
        if mediaSpeed:
            mediaSpeed = mediaSpeed.group(1).strip()
            speed = re.match('(\d+)', mediaSpeed)
            if speed:
                adapter.speed = ibm_hmc_lib.toInteger(speed.group(1)) * 1000
        usedAdapters = re.search('adapter_names\s+([\w\,]+)\s+EtherChannel',
                                 output)
        if usedAdapters:
            adapter.usedAdapters.extend(
                usedAdapters.group(1).strip().split(','))

        #determine link aggr operation status
        if adapter.interfaceType == ibm_hmc_lib.LINK_AGGREGATION_ADAPTER:
            aggrMode = re.search('mode\s+(\w+)\s+EtherChannel\s+mode', output)
            failOverInterface = re.search('backup_adapter\s+(\w+)', output)
            if aggrMode:
                if (aggrMode.group(1) == 'netif_backup') or (
                        failOverInterface
                        and failOverInterface.group(1).strip() and
                        failOverInterface.group(1).strip().upper() != 'NONE'):
                    adapter.operatingMode = ibm_hmc_lib.AGGREGATED_FAILOVER
                    adapter.backupAdapter = failOverInterface.group(1).strip()
                else:
                    adapter.operatingMode = ibm_hmc_lib.AGGREGATED_BAND

    return adapter
示例#8
0
 def _parseLpar(self, buffer):
     """
     This function performs parsing of the command output lssysscfg -r lpar -m '<Managed System Name>'
     and sets the values for IbmLparProfileDo
     @param buffer: command output buffer
     @type buffer: String
     @return: instance of IbmLparProfileDo class 
     """
     lPar = ibm_fsm.IbmLpar()
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         lPar.lparName = propertiesDict.get('name')
         if not lPar.lparName:
             raise ValueError(
                 "Failed parsing Lpar Config File output for: %s" % buffer)
         lPar.autoStart = ibm_hmc_lib.toInteger(
             propertiesDict.get('auto_start'))
         lPar.powerCtrlIds = propertiesDict.get('power_ctrl_lpar_ids')
         lPar.bootMode = propertiesDict.get('boot_mode')
         if lPar.bootMode and lPar.bootMode not in ibm_fsm.LPAR_BOOT_MODES:
             logger.warn('Unsupported boot mode %s. Setting to None' %
                         lPar.bootMode)
             lPar.bootMode = None
         lPar.redunErrPathRep = ibm_hmc_lib.toInteger(
             propertiesDict.get('redundant_err_path_reporting'))
         lPar.workgroupId = propertiesDict.get('work_group_id')
         lPar.defaultProfName = propertiesDict.get('default_profile')
         lPar.profileName = propertiesDict.get('curr_profile')
         state = LPAR_STATE_MAP.get(propertiesDict.get('primary_state'))
         if state:
             lPar.state = state
         lPar.type = propertiesDict.get('lpar_env')
         lPar.lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         lPar.logicalSerialNumber = propertiesDict.get('logical_serial_num')
         osTypeStr = propertiesDict.get('os_version')
         if osTypeStr:
             match = re.match('(\w+)\s(\d+\.\d+)', osTypeStr)
             if match:
                 lPar.osName = match.group(1)
                 lPar.osVersion = match.group(2)
         ipStr = propertiesDict.get('rmc_ipaddr')
         if ipStr and netutils.isValidIp(ipStr):
             lPar.rmcIp = ipStr.strip()
     return {lPar.lparId: lPar}
示例#9
0
 def _parseLparProfile(self, buffer):
     """
     This function performs parsing of the command output lssysscfg -r prof -m '<Managed System Name>' bloc
     and sets the values for IbmLparProfileDo
     @param buffer: command output buffer
     @type buffer: String
     @return: instance of IbmLparProfileDo class 
     """
     if buffer :
         propertiesDict = self.buildPropertiesDict(buffer)
         lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         if not lparId:
             raise ValueError('Failed to parse out Lpar Id for buffer %s' % buffer)
         lparProfile = ibm_fsm.IbmLparProfile()
         lparProfile.desNumHugePages = ibm_hmc_lib.toInteger(propertiesDict.get('desired_num_huge_pages'))
         lparProfile.minNumHugePages = ibm_hmc_lib.toInteger(propertiesDict.get('min_num_huge_pages'))
         lparProfile.maxNumHugePages = ibm_hmc_lib.toInteger(propertiesDict.get('max_num_huge_pages'))
         lparProfile.desCpu = ibm_hmc_lib.toInteger(propertiesDict.get('desired_procs'))
         lparProfile.minCpu = ibm_hmc_lib.toInteger(propertiesDict.get('min_procs'))
         lparProfile.maxCpu = ibm_hmc_lib.toInteger(propertiesDict.get('max_procs'))
         lparProfile.desPhysCpu = ibm_hmc_lib.toFloat(propertiesDict.get('desired_proc_units'))
         lparProfile.minPhysCpu = ibm_hmc_lib.toFloat(propertiesDict.get('min_proc_units'))
         lparProfile.maxPhysCpu = ibm_hmc_lib.toFloat(propertiesDict.get('max_proc_units'))
         lparProfile.desMem = ibm_hmc_lib.toLong(propertiesDict.get('desired_mem'))
         lparProfile.minMem = ibm_hmc_lib.toLong(propertiesDict.get('min_mem'))
         lparProfile.maxMem = ibm_hmc_lib.toLong(propertiesDict.get('max_mem'))
         lparProfile.sharingMode = propertiesDict.get('sharing_mode')
         if lparProfile.sharingMode and lparProfile.sharingMode not in ibm_fsm.LPAR_SHARING_MODES:
             logger.warn('Unsupported sharing mode: %s. Setting to None.' % lparProfile.sharingMode)
             lparProfile.sharingMode = None
         lparProfile.cpuMode = propertiesDict.get('proc_mode')
         if lparProfile.cpuMode and ibm_fsm.LPAR_CPU_MODES.has_key(lparProfile.cpuMode):
             lparProfile.cpuMode = ibm_fsm.LPAR_CPU_MODES.get(lparProfile.cpuMode)
         else:
             logger.warn('Unsupported CPU mode %s. Setting to None' % lparProfile.cpuMode)
             lparProfile.cpuMode = None
         lparProfile.uncapWeight = ibm_hmc_lib.toInteger(propertiesDict.get('uncap_weight'))
         lparProfile.connMonEnabled = ibm_hmc_lib.toInteger(propertiesDict.get('conn_monitoring'))
         lparProfile.maxVirtSlots = ibm_hmc_lib.toInteger(propertiesDict.get('max_virtual_slots'))
         lparProfile.ioPoolIds = propertiesDict.get('lpar_io_pool_ids')
         lparProfile.virtSerialAdapters = propertiesDict.get('virtual_serial_adapters')
         
         return {lparId : lparProfile}
示例#10
0
 def _parsePoolAssignment(self, buffer):
     """
     This function parses the output of the lshwres -r proc --level lpar -m '<Managed System Name>'
     @param buffer: command output buffer
     @type buffer: String
     """
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         if propertiesDict.has_key('curr_shared_proc_pool_id'):
             return {lparId: propertiesDict.get('curr_shared_proc_pool_id')}
示例#11
0
 def _parsePoolAssignment(self, buffer):
     """
     This function parses the output of the lshwres -r proc --level lpar -m '<Managed System Name>'
     @param buffer: command output buffer
     @type buffer: String
     """
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         if propertiesDict.has_key('curr_shared_proc_pool_id'):
             return {lparId : propertiesDict.get('curr_shared_proc_pool_id')}
示例#12
0
 def _parseMemoryParameters(self, output):
     """
     This procedure parses and sets the values of the Memory Configuration for the Managed System
     @param output: output of 'lshwres -r mem --level sys <Managed System>' command
     @type output: String
     @param managedSysDo: data object of ManagedSystemDo
     @type managedSysDo: ManagedSystemDo class instace 
     """
     if output:
         propertiesDict = self.buildPropertiesDict(output)
         memoryParameters = ibm_hmc_lib.ManagedSystemMemoryParameters()
         memoryParameters.configurableSysMem = ibm_hmc_lib.toLong(propertiesDict.get('configurable_sys_mem'))
         memoryParameters.memRegSize = ibm_hmc_lib.toInteger(propertiesDict.get('mem_region_size'))
         memoryParameters.currAvailMem = ibm_hmc_lib.toLong(propertiesDict.get('curr_avail_sys_mem'))
         memoryParameters.installedMem = ibm_hmc_lib.toLong(propertiesDict.get('installed_sys_mem'))
         memoryParameters.reqHugePagesNum = ibm_hmc_lib.toLong(propertiesDict.get('requested_num_sys_huge_pages'))
         memoryParameters.pendingAvailMem = ibm_hmc_lib.toLong(propertiesDict.get('pend_avail_sys_mem'))
         memoryParameters.firmwareMem = ibm_hmc_lib.toLong(propertiesDict.get('sys_firmware_mem'))
         memoryParameters.hugePageSize = ibm_hmc_lib.toLong(propertiesDict.get('huge_page_size'))
         memoryParameters.maxNumberHugePages = ibm_hmc_lib.toInteger(propertiesDict.get('max_num_sys_huge_pages'))
         return memoryParameters
示例#13
0
 def _parseCpuParameters(self, output):
     """
     This procedure parses and sets the values of the Processor Configuration for the Managed System
     @param output: output of 'lshwres -r proc --level sys <Managed System>' command
     @type output: String
     @param managedSysDo: data object of ManagedSystemDo
     @type managedSysDo: ManagedSystemDo class instace 
     """
     if output:
         propertiesDict = self.buildPropertiesDict(output)
         cpuParameters = ibm_hmc_lib.ManagedSystemProcessorParameters()
         cpuParameters.minCpuPerVirtualCpu = ibm_hmc_lib.toFloat(propertiesDict.get('min_proc_units_per_virtual_proc'))
         cpuParameters.curCpuAvail = ibm_hmc_lib.toFloat(propertiesDict.get('curr_avail_sys_proc_units'))
         cpuParameters.maxCpuPerLpar = ibm_hmc_lib.toInteger(propertiesDict.get('max_procs_per_lpar'))
         cpuParameters.maxVirtCpuPerLpar = ibm_hmc_lib.toInteger(propertiesDict.get('max_virtual_procs_per_lpar'))
         cpuParameters.instCpuUnits = ibm_hmc_lib.toFloat(propertiesDict.get('installed_sys_proc_units'))
         cpuParameters.pendingAvailCpuUnits = ibm_hmc_lib.toFloat(propertiesDict.get('pend_avail_sys_proc_units'))
         cpuParameters.maxSharedCpuPools = ibm_hmc_lib.toInteger(propertiesDict.get('max_shared_proc_pools'))
         cpuParameters.maxOs400CpuUnits = ibm_hmc_lib.toInteger(propertiesDict.get('max_curr_procs_per_os400_lpar'))
         cpuParameters.configurableCpuUnits = ibm_hmc_lib.toFloat(propertiesDict.get('configurable_sys_proc_units'))
         return cpuParameters
示例#14
0
    def _parserGenericParameters(self, buffer):
        """
        This procedure parses and sets the values for the Managed System
        @param output: output of 'lssyscfg -r sys' command
        @type output: String
        @param managedSysDo: data object of ManagedSystemDo
        @type managedSysDo: ManagedSystemDo class instance 
        """
        if buffer:
            managedSysGenParams = ibm_hmc_lib.ManagedSystemGenericParameters()
            propertiesDict = self.buildPropertiesDict(buffer)
            if not propertiesDict.get('name'):
                raise ValueError, "Failed to parse out the Managed System Name for: %s " % buffer
            managedSysGenParams.name = propertiesDict.get('name')
            managedSysGenParams.serialNumber = propertiesDict.get('serial_num')
            managedSysGenParams.ipAddr = propertiesDict.get('ipaddr')
            managedSysGenParams.state = propertiesDict.get('state')
            managedSysGenParams.codCpuCapable = ibm_hmc_lib.toInteger(propertiesDict.get('cod_proc_capable'))
            managedSysGenParams.codMemCapable = ibm_hmc_lib.toInteger(propertiesDict.get('cod_mem_capable'))
            managedSysGenParams.hugeMemCapable = ibm_hmc_lib.toInteger(propertiesDict.get('huge_page_mem_capable'))
            managedSysGenParams.maxLpars = ibm_hmc_lib.toInteger(propertiesDict.get('max_lpars'))
            managedSysGenParams.microLparCape = ibm_hmc_lib.toInteger(propertiesDict.get('micro_lpar_capable'))
            managedSysGenParams.servLparId = ibm_hmc_lib.toInteger(propertiesDict.get('service_lpar_id'))
            managedSysGenParams.servLparName = propertiesDict.get('service_lpar_name')
            managedSysGenParams.type_model = propertiesDict.get('type_model')

            return managedSysGenParams
        else:
            raise ValueError, "Failed to parse out the Managed System Name for: %s " % buffer
示例#15
0
 def _parseLpar(self, buffer):
     """
     This function performs parsing of the command output lssysscfg -r lpar -m '<Managed System Name>'
     and sets the values for IbmLparProfileDo
     @param buffer: command output buffer
     @type buffer: String
     @return: instance of IbmLparProfileDo class 
     """
     lPar = ibm_fsm.IbmLpar()
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         lPar.lparName = propertiesDict.get('name')
         if not lPar.lparName:
             raise ValueError("Failed parsing Lpar Config File output for: %s" % buffer)
         lPar.autoStart = ibm_hmc_lib.toInteger(propertiesDict.get('auto_start'))
         lPar.powerCtrlIds = propertiesDict.get('power_ctrl_lpar_ids')
         lPar.bootMode = propertiesDict.get('boot_mode')
         if lPar.bootMode and lPar.bootMode not in ibm_fsm.LPAR_BOOT_MODES:
             logger.warn('Unsupported boot mode %s. Setting to None' % lPar.bootMode)
             lPar.bootMode = None
         lPar.redunErrPathRep = ibm_hmc_lib.toInteger(propertiesDict.get('redundant_err_path_reporting'))
         lPar.workgroupId = propertiesDict.get('work_group_id')
         lPar.defaultProfName = propertiesDict.get('default_profile')
         lPar.profileName = propertiesDict.get('curr_profile')
         state = LPAR_STATE_MAP.get(propertiesDict.get('primary_state'))
         if state:
             lPar.state = state
         lPar.type = propertiesDict.get('lpar_env')
         lPar.lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         lPar.logicalSerialNumber = propertiesDict.get('logical_serial_num')
         osTypeStr = propertiesDict.get('os_version')
         if osTypeStr:
             match = re.match('(\w+)\s(\d+\.\d+)', osTypeStr)
             if match:
                 lPar.osName = match.group(1)
                 lPar.osVersion = match.group(2) 
         ipStr =  propertiesDict.get('rmc_ipaddr')
         if ipStr and netutils.isValidIp(ipStr):
             lPar.rmcIp = ipStr.strip()
     return {lPar.lparId : lPar}
示例#16
0
 def _parseScsi(self, buffer):
     """
     Created SCSI Adapter DO from the output of the lshwres -r virtualio --rsubtype scsi -m '<Managed System Name>'
     @param buffer: command output
     @type buffer: String 
     """
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         vScsi = ibm_fsm.IbmVirtualScsiAdapter()
         vScsi.slotNumber = propertiesDict.get('slot_num')
         vScsi.remoteSlotNumber = propertiesDict.get('remote_slot_num')
         if vScsi.remoteSlotNumber is None or vScsi.remoteSlotNumber == '' or vScsi.slotNumber is None or vScsi.slotNumber == '':
             raise ValueError, "Failed parsing Virtual SCSI for %s" % buffer
         vScsi.type = propertiesDict.get('adapter_type')
         if vScsi.type == 'server':
             return None
         vScsi.parentId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         vScsi.parentName = propertiesDict.get('lpar_name')
         vScsi.remoteLparId = ibm_hmc_lib.toInteger(propertiesDict.get('remote_lpar_id'))
         vScsi.remoteLparName = propertiesDict.get('remote_lpar_name')
         vScsi.isVirtual = 1
         return vScsi
示例#17
0
 def _parseEth(self, buffer):
     """
     Created NIC DO from the output of the lshwres -r virtualio --rsubtype eth --level lpar -m '<Managed System Name>'
     @param buffer: command output
     @type buffer: String 
     @return: instance of NetworkInterfaceDo
     """
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         vEth = ibm_hmc_lib.LparNetworkInterface()
         vEth.macAddress = propertiesDict.get('mac_addr')
         if not vEth.macAddress and not netutils.isValidMac(vEth.macAddress):
             raise ValueError, "Failed parsing MAC addres of Virtual Ethernet Card from buffer: %s" % buffer
         vEth.macAddress = netutils.parseMac(vEth.macAddress)
         vEth.portVlanId = ibm_hmc_lib.toInteger(propertiesDict.get('port_vlan_id'))
         vEth.lparName = propertiesDict.get('lpar_name')
         vEth.slotNum = propertiesDict.get('slot_num')
         if not vEth.lparName:
             raise ValueError, "Failed parsing LPar Name for Virtual Ethernet Card from buffer: %s" % buffer
         vEth.lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
         vEth.isVirtual = 1
         
         return vEth
示例#18
0
 def _parseScsi(self, buffer):
     """
     Created SCSI Adapter DO from the output of the lshwres -r virtualio --rsubtype scsi -m '<Managed System Name>'
     @param buffer: command output
     @type buffer: String 
     """
     if buffer:
         propertiesDict = self.buildPropertiesDict(buffer)
         vScsi = ibm_fsm.IbmVirtualScsiAdapter()
         vScsi.slotNumber = propertiesDict.get('slot_num')
         vScsi.remoteSlotNumber = propertiesDict.get('remote_slot_num')
         if vScsi.remoteSlotNumber is None or vScsi.remoteSlotNumber == '' or vScsi.slotNumber is None or vScsi.slotNumber == '':
             raise ValueError, "Failed parsing Virtual SCSI for %s" % buffer
         vScsi.type = propertiesDict.get('adapter_type')
         if vScsi.type == 'server':
             return None
         vScsi.parentId = ibm_hmc_lib.toInteger(
             propertiesDict.get('lpar_id'))
         vScsi.parentName = propertiesDict.get('lpar_name')
         vScsi.remoteLparId = ibm_hmc_lib.toInteger(
             propertiesDict.get('remote_lpar_id'))
         vScsi.remoteLparName = propertiesDict.get('remote_lpar_name')
         vScsi.isVirtual = 1
         return vScsi
def parseEthernetAdapters(output):
    adaptersDict = {}
    if output:
        entries = ibm_hmc_lib.splitCommandOutput(output)
        for entrie in entries:
            if entrie and entrie.find(':') != -1:
                try:
                    iface = ibm_hmc_lib.LparNetworkInterface()
                    tokens = entrie.split(':')
                    iface.name = tokens[0].strip()
                    if iface.name:
                        ifaceIndex = re.match('\s*[A-Za-z]+(\d+)', iface.name)
                        if ifaceIndex:
                            iface.interfaceIndex = ibm_hmc_lib.toInteger(ifaceIndex.group(1))
                    iface.physicalPath = tokens[1].strip()
                    iface.interfaceType = ibm_hmc_lib.ETH_ADAPTER
                    adaptersDict[iface.name] = iface
                except:
                    logger.warn('Failed parsing interface from string %s' % entrie)
    return adaptersDict
示例#20
0
def parseVirtIoSlots(buffer):
    """
    Parses and sets the values for the Virtual I/O Slots Do
    @param buffer: output of the command ''
    @type buffer: String
    @return: IoSlotDo instance
    """
    if buffer:
        ioSlot = ibm_hmc_lib.IoSlot()
        propertiesDict = ibm_hmc_lib.buildPropertiesDict(buffer)
        ioSlot.drcName = propertiesDict.get('drc_name')
        if not ioSlot.drcName:
            raise ValueError, "Failed parsing virtual I/O Slot for %s" % buffer
        ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName)
        ioSlot.name = ioSlot.drcName
        ioSlot.lpar_name = propertiesDict.get('lpar_name')
        ioSlot.lpar_id = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
        ioSlot.isVirtual = 1
        ioSlot.slotNum = propertiesDict.get('slot_num')
        ioSlot.slotType = propertiesDict.get('config')
        return ioSlot
示例#21
0
def parseVirtIoSlots(buffer):
    """
    Parses and sets the values for the Virtual I/O Slots Do
    @param buffer: output of the command ''
    @type buffer: String
    @return: IoSlotDo instance
    """
    if buffer:
        ioSlot = ibm_hmc_lib.IoSlot()
        propertiesDict = ibm_hmc_lib.buildPropertiesDict(buffer)
        ioSlot.drcName = propertiesDict.get('drc_name')
        if not ioSlot.drcName:
            raise ValueError, "Failed parsing virtual I/O Slot for %s" % buffer
        ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(
            ioSlot.drcName)
        ioSlot.name = ioSlot.drcName
        ioSlot.lpar_name = propertiesDict.get('lpar_name')
        ioSlot.lpar_id = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
        ioSlot.isVirtual = 1
        ioSlot.slotNum = propertiesDict.get('slot_num')
        ioSlot.slotType = propertiesDict.get('config')
        return ioSlot
def parseEthernetAdapters(output):
    adaptersDict = {}
    if output:
        entries = ibm_hmc_lib.splitCommandOutput(output)
        for entrie in entries:
            if entrie and entrie.find(':') != -1:
                try:
                    iface = ibm_hmc_lib.LparNetworkInterface()
                    tokens = entrie.split(':')
                    iface.name = tokens[0].strip()
                    if iface.name:
                        ifaceIndex = re.match('\s*[A-Za-z]+(\d+)', iface.name)
                        if ifaceIndex:
                            iface.interfaceIndex = ibm_hmc_lib.toInteger(
                                ifaceIndex.group(1))
                    iface.physicalPath = tokens[1].strip()
                    iface.interfaceType = ibm_hmc_lib.ETH_ADAPTER
                    adaptersDict[iface.name] = iface
                except:
                    logger.warn('Failed parsing interface from string %s' %
                                entrie)
    return adaptersDict
示例#23
0
    def _parserGenericParameters(self, buffer):
        """
        This procedure parses and sets the values for the Managed System
        @param output: output of 'lssyscfg -r sys' command
        @type output: String
        @param managedSysDo: data object of ManagedSystemDo
        @type managedSysDo: ManagedSystemDo class instance 
        """
        if buffer:
            managedSysGenParams = ibm_hmc_lib.ManagedSystemGenericParameters()
            propertiesDict = self.buildPropertiesDict(buffer)
            if not propertiesDict.get('name'):
                raise ValueError, "Failed to parse out the Managed System Name for: %s " % buffer
            managedSysGenParams.name = propertiesDict.get('name')
            managedSysGenParams.serialNumber = propertiesDict.get('serial_num')
            managedSysGenParams.ipAddr = propertiesDict.get('ipaddr')
            managedSysGenParams.state = propertiesDict.get('state')
            managedSysGenParams.codCpuCapable = ibm_hmc_lib.toInteger(
                propertiesDict.get('cod_proc_capable'))
            managedSysGenParams.codMemCapable = ibm_hmc_lib.toInteger(
                propertiesDict.get('cod_mem_capable'))
            managedSysGenParams.hugeMemCapable = ibm_hmc_lib.toInteger(
                propertiesDict.get('huge_page_mem_capable'))
            managedSysGenParams.maxLpars = ibm_hmc_lib.toInteger(
                propertiesDict.get('max_lpars'))
            managedSysGenParams.microLparCape = ibm_hmc_lib.toInteger(
                propertiesDict.get('micro_lpar_capable'))
            managedSysGenParams.servLparId = ibm_hmc_lib.toInteger(
                propertiesDict.get('service_lpar_id'))
            managedSysGenParams.servLparName = propertiesDict.get(
                'service_lpar_name')
            managedSysGenParams.type_model = propertiesDict.get('type_model')

            return managedSysGenParams
        else:
            raise ValueError, "Failed to parse out the Managed System Name for: %s " % buffer
示例#24
0
    def _parseLparProfile(self, buffer):
        """
        This function performs parsing of the command output lssysscfg -r prof -m '<Managed System Name>' bloc
        and sets the values for IbmLparProfileDo
        @param buffer: command output buffer
        @type buffer: String
        @return: instance of IbmLparProfileDo class 
        """
        if buffer:
            propertiesDict = self.buildPropertiesDict(buffer)
            lparId = ibm_hmc_lib.toInteger(propertiesDict.get('lpar_id'))
            if not lparId:
                raise ValueError('Failed to parse out Lpar Id for buffer %s' %
                                 buffer)
            lparProfile = ibm_fsm.IbmLparProfile()
            lparProfile.desNumHugePages = ibm_hmc_lib.toInteger(
                propertiesDict.get('desired_num_huge_pages'))
            lparProfile.minNumHugePages = ibm_hmc_lib.toInteger(
                propertiesDict.get('min_num_huge_pages'))
            lparProfile.maxNumHugePages = ibm_hmc_lib.toInteger(
                propertiesDict.get('max_num_huge_pages'))
            lparProfile.desCpu = ibm_hmc_lib.toInteger(
                propertiesDict.get('desired_procs'))
            lparProfile.minCpu = ibm_hmc_lib.toInteger(
                propertiesDict.get('min_procs'))
            lparProfile.maxCpu = ibm_hmc_lib.toInteger(
                propertiesDict.get('max_procs'))
            lparProfile.desPhysCpu = ibm_hmc_lib.toFloat(
                propertiesDict.get('desired_proc_units'))
            lparProfile.minPhysCpu = ibm_hmc_lib.toFloat(
                propertiesDict.get('min_proc_units'))
            lparProfile.maxPhysCpu = ibm_hmc_lib.toFloat(
                propertiesDict.get('max_proc_units'))
            lparProfile.desMem = ibm_hmc_lib.toLong(
                propertiesDict.get('desired_mem'))
            lparProfile.minMem = ibm_hmc_lib.toLong(
                propertiesDict.get('min_mem'))
            lparProfile.maxMem = ibm_hmc_lib.toLong(
                propertiesDict.get('max_mem'))
            lparProfile.sharingMode = propertiesDict.get('sharing_mode')
            if lparProfile.sharingMode and lparProfile.sharingMode not in ibm_fsm.LPAR_SHARING_MODES:
                logger.warn('Unsupported sharing mode: %s. Setting to None.' %
                            lparProfile.sharingMode)
                lparProfile.sharingMode = None
            lparProfile.cpuMode = propertiesDict.get('proc_mode')
            if lparProfile.cpuMode and ibm_fsm.LPAR_CPU_MODES.has_key(
                    lparProfile.cpuMode):
                lparProfile.cpuMode = ibm_fsm.LPAR_CPU_MODES.get(
                    lparProfile.cpuMode)
            else:
                logger.warn('Unsupported CPU mode %s. Setting to None' %
                            lparProfile.cpuMode)
                lparProfile.cpuMode = None
            lparProfile.uncapWeight = ibm_hmc_lib.toInteger(
                propertiesDict.get('uncap_weight'))
            lparProfile.connMonEnabled = ibm_hmc_lib.toInteger(
                propertiesDict.get('conn_monitoring'))
            lparProfile.maxVirtSlots = ibm_hmc_lib.toInteger(
                propertiesDict.get('max_virtual_slots'))
            lparProfile.ioPoolIds = propertiesDict.get('lpar_io_pool_ids')
            lparProfile.virtSerialAdapters = propertiesDict.get(
                'virtual_serial_adapters')

            return {lparId: lparProfile}