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
Example #2
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    (vec, errStr) = TTY_Connection_Utils.mainFunction(Framework)
    logger.debug('OSHVector contains ', vec.size(), ' objects.')
    # just in case we couldnt do any connection
    if vec.size() == 0:
        logger.debug('Failed to connect, No Host CI will be created')
        if (errStr == None or errStr.strip() == ''):
            Framework.reportError('Discovery failed due to internal error')
        else:
            Framework.reportWarning(errStr)
    else:
        OSHVResult.addAll(vec)
    return OSHVResult
Example #3
0
def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()

	(vec, errStr) = TTY_Connection_Utils.mainFunction(Framework)
	logger.debug('OSHVector contains ', vec.size(), ' objects.')
	# just in case we couldnt do any connection
	if vec.size() == 0:
		logger.debug('Failed to connect, No Host CI will be created')
		if (errStr == None or errStr.strip() == ''):
			Framework.reportError('Discovery failed due to internal error')
		else:
			Framework.reportWarning(errStr)
	else:
		OSHVResult.addAll(vec)
	return OSHVResult
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