Пример #1
0
def doDiscovery(Framework,
                shell,
                client,
                ip,
                codepage,
                connectedShellCredId=None):
    '''Framework, Shell, BaseClient, str, str -> ObjectStateHolderVector
    @raise Exception: discovery failed
    @raise JException: discovery failed
    '''
    vector = ObjectStateHolderVector()
    languageName = shell.osLanguage.bundlePostfix
    host_cmdbid = Framework.getDestinationAttribute('host_cmdbid')
    host_key = Framework.getDestinationAttribute('host_key')
    mac_address = Framework.getDestinationAttribute('ip_mac_address')
    if not mac_address or len(mac_address) == 0 or mac_address == 'NA':
        mac_address = None

    langBund = Framework.getEnvironmentInformation().getBundle(
        'langNetwork', languageName)

    shellObj = createShellObj(shell, client, ip, langBund, languageName,
                              codepage, mac_address, connectedShellCredId)

    #NAT
    natIPs = getNatIPFromConfigurationFile()

    uduid = None
    if not isinstance(shell, shellutils.NexusShell):
        uduid = getUduid(client, isStampEnabled(Framework, ip))
        logger.debug("Get UD_UNIQUE_ID:", uduid)
    if (shell.isWinOs()):
        try:
            environment = shell_interpreter.Factory().create(
                shell).getEnvironment()
            environment.appendPath('PATH', '%WINDIR%\\system32\\wbem\\')
        except:
            logger.debug('Failed to add default wmic path.')

    #NAT
        vector.addAll(
            NTCMD_Connection_Utils.doHPCmd(shell, shellObj, ip, langBund,
                                           Framework, host_cmdbid, host_key,
                                           None, uduid, natIPs))
    else:
        vector.addAll(
            TTY_Connection_Utils.getOSandStuff(shell, shellObj, Framework,
                                               langBund, uduid, natIPs))

    return vector
Пример #2
0
def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()
	(vec, errObj) = NTCMD_Connection_Utils.mainFunction(Framework)

	logger.debug('OSHVector contains ', vec.size(), ' objects.')
	# just in case we couldn't do any connection
	if vec.size() == 0:
		logger.debug('Failed to connect. No Host CI will be created')
		if (errObj == None or errObj.errMsg == None or errObj.errMsg.strip() == ''):
			altErr = errorobject.createError(errorcodes.INTERNAL_ERROR ,None , 'Discovery failed due to internal error')
			logger.reportErrorObject(altErr)
		else:
			logger.reportWarningObject(errObj)
	else:
		OSHVResult.addAll(vec)


	return OSHVResult
Пример #3
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    (vec, errObj) = NTCMD_Connection_Utils.mainFunction(Framework)

    logger.debug('OSHVector contains ', vec.size(), ' objects.')
    # just in case we couldn't do any connection
    if vec.size() == 0:
        logger.debug('Failed to connect. No Host CI will be created')
        if (errObj == None or errObj.errMsg == None
                or errObj.errMsg.strip() == ''):
            altErr = errorobject.createError(
                errorcodes.INTERNAL_ERROR, None,
                'Discovery failed due to internal error')
            logger.reportErrorObject(altErr)
        else:
            logger.reportWarningObject(errObj)
    else:
        OSHVResult.addAll(vec)

    return OSHVResult
Пример #4
0
def doDiscovery(Framework, shell, client, ip, codepage, connectedShellCredId = None):
    '''Framework, Shell, BaseClient, str, str -> ObjectStateHolderVector
    @raise Exception: discovery failed
    @raise JException: discovery failed
    '''
    vector = ObjectStateHolderVector()
    languageName = shell.osLanguage.bundlePostfix
    host_cmdbid = Framework.getDestinationAttribute('host_cmdbid')
    host_key = Framework.getDestinationAttribute('host_key')
    mac_address = Framework.getDestinationAttribute('ip_mac_address')
    if not mac_address or len(mac_address) == 0 or mac_address == 'NA':
        mac_address = None

    langBund = Framework.getEnvironmentInformation().getBundle('langNetwork', languageName)

    shellObj = createShellObj(shell, client, ip, langBund, languageName, codepage, mac_address, connectedShellCredId)

    #NAT
    natIPs = getNatIPFromConfigurationFile()

    uduid = None
    if not isinstance(shell, shellutils.NexusShell):
        uduid = getUduid(client, isStampEnabled(Framework, ip))
        logger.debug("Get UD_UNIQUE_ID:", uduid)
    if (shell.isWinOs()):
        try:
            environment = shell_interpreter.Factory().create(shell).getEnvironment()
            environment.appendPath('PATH', '%WINDIR%\\system32\\wbem\\')
        except:
            logger.debug('Failed to add default wmic path.')

    #NAT
        vector.addAll(NTCMD_Connection_Utils.doHPCmd(shell, shellObj, ip, langBund, Framework, host_cmdbid, host_key, None, uduid, natIPs))
    else:
        vector.addAll(TTY_Connection_Utils.getOSandStuff(shell, shellObj, Framework, langBund, uduid, natIPs))

    return vector