Exemplo n.º 1
0
def createTransportPathObjects(cluster, hostOshByName, resultsVector,
                               framework):
    for tPath in cluster.transportPaths:
        sourceInterfaceResult = createTransportInterfaceObject(
            tPath.fromNode, tPath.fromInterface, cluster, hostOshByName)
        targetInterfaceResult = createTransportInterfaceObject(
            tPath.toNode, tPath.toInterface, cluster, hostOshByName)
        if sourceInterfaceResult and targetInterfaceResult:
            (sourceInterfaceOsh, sourceAdapter) = sourceInterfaceResult
            (targetInterfaceOsh, targetAdapter) = targetInterfaceResult
            resultsVector.add(sourceInterfaceOsh)
            resultsVector.add(targetInterfaceOsh)

            versionAsDouble = logger.Version().getVersion(framework)
            if versionAsDouble >= 9:
                layer2Osh = ObjectStateHolder('layer2_connection')
                linkId = "%s:%s" % (sourceAdapter.mac, targetAdapter.mac)
                linkId = str(hash(linkId))
                layer2Osh.setAttribute('layer2_connection_id', linkId)

                sourceMemberLink = modeling.createLinkOSH(
                    'member', layer2Osh, sourceInterfaceOsh)
                targetMemberLink = modeling.createLinkOSH(
                    'member', layer2Osh, targetInterfaceOsh)

                resultsVector.add(layer2Osh)
                resultsVector.add(sourceMemberLink)
                resultsVector.add(targetMemberLink)
            else:
                layer2Link = modeling.createLinkOSH('layertwo',
                                                    sourceInterfaceOsh,
                                                    targetInterfaceOsh)
                resultsVector.add(layer2Link)
Exemplo n.º 2
0
 def isApplicable(self, context):
     self.__framework = context.framework
     versionAsDouble = logger.Version().getVersion(self.__framework)
     if versionAsDouble >= 9:
         return 1
     else:
         return 0
Exemplo n.º 3
0
def makeSiebelgatewayOSH(client, username, enterprise, srvrmgrPath,
                         credentialsId, ip, port, Framework):
    # container host of siebel app
    containerHostOSH = modeling.createHostOSH(ip)

    # siebel gateway application
    gatewayOSH = modeling.createApplicationOSH('siebel_gateway', ip,
                                               containerHostOSH,
                                               'Enterprise App', 'oracle_corp')
    gatewayOSH.setAttribute('site', enterprise)
    gatewayOSH.setAttribute('application_ip', ip)
    gatewayOSH.setAttribute('application_username', username)
    gatewayOSH.setAttribute('srvrmgr_path', srvrmgrPath)
    gatewayOSH.setAttribute('credentials_id', credentialsId)
    if port:
        gatewayOSH.setIntegerAttribute('application_port', port)

    #9.0 workaround
    versionAsDouble = logger.Version().getVersion(Framework)
    if versionAsDouble >= 9:
        gatewayOSH.removeAttribute('data_name')
        gatewayOSH.setAttribute('name', ip)
        modeling.setApplicationProductName(gatewayOSH,
                                           'Siebel Gateway Name Server')

    # get DB (Data Source) Attributes
    cmd = 'list parameter DSConnectString for named subsystem GatewayDataSrc'
    gtwydsconnstrTblTxt = client.executeCmd(
        cmd)  #@@CMD_PERMISION siebel protocol execution
    gtwydsconnstrTbl = siebel_common.makeTable(gtwydsconnstrTblTxt)
    if gtwydsconnstrTbl == None:
        raise 'Failed to execute command: %s ;result %s ' % (
            cmd, gtwydsconnstrTblTxt)
    gtwydsconnstr = gtwydsconnstrTbl[0][0][1]
    gatewayOSH.setAttribute('gtwy_ds_conn_str', gtwydsconnstr)
    logger.debug('DSConnectString:', gtwydsconnstr)

    cmd = 'list parameters DSSQLStyle for named subsystem GatewayDataSrc'
    gtwydstype = getDataSourceType(client, cmd, gatewayOSH)
    if gtwydstype == None:
        cmd = 'list parameters DSSQLStyle for named subsystem ServerDataSrc'
        gtwydstype = getDataSourceType(client, cmd, gatewayOSH)
    if gtwydstype == None:
        cmd = 'list advanced params DSSQLStyle for named subsystem ServerDataSrc'
        gtwydstype = getDataSourceType(client, cmd, gatewayOSH)
    if gtwydstype == None:
        errorMSG = 'Failed to check gateway database type'
        logger.debugException(errorMSG)
        Framework.reportWarning(errorMSG)
    return gatewayOSH
Exemplo n.º 4
0
def createGatewayOsh(ip, port, resultsVector, framework):

    gatewayHostOsh = modeling.createHostOSH(ip)
    resultsVector.add(gatewayHostOsh)

    gatewayOsh = modeling.createApplicationOSH('siebel_gateway',
                                               ip,
                                               gatewayHostOsh,
                                               vendor='oracle_corp')
    gatewayOsh.setAttribute('application_port', int(port))

    #9.0 workaround
    versionAsDouble = logger.Version().getVersion(framework)
    if versionAsDouble >= 9:
        gatewayOsh.removeAttribute('data_name')
        gatewayOsh.setAttribute('name', ip)
        modeling.setApplicationProductName(gatewayOsh,
                                           'Siebel Gateway Name Server')

    return gatewayOsh
Exemplo n.º 5
0
import eview400_lib
import file_mon_utils

from appilog.common.system.types import ObjectStateHolder
from appilog.common.system.types.vectors import ObjectStateHolderVector
from java.util import Properties, Date
from com.hp.ucmdb.discovery.library.clients.agents import BaseAgent
from com.hp.ucmdb.discovery.library.clients import ClientsConsts, ScriptsExecutionManager
from com.hp.ucmdb.discovery.library.common import CollectorsParameters
import errorobject
import errorcodes
from eview400_lib import isNotNull, isNull

# Global Variables
_STR_EMPTY = ''
UCMDB_VERSION = logger.Version().getVersion(
    ScriptsExecutionManager.getFramework())

# iSeries Commands

_CMD_EVIEW_VERSION = 'EVDSPPFM eview/version'
_CMD_SYSVAL_QMODEL = 'DSPSYSVAL SYSVAL(QMODEL)'
_CMD_SYSVAL_QSRLNBR = 'DSPSYSVAL SYSVAL(QSRLNBR)'
_CMD_ETHERNET = 'ETHERNET'
_CMD_DSPNETA = 'DSPNETA'


# Classes
class EViewConfFileNameFilter:
    def accept(self, fileName):
        return re.search('^ev400_config_.*$', fileName.lower()) is not None
def makeAppServer(client, username, enterprise, serverObj, serverDataRow, siteOSH, Framework, OSHVResult):
	# init return value

	logger.debug('server:', string.join(serverObj), ' dataRow:', serverDataRow)
	datalist = serverObj
	sblsvrName = datalist[0]
	logger.debug('sblsvrName:', sblsvrName)
	hostName = datalist[1]
	installDir = datalist[2]
	sblmgrPID = datalist[3]
	serverID = datalist[9]
	# if no PID, server is not running. send an event on it
	# the message of the event will be everything that follows
	# the PID field
	if string.strip(sblmgrPID) == '':
		logger.debug('problem server:', serverDataRow)
		runningServer = 0
		logger.debug('app server', sblsvrName, ' is not Running')
	else:
		runningServer = 1
		# called status, but actually version details
		status = datalist[8]
		logger.debug('status:', status)
		versionTokens = status.split()
		version = versionTokens[0]
		build = versionTokens[1]
		lang = versionTokens[2]

	# host
	logger.debug('building host:', hostName)
	try:
		ip = netutils.getHostAddress(hostName)
		logger.debug('found ip:', ip, ' for hostName:', hostName)
		if ip == None:
			return None
		if netutils.isLocalIp(ip):
			logger.debug('got loopback ip, probably error.')
			return None
		appServerHostOSH = modeling.createHostOSH(ip)
	except:
		logger.errorException('failed to convert host name:', hostName, ' to IP')
		return None

	# siebel application server
	appServerOSH = modeling.createApplicationOSH('siebel_app_server', sblsvrName, appServerHostOSH, 'Enterprise App', 'oracle_corp')
	appServerOSH.setAttribute('application_ip', ip)
	appServerOSH.setAttribute('application_username', username)
	appServerOSH.setAttribute('install_dir', installDir)
	appServerOSH.setAttribute('svr_id',serverID)

	modeling.setAppServerType(appServerOSH)

	#9.0 workaround
	versionAsDouble = logger.Version().getVersion(Framework)
	if versionAsDouble >= 9:
		appServerOSH.removeAttribute('data_name')
		appServerOSH.setAttribute('name', sblsvrName)
		modeling.setApplicationProductName(appServerOSH, 'Siebel Server')

	OSHVResult.add(appServerHostOSH)
	OSHVResult.add(appServerOSH)

	if runningServer:
		appServerOSH.setAttribute('version', version)
		appServerOSH.setAttribute('application_version', version)
		appServerOSH.setAttribute('build', build)
		appServerOSH.setAttribute('lang', lang)

		# NOTE: setting the current app server so that all info will be only
		# for it
		prompt = client.executeCmd(string.join(['set server ', sblsvrName]), 5000)#@@CMD_PERMISION siebel protocol execution
		logger.debug(prompt)

		# get component groups (and components for each group) for this server
		# NOTE: as far as we know there can't be components that are not under a group
		# if such a situation can exist we won't find such 'leaf' components
		# with the current code

		#
		#
		makeComponentGroups(client, appServerOSH, ip, OSHVResult, enterprise, siteOSH)

		if version[0] == '7' or version[0] == '8':
			# get DB (Data Source) Attributes
			# table[0][0][1] means:
			# [0] - first row (should be only one, we are inside a server context)
			# [0] - first column: the parsed fields (second column is original row for error purposes)
			# [1] - second value in the parsed fields
			try:
				svrdsconnstrTblTxt = client.executeCmd('list parameter DSConnectString for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
				svrdsconnstrTbl = siebel_common.makeTable(svrdsconnstrTblTxt)
				svrdsconnstr = string.upper(svrdsconnstrTbl[0][0][1])
				logger.debug('svrdsconnstr:', svrdsconnstr)
				appServerOSH.setAttribute('srv_ds_conn_str', svrdsconnstr)
			except:
				error_message = 'failed to get DSConnectString (to set attribute srv_ds_conn_str) on server'
				logger.debug(error_message)
				Framework.reportWarning(error_message)
			try:
				svrdstypeTblTxt = client.executeCmd('list parameters DSSQLStyle for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
				svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt)
				if svrdstypeTbl:
					svrdstype = svrdstypeTbl[0][0][1]
				else:
					svrdstypeTblTxt = client.executeCmd('list parameters DSDLLName for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution
					svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt)
					svrdstype = DLL_TO_SQL_TYPE_MAP[svrdstypeTbl[0][0][1]]

				logger.debug('svrdstype:', svrdstype)
				appServerOSH.setAttribute('svr_ds_type', svrdstype)
			except:
				error_message = 'failed to get DSSQLStyle (to set attribute svr_ds_type) on server'
				logger.debugException(error_message)
				Framework.reportWarning(error_message)


			serverType = getSiebelServerType(client)
			if serverType:
				appServerOSH.setStringAttribute('data_description', serverType)
			else:
				logger.warn("Cannot determine the type of server '%s', no required components were found" % sblsvrName)

		if version[0] == '6':
			# in Siebel 2000 (tested with 6.3), we can't obtain some of the parameters using command line API
			# get missing attributes from configuration file
			logger.info('Datasource parameters are not supported in version ', version)
			logger.info('Please run SIEBEL_DIS_APP_SERVER_CONFIG pattern to get server datasource attributes')

		try:
			odbcDSNTblTxt = client.executeCmd('list param connect')#@@CMD_PERMISION siebel protocol execution
			odbcDSNTbl = siebel_common.makeTable(odbcDSNTblTxt)
			odbcDSN = odbcDSNTbl[0][0][1]
			logger.debug('odbcDSN:', odbcDSN)
			appServerOSH.setAttribute('odbc_dsn', odbcDSN)
		except:
			error_message = 'failed to get ODBC DSN (connect param (to set attribute odbc_dsn) on server'
			logger.debug(error_message)
			Framework.reportWarning(error_message)

		# NOTE: unsetting the current app server
		prompt = client.executeCmd('unset server', 3000)#@@CMD_PERMISION siebel protocol execution
		logger.debug(prompt)

	return appServerOSH
Exemplo n.º 7
0
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
Exemplo n.º 8
0
def doDicovery(shell, framework, rootServerOsh):
    resultVector = ObjectStateHolderVector()
    try:
        domainsList = discoverDomainsList(shell)
    except ValueError:
        raise ValueError, 'No libvirt Found. Failed to discover neither Xen nor KVM'
    domainsConfigDict = discoverDomainConfiguration(shell, domainsList)

    bridgeDict = discoverBridges(shell)
    ifaceNameToIfaceMacMap = discoverInterfacesByIfconfig(shell)
    #building topology
    ucmdbVersion = logger.Version().getVersion(framework)

    resultVector.add(rootServerOsh)
    bridgeToPortOshMap = {}
    for bridge in bridgeDict.values():
        bridgeOsh = createBridgeOsh(bridge.mac, bridge.name, rootServerOsh)
        if bridgeOsh:
            portNumber = 0
            for ifaceName in bridge.ifaceNameList:
                ifaceMac = ifaceNameToIfaceMacMap.get(ifaceName)
                interfaceOsh = modeling.createInterfaceOSH(
                    ifaceMac, rootServerOsh)
                resultVector.add(bridgeOsh)
                if interfaceOsh:
                    linkOsh = modeling.createLinkOSH('containment', bridgeOsh,
                                                     interfaceOsh)
                    resultVector.add(linkOsh)
                    resultVector.add(interfaceOsh)
                    portOsh = createBridgePhysicalPort(str(portNumber),
                                                       bridgeOsh)
                    portNumber += 1
                    linkOsh = modeling.createLinkOSH('realization', portOsh,
                                                     interfaceOsh)
                    bridgeToPortOshMap[bridge.name] = portOsh
                    resultVector.add(portOsh)
                    resultVector.add(linkOsh)

    (hypervisorVersion,
     hypervisorVersionDescription) = getHypervisorData(shell)
    if hypervisorVersion and not domainsConfigDict and checkKvmIrqProcess(
            shell):
        hypervisorOsh = KvmHypervisor(
            hypervisorVersion,
            hypervisorVersionDescription).build(rootServerOsh)
        resultVector.add(hypervisorOsh)

    for (domainName, config) in domainsConfigDict.items():
        hypervisorOsh = config.name == XEN_DOMAIN and XenHypervisor(
            hypervisorVersion, hypervisorVersionDescription).build(
                rootServerOsh) or KvmHypervisor(
                    hypervisorVersion,
                    hypervisorVersionDescription).build(rootServerOsh)
        resultVector.add(hypervisorOsh)

        if config.domainId == 0 and config.name == XEN_DOMAIN:
            domainConfigOsh = createXenDomainConfigOsh(config, rootServerOsh)
            resultVector.add(domainConfigOsh)
        else:
            vHostOsh = createVirtHostOsh(config)
            if vHostOsh:
                domainConfigOsh = config.name == XEN_DOMAIN and createXenDomainConfigOsh(
                    config, vHostOsh) or createKvmDomainConfigOsh(
                        config, vHostOsh)
                linkOsh = modeling.createLinkOSH('run', hypervisorOsh,
                                                 vHostOsh)
                resultVector.add(vHostOsh)
                resultVector.add(domainConfigOsh)
                resultVector.add(linkOsh)
                for networkInterface in config.interfaceList:
                    interfaceOsh = modeling.createInterfaceOSH(
                        networkInterface.macAddress, vHostOsh)
                    if interfaceOsh:
                        interfaceOsh.setBoolAttribute('isvirtual', 1)
                        resultVector.add(interfaceOsh)
                for i in range(len(config.bridgeNameList)):
                    bridgeName = config.bridgeNameList[i]
                    ifaceMac = config.interfaceList[i]
                    bridge = bridgeDict.get(bridgeName)
                    if bridge:
                        interfaceOsh = modeling.createInterfaceOSH(
                            networkInterface.macAddress, vHostOsh)
                        portOsh = bridgeToPortOshMap.get(bridgeName)
                        if ucmdbVersion < 9:
                            linkOsh = modeling.createLinkOSH(
                                'layertwo', interfaceOsh, portOsh)
                            resultVector.add(linkOsh)
                shareOsh = createNetworkShare(config.disk, rootServerOsh,
                                              ucmdbVersion)
                if shareOsh:
                    diskOsh = modeling.createDiskOSH(
                        vHostOsh, config.mountPoint,
                        modeling.UNKNOWN_STORAGE_TYPE)
                    if diskOsh:
                        linkOsh = modeling.createLinkOSH(
                            'realization', shareOsh, diskOsh)
                        resultVector.add(shareOsh)
                        resultVector.add(diskOsh)
                        resultVector.add(linkOsh)
    return resultVector