def createCpuObjects(globalCpusById, globalZoneOsh, resultsVector): for id_, cpu in globalCpusById.items(): cpuId = 'VCPU%s' % id_ cpuOsh = modeling.createCpuOsh(cpuId, globalZoneOsh, speed = cpu.speed, data_name = cpu.name) cpuOsh.setBoolAttribute('isvirtual', 1) resultsVector.add(cpuOsh) cpu.osh = cpuOsh
def makeCPUOSH(hostId, cid, vendor='', speed='', usage='', data_name='', coreNumber=0, descr='', is_virtual = False): hostOsh = modeling.createOshByCmdbIdString('host', hostId) cpuOsh = modeling.createCpuOsh(cid, hostOsh, speed, coreNumber, vendor, descr, data_name) if is_virtual: cpuOsh.setBoolAttribute('isvirtual', 1) return cpuOsh
def build(self, processor, esxOsh): if processor is None: raise ValueError("processor is None") if processor._index is None: raise ValueError("processor index is not set") cpuId = "CPU%s" % processor._index return modeling.createCpuOsh(cpuId, esxOsh, processor.currentClockSpeed, processor.numberOfEnabledCores, None, processor.modelName, processor.modelName)
def reportServer(hostDo, chassis_map): vector = ObjectStateHolderVector() server_osh = buildServer(hostDo) chassis_osh = chassis_map.get(hostDo.referenced_chassis) if not chassis_osh: logger.warn( 'Failed to get referenced chassis "%s" for server %s. Server will not be reported.' % (hostDo.referenced_chassis, hostDo)) return vector, None, {} link_osh = modeling.createLinkOSH('containment', chassis_osh, server_osh) vector.add(server_osh) vector.add(chassis_osh) vector.add(link_osh) if hostDo.ipList: for ip in hostDo.ipList: ip_osh = modeling.createIpOSH(ip) link_osh = modeling.createLinkOSH('containment', server_osh, ip_osh) vector.add(ip_osh) vector.add(link_osh) iface_mac_to_iface_osh = {} if hostDo.macs: for mac in hostDo.macs: interface_osh = modeling.createInterfaceOSH(mac, server_osh) vector.add(interface_osh) iface_mac_to_iface_osh[mac] = interface_osh if hostDo.managedSystem: if hostDo.managedSystem.cpuParameters and hostDo.managedSystem.cpuParameters.instCpuUnits: for i in xrange( int(hostDo.managedSystem.cpuParameters.instCpuUnits)): cpuOsh = modeling.createCpuOsh('CPU' + str(i), server_osh) # We treat a core as a physical CPU, so set core_number to 1 cpuOsh.setIntegerAttribute("core_number", 1) vector.add(cpuOsh) if hostDo.managedSystem.ioSlotList: for ioSlot in hostDo.managedSystem.ioSlotList: vector.add(ibm_hmc_lib.createIoSlotOsh(ioSlot, server_osh)) return vector, server_osh, iface_mac_to_iface_osh
def reportServer(hostDo, chassis_map): vector = ObjectStateHolderVector() server_osh = buildServer(hostDo) chassis_osh = chassis_map.get(hostDo.referenced_chassis) if not chassis_osh: logger.warn('Failed to get referenced chassis "%s" for server %s. Server will not be reported.' % (hostDo.referenced_chassis, hostDo)) return vector, None, {} link_osh = modeling.createLinkOSH('containment', chassis_osh, server_osh) vector.add(server_osh) vector.add(chassis_osh) vector.add(link_osh) if hostDo.ipList: for ip in hostDo.ipList: ip_osh = modeling.createIpOSH(ip) link_osh = modeling.createLinkOSH('containment', server_osh, ip_osh) vector.add(ip_osh) vector.add(link_osh) iface_mac_to_iface_osh = {} if hostDo.macs: for mac in hostDo.macs: interface_osh = modeling.createInterfaceOSH(mac, server_osh) vector.add(interface_osh) iface_mac_to_iface_osh[mac] = interface_osh if hostDo.managedSystem: if hostDo.managedSystem.cpuParameters and hostDo.managedSystem.cpuParameters.instCpuUnits: for i in xrange(int(hostDo.managedSystem.cpuParameters.instCpuUnits)): cpuOsh = modeling.createCpuOsh('CPU' + str(i), server_osh) # We treat a core as a physical CPU, so set core_number to 1 cpuOsh.setIntegerAttribute("core_number", 1) vector.add(cpuOsh) if hostDo.managedSystem.ioSlotList: for ioSlot in hostDo.managedSystem.ioSlotList: vector.add(ibm_hmc_lib.createIoSlotOsh(ioSlot, server_osh)) return vector, server_osh, iface_mac_to_iface_osh
def build(self, cpu, container): cpuOsh = modeling.createCpuOsh(cpu.idStr, container, cpu.speed, cpu.coresCount, cpu.vendor, cpu.description, data_name = cpu.description) return cpuOsh
def build_cpu(self, cpu, hostOsh): return modeling.createCpuOsh('CPU%s' % cpu['number'], hostOsh, cpu['speed'], vendor=cpu['vendor'], data_name=cpu['modelname'])
def doDiscovery(shell, hostOsh, managedSystemOsh, framework, osType): vector = ObjectStateHolderVector() scsiAdaptersList = [] physAdaptList = [] virtAdaptList = [] seaAdaptList = [] linkAggrAdaptList = [] volumeGroupsDict = {} physicalVolumeDict = {} logicalVolumeDict = {} scsiManList = [] pvAssignList = [] fiberChannelAdaptersList = [] ethAliasesList = [] isVio = ibm_hmc_lib.isVio(shell) if isVio: try: cpus = discoverCpus(shell) for cpu in cpus: cpuOsh = modeling.createCpuOsh(cpu.idStr, managedSystemOsh, cpu.speed, cpu.coresCount, 'ibm_corp', data_name = cpu.model) vector.add(cpuOsh) except: logger.errorException('') framework.reportWarning('Failed to discover CPUs') if osType and osType.upper() == 'AIX': try: fiberChannelAdaptersList = discoverFiberChannels(shell) except: framework.reportWarning("Failed to discover Fibre Channel adapters") ethAdaptersDict = {} if isVio: ethAdaptersDict = discoverEthernetAdapters(shell) ethAliasesList = discoverEhernetAdapterAliasses(shell) else: ethAdaptersDict = discoverAixLparEthernetAdapters(shell) physAdaptList = getPhysicalEthAdapters(ethAdaptersDict.values()) virtAdaptList = getVirtualEthAdapters(ethAdaptersDict.values()) seaAdaptList = getSeaAdapters(ethAdaptersDict.values()) linkAggrAdaptList = getLinkAggregationInterfaces(ethAdaptersDict.values()) calculateAdaptersSpeed(linkAggrAdaptList, ethAdaptersDict) calculateAdaptersSpeed(seaAdaptList, ethAdaptersDict) calculateAdaptersSpeed(virtAdaptList, ethAdaptersDict) volumeGroupsDict = discoverVolumeGroups(shell) physicalVolumeDict = discoverPhysicalVolumes(shell) logicalVolumeDict = discoverLogicalVolumes(shell, volumeGroupsDict) if isVio: scsiAdaptersList = discoverScsi(shell, physicalVolumeDict, logicalVolumeDict) (scsiManList, pvAssignList) = discoverPhysScsiAndRaid(shell, physicalVolumeDict) else: (scsiManList, pvAssignList) = discoverLparPhysScsiAndRaid(shell, physicalVolumeDict) elif osType and osType.upper() == 'LINUX': scsiAdaptersList = discoverLinuxVScsiAdapters(shell) (volumeGroupsDict, logicalVolumeDict, physicalVolumeDict) = discoverLinuxStorageInfo(shell) ethAdaptersDict = {} if physAdaptList: for physAdapt in physAdaptList: physAdaptOsh = createInterfaceOsh(physAdapt, hostOsh) linkOsh = modeling.createLinkOSH('contained', managedSystemOsh, physAdaptOsh) vector.add(linkOsh) if physAdapt.physicalPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = physAdapt.physicalPath ioSlot.drcName = physAdapt.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, physAdaptOsh) vector.add(ioSlotOsh) vector.add(linkOsh) if ethAliasesList: for aliasName in ['en'+str(physAdapt.interfaceIndex), 'et'+str(physAdapt.interfaceIndex)]: if aliasName in ethAliasesList: aliasOsh = createAliasOsh(aliasName, hostOsh, physAdapt) if aliasOsh: vector.add(aliasOsh) vector.add(vector.add(modeling.createLinkOSH('realization', physAdaptOsh, aliasOsh))) if logger.Version().getVersion(framework) < 9: interfaceIndexOsh = createInterfaceIndexOsh(physAdapt, hostOsh) if interfaceIndexOsh: linkOsh = modeling.createLinkOSH('parent', interfaceIndexOsh, physAdaptOsh) vector.add(interfaceIndexOsh) vector.add(linkOsh) # vector.add(physAdaptOsh) ethAdaptersDict[physAdapt.name] = physAdaptOsh if linkAggrAdaptList: for linkAggr in linkAggrAdaptList: linkAggrOsh = createLinkAggrOsh(linkAggr, hostOsh) if linkAggr.usedAdapters: vector.add(linkAggrOsh) ethAdaptersDict[linkAggr.name] = linkAggrOsh for usedAdapterName in linkAggr.usedAdapters: physAdaptOsh = ethAdaptersDict.get(usedAdapterName) if physAdaptOsh: #change the KEY attribute for the Physical Ethernet Adapter mac = physAdaptOsh.getAttributeValue('interface_macaddr') newKey = '%s_%s' % (mac, usedAdapterName) physAdaptOsh.setAttribute('interface_macaddr', newKey) ethAdaptersDict[usedAdapterName] = physAdaptOsh linkOsh = modeling.createLinkOSH('member', linkAggrOsh, physAdaptOsh) vector.add(linkOsh) if linkAggr.backupAdapter: ethBackOsh = ethAdaptersDict.get(linkAggr.backupAdapter) linkOsh = modeling.createLinkOSH('member', linkAggrOsh, ethBackOsh) vector.add(linkOsh) #Adding Physical ETH adapters to the result vector if ethAdaptersDict: for physAdaptOsh in ethAdaptersDict.values(): vector.add(physAdaptOsh) if seaAdaptList: for seaAdapter in seaAdaptList: seaAdapterOsh = createSeaOsh(seaAdapter, hostOsh) if seaAdapter.usedAdapters: vector.add(seaAdapterOsh) ethAdaptersDict[seaAdapter.name] = seaAdapterOsh for usedAdapterName in seaAdapter.usedAdapters: backAdapterOsh = ethAdaptersDict.get(usedAdapterName) if backAdapterOsh: linkOsh = modeling.createLinkOSH('use', seaAdapterOsh, backAdapterOsh) vector.add(linkOsh) if virtAdaptList: for virtualAdapter in virtAdaptList: virtAdapterOsh = ibm_hmc_lib.createVEthOsh(virtualAdapter, hostOsh) vector.add(virtAdapterOsh) if ethAliasesList: for aliasName in ['en'+str(virtualAdapter.interfaceIndex), 'et'+str(virtualAdapter.interfaceIndex)]: if aliasName in ethAliasesList: aliasOsh = createAliasOsh(aliasName, hostOsh, virtualAdapter) if aliasOsh: vector.add(aliasOsh) vector.add(vector.add(modeling.createLinkOSH('realization', virtAdapterOsh, aliasOsh))) if virtualAdapter.usedAdapters: for usedAdapterName in virtualAdapter.usedAdapters: backAdapterOsh = ethAdaptersDict.get(usedAdapterName) if backAdapterOsh: linkOsh = modeling.createLinkOSH('use', virtAdapterOsh, backAdapterOsh) vector.add(linkOsh) #FIXME: move to function to avoid code dups if virtualAdapter.physicalPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = virtualAdapter.physicalPath ioSlot.drcName = virtualAdapter.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName) if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, virtAdapterOsh) vector.add(ioSlotOsh) vector.add(linkOsh) if fiberChannelAdaptersList: for fiberChannelAdapter in fiberChannelAdaptersList: fiberChannelOsh = createFiberChannelOsh(fiberChannelAdapter, managedSystemOsh) vector.add(fiberChannelOsh) linkOsh = modeling.createLinkOSH('contained', hostOsh, fiberChannelOsh) vector.add(linkOsh) if fiberChannelAdapter.physPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = fiberChannelAdapter.physPath ioSlot.drcName = fiberChannelAdapter.physPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, fiberChannelOsh) vector.add(ioSlotOsh) vector.add(linkOsh) #create Storage Topology vector.addAll(storage_topology.createStorageTopology(volumeGroupsDict.values(), logicalVolumeDict.values(), physicalVolumeDict.values(), scsiAdaptersList, hostOsh)) if scsiManList and pvAssignList: pScsiDict = {} for scsi in scsiManList: scsiOsh = None ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = scsi.physicalPath ioSlot.drcName = scsi.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName(ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, managedSystemOsh) scsiOsh = storage_topology.createScsiAdapterOsh(scsi, managedSystemOsh) linkOsh = modeling.createLinkOSH('contained', hostOsh, scsiOsh) vector.add(linkOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) scsiOsh = storage_topology.createScsiAdapterOsh(scsi, hostOsh) vector.add(scsiOsh) pScsiDict[scsi.slotNumber] = scsiOsh linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, scsiOsh) vector.add(ioSlotOsh) vector.add(linkOsh) for pv in pvAssignList: pvOsh = storage_topology.createPhysicalVolumeOsh(pv, hostOsh) scsiOsh = pScsiDict.get(pv.scsiAdapterSlotNumber) if pvOsh and scsiOsh: vector.add(pvOsh) linkOsh = modeling.createLinkOSH("depend", pvOsh, scsiOsh) vector.add(linkOsh) return vector
def ReportTopology(chassises, servers, system_pools, vms, switches, storages, fsm_osh, reportHostName): vector = ObjectStateHolderVector() vector.add(fsm_osh) vm_map = {} for vm in vms: key = '%s%s' % (vm.serial, vm.vm_id) vm_map[key] = vm chassis_name_to_chassis_osh = {} server_serial_to_server_osh = {} server_serial_to_interfaces = {} if chassises: for chassis in chassises: vect, chassis_osh = reportChassis(chassis, fsm_osh) chassis_name_to_chassis_osh[chassis.name] = chassis_osh if chassis.name and chassis.name.find(' ') != -1: chassis_name_to_chassis_osh[ chassis.name[:chassis.name.find(' ')]] = chassis_osh vector.addAll(vect) if servers: for server in servers: vect, server_osh, iface_map = reportServer( server, chassis_name_to_chassis_osh) if not server_osh: continue vector.addAll(vect) server_serial_to_server_osh[server.serial] = server_osh server_serial_to_interfaces[server.serial] = iface_map #report cpu pools cpuPoolOshDict = {} hypervisor_osh = createIbmHypervisorOsh(server_osh) if server.managedSystem and server.managedSystem.cpuPoolList: cpuQuont = 0 for processorPool in server.managedSystem.cpuPoolList: processorPoolOsh = createProcessorPoolOsh( processorPool, hypervisor_osh) vector.add(processorPoolOsh) cpuPoolOshDict[processorPool.name] = processorPoolOsh if processorPool.physCpuConf: cpuQuont += int(processorPool.physCpuConf) for i in xrange(cpuQuont): cpuOsh = modeling.createCpuOsh( 'CPU' + str(i), server_osh) linkOsh = modeling.createLinkOSH( 'contained', processorPoolOsh, cpuOsh) vector.add(linkOsh) #reporting vms lparOshDict = {} if server.managedSystem.lparProfilesDict: for lpar in server.managedSystem.lparProfilesDict.values(): if lpar.type not in ('aixlinux', 'os400', 'vioserver'): continue #if lpar.lparProfile.lparIpAddress or (reportHostName and reportHostName.lower().strip() == 'true'): #creating Lpar # virtualHostOsh = modeling.createHostOSH(lpar.lparProfile.lparIpAddress, 'host', lpar.osName) virtualHostOsh = None host_class = getHostClassByEnvType(lpar.type) vect, virtualHostOsh = reportVirtualMachine( vm_map, server, server_osh, host_class, lpar, server_serial_to_interfaces) vector.addAll(vect) if not virtualHostOsh: logger.warn('Failed to create Lpar %s ' % lpar.lparName) continue if reportHostName and reportHostName.lower().strip( ) == 'true': virtualHostOsh.setStringAttribute( 'name', lpar.lparName) lparOshDict[lpar.lparId] = virtualHostOsh vector.add(virtualHostOsh) #creating Lpar Profile lparProfileOsh = createLparProfileOsh(lpar, virtualHostOsh) vector.add(lparProfileOsh) #Linking Lpar to Shared Pool if lpar.sharedPoolId and cpuPoolOshDict.has_key( lpar.sharedPoolId): linkOsh = modeling.createLinkOSH( 'use', virtualHostOsh, cpuPoolOshDict[lpar.sharedPoolId]) vector.add(linkOsh) if server.managedSystem.vScsiList: for vScsi in server.managedSystem.vScsiList: localLparOsh = lparOshDict.get(vScsi.parentId) remoteLparOsh = lparOshDict.get(vScsi.remoteLparId) if localLparOsh and remoteLparOsh: localVScsiOsh = storage_topology.createScsiAdapterOsh( vScsi, localLparOsh) remoteVScsiOsh = createRemoteScsiAdapterOsh( vScsi, remoteLparOsh) linkOsh = modeling.createLinkOSH( 'use', remoteVScsiOsh, localVScsiOsh) vector.add(localVScsiOsh) vector.add(remoteVScsiOsh) vector.add(linkOsh) # create and link v I/O Slot to vSCSI for vIoSlot in server.managedSystem.vIoSlotList: if vIoSlot.slotType == 'scsi' and vIoSlot.lpar_id == vScsi.parentId and vIoSlot.slotNum == vScsi.slotNumber: vIoSlotOsh = ibm_hmc_lib.createIoSlotOsh( vIoSlot, localLparOsh) linkOsh = modeling.createLinkOSH( 'contained', vIoSlotOsh, localVScsiOsh) vector.add(vIoSlotOsh) vector.add(linkOsh) if vIoSlot.slotType == 'scsi' and vIoSlot.lpar_id == vScsi.remoteLparId and vIoSlot.slotNum == vScsi.remoteSlotNumber: vIoSlotOsh = ibm_hmc_lib.createIoSlotOsh( vIoSlot, remoteLparOsh) linkOsh = modeling.createLinkOSH( 'contained', vIoSlotOsh, remoteVScsiOsh) vector.add(vIoSlotOsh) vector.add(linkOsh) if storages: for subsystem in storages: vect, subsystem_osh = reportStorageSystem(subsystem, fsm_osh) vector.addAll(vect) if switches: for switch in switches: try: vect, sw_osh = reportSwitch(switch, chassis_name_to_chassis_osh, server_serial_to_interfaces, fsm_osh) except: logger.debug("Failed to report Switch. Data missing.") return vector
def build(self, cpu, container): cpuOsh = modeling.createCpuOsh( cpu.idStr, container, cpu.speed, cpu.coresCount, cpu.vendor, cpu.description, data_name=cpu.description ) return cpuOsh
def ReportTopology(chassises, servers, system_pools, vms, switches, storages, fsm_osh, reportHostName): vector = ObjectStateHolderVector() vector.add(fsm_osh) vm_map = {} for vm in vms: key = '%s%s' % (vm.serial, vm.vm_id) vm_map[key] = vm chassis_name_to_chassis_osh = {} server_serial_to_server_osh = {} server_serial_to_interfaces = {} if chassises: for chassis in chassises: vect, chassis_osh = reportChassis(chassis, fsm_osh) chassis_name_to_chassis_osh[chassis.name] = chassis_osh if chassis.name and chassis.name.find(' ') != -1: chassis_name_to_chassis_osh[chassis.name[:chassis.name.find(' ')]] = chassis_osh vector.addAll(vect) if servers: for server in servers: vect, server_osh, iface_map = reportServer(server, chassis_name_to_chassis_osh) if not server_osh: continue vector.addAll(vect) server_serial_to_server_osh[server.serial] = server_osh server_serial_to_interfaces[server.serial] = iface_map #report cpu pools cpuPoolOshDict = {} hypervisor_osh = createIbmHypervisorOsh(server_osh) if server.managedSystem and server.managedSystem.cpuPoolList: cpuQuont = 0 for processorPool in server.managedSystem.cpuPoolList: processorPoolOsh = createProcessorPoolOsh(processorPool, hypervisor_osh) vector.add(processorPoolOsh) cpuPoolOshDict[processorPool.name] = processorPoolOsh if processorPool.physCpuConf: cpuQuont += int(processorPool.physCpuConf) for i in xrange(cpuQuont): cpuOsh = modeling.createCpuOsh('CPU' + str(i), server_osh) linkOsh = modeling.createLinkOSH('contained', processorPoolOsh, cpuOsh) vector.add(linkOsh) #reporting vms lparOshDict = {} if server.managedSystem.lparProfilesDict: for lpar in server.managedSystem.lparProfilesDict.values(): if lpar.type not in ('aixlinux', 'os400', 'vioserver'): continue #if lpar.lparProfile.lparIpAddress or (reportHostName and reportHostName.lower().strip() == 'true'): #creating Lpar # virtualHostOsh = modeling.createHostOSH(lpar.lparProfile.lparIpAddress, 'host', lpar.osName) virtualHostOsh = None host_class = getHostClassByEnvType(lpar.type) vect, virtualHostOsh = reportVirtualMachine(vm_map, server, server_osh, host_class, lpar, server_serial_to_interfaces) vector.addAll(vect) if not virtualHostOsh: logger.warn('Failed to create Lpar %s ' % lpar.lparName) continue if reportHostName and reportHostName.lower().strip() == 'true': virtualHostOsh.setStringAttribute('name', lpar.lparName) lparOshDict[lpar.lparId] = virtualHostOsh vector.add(virtualHostOsh) #creating Lpar Profile lparProfileOsh = createLparProfileOsh(lpar, virtualHostOsh) vector.add(lparProfileOsh) #Linking Lpar to Shared Pool if lpar.sharedPoolId and cpuPoolOshDict.has_key(lpar.sharedPoolId): linkOsh = modeling.createLinkOSH('use', virtualHostOsh, cpuPoolOshDict[lpar.sharedPoolId]) vector.add(linkOsh) if server.managedSystem.vScsiList: for vScsi in server.managedSystem.vScsiList: localLparOsh = lparOshDict.get(vScsi.parentId) remoteLparOsh = lparOshDict.get(vScsi.remoteLparId) if localLparOsh and remoteLparOsh: localVScsiOsh = storage_topology.createScsiAdapterOsh(vScsi, localLparOsh) remoteVScsiOsh = createRemoteScsiAdapterOsh(vScsi, remoteLparOsh) linkOsh = modeling.createLinkOSH('use', remoteVScsiOsh, localVScsiOsh) vector.add(localVScsiOsh) vector.add(remoteVScsiOsh) vector.add(linkOsh) # create and link v I/O Slot to vSCSI for vIoSlot in server.managedSystem.vIoSlotList: if vIoSlot.slotType == 'scsi' and vIoSlot.lpar_id == vScsi.parentId and vIoSlot.slotNum == vScsi.slotNumber: vIoSlotOsh = ibm_hmc_lib.createIoSlotOsh(vIoSlot, localLparOsh) linkOsh = modeling.createLinkOSH('contained', vIoSlotOsh, localVScsiOsh) vector.add(vIoSlotOsh) vector.add(linkOsh) if vIoSlot.slotType == 'scsi' and vIoSlot.lpar_id == vScsi.remoteLparId and vIoSlot.slotNum == vScsi.remoteSlotNumber: vIoSlotOsh = ibm_hmc_lib.createIoSlotOsh(vIoSlot, remoteLparOsh) linkOsh = modeling.createLinkOSH('contained', vIoSlotOsh, remoteVScsiOsh) vector.add(vIoSlotOsh) vector.add(linkOsh) if storages: for subsystem in storages: vect, subsystem_osh = reportStorageSystem(subsystem, fsm_osh) vector.addAll(vect) if switches: for switch in switches: try: vect, sw_osh = reportSwitch(switch, chassis_name_to_chassis_osh, server_serial_to_interfaces, fsm_osh) except: logger.debug("Failed to report Switch. Data missing.") return vector
def doDiscovery(shell, hostOsh, managedSystemOsh, framework, osType): vector = ObjectStateHolderVector() scsiAdaptersList = [] physAdaptList = [] virtAdaptList = [] seaAdaptList = [] linkAggrAdaptList = [] volumeGroupsDict = {} physicalVolumeDict = {} logicalVolumeDict = {} scsiManList = [] pvAssignList = [] fiberChannelAdaptersList = [] ethAliasesList = [] isVio = ibm_hmc_lib.isVio(shell) try: cpus = discover_cpus(shell, framework, isVio) for cpu in cpus: cpuOsh = modeling.createCpuOsh(cpu.idStr, managedSystemOsh, cpu.speed, cpu.coresCount, 'ibm_corp', data_name=cpu.model) vector.add(cpuOsh) except: logger.errorException('') framework.reportWarning('Failed to discover CPUs') if osType and osType.upper() == 'AIX': try: fiberChannelAdaptersList = discoverFiberChannels(shell) except: framework.reportWarning( "Failed to discover Fibre Channel adapters") ethAdaptersDict = {} if isVio: ethAdaptersDict = discoverEthernetAdapters(shell) ethAliasesList = discoverEhernetAdapterAliasses(shell) else: ethAdaptersDict = discoverAixLparEthernetAdapters(shell) physAdaptList = getPhysicalEthAdapters(ethAdaptersDict.values()) virtAdaptList = getVirtualEthAdapters(ethAdaptersDict.values()) seaAdaptList = getSeaAdapters(ethAdaptersDict.values()) linkAggrAdaptList = getLinkAggregationInterfaces( ethAdaptersDict.values()) calculateAdaptersSpeed(linkAggrAdaptList, ethAdaptersDict) calculateAdaptersSpeed(seaAdaptList, ethAdaptersDict) calculateAdaptersSpeed(virtAdaptList, ethAdaptersDict) volumeGroupsDict = discoverVolumeGroups(shell) physicalVolumeDict = discoverPhysicalVolumes(shell) logicalVolumeDict = discoverLogicalVolumes(shell, volumeGroupsDict) if isVio: scsiAdaptersList = discoverScsi(shell, physicalVolumeDict, logicalVolumeDict) (scsiManList, pvAssignList) = discoverPhysScsiAndRaid(shell, physicalVolumeDict) else: (scsiManList, pvAssignList) = discoverLparPhysScsiAndRaid( shell, physicalVolumeDict) elif osType and osType.upper() == 'LINUX': scsiAdaptersList = discoverLinuxVScsiAdapters(shell) (volumeGroupsDict, logicalVolumeDict, physicalVolumeDict) = discoverLinuxStorageInfo(shell) ethAdaptersDict = {} if physAdaptList: for physAdapt in physAdaptList: physAdaptOsh = createInterfaceOsh(physAdapt, hostOsh) linkOsh = modeling.createLinkOSH('contained', managedSystemOsh, physAdaptOsh) vector.add(linkOsh) if physAdapt.physicalPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = physAdapt.physicalPath ioSlot.drcName = physAdapt.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName( ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh( ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, physAdaptOsh) vector.add(ioSlotOsh) vector.add(linkOsh) if ethAliasesList: for aliasName in [ 'en' + str(physAdapt.interfaceIndex), 'et' + str(physAdapt.interfaceIndex) ]: if aliasName in ethAliasesList: aliasOsh = createAliasOsh(aliasName, hostOsh, physAdapt) if aliasOsh: vector.add(aliasOsh) vector.add( vector.add( modeling.createLinkOSH( 'realization', physAdaptOsh, aliasOsh))) if logger.Version().getVersion(framework) < 9: interfaceIndexOsh = createInterfaceIndexOsh(physAdapt, hostOsh) if interfaceIndexOsh: linkOsh = modeling.createLinkOSH('parent', interfaceIndexOsh, physAdaptOsh) vector.add(interfaceIndexOsh) vector.add(linkOsh) # vector.add(physAdaptOsh) ethAdaptersDict[physAdapt.name] = physAdaptOsh if linkAggrAdaptList: for linkAggr in linkAggrAdaptList: linkAggrOsh = createLinkAggrOsh(linkAggr, hostOsh) if linkAggr.usedAdapters: vector.add(linkAggrOsh) ethAdaptersDict[linkAggr.name] = linkAggrOsh for usedAdapterName in linkAggr.usedAdapters: physAdaptOsh = ethAdaptersDict.get(usedAdapterName) if physAdaptOsh: #change the KEY attribute for the Physical Ethernet Adapter mac = physAdaptOsh.getAttributeValue( 'interface_macaddr') newKey = '%s_%s' % (mac, usedAdapterName) physAdaptOsh.setAttribute('interface_macaddr', newKey) ethAdaptersDict[usedAdapterName] = physAdaptOsh linkOsh = modeling.createLinkOSH( 'member', linkAggrOsh, physAdaptOsh) vector.add(linkOsh) if linkAggr.backupAdapter: ethBackOsh = ethAdaptersDict.get(linkAggr.backupAdapter) linkOsh = modeling.createLinkOSH('member', linkAggrOsh, ethBackOsh) vector.add(linkOsh) #Adding Physical ETH adapters to the result vector if ethAdaptersDict: for physAdaptOsh in ethAdaptersDict.values(): vector.add(physAdaptOsh) if seaAdaptList: for seaAdapter in seaAdaptList: seaAdapterOsh = createSeaOsh(seaAdapter, hostOsh) if seaAdapter.usedAdapters: vector.add(seaAdapterOsh) ethAdaptersDict[seaAdapter.name] = seaAdapterOsh for usedAdapterName in seaAdapter.usedAdapters: backAdapterOsh = ethAdaptersDict.get(usedAdapterName) if backAdapterOsh: linkOsh = modeling.createLinkOSH( 'use', seaAdapterOsh, backAdapterOsh) vector.add(linkOsh) if virtAdaptList: for virtualAdapter in virtAdaptList: virtAdapterOsh = ibm_hmc_lib.createVEthOsh(virtualAdapter, hostOsh) vector.add(virtAdapterOsh) if ethAliasesList: for aliasName in [ 'en' + str(virtualAdapter.interfaceIndex), 'et' + str(virtualAdapter.interfaceIndex) ]: if aliasName in ethAliasesList: aliasOsh = createAliasOsh(aliasName, hostOsh, virtualAdapter) if aliasOsh: vector.add(aliasOsh) vector.add( vector.add( modeling.createLinkOSH( 'realization', virtAdapterOsh, aliasOsh))) if virtualAdapter.usedAdapters: for usedAdapterName in virtualAdapter.usedAdapters: backAdapterOsh = ethAdaptersDict.get(usedAdapterName) if backAdapterOsh: linkOsh = modeling.createLinkOSH( 'use', virtAdapterOsh, backAdapterOsh) vector.add(linkOsh) if virtualAdapter.physicalPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = virtualAdapter.physicalPath ioSlot.drcName = virtualAdapter.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName( ioSlot.drcName) if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh( ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, virtAdapterOsh) vector.add(ioSlotOsh) vector.add(linkOsh) if fiberChannelAdaptersList: for fiberChannelAdapter in fiberChannelAdaptersList: fiberChannelOsh = createFiberChannelOsh(fiberChannelAdapter, managedSystemOsh) vector.add(fiberChannelOsh) linkOsh = modeling.createLinkOSH('contained', hostOsh, fiberChannelOsh) vector.add(linkOsh) if fiberChannelAdapter.physPath: ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = fiberChannelAdapter.physPath ioSlot.drcName = fiberChannelAdapter.physPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName( ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh( ioSlot, managedSystemOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, fiberChannelOsh) vector.add(ioSlotOsh) vector.add(linkOsh) #create Storage Topology vector.addAll( storage_topology.createStorageTopology(volumeGroupsDict.values(), logicalVolumeDict.values(), physicalVolumeDict.values(), scsiAdaptersList, hostOsh)) if scsiManList and pvAssignList: pScsiDict = {} for scsi in scsiManList: scsiOsh = None ioSlot = ibm_hmc_lib.IoSlot() ioSlot.name = scsi.physicalPath ioSlot.drcName = scsi.physicalPath ioSlot.normalizedDrcName = ibm_hmc_lib.normaliseIoSlotDrcName( ioSlot.drcName) ioSlotOsh = None if isPhysicalSlot(ioSlot): ioSlotOsh = ibm_hmc_lib.createIoSlotOsh( ioSlot, managedSystemOsh) scsiOsh = storage_topology.createScsiAdapterOsh( scsi, managedSystemOsh) linkOsh = modeling.createLinkOSH('contained', hostOsh, scsiOsh) vector.add(linkOsh) else: ioSlotOsh = ibm_hmc_lib.createIoSlotOsh(ioSlot, hostOsh) scsiOsh = storage_topology.createScsiAdapterOsh(scsi, hostOsh) vector.add(scsiOsh) pScsiDict[scsi.slotNumber] = scsiOsh linkOsh = modeling.createLinkOSH('contained', ioSlotOsh, scsiOsh) vector.add(ioSlotOsh) vector.add(linkOsh) for pv in pvAssignList: pvOsh = storage_topology.createPhysicalVolumeOsh(pv, hostOsh) scsiOsh = pScsiDict.get(pv.scsiAdapterSlotNumber) if pvOsh and scsiOsh: vector.add(pvOsh) linkOsh = modeling.createLinkOSH("depend", pvOsh, scsiOsh) vector.add(linkOsh) return vector