• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python modeling.createOshByCmdbIdString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中modeling.createOshByCmdbIdString函数的典型用法代码示例。如果您正苦于以下问题:Python createOshByCmdbIdString函数的具体用法?Python createOshByCmdbIdString怎么用?Python createOshByCmdbIdString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createOshByCmdbIdString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    client = Framework.createClient()
    shell = shellutils.ShellFactory().createShell(client)

    # Image Id -> Image OSH
    imageDict = dict()
    # Container Id -> Container OSH
    containerDict = dict()
    # Container Id -> linked Container Id
    containerLinks = dict()

    # Node from Trigger
    nodeId = Framework.getTriggerCIData('hostId')
    nodeOSH = modeling.createOshByCmdbIdString("node", nodeId)
    OSHVResult.add(nodeOSH)

    # Trigger CI Running Software docker daemon
    dockerId = Framework.getTriggerCIData("triggerId")
    dockerDaemonOSH = modeling.createOshByCmdbIdString("docker_daemon", dockerId)
    OSHVResult.add(dockerDaemonOSH)

    # Docker version for docker daemon
    versionOutput = shell.execCmd('docker -v')
    if shell.getLastCmdReturnCode() == 0:
        dockerDaemonOSH.setAttribute('version', versionOutput.strip())
    else:
        Framework.reportError('Failed in command: docker version.')

    #Get Filesystem
    filesystemDict = dict()
    skipDockerVolume = getFilesystem(shell, filesystemDict)

    # Docker
    dockerOSH = ObjectStateHolder('docker')
    dockerOSH.setAttribute('name', 'Docker')
    dockerOSH.setContainer(nodeOSH)
    OSHVResult.add(dockerOSH)
    dockerDaemonLink = modeling.createLinkOSH('membership', dockerOSH, dockerDaemonOSH)
    OSHVResult.add(dockerDaemonLink)
    dockerNodeLink = modeling.createLinkOSH('dependency', dockerOSH, nodeOSH)
    OSHVResult.add(dockerNodeLink)

    discoverDockerImage(shell, imageDict, nodeOSH, OSHVResult, Framework)

    discoverDockerContainer(shell, skipDockerVolume, filesystemDict, containerDict, containerLinks, imageDict, dockerDaemonOSH, nodeOSH, client, Framework, OSHVResult)

    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:48,代码来源:docker_discovery_by_shell.py


示例2: get_common_topology_context

def get_common_topology_context(discoverer, dnsresolver, installpath, config):
    discovererRegistry = {}
    discovererRegistry[baseCits.node] = partial(discoverer.getDeploymentHosts,
                                                Sfn(dnsresolver.resolve_ips))
    discovererRegistry[baseCits.ip] = hana_host.Host.ips.fget
    discovererRegistry[cits.hanadb] = discoverer.getHanaDatabaseServer
    discovererRegistry[cits.hanadbInstance] = lambda host: discoverer.getHanaDatabaseInstance(host.name)
    discovererRegistry[baseCits.configFile] = lambda dbServer: discoverer.getHanaDbConfigFiles()
    discovererRegistry[baseCits.ipServiceEndpoint] = lambda host: discoverer.getHanaDbInstanceEndpoints(host.name)

    discovererRegistry[dbCits.schema] = lambda dbServer: discoverer.getHanaDbSchemas()
    discovererRegistry[dbCits.user] = lambda dbServer: discoverer.getHanaDbUsers()
    discovererRegistry[dbCits.dataFile] = lambda db_instance: discoverer.getHanaDbDataFiles(db_instance)
    discovererRegistry[dbCits.logFile] = lambda db_instance: discoverer.getHanaDbLogFiles(db_instance)
    discovererRegistry[dbCits.traceFile] = lambda db_instance: discoverer.getHanaDbTraceFiles(db_instance)

#        linkage condition
    discovererRegistry[(dbCits.user, baseCits.ownership, dbCits.schema)] = lambda user, schema: schema.owner == user.name
    discovererRegistry[(cits.hanadbInstance, baseCits.usage, baseCits.ipServiceEndpoint)] = lambda hana_instance, endpoint: endpoint.getAddress() == hana_instance.hostname and endpoint.getPortType() == hana.PortTypeEnum.HANA
    discovererRegistry[(cits.hanadb, baseCits.membership, cits.hanadbInstance)] = lambda hanaDb, hanaInstance: True
    discovererRegistry[(baseCits.node, baseCits.containment, baseCits.ip)] = lambda host, ip: ip in host.ips

    pdoBuilderRegistry = {}
    pdoBuilderRegistry[cits.hanadbInstance] = lambda instance: buildDatabaseInstancePdo(instance, installpath, sid=config.sid)
    pdoBuilderRegistry[dbCits.user] = buildDbUserPdoFromDatabaseUser
    pdoBuilderRegistry[baseCits.ipServiceEndpoint] = partial(buildEndpointPdoFromEndpoint, Sfn(dnsresolver.resolve_ips))

    #Should be coming from core hana_topology module
    baseTopologyBuilderRegistry = {
       # ignore the name as it is could be an alias and not a real hostname
       baseCits.node: lambda node_pdo: hana_host.Builder().build_host(node_pdo._replace(name=None)),
       baseCits.ip: modeling.createIpOSH,
       baseCits.configFile: fptools.partiallyApply(modeling.createConfigurationDocumentOshByFile, fptools._, None),
       baseCits.ipServiceEndpoint: netutils.ServiceEndpointBuilder().visitEndpoint
    }

    linkReporter = hana.LinkReporter()
    linkReporterRegistry = {
        baseCits.containment: linkReporter.reportContainment,
        baseCits.composition: linkReporter.reportComposition,
        baseCits.membership: lambda do1, osh1, do2, osh2: linkReporter.reportMembership(osh1, osh2),
        baseCits.ownership: lambda do1, osh1, do2, osh2: linkReporter.reportOwnership(osh1, osh2),
        baseCits.usage: lambda do1, osh1, do2, osh2: linkReporter.reportUsage(osh1, osh2),
        baseCits.replicated: hana.DatabaseTopologyReporter().reportReplication,
    }

    topologyBuilderRegistry = {}
    topologyBuilderRegistry.update(baseTopologyBuilderRegistry)
    topologyBuilderRegistry.update(linkReporterRegistry)

    dbTopologyBuilder = hana.DatabaseTopologyBuilder()
    topologyBuilderRegistry[cits.hanadb] = lambda _: modeling.createOshByCmdbIdString(cits.hanadb, config.hanadb_cmdbid)
    topologyBuilderRegistry[cits.hanadbInstance] = dbTopologyBuilder.buildDatabaseInstanceOsh
    topologyBuilderRegistry[dbCits.schema] = dbTopologyBuilder.buildSchemaOsh
    topologyBuilderRegistry[dbCits.user] = dbTopologyBuilder.buildUserOsh
    topologyBuilderRegistry[dbCits.dataFile] = dbTopologyBuilder.buildDataFileOsh
    topologyBuilderRegistry[dbCits.logFile] = dbTopologyBuilder.buildLogFileOsh
    topologyBuilderRegistry[dbCits.traceFile] = dbTopologyBuilder.buildTraceFileOsh

    return discovererRegistry, pdoBuilderRegistry, topologyBuilderRegistry
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:60,代码来源:hanadb_by_shell.py


示例3: reportDeleteConnectedShell

def reportDeleteConnectedShell(Framework):
    shellId = Framework.getDestinationAttribute('shellId')
    shellOsh = modeling.createOshByCmdbIdString('shell', shellId)
    Framework.deleteObject(shellOsh)
    Framework.flushObjects()

    Framework.setStepExecutionStatus(WorkflowStepStatus.SUCCESS)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:7,代码来源:DeleteConnectedShell.py


示例4: _createHostOsh

    def _createHostOsh(self):
        ''' method creates containing host OSH depending on settings in XML and discovered data '''

        appComponent = self.getApplicationComponent()

        if appComponent.isClustered():
            # clustered applications should use weak hosts by IP
            hostIp = self._applicationIp

            if hostIp and ip_addr.IPAddress(hostIp).get_is_private():
                hostIp = self.getConnectionIp()

            if not hostIp:
                raise applications.ApplicationSignatureException("Cannot report application since no valid host IP is found")

            logger.debug(" -- clustered application uses host by IP '%s'" % hostIp)

            self.hostOsh = modeling.createHostOSH(hostIp)
        else:
            # non-clustered applications use host by hostId

            self.hostOsh = self.getApplicationComponent().getHostOsh()
            logger.debug(self.hostOsh)

            if self.hostOsh:
                logger.debug(" -- application uses host by Host OSH")
            else:
                logger.debug(" -- application uses host by CMDB ID")
                hostId = self.getApplicationComponent().getHostId()
                if hostId:
                    self.hostOsh = modeling.createOshByCmdbIdString('host', hostId)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:31,代码来源:asm_applications.py


示例5: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    jobId = Framework.getDiscoveryJobId()
    host_id    = Framework.getDestinationAttribute('id')
    host_name = Framework.getTriggerCIData('host_name')
    dnsServers = Framework.getTriggerCIDataAsList('dnsServers') or None
        
    try:
        host_name = host_name.split(" ")
        ips = pi_utils.getIPs(host_name[0], Framework)
        
        if not ips:
            raise ValueError()
        
        hostOSH = modeling.createOshByCmdbIdString('node', host_id)
        modeling.addHostAttributes(hostOSH, None, host_name[0])
        #OSHVResult.add(hostOSH)       
        
        for ip in ips:
            ipRes = pi_utils.getIPOSHV(Framework, ip, None, dnsServers, False, True)
            if ipRes.size() > 0:               
                OSHVResult.add(modeling.createLinkOSH('containment',hostOSH,modeling.createIpOSH(ip)))
                OSHVResult.addAll(ipRes)
        if OSHVResult.size() <=0:
            raise ValueError()       
    except Exception, e:
        msg = logger.prepareJythonStackTrace("Error getting IPs for %s: " % (host_name), e)
        errormessages.resolveAndReport(msg, jobId, Framework)
        logger.error(msg)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:29,代码来源:DNS_Discovery_Host.py


示例6: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    logger.info('Starting HACMP Applications')
    hostIP = Framework.getDestinationAttribute('ip_address')
    logger.debug ('Host IP: ',hostIP)
    cluster =  Framework.getDestinationAttribute('cluster')
    hostOS = Framework.getDestinationAttribute('host_os')
    hostOS = hostOS or 'NA'
    protocolName = Framework.getDestinationAttribute('Protocol')
    hostId = Framework.getDestinationAttribute('hostId')
    ##  Get Parameter Section
    cldisp_command = Framework.getParameter('cldisp_command') or 'cldisp'
    cllsif_command = Framework.getParameter('cllsif_command') or 'cllsif'

    try:
        client = Framework.createClient()
        shell = ShellUtils(client)
        #   If we get  good client connection , run the client commands to get the Application information for the cluster
        HostOSH = modeling.createOshByCmdbIdString('host', hostId)
        ClusterOSH = getclusterOSH(cluster)
        appDictionary = getapplicationInfo(shell,  cldisp_command,  Framework)
        resourceDictionary = getresourceinfo(shell, cllsif_command)
        OSHVResult.addAll(createserviceapplicationOSH (shell, appDictionary, resourceDictionary, HostOSH, ClusterOSH,   Framework))
        client.close()
    except JavaException, ex:
        strException = ex.getMessage()
        logger.debugException('')
        errormessages.resolveAndReport(strException, protocolName, Framework)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:28,代码来源:TTY_HACMP_Applications.py


示例7: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS')
    portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT')
    service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT')
    service_type = Framework.getDestinationAttribute('SERVICE_TYPE')
    application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID')
    application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS')
    junction_id = Framework.getDestinationAttribute('JUNCTION_ID')
    junction_root_class = Framework.getDestinationAttribute('JUNCTION_CLASS')
    junction_name = Framework.getDestinationAttribute('JUNCTION_NAME')
    SCPId = Framework.getDestinationAttribute('id')

    junctionOsh = modeling.createOshByCmdbIdString(junction_root_class, junction_id)

    url = urlparse(service_context)
    if url:
        # get context root path from url
        path = url.path
        if path.startswith(junction_name + '/'):
            logger.info('Create one consumer-provider link between application and junction')
            OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, junction_id,
                                               junction_root_class, SCPId, service_context))
            for index in range(len(ipList)):
                scpOsh = scp.createScpOsh(junctionOsh, service_type, ip=ipList[index], port=portList[index], context=service_context)
                logger.info('Create scp with ip %s and port %s' % (ipList[index], portList[index]))
                ipOsh = modeling.createIpOSH(ipList[index])
                OSHVResult.add(scpOsh)
                OSHVResult.add(ipOsh)

    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:33,代码来源:webseal_tunnel.py


示例8: disHPUX

def disHPUX(host_obj, client, Framework = None, langBund = None, pid2Process = None):
	hostId = Framework.getDestinationAttribute('hostId')
	discoverProcesses = Boolean.parseBoolean(Framework.getParameter('discoverProcesses'))

	myVec = ObjectStateHolderVector()
	
	# Better format, but not supported on all HPUX systems
	#r = client.executeCmd('ps -e -o pid,time,sz,comm,args')
	r = client.execCmd('ps -ef')#[email protected]@CMD_PERMISION tty protocol execution
	if r == None:
		return myVec

	lines = ''
	if(re.search('\r\n',r)):
		lines = r.split('\r\n')
	elif (re.search('\n',r)):
		lines = r.split('\n')
	else:
		return myVec
	processList = []
	pdu = None
	try:
		pdu = processdbutils.ProcessDbUtils(Framework)
		hostOSH = None
		for line in lines:
			## Reg for processes with args
			res = re.search('(\w+)\s+(\d+).*\s\d+\:\d\d\s([0-9a-zA-Z_.\[\]\-+:/]+)\s(.*)',line)
			if(res):
				cleanArgs = res.group(4)
			else:
				## Reg for processes with no args
				res = re.search('(\w+)\s+(\d+).*\s\d+\:\d\d\s([0-9a-zA-Z_.\-+:/]+)',line)
				if(res):
					cleanArgs = ''
			if(res):
				owner = res.group(1)
				commAndPath = res.group(3)
				pid = res.group(2)
				cleanCommand = ''
				if commAndPath.find('/') == -1:
					cleanCommand = commAndPath
				else:
					res2 = re.search('(.*/)([^/]+)',commAndPath)
					if (res2):
						cleanCommand = res2.group(2)
					else:
						continue
				if hostOSH == None:
					hostOSH = modeling.createOshByCmdbIdString('host', hostId)
				
				commandLine = cleanCommand + ' ' + cleanArgs
				addProcess(pdu, hostId, cleanCommand, pid, commandLine, commAndPath, cleanArgs, processList, discoverProcesses, myVec, hostOSH, None, owner)

		pdu.flushHostProcesses(hostId)
		if pid2Process is not None:
			pid2Process.putAll(pdu.getProcessCmdMap())
	finally:
		if pdu != None:
			pdu.close()
	return myVec
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:60,代码来源:TTY_HR_Process_Lib.py


示例9: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    logger.info ("Starting IMS Discovery")
    DiscoverIMSDB = Boolean.parseBoolean(Framework.getParameter('DiscoverIMSDB'))

    # create LPAR node from the ID passed in
    hostId = Framework.getDestinationAttribute(PARAM_HOST_ID)
    lparOsh = None

    if eview_lib.isNotNull(hostId):
        lparOsh = modeling.createOshByCmdbIdString('host_node', hostId)

    ls = eview_lib.EvShell(Framework)
    IMSSubSysDict = getIMSSubSys(ls, lparOsh)
    OSHVResult.addAll(getIMSActRegions(ls,lparOsh, IMSSubSysDict ))


    if DiscoverIMSDB and len(IMSSubSysDict) > 0:
        databaseAreaDictionary = {}
        databaseDictionary = {}
        OSHVResult.addAll(getIMSDB(ls, IMSSubSysDict,  databaseAreaDictionary , databaseDictionary))
        OSHVResult.addAll(getAREAs(ls, IMSSubSysDict,  databaseAreaDictionary , databaseDictionary))
        OSHVResult.addAll(processPrograms(ls,IMSSubSysDict, Framework))
    ls.closeClient()

    logger.info ("Finished IMS Discovery")
    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:28,代码来源:eview_ims.py


示例10: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    shell = None
    protocol = Framework.getDestinationAttribute('Protocol')
    try:
        try:
            try:
                hostName = Framework.getDestinationAttribute('hostname')
                msMqManagerUcmdbId = Framework.getDestinationAttribute('msmq_id')
                msMqManagerOsh = modeling.createOshByCmdbIdString('msmqmanager', msMqManagerUcmdbId)
                client = Framework.createClient()
                shell = shellutils.ShellUtils(client)
                msMqDiscoverer = MsMqDiscoverer(shell, msMqManagerOsh, hostName)
                if msMqDiscoverer:
                    msMqDiscoverer.discover()
                    msMqDiscoverer.addResultsToVector(OSHVResult)
            finally:
                try:
                    shell and shell.closeClient()
                except:
                    logger.debugException('')
                    logger.error('Unable to close shell')
                if OSHVResult.size() == 0:
                    raise Exception, "Failed getting information about Microsoft Message Queue"

        except JavaException, ex:
            msg =ex.getMessage()
            errormessages.resolveAndReport(msg, protocol, Framework)
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, protocol, Framework)
    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:32,代码来源:ntcmd_msmq.py


示例11: buildNetDeviceOSHV

def buildNetDeviceOSHV(localFramework, netDeviceCmdbIdList, netDeviceNameList):
    try:
        returnOSHV = ObjectStateHolderVector()
        ## Check validity of provided lists
        if not netDeviceCmdbIdList:
            localFramework.reportError('Please check adapter parameter <netdevice_cmdbid>')
            return None
        if not netDeviceNameList:
            localFramework.reportError('Please check adapter parameter <netdevice_name>')
            return None
        if len(netDeviceCmdbIdList) != len(netDeviceNameList):
            localFramework.reportError('The lists <netdevice_cmdbid> and <netdevice_name> have different sizes: <%s> and <%s>! Please check adapter input configuration' \
                        % (len(netDeviceCmdbIdList), len(netDeviceNameList)))
            return None

        ## Build OSH and dict
        for netDeviceIndex in range(len(netDeviceCmdbIdList)):
            netDeviceCmdbId = netDeviceCmdbIdList[netDeviceIndex]
            netDeviceName = netDeviceNameList[netDeviceIndex]
            ## Check if attributes are good
            if not netDeviceCmdbId or not netDeviceName:
                logger.debug('Skipping invalid NetDevice name or CMDB ID in adapter input parameter...')
                continue
            ## Build OSH and add to OSHV
            netDeviceOSH = modeling.createOshByCmdbIdString('netdevice', netDeviceCmdbId)
            #netDeviceOSH.setAttribute('name', netDeviceName)
            netDeviceOSH.setAttribute('data_externalid', netDeviceName)
            ciscoworks_utils.debugPrint(4, '[' + SCRIPT_NAME + ':buildNetDeviceOSHV] Built OSH for NetDevice <%s> with CMDB ID <%s>' % (netDeviceName, netDeviceCmdbId))
            returnOSHV.add(netDeviceOSH)
        return returnOSHV
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.warn('[' + SCRIPT_NAME + ':buildNetDeviceOSHV] Exception: <%s>' % excInfo)
        pass
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:34,代码来源:CiscoWorks_Layer2.py


示例12: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # # Write implementation to return new result CIs here...
    ipList = Framework.getTriggerCIDataAsList('PHYSICAL_IP_ADDRESS')
    portList = Framework.getTriggerCIDataAsList('PHYSICAL_PORT')
    service_context = Framework.getDestinationAttribute('SERVICE_CONTEXT')
    service_type = Framework.getDestinationAttribute('SERVICE_TYPE')
    cluster_id = Framework.getDestinationAttribute('CLUSTER_ID')
    application_resource_id = Framework.getDestinationAttribute('APPLICATION_RESOURCE_ID')
    cluster_root_class = Framework.getDestinationAttribute('CLUSTER_CLASS')
    application_resource_class = Framework.getDestinationAttribute('APPLICATION_RESOURCE_CLASS')
    SCPId = Framework.getDestinationAttribute('id')

    clusterOsh = modeling.createOshByCmdbIdString(cluster_root_class, cluster_id)

    OSHVResult.addAll(scp.createCPLink(application_resource_id, application_resource_class, cluster_id,
                                       cluster_root_class, SCPId, service_context))
    
    for index in range(len(ipList)):
        scpOsh = scp.createScpOsh(clusterOsh, service_type, ip=ipList[index], port=portList[index], context=service_context)
        ipOsh = modeling.createIpOSH(ipList[index])
        OSHVResult.add(scpOsh)
        OSHVResult.add(ipOsh)           

    return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:26,代码来源:cluster_tunnel.py


示例13: disVMKernel

def disVMKernel(hostId, shell, Framework = None, langBund = None):
    ''' Discover physical memory on VMKernel 
    str, Shell, Framework, Properties -> oshVector
    @raise ValueError: memory size is not a digit
    @command: esxcfg-info -F xml | sed -n \'/<memory-info>/,/<\/memory-info>/p\'
    '''
    resVec = ObjectStateHolderVector()
    hostOsh = modeling.createOshByCmdbIdString('host', hostId)

    xml = shell.execCmd('esxcfg-info -F xml | sed -n \'/<memory-info>/,/<\/memory-info>/p\' | sed -n \'1,/<\/memory-info>/p\'')
    #Cleanup retrieved xml. Sometimes there is some debug info added
    xml = xml[xml.find('<'): xml.rfind('>') + 1]

    builder = SAXBuilder(0)
    document = builder.build(StringReader(xml))
    rootElement = document.getRootElement()

    memory_values = rootElement.getChild('aux-source-memory-stats').getChildren('value')
    for value in memory_values:
        if value.getAttributeValue('name') == 'physical-memory-est.':
            memorySizeInKilobytes = int(value.getText())
            memory.report(resVec, hostOsh, memorySizeInKilobytes)
    #TODO: Implement swap discovery for vmkernel
    resVec.add(hostOsh)
    return resVec
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:25,代码来源:TTY_HR_Memory_Lib.py


示例14: DiscoveryMain

def DiscoveryMain(Framework):
	version = Framework.getDestinationAttribute('siebelVersion')
	siebelRootDir = Framework.getDestinationAttribute('siebelInstallDir')

	OSHVResult = ObjectStateHolderVector()
	appServerId = Framework.getDestinationAttribute('id')
	appServerOSH = modeling.createOshByCmdbIdString('siebel_app_server', appServerId)
	modeling.setAppServerType(appServerOSH)

	client = None
	try:
		client = Framework.createClient()
		discoverConfigFile(siebelRootDir,appServerOSH,client,version,OSHVResult)
	except:
		errmsg = 'Connection failed: %s' % str(sys.exc_info()[1]).strip()
		Framework.reportError(errmsg)
		logger.debugException(errmsg)

	if(client != None):
		try:
			client.close()
		except:
			pass

	return OSHVResult
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:25,代码来源:siebel_discover_appserver_config.py


示例15: disLinux

def disLinux(hostId, shell, Framework = None, langBund = None):
    ''' Discover physical memory and swap memory on GNU/Linux 
    str, Shell, Framework, Properties -> oshVector
    @command: /usr/bin/free -m
    '''
    myVec = ObjectStateHolderVector()
    hostOsh = modeling.createOshByCmdbIdString('host', hostId)

    output = None
    try:
        output = shell.execCmd('/usr/bin/free -m')#[email protected]@CMD_PERMISION tty protocol execution
        if not output or shell.getLastCmdReturnCode() != 0:
            raise ValueError
    except:
        logger.warn("Failed getting memory size from 'free'")
    else:
        lines = output.split('\n')
        for line in lines:
            if line:
                if re.search('cache', line):
                    continue
                matcher = re.match("Mem:\s+(\d+)\s+", line)
                if matcher:
                    memorySizeInMegabytes = int(matcher.group(1))
                    memorySizeInKilobytes = memorySizeInMegabytes * 1024
                    memory.report(myVec, hostOsh, memorySizeInKilobytes)
                else:
                    matcher = re.match("Swap:\s+(\d+)\s+", line)
                    if matcher:
                        swapMemorySizeInMegabytes = int(matcher.group(1))
                        modeling.setHostSwapMemorySizeAttribute(hostOsh, swapMemorySizeInMegabytes)

    myVec.add(hostOsh)
    return myVec
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:34,代码来源:TTY_HR_Memory_Lib.py


示例16: start_eapps_discovery

def start_eapps_discovery(Framework, wse_path, shellUtils, OSHVResult, protocol, HOST_ID, WEBSERVER_ID):

	wsefile = Framework.getParameter('eappsCfgPath')
	path = wse_path
	if protocol == 'ntcmd':
		if (wsefile == None or wsefile == ''):
			wsefile  = '%s\\BIN\\eapps.cfg' % wse_path
		sarmLogFolder = wse_path + '\\log'
	else:
		if (wsefile == None or wsefile == ''):
			wsefile  = '%s/eapps.cfg' % wse_path
		sarmLogFolder = wse_path + '/log'

	data = None
	try:
		data = shellUtils.safecat(wsefile)
		if not data:
			raise ValueError
	except:
		raise ConfigFileNotFoundException

	webserverOSH = modeling.createOshByCmdbIdString('webserver', WEBSERVER_ID)
	if webserverOSH is not None:
		parseCfgFileData(data, path, sarmLogFolder, shellUtils, webserverOSH, OSHVResult, HOST_ID, Framework)
	else:
		raise ValueError, 'failed creating webserver OSH from eapps.cfg'
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:26,代码来源:siebel_discover_wse.py


示例17: makeUserOSH

def makeUserOSH(hostCmdbId, userName, desc, uid, gid, homeDir):
    'host OSH, str, str, str, str, str -> OSH vector'
    iuid = -1
    igid = -1
    try:
        iuid = Long(uid)
    except:
        iuid = -1

    try:
        igid = Long(gid)
    except:
        igid = -1

    myVec = ObjectStateHolderVector()

    u_obj = ObjectStateHolder('osuser')
    host_objSH = modeling.createOshByCmdbIdString('host', hostCmdbId)
    u_obj.setContainer(host_objSH)

    u_obj.setAttribute('data_name', userName)
    if(len(uid) > 0):
        u_obj.setAttribute('user_id', Long(iuid))
    if(len(gid) > 0):
        u_obj.setAttribute('group_id', Long(igid))
    if(len(desc) > 0):
        u_obj.setAttribute('data_note', desc)
    if(len(homeDir) > 0):
        u_obj.setAttribute('homedir', homeDir)
    myVec.add(u_obj)

    return(myVec)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:32,代码来源:TTY_HR_User_Lib.py


示例18: disWinOS

def disWinOS(host_obj, shell, Framework, langBund, softNameToInstSoftOSH=None):
    host = modeling.createOshByCmdbIdString("host", host_obj)
    resultsVector = ObjectStateHolderVector()
    if not NTCMD_HR_REG_Software_Lib.doSoftware(shell, host, resultsVector, softNameToInstSoftOSH):
        discoverSoftwareByWmic(shell, host, resultsVector, softNameToInstSoftOSH)

    wmiProvider = getWmiProvider(shell)
    hostDiscoverer = WmiHostDiscoverer(wmiProvider)
    if hostDiscoverer.isWin2008():
        softwares = discover2008Hotfixes(wmiProvider, host)
        for software in softwares:
            if not software.osh:
                continue
            if softNameToInstSoftOSH is not None:
                if software.name in softNameToInstSoftOSH:
                    continue
                softNameToInstSoftOSH[software.name] = software.osh
            resultsVector.add(software.osh)

    elif hostDiscoverer.isWindows8_2012():
        softwares = discover2012Hotfixes(wmiProvider, host)
        for software in softwares:
            if not software.osh:
                continue
            if softNameToInstSoftOSH is not None:
                if software.name in softNameToInstSoftOSH:
                    continue
                softNameToInstSoftOSH[software.name] = software.osh
            resultsVector.add(software.osh)
        softwareList = WindowsAppsDiscoverer(shell).discover()
        softwareOshVector = InstalledSoftwareReporter().reportAll(softwareList, host)
        resultsVector.addAll(softwareOshVector)

    return resultsVector
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:34,代码来源:TTY_HR_Software_Lib.py


示例19: discoverITS

def discoverITS(client, installpath, WEBSERVER_ID, OSHVResult):

    shellUtils = ShellUtils(client)

    webserverOSH = modeling.createOshByCmdbIdString('webserver', WEBSERVER_ID)

    sapitsOSH = ObjectStateHolder('sap_its_wgate')
    sapitsOSH.setAttribute('data_name', 'ITS_' + client.getIpAddress())
    sapitsOSH.setContainer(webserverOSH)
    OSHVResult.add(sapitsOSH)

    mapInstanceNameToAgate = getAgates(shellUtils, installpath, sapitsOSH, OSHVResult)

    filePath = installpath + '\\config\\ItsRegistryALL.xml'
    data = shellUtils.safecat(filePath)

    logger.debug('got ItsRegistryALL file')
    # data = stripNtcmdHeaders(data)
    if data == None or error(data):
        logger.error('No data found')
    else:
        builder = SAXBuilder(0)
        doc = builder.build(StringReader(data))
        root = doc.getRootElement()
        keyElem = getElementByAttrValue(root, 'key', 'name', 'AGate')
        instancesRoot = getElementByAttrValue(keyElem, 'key', 'name', 'Instances')
        instances = instancesRoot.getChildren('value')
        it = instances.iterator()
        while it.hasNext():
            instance = it.next()
            name = instance.getText()
            agates = mapInstanceNameToAgate.get(name)
            if agates != None and agates.isEmpty() == 0:
                servers(name, installpath, sapitsOSH, agates, shellUtils, OSHVResult)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:34,代码来源:sap_its.py


示例20: build_network_device

def build_network_device(device):
    '''
    Build Layer 2 connection end.
    @type param: NetworkDevice -> OSH
    '''
    device_osh = None
    device_ip_address_osh = None
    device_interface_osh = None
    device_member_ip = None
    if device.ucmdb_id:
        device_osh = modeling.createOshByCmdbIdString('node', device.ucmdb_id)
    if device.mac_address:
        if not device_osh:
            device_osh = modeling.createCompleteHostOSH('node', device.mac_address)
        device_interface_osh = modeling.createInterfaceOSH(device.mac_address, device_osh)
    if device.ip_address:
        if not device_osh:
            device_osh = modeling.createHostOSH(device.ip_address)
        device_ip_address_osh = modeling.createIpOSH(device.ip_address)
        device_member_ip = modeling.createLinkOSH('contained', device_osh, device_ip_address_osh)
    if device.port:
        if device_interface_osh:
            device_interface_osh.setAttribute('interface_name', device.port)
        elif device_osh:
            device_interface_osh = ObjectStateHolder('interface')
            device_interface_osh.setContainer(device_osh)
            device_interface_osh.setAttribute('interface_name', device.port)
    return device_osh, device_ip_address_osh, device_interface_osh, device_member_ip
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:28,代码来源:SNMP_CDP_LLDP.py



注:本文中的modeling.createOshByCmdbIdString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python modeller.environ函数代码示例发布时间:2022-05-27
下一篇:
Python modeling.createLinkOSH函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap