def createZoneConfigObject(zone, resultsVector): zoneConfigOsh = ObjectStateHolder('solaris_zone_config') zoneConfigOsh.setAttribute('data_name', 'Solaris Zone Configuration') zoneConfigOsh.setAttribute('zone_name', zone.name) zoneConfigOsh.setAttribute('zone_path', zone.path) zoneConfigOsh.setAttribute('zone_status', zone.status) zoneConfigOsh.setAttribute('zone_brand', zone.brand) if zone.uuid: zoneConfigOsh.setAttribute('zone_uuid', zone.uuid) if zone.autoboot is not None: zoneConfigOsh.setBoolAttribute('zone_autoboot', zone.autoboot) if zone.limitPrivileges: zoneConfigOsh.setAttribute('limit_privileges', zone.limitPrivileges) if zone.schedulingClass: zoneConfigOsh.setAttribute('scheduling_class', zone.schedulingClass) if zone.cpuShares is not None: zoneConfigOsh.setIntegerAttribute('cpu_shares', zone.cpuShares) if zone.cpuCap is not None: zoneConfigOsh.setFloatAttribute('capped_cpu_ncpus', zone.cpuCap) if zone.dedicatedCpu: if zone.dedicatedCpu.ncpus: zoneConfigOsh.setAttribute('dedicated_cpu_ncpus', zone.dedicatedCpu.ncpus) if zone.dedicatedCpu.importance: zoneConfigOsh.setIntegerAttribute('dedicated_cpu_importance', zone.dedicatedCpu.importance) if zone.memoryCaps: if zone.memoryCaps.physicalCap is not None: zoneConfigOsh.setLongAttribute('capped_memory_physical', zone.memoryCaps.physicalCap) if zone.memoryCaps.swapCap is not None: zoneConfigOsh.setLongAttribute('capped_memory_swap', zone.memoryCaps.swapCap) if zone.memoryCaps.lockedCap is not None: zoneConfigOsh.setLongAttribute('capped_memory_locked', zone.memoryCaps.lockedCap) zoneConfigOsh.setContainer(zone.hostOsh) resultsVector.add(zoneConfigOsh) zone.configOsh = zoneConfigOsh
def createProcessorPoolOsh(processorPool, hypervisorOsh): """ Creates Shared Processor Pool Object State Holder @param processorPool: the discovered Shared Processor Pool @type processorPool: instance of the IbmProcessorPool Data Object @param hypervisorOsh: @type hypervisorOsh: @return: Object State Holder of the IBM Processor Pool CI """ if processorPool and processorPool.name and hypervisorOsh: processorPoolOsh = ObjectStateHolder('ibm_resource_pool') processorPoolOsh.setContainer(hypervisorOsh) processorPoolOsh.setStringAttribute('data_name', processorPool.name) processorPoolOsh.setStringAttribute('pool_id', processorPool.name) if processorPool.physCpuAvail is not None: processorPoolOsh.setFloatAttribute('physical_cpus_available', processorPool.physCpuAvail) if processorPool.physCpuConf is not None: processorPoolOsh.setFloatAttribute('physical_cpus_configurable', processorPool.physCpuConf) if processorPool.physCpuPendingAvail is not None: processorPoolOsh.setFloatAttribute('physical_cpus_pending', processorPool.physCpuPendingAvail) return processorPoolOsh
def createProcessorPoolOsh(processorPool, hypervisorOsh): """ Creates Shared Processor Pool Object State Holder @param processorPool: the discovered Shared Processor Pool @type processorPool: instance of the IbmProcessorPool Data Object @param hypervisorOsh: @type hypervisorOsh: @return: Object State Holder of the IBM Processor Pool CI """ if processorPool and processorPool.name and hypervisorOsh: processorPoolOsh = ObjectStateHolder('ibm_resource_pool') processorPoolOsh.setContainer(hypervisorOsh) processorPoolOsh.setStringAttribute('data_name', processorPool.name) processorPoolOsh.setStringAttribute('pool_id', processorPool.name) if processorPool.physCpuAvail is not None: processorPoolOsh.setFloatAttribute('physical_cpus_available', processorPool.physCpuAvail) if processorPool.physCpuConf is not None: processorPoolOsh.setFloatAttribute('physical_cpus_configurable', processorPool.physCpuConf) if processorPool.physCpuPendingAvail is not None: processorPoolOsh.setFloatAttribute( 'physical_cpus_pending', processorPool.physCpuPendingAvail) return processorPoolOsh
def processObjects(allObjects): vector = ObjectStateHolderVector() iter = allObjects.iterator() #ciList = [[id, type, props]] ciList = [] ciDict = {} createCi = 1 while iter.hasNext(): #attributes = [name, type, key, value] attributes = [] objectElement = iter.next() mamId = objectElement.getAttribute('mamId').getValue() cit = objectElement.getAttribute('name').getValue() if mamId != None and cit != None: # add the attributes... allAttributes = objectElement.getChildren('field') iterAtt = allAttributes.iterator() while iterAtt.hasNext(): attElement = iterAtt.next() attName = attElement.getAttribute('name').getValue() attType = attElement.getAttribute('datatype').getValue() #print 'GOT TYPE: ', attType attKey = attElement.getAttribute('key') attValue = attElement.getText() if attType == None or attType == "": attType = "string" if attKey == None or attKey == "": attKey = "false" else: attKey = attKey.getValue() if attName != "" and attType != "": attributes.append([attName, attType, attKey, attValue]) # create CI or not? Is key empty or none? if attKey == "true": # print 'KEY ATTRIB <', attName, '> with value <', attValue, '> for CIT <', cit, '> with MAMID <', mamId, '>' if attValue != None and attValue.strip() != "": createCi = 1 else: createCi = 0 #info (concatenate("Id: ", mamId, ", Type: ", cit, ", Properties: ", attributes)) if createCi == 1: ciList.append([mamId, cit, attributes]) ciDict[mamId] = [mamId, cit, attributes] for ciVal in ciList: dontCreateCI = 0 #info("\tAdding %s [%s] => [%s]" % (ciVal[1], ciVal[0], ciVal[2]) ) id = ciVal[0] type = ciVal[1] osh = ObjectStateHolder(type) if ciVal[2] != None: props = ciVal[2] createContainer = 0 containerOsh = None for prop in props: if prop[0] == 'root_container': if dontCreateCI or prop[3] not in ciDict.keys(): # print 'MAM ID <', prop[3], '> not found!' dontCreateCI = 1 continue parent = ciDict[prop[3]] # create the container osh if parent != None: #parentId = parent[0] parentType = parent[1] parentProps = parent[2] containerOsh = ObjectStateHolder(parentType) if parentProps != None: for parentProp in parentProps: containerOsh.setAttribute( parentProp[0], parentProp[3]) createContainer = 1 #print 'Props <', prop, '>' try: if prop[1] == 'StrProp': osh.setStringAttribute(prop[0], prop[3]) elif prop[1] == 'StrListProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setListAttribute(prop[0], [prop[3]]) elif prop[1] == 'DoubleProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setDoubleAttribute(prop[0], prop[3]) elif prop[1] == 'FloatProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setFloatAttribute(prop[0], prop[3]) elif prop[1] == 'IntProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: #print '[VINAY] Got int <', prop[3], '>' osh.setIntegerAttribute(prop[0], prop[3]) elif prop[1] == 'LongProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: #print '[VINAY] Got long <', prop[3], '>' osh.setLongAttribute(prop[0], prop[3]) elif prop[1] == 'BoolProp' and prop[3] != None and prop[ 3] != '' and len(prop[3]) > 0: osh.setBoolAttribute(prop[0], prop[3]) elif prop[3] != None and prop[3] != '' and len( prop[3]) > 0: osh.setAttribute(prop[0], prop[3]) if createContainer == 1: osh.setContainer(containerOsh) except: stacktrace = traceback.format_exception( sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.warn('Exception setting attribute <', prop[0], '> with value <', prop[3], '>:\n', stacktrace) pass if dontCreateCI: continue vector.add(osh) return (vector, ciDict)
def createLparProfileOsh(lparProfile, hostOsh): """ Creates the Lpar Profile Object State Holder @param lparProfile: the discovered parameters of the Lpar or VIO Server @type lparProfile: instance of the LparProfile Data Object @param hostOsh: lpar of vio server host @type hostOsh: Object State Holder of the Host CI or any of its children @return: Object State Holder for the LPar Profile """ if lparProfile: lparProfileOsh = ObjectStateHolder('ibm_lpar_profile') lparProfileOsh.setStringAttribute('data_name', lparProfile.lparProfile.name) lparProfileOsh.setContainer(hostOsh) if lparProfile.logicalSerialNumber: lparProfileOsh.setStringAttribute('logical_serial_number', lparProfile.logicalSerialNumber) if lparProfile.lparProfile.sharingMode: lparProfileOsh.setStringAttribute( 'sharing_mode', lparProfile.lparProfile.sharingMode) if lparProfile.lparProfile.cpuMode: lparProfileOsh.setStringAttribute('proc_mode', lparProfile.lparProfile.cpuMode) if lparProfile.lparProfile.uncapWeight is not None: lparProfileOsh.setIntegerAttribute( 'uncap_weight', lparProfile.lparProfile.uncapWeight) if lparProfile.powerCtrlIds: lparProfileOsh.setStringAttribute('power_ctrl_lpar_ids', lparProfile.powerCtrlIds) if lparProfile.bootMode: lparProfileOsh.setStringAttribute('boot_mode', lparProfile.bootMode) if lparProfile.lparProfile.connMonEnabled is not None: lparProfileOsh.setBoolAttribute( 'conn_monitoring', lparProfile.lparProfile.connMonEnabled) if lparProfile.lparProfile.maxVirtSlots is not None: lparProfileOsh.setIntegerAttribute( 'max_virtual_slots', lparProfile.lparProfile.maxVirtSlots) if lparProfile.autoStart is not None: lparProfileOsh.setBoolAttribute('auto_start', lparProfile.autoStart) if lparProfile.lparProfile.ioPoolIds: lparProfileOsh.setStringAttribute( 'lpar_io_pool_ids', lparProfile.lparProfile.ioPoolIds) if lparProfile.redunErrPathRep is not None: lparProfileOsh.setBoolAttribute('redundant_err_path_reporting', lparProfile.redunErrPathRep) if lparProfile.lparProfile.desNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'desired_num_huge_pages', lparProfile.lparProfile.desNumHugePages) if lparProfile.lparProfile.minNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'min_num_huge_pages', lparProfile.lparProfile.minNumHugePages) if lparProfile.lparProfile.maxNumHugePages is not None: lparProfileOsh.setIntegerAttribute( 'max_num_huge_pages', lparProfile.lparProfile.maxNumHugePages) if lparProfile.lparProfile.desCpu is not None: lparProfileOsh.setIntegerAttribute('desired_procs', lparProfile.lparProfile.desCpu) if lparProfile.lparProfile.minCpu is not None: lparProfileOsh.setIntegerAttribute('min_procs', lparProfile.lparProfile.minCpu) if lparProfile.lparProfile.maxCpu is not None: lparProfileOsh.setIntegerAttribute('max_procs', lparProfile.lparProfile.maxCpu) if lparProfile.lparProfile.desPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'desired_proc_units', lparProfile.lparProfile.desPhysCpu) if lparProfile.lparProfile.minPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'min_proc_units', lparProfile.lparProfile.minPhysCpu) if lparProfile.lparProfile.maxPhysCpu is not None: lparProfileOsh.setFloatAttribute( 'max_proc_units', lparProfile.lparProfile.maxPhysCpu) if lparProfile.lparProfile.desMem is not None: lparProfileOsh.setLongAttribute('desired_mem', lparProfile.lparProfile.desMem) if lparProfile.lparProfile.minMem is not None: lparProfileOsh.setLongAttribute('min_mem', lparProfile.lparProfile.minMem) if lparProfile.lparProfile.maxMem is not None: lparProfileOsh.setLongAttribute('max_mem', lparProfile.lparProfile.maxMem) if lparProfile.workgroupId: lparProfileOsh.setStringAttribute('work_group_id', lparProfile.workgroupId) if lparProfile.defaultProfName: lparProfileOsh.setStringAttribute('default_profile_name', lparProfile.defaultProfName) if lparProfile.profileName: lparProfileOsh.setStringAttribute('profile_name', lparProfile.profileName) if lparProfile.state: lparProfileOsh.setStringAttribute('lpar_state', lparProfile.state) if lparProfile.type: lparProfileOsh.setStringAttribute('lpar_type', lparProfile.type) if lparProfile.lparId is not None: lparProfileOsh.setIntegerAttribute('lpar_id', lparProfile.lparId) if lparProfile.lparName: lparProfileOsh.setStringAttribute('lpar_name', lparProfile.lparName) if lparProfile.lparProfile.virtSerialAdapters: lparProfileOsh.setStringAttribute( 'virtual_serial_adapters', lparProfile.lparProfile.virtSerialAdapters) return lparProfileOsh
def createLparProfileOsh(lparProfile, hostOsh): """ Creates the Lpar Profile Object State Holder @param lparProfile: the discovered parameters of the Lpar or VIO Server @type lparProfile: instance of the LparProfile Data Object @param hostOsh: lpar of vio server host @type hostOsh: Object State Holder of the Host CI or any of its children @return: Object State Holder for the LPar Profile """ if lparProfile: lparProfileOsh = ObjectStateHolder('ibm_lpar_profile') lparProfileOsh.setStringAttribute('data_name', lparProfile.lparProfile.name) lparProfileOsh.setContainer(hostOsh) if lparProfile.logicalSerialNumber: lparProfileOsh.setStringAttribute('logical_serial_number', lparProfile.logicalSerialNumber) if lparProfile.lparProfile.sharingMode: lparProfileOsh.setStringAttribute('sharing_mode', lparProfile.lparProfile.sharingMode) if lparProfile.lparProfile.cpuMode: lparProfileOsh.setStringAttribute('proc_mode', lparProfile.lparProfile.cpuMode) if lparProfile.lparProfile.uncapWeight is not None: lparProfileOsh.setIntegerAttribute('uncap_weight', lparProfile.lparProfile.uncapWeight) if lparProfile.powerCtrlIds: lparProfileOsh.setStringAttribute('power_ctrl_lpar_ids', lparProfile.powerCtrlIds) if lparProfile.bootMode: lparProfileOsh.setStringAttribute('boot_mode', lparProfile.bootMode) if lparProfile.lparProfile.connMonEnabled is not None: lparProfileOsh.setBoolAttribute('conn_monitoring', lparProfile.lparProfile.connMonEnabled) if lparProfile.lparProfile.maxVirtSlots is not None: lparProfileOsh.setIntegerAttribute('max_virtual_slots', lparProfile.lparProfile.maxVirtSlots) if lparProfile.autoStart is not None: lparProfileOsh.setBoolAttribute('auto_start', lparProfile.autoStart) if lparProfile.lparProfile.ioPoolIds: lparProfileOsh.setStringAttribute('lpar_io_pool_ids', lparProfile.lparProfile.ioPoolIds) if lparProfile.redunErrPathRep is not None: lparProfileOsh.setBoolAttribute('redundant_err_path_reporting', lparProfile.redunErrPathRep) if lparProfile.lparProfile.desNumHugePages is not None: lparProfileOsh.setIntegerAttribute('desired_num_huge_pages', lparProfile.lparProfile.desNumHugePages) if lparProfile.lparProfile.minNumHugePages is not None: lparProfileOsh.setIntegerAttribute('min_num_huge_pages', lparProfile.lparProfile.minNumHugePages) if lparProfile.lparProfile.maxNumHugePages is not None: lparProfileOsh.setIntegerAttribute('max_num_huge_pages', lparProfile.lparProfile.maxNumHugePages) if lparProfile.lparProfile.desCpu is not None: lparProfileOsh.setIntegerAttribute('desired_procs', lparProfile.lparProfile.desCpu) if lparProfile.lparProfile.minCpu is not None: lparProfileOsh.setIntegerAttribute('min_procs', lparProfile.lparProfile.minCpu) if lparProfile.lparProfile.maxCpu is not None: lparProfileOsh.setIntegerAttribute('max_procs', lparProfile.lparProfile.maxCpu) if lparProfile.lparProfile.desPhysCpu is not None: lparProfileOsh.setFloatAttribute('desired_proc_units', lparProfile.lparProfile.desPhysCpu) if lparProfile.lparProfile.minPhysCpu is not None: lparProfileOsh.setFloatAttribute('min_proc_units', lparProfile.lparProfile.minPhysCpu) if lparProfile.lparProfile.maxPhysCpu is not None: lparProfileOsh.setFloatAttribute('max_proc_units', lparProfile.lparProfile.maxPhysCpu) if lparProfile.lparProfile.desMem is not None: lparProfileOsh.setLongAttribute('desired_mem', lparProfile.lparProfile.desMem) if lparProfile.lparProfile.minMem is not None: lparProfileOsh.setLongAttribute('min_mem', lparProfile.lparProfile.minMem) if lparProfile.lparProfile.maxMem is not None: lparProfileOsh.setLongAttribute('max_mem', lparProfile.lparProfile.maxMem) if lparProfile.workgroupId: lparProfileOsh.setStringAttribute('work_group_id', lparProfile.workgroupId) if lparProfile.defaultProfName: lparProfileOsh.setStringAttribute('default_profile_name', lparProfile.defaultProfName) if lparProfile.profileName: lparProfileOsh.setStringAttribute('profile_name', lparProfile.profileName) if lparProfile.state: lparProfileOsh.setStringAttribute('lpar_state', lparProfile.state) if lparProfile.type: lparProfileOsh.setStringAttribute('lpar_type', lparProfile.type) if lparProfile.lparId is not None: lparProfileOsh.setIntegerAttribute('lpar_id', lparProfile.lparId) if lparProfile.lparName: lparProfileOsh.setStringAttribute('lpar_name', lparProfile.lparName) if lparProfile.lparProfile.virtSerialAdapters: lparProfileOsh.setStringAttribute('virtual_serial_adapters', lparProfile.lparProfile.virtSerialAdapters) return lparProfileOsh
def processObjects(allObjects): vector = ObjectStateHolderVector() iter = allObjects.iterator() #ciList = [[id, type, props]] ciList = [] ciDict = {} createCi = 1 while iter.hasNext(): #attributes = [name, type, key, value] attributes = [] objectElement = iter.next() mamId = objectElement.getAttribute('mamId').getValue() cit = objectElement.getAttribute('name').getValue() if mamId != None and cit != None: # add the attributes... allAttributes = objectElement.getChildren('field') iterAtt = allAttributes.iterator() while iterAtt.hasNext(): attElement = iterAtt.next() attName = attElement.getAttribute('name').getValue() attType = attElement.getAttribute('datatype').getValue() #print 'GOT TYPE: ', attType attKey = attElement.getAttribute('key') attValue = attElement.getText() if attType == None or attType == "": attType = "string" if attKey == None or attKey == "": attKey = "false" else: attKey = attKey.getValue() if attName != "" and attType != "": attributes.append([attName, attType, attKey, attValue]) # create CI or not? Is key empty or none? if attKey == "true": # print 'KEY ATTRIB <', attName, '> with value <', attValue, '> for CIT <', cit, '> with MAMID <', mamId, '>' if attValue != None and attValue.strip() != "": createCi = 1 else: createCi = 0 #info (concatenate("Id: ", mamId, ", Type: ", cit, ", Properties: ", attributes)) if createCi == 1: ciList.append([mamId, cit, attributes]) ciDict[mamId] = [mamId, cit, attributes] for ciVal in ciList: dontCreateCI = 0 #info("\tAdding %s [%s] => [%s]" % (ciVal[1], ciVal[0], ciVal[2]) ) id = ciVal[0] type = ciVal[1] osh = ObjectStateHolder(type) if ciVal[2] != None: props = ciVal[2] createContainer = 0 containerOsh = None for prop in props: if prop[0] == 'root_container': if dontCreateCI or prop[3] not in ciDict.keys(): # print 'MAM ID <', prop[3], '> not found!' dontCreateCI = 1 continue parent = ciDict[prop[3]] # create the container osh if parent != None: #parentId = parent[0] parentType = parent[1] parentProps = parent[2] containerOsh = ObjectStateHolder(parentType) if parentProps != None: for parentProp in parentProps: containerOsh.setAttribute(parentProp[0], parentProp[3]) createContainer = 1 #print 'Props <', prop, '>' try: if prop[1] == 'StrProp': osh.setStringAttribute(prop[0], prop[3]) elif prop[1] == 'StrListProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setListAttribute(prop[0], [prop[3]]) elif prop[1] == 'DoubleProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setDoubleAttribute(prop[0], prop[3]) elif prop[1] == 'FloatProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setFloatAttribute(prop[0], prop[3]) elif prop[1] == 'IntProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: #print '[VINAY] Got int <', prop[3], '>' osh.setIntegerAttribute(prop[0], prop[3]) elif prop[1] == 'LongProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: #print '[VINAY] Got long <', prop[3], '>' osh.setLongAttribute(prop[0], prop[3]) elif prop[1] == 'BoolProp' and prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setBoolAttribute(prop[0], prop[3]) elif prop[3] != None and prop[3] != '' and len(prop[3]) > 0: osh.setAttribute(prop[0], prop[3]) if createContainer == 1: osh.setContainer(containerOsh) except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.warn('Exception setting attribute <', prop[0], '> with value <', prop[3], '>:\n', stacktrace) pass if dontCreateCI: continue vector.add(osh) return (vector, ciDict)