Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def DiscoveryMain(framework):
    vector = ObjectStateHolderVector()
    protocol = framework.getDestinationAttribute('Protocol')
    try:
        client = framework.createClient()
        shell = None
        try:
            shell = shellutils.ShellUtils(client)
            dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell)
            params = _obtainParams(framework)
            zoneNameList, includeOutscopeIPs, reportBrokenAliases = params
            zoneTopologies = dns_discoverer.discoverDnsZoneTopologies(
                dnsDiscoverer, zoneNameList, protocol)
            vector.addAll(
                dns_discoverer.reportTopologies(zoneTopologies,
                                                includeOutscopeIPs,
                                                reportBrokenAliases))
        finally:
            try:
                shell and shell.closeClient()
            except:
                logger.debugException('')
                logger.error('Unable to close shell')
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, framework)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def DiscoveryMain(Framework):
    debugPrint('[DiscoveryMain] Starting...')
    # General variables
    OSHVResult = ObjectStateHolderVector()
    protocolName = 'SQL'
    sqlClient = None

    # We need dictionaries for each OSH type since results of
    # SQL queries will contain multiple rows with the same info
    datacenterOshDict = {}  # Use building name as key
    rackOshDict = {}  # Use rack+building name as key
    pduOshDict = {}  # Use PDU+building name as key
    rppOshDict = {}  # Use RPP+building name as key
    hostOshDict = {}  # Use serial number as key

    try:
        # JDBC client
        sqlClient = Framework.createClient()

        # Discover...
        OSHVResult.addAll(
            getDevices(Framework, sqlClient, datacenterOshDict, rackOshDict,
                       pduOshDict, rppOshDict, hostOshDict))
        OSHVResult.addAll(
            getPowerRoutes(Framework, sqlClient, datacenterOshDict,
                           rackOshDict, pduOshDict, rppOshDict, hostOshDict))
    except Exception, ex:
        strException = str(ex.getMessage())
        errormessages.resolveAndReport(strException, protocolName, Framework)
Ejemplo n.º 5
0
    def onConnection(self, context):
        '''
        Method handles successful connection described by context
        '''

        self.connected = True

        try:

            vector = self.discoveryFunction(context, self.framework)

            if vector is not None:

                logger.debug(" -- Sending vector of %s objects" %
                             vector.size())
                if self._logVector:
                    logger.debug(vector.toXmlString())

                self.framework.sendObjects(vector)
                self.framework.flushObjects()

            else:
                logger.warn(
                    "Discovery function returned result vector that is None")

        except JException, ex:
            msg = ex.getMessage()
            msg = cim_discover.translateErrorMessage(msg)
            logger.debug(msg)
            errormessages.resolveAndReport(msg, cim.Protocol.DISPLAY,
                                           self.framework)
Ejemplo n.º 6
0
 def findConfigPath(self):
     """
     Returns path to mysql configuration file
     @return string my.cnf path
     """
     if self.configPath:
         return self.configPath
     #try to take from options
     fileMonitor = file_mon_utils.FileMonitor(self.Framework, self.shell,
                                              None, '', None)
     if self.DEFAULTS_FILE_OPT_NAME in self.opts.keys():
         self.configPath = self.opts[self.DEFAULTS_FILE_OPT_NAME]
         cnfPath = self.opts[self.DEFAULTS_FILE_OPT_NAME]
         if fileMonitor.checkPath(cnfPath):
             self.configPath = cnfPath
         else:
             strException = 'MySQL configuration file path is not valid'
             errormessages.resolveAndReport(
                 strException,
                 self.Framework.getDestinationAttribute('Protocol'),
                 self.Framework)
     #try to get from help
     elif not self.getConfigsFromHelp(fileMonitor):
         strException = 'Failed to find MySQL configuration file location'
         errormessages.resolveAndReport(
             strException,
             self.Framework.getDestinationAttribute('Protocol'),
             self.Framework)
     return self.configPath
Ejemplo n.º 7
0
def DiscoveryMain(framework):
    vector = ObjectStateHolderVector()
    protocol = 'local_shell'
    try:
        zoneNameList, includeOutscopeIPs, ip, reportBrokenAliases = _obtainParams(framework)
        if not zoneNameList:
            logger.reportError('List of zones for transfer is not specified')
            return
        client = framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
        shell = None
        try:
            shell = shellutils.ShellUtils(client)
            #pass name server IP to the discoverer
            dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell, ip)
            zoneTopologies = dns_discoverer.discoverDnsZoneTopologies(dnsDiscoverer, zoneNameList, protocol)
            vector.addAll(dns_discoverer.reportTopologies(zoneTopologies, includeOutscopeIPs, reportBrokenAliases))
        finally:
            try:
                shell and shell.closeClient()
            except:
                logger.debugException('')
                logger.error('Unable to close shell')
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, framework)
Ejemplo n.º 8
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    CmdbOIDFactory = CmdbObjectID.Factory
    hostId = CmdbOIDFactory.restoreObjectID(Framework.getDestinationAttribute('hostId'))
    sqlServerId = CmdbOIDFactory.restoreObjectID(Framework.getDestinationAttribute('id'))

    try:
        props = Properties()
 
        instance_name = Framework.getDestinationAttribute('instanceName')
        if instance_name and instance_name != 'NA' and instance_name.find('\\') != -1:
            props.setProperty('sqlprotocol_dbsid', instance_name[instance_name.find('\\')+1:])
        mssqlClient = Framework.createClient(props)
        connection = SqlServerConnection.ClientSqlServerConnection(mssqlClient)
        logger.debug("got connection")
        discoveryOptions = SqlServerDiscoveryOptions()
        discoveryOptions.discoverConfigs = Boolean.parseBoolean(Framework.getParameter('discoverConfigs'))
        discoveryOptions.discoverDbUser = Boolean.parseBoolean(Framework.getParameter('discoverDbUser'))
        discoveryOptions.discoverSqlFile = Boolean.parseBoolean(Framework.getParameter('discoverSqlFile'))
        discoveryOptions.discoverSqlJob = Boolean.parseBoolean(Framework.getParameter('discoverSqlJob'))
        discoveryOptions.discoverProcedures = Boolean.parseBoolean(Framework.getParameter('discoverStoredProcedures'))
        discoveryOptions.discoverInternalProcedures = Boolean.parseBoolean(Framework.getParameter('discoverInternalProcedures'))

        sqlServer = SqlServer.SqlServer(connection, discoveryOptions)
        OSHVResult.addAll(sqlServer.collectData(hostId, sqlServerId, discoveryOptions.discoverConfigs))
        mssqlClient.close()
    except JavaException, ex:
        strException = ex.getMessage()
        errormessages.resolveAndReport(strException, ClientsConsts.SQL_PROTOCOL_NAME, Framework)
Ejemplo n.º 9
0
def DiscoveryMain(Framework):
    shell = None
    try:
        try:
            protocolName = __getProtocolName(Framework)
            discoverSharePointUrls = Boolean.parseBoolean(Framework.getParameter('discoverSharePointUrls'))
            reportIntermediateWebService = Framework.getParameter('reportIntermediateWebService')
            if reportIntermediateWebService:
                reportIntermediateWebService = Boolean.parseBoolean(reportIntermediateWebService)
            else:
                #set default value
                reportIntermediateWebService = 1
            relativeCommandTimeoutMultiplier = Framework.getParameter('relativeCommandTimeoutMultiplier')
            relativeCommandTimeoutMultiplier = int(relativeCommandTimeoutMultiplier)
            client = Framework.createClient()
            shell = ShellFactory().createShell(client)
            logger.debug('getting SharePoint discoverer for protocol %s' % protocolName)
            discoverer = sharepoint_win_shell.getDiscoverer(shell, protocolName, relativeCommandTimeoutMultiplier)
            logger.debug('got discoverer')
            resources = _discoverSharePoint(discoverer)
            resources.build()
            return resources.report(discoverSharePointUrls, reportIntermediateWebService)
        except SharePointException:
            logger.reportError()
            logger.debugException('')
        except JavaException, ex:
            strException = ex.getMessage()
            errormessages.resolveAndReport(strException, protocolName, Framework)
        except:
            strException = logger.prepareJythonStackTrace('')
            errormessages.resolveAndReport(strException, protocolName, Framework)
Ejemplo n.º 10
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    protocol = Framework.getDestinationAttribute('Protocol')
    try:
        csvFileName = Framework.getRequiredParameterValue(PARAM_CSV_FILE)
        delimiter = Framework.getRequiredParameterValue(
            PARAM_CSV_FILE_DELIMITER)
        if delimiter and delimiter.isdigit():
            delimiter = chr(int(delimiter))
        rowToStartIndex = Framework.getRequiredParameterValue(
            PARAM_ROW_TO_START_INDEX)
        bulkSize = Framework.getParameter(import_utils.PARAM_BULK_SIZE)
        flushObjects = Framework.getParameter(import_utils.PARAM_FLUSH_OBJECTS)
        fileEncoding = Framework.getParameter(import_utils.PARAM_FILE_ENCODING)

        dataSource = CsvFileDataSource(csvFileName, delimiter,
                                       int(rowToStartIndex), Framework,
                                       fileEncoding)
        dataSource.quoteSymbol = Framework.getParameter(PARAM_QUOTE_SYMBOL)

        if flushObjects and (flushObjects.lower() == "true"):
            import_utils.importFlushingCis(dataSource, OSHVResult, Framework,
                                           bulkSize)
        else:
            import_utils.importCis(dataSource, OSHVResult, Framework)

    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)
Ejemplo n.º 11
0
def processWsdl(wsdl_url,
                Framework,
                wsdl_url_data=None,
                importWsdlDocuments=1,
                containerOSH=None):
    ucmdbVersion = Version().getVersion(Framework)
    locator = resource_locator.getProbeResourceLocator(ucmdbVersion)
    webserviceFolder = 'webservice'
    System.setProperty("wasp.location",
                       locator.contentLibPathOf(webserviceFolder))
    importWsdldNames = []
    importWsdldNameToData = {}

    OSHVResult = ObjectStateHolderVector()

    try:
        result = readWSDL(wsdl_url, wsdl_url_data, importWsdlDocuments)
        wsdl_url_data = result[0]
        defintion = result[1]
    except UnknownHostException, ex:
        host = ex.getMessage()
        msg = "Unknown host: %s" % host
        logger.debugException("Failed reading url: '%s', reason: '%s'\n" %
                              (wsdl_url, msg))
        errormessages.resolveAndReport(msg, ClientsConsts.HTTP_PROTOCOL_NAME,
                                       Framework)
        return OSHVResult
Ejemplo n.º 12
0
def DiscoveryMain(Framework):
    resultCollection = ObjectStateHolderVector()

    hostId = Framework.getDestinationAttribute('hostId')
    hostIp = Framework.getDestinationAttribute('ip_address')
    nodeName = Framework.getDestinationAttribute('nodeName')

    client = None
    try:
        client = Framework.createClient()
        catalogUidToSqlMx = _discoverSqlMx(client, nodeName)
        catalogUidToMxSchema = {}
        if catalogUidToSqlMx:
            catalogUidToMxSchema = _discoverSqlMxSchemas(client)
            client.executeCmd('exit;', 0, 1)
        sqlmpList = _discoverSqlMp(client)
        client.executeCmd('exit;', 0, 1)
        hostOsh = modeling.createOshByCmdbIdString('host', hostId)
        resultCollection.add(hostOsh)
        _reportNonStopTopology(resultCollection, hostOsh, hostIp,
                               catalogUidToSqlMx, catalogUidToMxSchema,
                               sqlmpList)
    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, ClientsConsts.SSH_PROTOCOL_NAME,
                                       Framework)
Ejemplo n.º 13
0
def DiscoveryMain(Framework):
    resultVector = ObjectStateHolderVector()

    ipAddress = Framework.getDestinationAttribute(DestinationProperty.IP_ADDRESS)
    credentialsId = Framework.getDestinationAttribute(DestinationProperty.CREDENTIALS_ID)
    hypervisorCmdbId = Framework.getDestinationAttribute(DestinationProperty.HYPERVISOR_CMDB_ID)
    esxCmdbId = Framework.getDestinationAttribute(DestinationProperty.ESX_CMDB_ID)
    esxBiosUuid = Framework.getDestinationAttribute(DestinationProperty.ESX_BIOS_UUID)
    
    if not esxBiosUuid:
        msg = "ESX BIOS UUID from trigger data is empty"
        errorObject = errorobject.createError(errorcodes.INTERNAL_ERROR_WITH_PROTOCOL_DETAILS, [cim.Protocol.DISPLAY, msg], msg)
        logger.reportErrorObject(errorObject)
        logger.error(msg)
        return resultVector
    
    try:
        unitaryComputerSystem = discoverEsxInventory(ipAddress, credentialsId, esxBiosUuid, Framework)
        
        inventoryResultVector = reportEsxInventory(unitaryComputerSystem, esxCmdbId)
        resultVector.addAll(inventoryResultVector)
        
        virtualMachines = discoverEsxVirtualTopology(ipAddress, credentialsId, esxBiosUuid, Framework)
        if virtualMachines:
            virtualResultVector = reportVirtualTopology(virtualMachines, hypervisorCmdbId)
            resultVector.addAll(virtualResultVector)
        
    except JException, ex:
        msg = ex.getMessage()
        msg = cim_discover.translateErrorMessage(msg)
        logger.debug(msg)
        errormessages.resolveAndReport(msg, cim.Protocol.DISPLAY, Framework)
Ejemplo n.º 14
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    try:
        hostId = Framework.getDestinationAttribute('hostId')
        hostOsh = modeling.createOshByCmdbIdString('host_node', hostId)

        snmpClient = Framework.createClient()
        try:
            cssDiscoverer = createCssDiscoverer(snmpClient, Framework,
                                                OSHVResult, hostOsh)
            cssDiscoverer.discoverContentRules()
            cssDiscoverer.discoverServices()
        finally:
            snmpClient.close()
    except NoCssException:
        errobj = errorobject.createError(
            errorcodes.CSS_NOT_FOUND_ON_TARGET_HOST, None,
            'CSS was not found on target host')
        logger.reportErrorObject(errobj)
    except:
        errorMessage = logger.prepareJythonStackTrace('')
        logger.error(errorMessage)
        errormessages.resolveAndReport(errorMessage, 'SNMP', Framework)

    return OSHVResult
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    ipAddress = Framework.getDestinationAttribute('ip_address')
    credentialsId = Framework.getDestinationAttribute('credentialsId')
    hostId = Framework.getDestinationAttribute('hostId')
    hostOsh = modeling.createOshByCmdbIdString('host', hostId)
    PROTOCOL_NAME = 'PowerShell'
    try:
        client = Framework.createClient()
        shell =shellutils.ShellUtils(client)
        discoverer = None
        try:
            for discovererClass in [msexchange_win_shell.Exchange2007Discoverer, msexchange_win_shell.Exchange2010Discoverer]:
                try:
                    discoverer = discovererClass(shell)
                    exchangeServers = discoverer.discover()
                    for exchangeServer in exchangeServers:
                        topoBuilder = msexchange.TopologyBuilder(exchangeServer, hostOsh, ipAddress, credentialsId)
                        OSHVResult.addAll(topoBuilder.build())
                        break
                except msexchange_win_shell.AddSnapInException:
                    logger.warn('Failed to import Snap-In.')
                    discoverer = None
            if not discoverer:
                raise Exception("Failed to discover MS-Exchange. See Logs for details.")
        finally:
            shell.closeClient()
    except JavaException, ex:
        logger.debugException('')
        strException = str(ex.getMessage())
        errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
Ejemplo n.º 16
0
def DiscoveryMain(Framework):
    protocol = Framework.getDestinationAttribute('Protocol')
    try:
        SnmpTcpDiscoverer(Framework).discover()
    except JavaException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)
Ejemplo n.º 17
0
def DiscoveryMain(Framework):

	credentialsId = Framework.getDestinationAttribute('credentialsId')

	OSHVResult = ObjectStateHolderVector()
	matchers = SiebelAgent.SIEBEL_DEFAULT_ENTERPRISE_MATCHERS
	ip = Framework.getDestinationAttribute('ip_address')
	port = Framework.getDestinationAttribute('port')
	if port == 'NA':
		port = None

	try:
		client = None
		try:
			client = siebel_common.createClient(Framework, ip, matchers, credentialsId, port)
			username = client.getUserName()
			enterprise = client.getEnterprise()

			siteOSH = ObjectStateHolder('siebel_site')
			siteOSH.setAttribute('data_name', enterprise)
			siteOSH.setAttribute('gateway_address', ip)
			modeling.setAppSystemVendor(siteOSH)

			start_srvrmgr_discovery(client, ip, username, enterprise, siteOSH, Framework, OSHVResult)

		finally:
			if client is not None:
				client.close()
	except Exception, ex:
		strException = str(ex.getMessage())
		errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
		logger.debugException('')
Ejemplo n.º 18
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()    
    ipAddress = Framework.getDestinationAttribute('ip_address')
    credentialsId = Framework.getDestinationAttribute('credentialsId')
    hostId = Framework.getDestinationAttribute('hostId')
    
    hostOsh = ms_exchange_utils.restoreHostById(hostId)

    try:
        shellClient = Framework.createClient()
        client = PowerShellClient(shellClient, Framework)
        try:
            ExchangeServer = client.executeScenario("Exchange_Server_2007_Discovery.ps1")
            
            exchangeServerOsh = modeling.createExchangeServer(hostOsh, ipAddress, credentialsId, ExchangeServer.ExchangeSnapInVersion)
            exchangeServerOsh.setAttribute('guid', normalizeGuid(ExchangeServer.Guid))
            exchangeServerOsh.setAttribute('fqdn', ExchangeServer.Fqdn)
            
            buildNumber = parseBuildNumber(ExchangeServer.AdminDisplayVersion)
            if buildNumber:                
                exchangeServerOsh.setAttribute('build_number', buildNumber)
            #exchangeServerOsh.setAttribute('application_version_number', ExchangeServer.ExchangeSnapInVersion)
            versionNumber = parseExchangeVersion(ExchangeServer.AdminDisplayVersion)
            if versionNumber:
                exchangeServerOsh.setAttribute('application_version_number', exchange_version_mapping[versionNumber])
            exchangeServerOsh.setAttribute('application_version', ExchangeServer.AdminDisplayVersion)
            exchangeServerOsh.setDateAttribute('creation_date', DATE_FORMAT.parse(ExchangeServer.WhenCreated))
            
            OSHVResult.add(exchangeServerOsh)
        finally:
            client.close()
    except Exception, ex:
        logger.debugException('')
        strException = str(ex.getMessage())
        errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
Ejemplo n.º 19
0
def DiscoveryMain(Framework):
	debugPrint('[DiscoveryMain] Starting...')
	# General variables
	OSHVResult = ObjectStateHolderVector()
	protocolName = 'SQL'
	sqlClient = None

	# We need dictionaries for each OSH type since results of
	# SQL queries will contain multiple rows with the same info
	datacenterOshDict = {}	# Use building name as key
	rackOshDict = {}		# Use rack+building name as key
	pduOshDict = {}			# Use PDU+building name as key
	rppOshDict = {}			# Use RPP+building name as key
	hostOshDict = {}		# Use serial number as key

	try:
		# JDBC client
		sqlClient = Framework.createClient()

		# Discover...
		OSHVResult.addAll(getDevices(Framework, sqlClient, datacenterOshDict, rackOshDict, pduOshDict, rppOshDict, hostOshDict))
		OSHVResult.addAll(getPowerRoutes(Framework, sqlClient, datacenterOshDict, rackOshDict, pduOshDict, rppOshDict, hostOshDict))
	except Exception, ex:
		strException = str(ex.getMessage())
		errormessages.resolveAndReport(strException, protocolName, Framework)
Ejemplo n.º 20
0
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)
Ejemplo n.º 21
0
def DiscoveryMain(Framework):

    protocolName = "NTCMD"

    OSHVResult = ObjectStateHolderVector()
    param = Framework.getParameter('discoverSoftware')
    if (param != None) and not Boolean.parseBoolean(param):
        logger.debug(
            'No discovery for software by NTCMD, parameter discoverSoftware is false'
        )
        return OSHVResult

    hostID = Framework.getDestinationAttribute('hostId')

    hostOSH = modeling.createOshByCmdbIdString('host', hostID)

    clientShUtils = None
    try:
        props = Properties()
        props.setProperty(AgentConstants.PROP_NTCMD_AGENT_COMMAND_TIMEOUT,
                          '100000')
        client = Framework.createClient(props)
        if client is None:
            raise Exception, 'Failed to create NTCMD client'
    except Exception, ex:
        strException = ex.getMessage()
        errormessages.resolveAndReport(strException, protocolName, Framework)
Ejemplo n.º 22
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    #ipAddress = Framework.getDestinationAttribute('ip_address')
    #credentialsId = Framework.getDestinationAttribute('credentialsId')
    hostId = Framework.getDestinationAttribute('hostId')

    try:
        factory = hyperv.ShellClientFactory(Framework)
        shell = None
        try:
            shell = factory.createClient()

            language = shell.getOsLanguage()
            bundle = hyperv.getBundleByLanguage(language, Framework)
            namespace = hyperv.ShellNamespaceLookUp().lookUp(shell)
            wmiProvider = hyperv.ShellHypervAgentProvider(
                shell, bundle, namespace)
            hyperv.discoverHypervHost(
                wmiProvider, hostId, Framework, OSHVResult,
                namespace[2:])  #strip heading slashes in namespace

        finally:
            if shell is not None:
                shell.closeClient()
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, NTCMD_PROTOCOL, Framework)
Ejemplo n.º 23
0
def DiscoveryMain(framework):
    vector = ObjectStateHolderVector()
    protocol = 'local_shell'
    try:
        zoneNameList, includeOutscopeIPs, ip, reportBrokenAliases = _obtainParams(
            framework)
        if not zoneNameList:
            logger.reportError('List of zones for transfer is not specified')
            return
        client = framework.createClient(
            ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
        shell = None
        try:
            shell = shellutils.ShellUtils(client)
            #pass name server IP to the discoverer
            dnsDiscoverer = dns_discoverer.createDiscovererByShell(shell, ip)
            zoneTopologies = dns_discoverer.discoverDnsZoneTopologies(
                dnsDiscoverer, zoneNameList, protocol)
            vector.addAll(
                dns_discoverer.reportTopologies(zoneTopologies,
                                                includeOutscopeIPs,
                                                reportBrokenAliases))
        finally:
            try:
                shell and shell.closeClient()
            except:
                logger.debugException('')
                logger.error('Unable to close shell')
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, framework)
Ejemplo n.º 24
0
    def discover(self):
        protocol = self.framework.getDestinationAttribute('Protocol')
        try:
            captureProcessInformation = self.framework.getParameter(
                'CaptureProcessInformation')
            numberOfTCPSnapshots = int(
                self.framework.getParameter('NumberOfTCPSnapshots'))
            delayBetweenTCPSnapshots = float(
                self.framework.getParameter('DelayBetweenTCPSnapshots'))
        except:
            logger.error(logger.prepareFullStackTrace(''))
            raise ValueError("Job parameters are invalid")
        else:
            if numberOfTCPSnapshots < 1 or delayBetweenTCPSnapshots <= 0:
                raise ValueError("Job parameters are invalid")

            try:
                if captureProcessInformation.lower() == 'true':
                    self._discoverProcesses()

            except UnknownOSTypeException, ex:
                msg = str(ex)
                errormessages.resolveAndReport(msg,
                                               self.client.getClientType(),
                                               self.framework)
            except:
def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()	
	ipAddress = Framework.getDestinationAttribute('ip_address')
	credentialsId = Framework.getDestinationAttribute('credentialsId')
	hostId = Framework.getDestinationAttribute('hostId')
	
	hostOsh = ms_exchange_utils.restoreHostById(hostId)
	hostName = Framework.getDestinationAttribute('hostName')	
	if not hostName or hostName == 'N/A':
		hostName = ms_exchange_utils.getHostNameFromWmi(Framework)
	
	if not hostName:
		errobj = errorobject.createError(errorcodes.FAILED_GETTING_INFORMATION_NO_PROTOCOL, ['host name'], 'Failed to obtain host name')
		logger.reportErrorObject(errobj)
		return
	
	props = Properties()
	props.put(AgentConstants.PROP_WMI_NAMESPACE, WMI_NAMESPACE)	
	try:
		wmiClient = Framework.createClient(props)
		wmiAgent = WmiAgent(wmiClient, Framework)
		try:
			discoverExchangeServer(wmiAgent, ipAddress, credentialsId, OSHVResult, Framework, hostOsh, hostName)
		finally:			
			wmiClient.close()
	except Exception, ex:
		message = ex.getMessage()
		if (re.search("Invalid\sclass", message)):
			message = 'Unable to get Exchange data from WMI'
		logger.debugException(message)
		errormessages.resolveAndReport(message, WMI_PROTOCOL, Framework)
Ejemplo n.º 26
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    WEBSERVER_ID = Framework.getDestinationAttribute('id')
    installPath = Framework.getDestinationAttribute('installPath')
    client = None
    # since install path is the full path name to the process executable image
    # including the image name - separate the executable image name from its
    # directory path.
    # We need here only the path to the directory wehere the process resides
    m = re.search('(.*/)([^/]+)', installPath)
    if (m != None):
        installPath = m.group(1)
    try:
        try:
            client = Framework.createClient()
            rootPath = findRootPath(installPath)
            logger.debug('found rootPath: ', rootPath)
            if rootPath != None:
                discoverITS(client, rootPath, WEBSERVER_ID, OSHVResult)
            else:
                logger.error('Can not find the ITS root path')
        except:
            errorMsg = str(sys.exc_info()[1])
            logger.debugException(errorMsg)
            errormessages.resolveAndReport(errorMsg, 'NTCMD', Framework)
    finally:
        if(client != None):
            try:
                client.close()
            except:
                logger.debug('Failed to execute disconnect NTCMD..')

    return OSHVResult
Ejemplo n.º 27
0
def DiscoveryMain(Framework):
    resultVector = ObjectStateHolderVector()

    try:
        configurationReader = nnmi.ConfigurationReader(Framework)
        configuration = configurationReader.getConfiguration()

        connectionFactory = nnmi.ConnectionFactory(Framework)
        connections = connectionFactory.getConnections()

        if connections:
            if len(connections) > 1:
                logger.debug("More than one set of credentials found, the first one is used")

            connection = connections[0]
            
            strategy = nnmi.getDiscoveryStrategy(Framework, configuration)
            
            strategy.discover(connection)
            

    except nnmi.IntegrationException, ex:
        msg = str(ex)
        logger.error(msg)
        errormessages.resolveAndReport(msg, nnmi.NNM_PROTOCOL_NAME, Framework)
Ejemplo n.º 28
0
    def onConnection(self, context):
        '''
        Method handles successful connection described by context
        '''
        
        self.connected = True
        
        try:

            vector = self.discoveryFunction(context, self.framework)

            if vector is not None:
                
                logger.debug(" -- Sending vector of %s objects" % vector.size())
                if self._logVector:
                    logger.debug(vector.toXmlString())
                
                self.framework.sendObjects(vector)
                self.framework.flushObjects()
            
            else:
                logger.warn("Discovery function returned result vector that is None")
        
        except JException, ex:
            msg = ex.getMessage()
            msg = cim_discover.translateErrorMessage(msg)
            logger.debug(msg)
            errormessages.resolveAndReport(msg, cim.Protocol.DISPLAY, self.framework)
Ejemplo n.º 29
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()    
    #ipAddress = Framework.getDestinationAttribute('ip_address')
    #credentialsId = Framework.getDestinationAttribute('credentialsId')
    hostId = Framework.getDestinationAttribute('hostId')
    
    
    try:
        factory = hyperv.ShellClientFactory(Framework)
        shell = None
        try:
            shell = factory.createClient()
            
            language = shell.getOsLanguage()
            bundle = hyperv.getBundleByLanguage(language, Framework)
            namespace = hyperv.ShellNamespaceLookUp().lookUp(shell)
            wmiProvider = hyperv.ShellHypervAgentProvider(shell, bundle, namespace)
            hyperv.discoverHypervHost(wmiProvider, hostId, Framework, OSHVResult, namespace[2:])#strip heading slashes in namespace
            
        finally:  
            if shell is not None:          
                shell.closeClient()
    except JException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, NTCMD_PROTOCOL, Framework)
Ejemplo n.º 30
0
def DiscoveryMain(Framework):
    resultVector = ObjectStateHolderVector()

    try:
        configurationReader = nnmi.ConfigurationReader(Framework)
        configuration = configurationReader.getConfiguration()

        connectionFactory = nnmi.ConnectionFactory(Framework)
        connections = connectionFactory.getConnections()

        if connections:
            if len(connections) > 1:
                logger.debug(
                    "More than one set of credentials found, the first one is used"
                )

            connection = connections[0]

            strategy = nnmi.getDiscoveryStrategy(Framework, configuration)

            strategy.discover(connection)

    except nnmi.IntegrationException, ex:
        msg = str(ex)
        logger.error(msg)
        errormessages.resolveAndReport(msg, nnmi.NNM_PROTOCOL_NAME, Framework)
Ejemplo n.º 31
0
def DiscoveryMain(Framework):       
    protocol = Framework.getDestinationAttribute('Protocol')
    try:
        SnmpTcpDiscoverer(Framework).discover()
    except JavaException, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)
Ejemplo n.º 32
0
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
Ejemplo n.º 33
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    logger.debug('Start nmap_osfingerprint.py')
    ip = Framework.getDestinationAttribute('ip_address')
    timeout = Framework.getParameter('nmap_host_timeout')
    if not str(timeout).isdigit():
        msg = "Timeout parameter value must be a digit"
        logger.debug(msg)
        errormessages.resolveAndReport(msg,
                                       ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME,
                                       Framework)
        return OSHVResult

    timeout = int(timeout) * 1000
    scanKnownPortsOnly = Boolean.parseBoolean(
        Framework.getParameter('scan_known_ports_only'))
    portstoscan = Framework.getParameter('scan_these_ports_only')
    doServiceFingerprints = Boolean.parseBoolean(
        Framework.getParameter('Perform_Port_Fingerprints'))
    createApp = Boolean.parseBoolean(
        Framework.getParameter('Create_Application_CI'))
    discoverOsName = Boolean.parseBoolean(
        Framework.getParameter('discover_os_name'))
    nmapLocation = Framework.getParameter('nmap_location')
    #discover_UDP_Ports	= int(Framework.getParameter('Discover_UDP_Ports'))
    discoverUdpPorts = 0

    agent_root_dir = CollectorsParameters.BASE_PROBE_MGR_DIR
    agent_ext_dir = agent_root_dir + CollectorsParameters.getDiscoveryResourceFolder(
    ) + CollectorsParameters.FILE_SEPARATOR
    tmp_file_name = agent_ext_dir + string.replace(
        ip, '.', '_') + time.strftime("%H%M%S", time.gmtime(
            time.time())) + 'nmap.xml'

    syncNmapPortConfigFile(agent_root_dir)

    logger.debug('temp file for storing nmap results: ', tmp_file_name)
    try:
        client = Framework.createClient(
            ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
        try:
            performNmapDiscover(client, ip, tmp_file_name, timeout,
                                agent_ext_dir, scanKnownPortsOnly, portstoscan,
                                doServiceFingerprints, discoverUdpPorts,
                                nmapLocation)
            if os.path.exists(tmp_file_name):
                logger.debug('start processing the nmap results')
                processNmapResult(tmp_file_name, OSHVResult, discoverOsName,
                                  doServiceFingerprints, createApp, Framework)
            else:
                raise ValueError, 'Error nmap result file is missing: %s' % tmp_file_name
        finally:
            client.close()
            File(tmp_file_name).delete()
    except Exception, e:
        msg = str(e.getMessage())
        logger.debug(msg)
        errormessages.resolveAndReport(msg,
                                       ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME,
                                       Framework)
Ejemplo n.º 34
0
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)
Ejemplo n.º 35
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    WEBSERVER_ID = Framework.getDestinationAttribute('id')
    installPath = Framework.getDestinationAttribute('installPath')
    client = None
    # since install path is the full path name to the process executable image
    # including the image name - separate the executable image name from its
    # directory path.
    # We need here only the path to the directory wehere the process resides
    m = re.search('(.*/)([^/]+)', installPath)
    if (m != None):
        installPath = m.group(1)
    try:
        try:
            client = Framework.createClient()
            rootPath = findRootPath(installPath)
            logger.debug('found rootPath: ', rootPath)
            if rootPath != None:
                discoverITS(client, rootPath, WEBSERVER_ID, OSHVResult)
            else:
                logger.error('Can not find the ITS root path')
        except:
            errorMsg = str(sys.exc_info()[1])
            logger.debugException(errorMsg)
            errormessages.resolveAndReport(errorMsg, 'NTCMD', Framework)
    finally:
        if (client != None):
            try:
                client.close()
            except:
                logger.debug('Failed to execute disconnect NTCMD..')

    return OSHVResult
Ejemplo n.º 36
0
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
Ejemplo n.º 37
0
def DiscoveryMain(Framework):
    properties = Properties()
    vector = ObjectStateHolderVector()
    properties.setProperty('timeoutDiscover',
                           Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover',
                           Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol',
                           Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize',
                           Framework.getParameter('threadPoolSize'))
    ip = Framework.getDestinationAttribute('ip_address')
    domainName = Framework.getDestinationAttribute('domain_name')
    id = Framework.getTriggerCIData('id')
    ports = getUDAAvailablePorts(Framework)

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME,
                                        properties)
        try:
            range_uda_status = {}
            range_result = pingIPsInRange(Framework, client, ip, ports)
            range_uda_status.update(range_result)

            for x in range_uda_status.values():
                logger.debug(x)
                #build the udaStatus
                context = UdaState.Builder(x.ip).computerName(
                    x.computerName
                ).alive(x.alive).portAlive(x.portAlive).isDDMI(
                    x.isDDMI).isNative(x.isNative).isWin(x.isWin).osType(
                        x.osType).agentVersion(
                            str(x.agentVersion) +
                            ('-fips' if x.isFIPSEnabled else '')).UDUniqueId(
                                x.UDUniqueId).build()
                #save
                UdaStatusService.getInstance().saveUdaStatus(context)
                if Framework.getParameter('isCreateUDA') == 'true':
                    if x.UDUniqueId:
                        hostOsh = modeling.createHostOSH(x.ip)
                        hostOsh.setStringAttribute(
                            InventoryUtils.ATTR_UD_UNIQUE_ID, x.UDUniqueId)
                        uda = ObjectStateHolder('uda')
                        uda.setStringAttribute('application_ip', x.ip)
                        uda.setStringAttribute('application_ip_domain',
                                               domainName)
                        uda.setStringAttribute('discovered_product_name',
                                               'uda')
                        uda.setStringAttribute('version', str(x.agentVersion))
                        uda.setContainer(hostOsh)
                        vector.add(hostOsh)
                        vector.add(uda)
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME,
                                       Framework)
    return vector
Ejemplo n.º 38
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover',
                           Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover',
                           Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol',
                           Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize',
                           Framework.getParameter('threadPoolSize'))

    virtualMode = Framework.getParameter(
        'virtualModeDiscover').lower() == "true"
    byRangeFlag = Framework.getParameter("byScopeDiscover").lower() == "true"

    netAddress = Framework.getDestinationAttribute("netAddress")
    netMask = Framework.getDestinationAttribute("netMask")
    probeName = Framework.getDestinationAttribute("probeName")

    ignoreClientType = getGlobalSetting().getPropertyStringValue(
        'pingClientTypeIp', "False").lower() == "false"

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME,
                                        properties)
        try:
            ipRange = getRangeByNetwork(netAddress, netMask)
            if byRangeFlag:
                rangesList = icmp_utils.getProbeRanges([ipRange], probeName,
                                                       Framework)
            else:
                rangesList = [ipRange]
            logger.info('Start working on range: ', len(rangesList))
            totalReportedIps = 0
            for aRange in rangesList:
                totalReportedIps += icmp_utils.pingIPsInRange(
                    Framework,
                    client,
                    aRange,
                    virtualMode,
                    netAddress,
                    netMask,
                    ignoreClientType=ignoreClientType)
                Framework.saveState(aRange.toRangeString())

            logger.debug('Total reported IPs %s ' % totalReportedIps)
            logger.info('Finished working on all ranges..')
            Framework.clearState()
            if not totalReportedIps:
                logger.reportWarning(
                    "No live DataCenter IPs found in probe ranges")
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME,
                                       Framework)
    return ObjectStateHolderVector()
Ejemplo n.º 39
0
def DiscoveryMain(Framework):
    vector = ObjectStateHolderVector()
    serverId = Framework.getDestinationAttribute('id')
    ip_address = Framework.getDestinationAttribute('ip_address')
    client = None
    try:
        client = Framework.createClient()
        builder = TopologyBuilder()
        reporter = Reporter(builder)
        discoverer = Discoverer(client)

        # Discovery DB Server
        sybaseServer = discoverer.discoverSybaseServer(serverId, ip_address, client)
        logger.debug('Found Sybase Server')
        vector.addAll(reporter.reportSybaseServer(sybaseServer))
        _sendVectorImmediately(Framework, vector)
    except:
        errorMsg = str(sys.exc_info()[1])
        logger.debugException(errorMsg)
        errormessages.resolveAndReport(errorMsg, 'SQL', Framework)
    else:

        # Discovery Databases
        try:
            databases = discoverer.discoverDatabases()
            logger.debug('Found %s Databases' % len(databases))
            vector.addAll(reporter.reportDatabases(sybaseServer, *databases))
            _sendVectorImmediately(Framework, vector)
        except:
            logger.debug('Failed to discover Databases')
        else:

            # Discovery DB Devices
            databaseByName = {}
            for database in databases:
                databaseByName[database.getName()] = database
            try:
                devices = discoverer.discoverDevices(databaseByName)
                logger.debug('Found %s DB Devices' % len(devices))
                vector.addAll(reporter.reportDevices(sybaseServer, databaseByName, *devices))
                _sendVectorImmediately(Framework, vector)
            except:
                logger.debug('Failed to discover DB Devices')

            # Discovery DB Users
            try:
                logins = discoverer.discoverLogins()
                logger.debug('Found %s DB Users' % len(logins))
                vector.addAll(reporter.reportLogins(sybaseServer, *logins))
                _sendVectorImmediately(Framework, vector)
            except:
                logger.debug('Failed to discover DB Users')

    if client != None:
        client.close()

    Framework.sendObjects(vector)
    Framework.flushObjects()
    return vector
Ejemplo n.º 40
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    client = None
    layer2_connections_cdp = None
    layer2_connections_lldp = None
    try:
        try:
            client = Framework.createClient()
        except:
            errMsg = 'Exception while creating %s client: %s' % (
                ClientsConsts.SNMP_PROTOCOL_NAME, sys.exc_info()[1])
            errormessages.resolveAndReport(str(sys.exc_info()[1]),
                                           ClientsConsts.SNMP_PROTOCOL_NAME,
                                           Framework)
            logger.debugException(errMsg)
        else:
            host_id = Framework.getDestinationAttribute('hostId')
            discover_cdp_mib = Boolean.parseBoolean(
                Framework.getParameter('discoverCdpMib'))
            discover_lldp_mib = Boolean.parseBoolean(
                Framework.getParameter('discoverLldpMib'))
            local_device_discoverer = LocalDeviceDiscoverer(client, host_id)
            local_devices = local_device_discoverer.get_local_devices()
            if not local_devices or len(local_devices) == 0:
                logger.reportError('Failed to get local device info')

            if discover_cdp_mib:
                cdp_discoverer = CdpDiscoverer(client)
                remote_devices_cdp = cdp_discoverer.get_remote_devices()
                if remote_devices_cdp:
                    layer2_connections_cdp = get_layer2_connections(
                        local_devices, remote_devices_cdp)
                    for layer2_connection in layer2_connections_cdp:
                        OSHVResult.addAll(
                            build_layer2_connection(layer2_connection))

            if discover_lldp_mib:
                lldp_discoverer = LldpDiscoverer(client)
                remote_devices_lldp = lldp_discoverer.get_remote_devices()
                if remote_devices_lldp:
                    layer2_connections_lldp = get_layer2_connections(
                        local_devices, remote_devices_lldp)
                    for layer2_connection in layer2_connections_lldp:
                        OSHVResult.addAll(
                            build_layer2_connection(layer2_connection))

            if (not layer2_connections_cdp or len(layer2_connections_cdp)
                    == 0) and (not layer2_connections_lldp
                               or len(layer2_connections_lldp) == 0):
                logger.reportError('No data collected')

    finally:
        if client != None:
            client.close()
    return OSHVResult
Ejemplo n.º 41
0
def mainFunctionWithWbem(Framework, wmiClient, OSHVResult,
                         softNameToInstSoftOSH=None):
    '''
    Discovers installed software and, for Windows 2008, hotfixes

    This function uses Win32_Product class
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394378(v=vs.85).aspx
    It's available since Windows 2000

    In Windows 2003 Server,
    Win32_Product is not enabled by default, and must be enabled as follows:

    1.In Add or Remove Programs, click Add/Remove Windows Components.
    2. In the Windows Components Wizard, select Management and Monitoring Tools and then click Details.
    3. In the Management and Monitoring Tools dialog box, select WMI Windows Installer Provider and then click OK.
    4. Click Next.

    Cons:
    It is terribly slow (querying might take up to 10 seconds)
    It represents information only about software installed using MSI (Microsoft Installer)
    '''
    try:
        hostOSH = createHostOSH(Framework, wmiClient)
        OSHVResult.add(hostOSH)
        wmiProvider = WmiAgentProvider(wmiClient)
        softwareDiscoverer = SoftwareDiscoverer(wmiProvider)
        softwareItems = softwareDiscoverer.getInstalledSoftware()

        for software in softwareItems:
            softwareOSH = hostresource.createSoftwareOSH(
                    hostOSH, software.name, path=software.path,
                    displayVersion=software.version,
                    publisher=software.vendor,
                    productId=software.productId,
                    installDate=software.installDate)
            OSHVResult.add(softwareOSH)
            if softNameToInstSoftOSH != None:
                softNameToInstSoftOSH[software.name.strip()] = softwareOSH
        hostDiscoverer = WmiHostDiscoverer(wmiProvider)
        if hostDiscoverer.isWin2008():
            discoverWin2008HotFixes(wmiProvider, hostOSH, OSHVResult)
        if hostDiscoverer.isWindows8_2012():
            discoverWin8_2012HotFixes(wmiProvider, hostOSH, OSHVResult)

    except JavaException, ex:
        exInfo = ex.getMessage()
        pattern = "(Invalid class.?)|(Could not connect to WMI.?)"
        if (re.match(pattern, exInfo) is not None):
            logger.debug("Cannot perform regular software discovery (seems that remote 2003 Win server doesn't have appropriate WMI object installed).")
            logger.debug("Trying to discover installed software from Windows registry")
            # try to retrieve information by using old (not efficient) method using remote registry
            wmiClient.close()
            mainFunction(Framework, OSHVResult, softNameToInstSoftOSH)
            wmiClient = Framework.createClient()
        else:
            errormessages.resolveAndReport(exInfo, 'WMI', Framework)
Ejemplo n.º 42
0
def mainFunction(Framework, OSHVResult, softNameToInstSoftOSH=None):
    '''
    This function uses registry to provide information
    about installed software.

    '''

    props = Properties()
    props.setProperty(AgentConstants.PROP_WMI_NAMESPACE, 'root\\DEFAULT')
    wmiClient = None
    try:
        try:
            wmiClient = Framework.createClient(props)
            hostOSH = createHostOSH(Framework, wmiClient)
            OSHVResult.add(hostOSH)

            registryColumns = {'DisplayName': {}, 'InstallLocation': {},
                       'DisplayVersion': {}, 'Publisher': {}, 'ProductID': {},
                       'InstallDate': {}}
            keyNames = registryColumns.keys()
            # These are the Registry sections, where the Software Uninstall information is stored
            keyPaths = ['SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
                        'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall']
            for keyPath in keyPaths:
                try:
                    result = getRegistrySubkeys(wmiClient, keyPath, keyNames)
                    _mergeDictionaries(registryColumns, result)
                except JavaException, e:
                    logger.info('Not a 64bit OS: ' + str(e))

            # do the work
            _createSoftware(registryColumns['DisplayName'], registryColumns['InstallLocation'],
                           registryColumns['DisplayVersion'], registryColumns['Publisher'],
                           registryColumns['ProductID'], registryColumns['InstallDate'],
                           hostOSH, OSHVResult,
                           softNameToInstSoftOSH)

            try:
                props = Properties()
                props.setProperty(AgentConstants.PROP_WMI_NAMESPACE, 'root\\cimv2')
                client = Framework.createClient(props)
                wmiProvider = WmiAgentProvider(client)
                hostDiscoverer = WmiHostDiscoverer(wmiProvider)
                if hostDiscoverer.isWin2008():
                    logger.debug('win2008 detected')
                    discoverWin2008HotFixes(wmiProvider, hostOSH, OSHVResult)
                elif hostDiscoverer.isWindows8_2012():
                    logger.debug('win 8 or win 2012 detected')
                    discoverWin8_2012HotFixes(wmiProvider, hostOSH, OSHVResult)
                else:
                    logger.debug('Non-win2008/8/2012 detected')
            finally:
                client.close()
        except JavaException, ex:
            exInfo = ex.getMessage()
            errormessages.resolveAndReport(exInfo, 'WMI', Framework)
Ejemplo n.º 43
0
def DiscoveryMain(Framework):
    # General variables
    OSHVResult = ObjectStateHolderVector()
    properties = Properties()
    protocol = Framework.getDestinationAttribute('Protocol')
    processToPortDict = {} ## {PID:[processName, listeningPort, ipAddress, path, version, status, processCommandline]}
    databaseDict = {} ## {instanceName/SID:[dbType, listeningPort, ipAddress, installPath, version, status]}
    database_ip_service_endpoints ={}  ## {instanceName:[ip_address:port]}
    client = None
    secondClient = None
    isWindows = 'true'

    # Attempt to create a client
    try:
        client = Framework.createClient()

        ## We have a client
        ## Get processes running on the box
        if(client):
            dbconnect_utils.debugPrint(3, '[' + SCRIPT_NAME + ':DiscoveryMain] Got client <%s>' % client.getClientType())
            if client.getClientType() == 'wmi':
                ## Open a second client connection to the DEFAULT namespace for registry access
                props = Properties()
                props.setProperty(AgentConstants.PROP_WMI_NAMESPACE, 'root\\DEFAULT')
                secondClient = Framework.createClient(props)
                processToPortDict = dbconnect_agentutils.getProcListByWMI(client, secondClient)
#            elif client.getClientType() == 'snmp':
#                processToPortDict = dbconnect_agentutils.getProcListBySNMP(client)
            else:
                Framework.reportWarning('Unable to connect using WMI')

            ## We have process and port infromation
            ## Find databases, if any
            if processToPortDict != None and len(processToPortDict) > 0:
                for pid in processToPortDict.keys():
                    logger.debug('dddd: ', '[' + SCRIPT_NAME + ':DiscoveryMain] Got process/service/software <%s> listening on port <%s:%s>' % ((processToPortDict[pid])[dbconnect_utils.PROCESSNAME_INDEX], (processToPortDict[pid])[dbconnect_utils.IP_INDEX], (processToPortDict[pid])[dbconnect_utils.PORT_INDEX]))
                if Framework.getParameter('discover_oracle').strip().lower() == 'true':
                    dbconnect_oracle.findDatabases(client, processToPortDict, databaseDict, isWindows, secondClient)
                if Framework.getParameter('discover_mssql').strip().lower() == 'true':
                    dbconnect_mssql.findDatabases(client, processToPortDict, databaseDict, database_ip_service_endpoints, isWindows, secondClient)

                if databaseDict != None and len(databaseDict) > 0:
                    for dbName in databaseDict.keys():
                        dbconnect_utils.debugPrint('Found <%s> instance <%s> (%s) with listener port <%s:%s> and installed in <%s>' % ((databaseDict[dbName])[dbconnect_utils.DBTYPE_INDEX], dbName, (databaseDict[dbName])[dbconnect_utils.STATUS_INDEX], (databaseDict[dbName])[dbconnect_utils.IP_INDEX], (databaseDict[dbName])[dbconnect_utils.PORT_INDEX], (databaseDict[dbName])[dbconnect_utils.PATH_INDEX]))
                    OSHVResult.addAll(dbconnect_utils.makeDbOSHs(databaseDict))
                else:
                    Framework.reportWarning('No databases found')
            else:
                ## If we're here, we couldn't find any processes, service, or software
                ## and we have no data to search for databases
                Framework.reportWarning('Unable to get a list or processes, services, or installed software')
        else:
            dbconnect_utils.debugPrint('Unable to connect using WMI')
    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)
Ejemplo n.º 44
0
def workOnIP(Framework, ip, ports):
    OPTION_UD_UNIQUE_ID = "UD_UNIQUE_ID"
    us = UDAStatus(ip)
    us.alive = True
    alivePort = None
    logger.debug("IP %s alive:%s" % (ip, us.alive))
    if us.alive:
        for port in ports:
            us.portAlive = detectPortAvailable(ip, port)
            if us.portAlive:
                alivePort = port
                break

        logger.debug("Port alive %s on IP:Port %s:%s" %
                     (us.portAlive, us.ip, str(alivePort)))
        #set computerName by ping -a
        us.computerName = detectHostnameWithPing(ip)
        if us.portAlive:
            client = detectUDAAvailable(Framework, ip)
            if client:
                us.udaAlive = True
                logger.debug("UDA alive %s on IP %s" % (us.udaAlive, us.ip))
                try:
                    us.isDDMI = detectDDMIAgent(Framework, client, us)
                    logger.debug("UDA is DDMI %s on IP %s" %
                                 (us.isDDMI, us.ip))
                    if not us.isDDMI:
                        us.isNative = True  #detectUDANative(Framework, client, us)
                        logger.debug("UDA is native %s on IP %s" %
                                     (us.isNative, us.ip))
                        us.isFIPSEnabled = detectFIPSMode(client)

                        if isDupUDUniqueId(us.UDUniqueId):
                            logger.debug("old uuid ", us.UDUniqueId)
                            uduid = UUID.randomUUID()
                            logger.debug("generate new uuid ", uduid)
                            options = HashMap()
                            options.put(OPTION_UD_UNIQUE_ID, str(uduid))
                            client.setOptionsMap(options)
                            clientOptions = client.getOptionsMap()
                            uduid = clientOptions.get(OPTION_UD_UNIQUE_ID)
                            logger.debug("get new uuid ", uduid)
                            us.UDUniqueId = uduid

                except:
                    msg = logger.prepareJythonStackTrace('')
                    errormessages.resolveAndReport(
                        msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)
                    pass
                finally:
                    try:
                        client.close()
                    except:
                        pass
    return us
Ejemplo n.º 45
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    businessElementId = Framework.getDestinationAttribute('id')
    urlString = Framework.getDestinationAttribute('url')
    jobId = Framework.getDiscoveryJobId()
    dnsServers = Framework.getParameter('dnsServers') or None
    shell = None

    if dnsServers:
        dnsServers = [
            dnsServer for dnsServer in dnsServers.split(',')
            if dnsServer and dnsServer.strip()
        ] or None
    if dnsServers:
        logger.debug('Using dns servers: ', dnsServers)

    if not urlString:
        msg = "There is no specified URL in the input BusinessElement CI"
        errormessages.resolveAndReport(msg, jobId, Framework)
        return OSHVResult

    try:
        bizOSH = modeling.createOshByCmdbIdString('business_element',
                                                  businessElementId)
        OSHVResult.add(bizOSH)
        urlString = urlString[1:len(urlString) - 1]

        if netutils.isValidIp(urlString):
            productName = Framework.getDestinationAttribute('product')
            OSHVResult.add(
                scp.createScpOsh(bizOSH, 'tcp', urlString, 0, productName))
        else:
            protocol, hostname, port, context = parseUrl(urlString)
            if not hostname:
                raise ValueError("Hostname is not defined in URL '%s'" %
                                 urlString)

            if not protocol:
                raise ValueError(
                    "Failed to resolve the protocol from specified URL")

            shell = shellutils.ShellUtils(
                Framework.createClient(
                    ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME))
            OSHVResult.addAll(
                scp.createScpOSHV(bizOSH,
                                  protocol,
                                  hostname,
                                  port,
                                  context,
                                  shell,
                                  dnsServers=dnsServers))

    except ValueError, e:
        errormessages.resolveAndReport(e.message, jobId, Framework)
Ejemplo n.º 46
0
def DiscoveryMain(Framework):
    properties = Properties()

    SITE_ID = Framework.getDestinationAttribute('SITE_ID')
    instance_number = Framework.getDestinationAttribute('instance_number')
    connection_client = Framework.getDestinationAttribute('connection_client')
    logger.debug('Connecting to a SAP instance number:', str(instance_number))
    properties.setProperty(Protocol.SAP_PROTOCOL_ATTRIBUTE_SYSNUMBER, instance_number)

    if (connection_client is not None) and (connection_client != 'NA'):
        logger.debug('Connecting to a SAP system with client:', str(connection_client))
        properties.setProperty(Protocol.SAP_PROTOCOL_ATTRIBUTE_CLIENT, connection_client)
    discoverScenarioProcesses = Boolean.parseBoolean(Framework.getParameter('discoverScenarioProcesses'))
    GET_PROCESS_STEPS = Boolean.parseBoolean(Framework.getParameter('getProcessSteps'))
    reportCIsInChunks = Boolean.parseBoolean(Framework.getParameter('reportCIsInChunks'))

    errormsg = ''
    client = None
    try:
        try:
            client = Framework.createClient(properties)
            solman = saputils.SapSolman(client)
        except (NoClassDefFoundError, MissingJarsException, ExceptionInInitializerError):
            errormsg = 'SAP drivers are missing'
            logger.debugException(errormsg)
        except:
            errormsg = 'Connection failed'
            logger.debugException(errormsg)
        else:
            try:
                sVector, sysToOshPairs = discoverSystems(solman)
                Framework.sendObjects(sVector)
                sVector.clear()
                sysNames = [system.getName() for system, _ in sysToOshPairs]
                sys_name_to_system = {}
                for system, _ in sysToOshPairs:
                    sys_name_to_system[system.getName()] = system

                component2system = logicalComponents(sysNames, solman)
                businessProcesses(Framework, solman, component2system,
                                  sys_name_to_system, SITE_ID, GET_PROCESS_STEPS, reportCIsInChunks,
                                  discoverScenarioProcesses)
            except:
                strmsg = str(sys.exc_info()[1])
                if (strmsg.upper().find('TABLE_NOT_AVAILABLE') > -1):
                    errmsg = 'No solution manager found'
                    logger.debugException(errmsg)
                    Framework.reportError(errmsg)
                else:
                    # unknown exception caught
                    raise
    except JException, ex:
        ex_info = ex.getMessage()
        errormessages.resolveAndReport(ex_info, 'SAP JCO', Framework)
def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()	
	exchangeServerId = Framework.getDestinationAttribute('id')
	exchangeServerOsh = ms_exchange_utils.restoreExchangeServerOSH(exchangeServerId)
	
	try:
		shellClient = Framework.createClient()
		client = PowerShellClient(shellClient, Framework)
		try:
			ExchangeServer = client.executeScenario("Exchange_Server_2007_Discovery.ps1")
			
			exchangeSystemName = extractOrganizationNameFromDn(ExchangeServer.ExchangeLegacyDN)
			exchangeSystemOsh = ObjectStateHolder('exchangesystem')
			exchangeSystemOsh.setAttribute('data_name', exchangeSystemName)
			modeling.setAppSystemVendor(exchangeSystemOsh)
			OSHVResult.add(exchangeSystemOsh)
			OSHVResult.add(modeling.createLinkOSH('member', exchangeSystemOsh, exchangeServerOsh))
			adminGroupName = extractAdminGrouptFromDn(ExchangeServer.ExchangeLegacyDN)
			if adminGroupName and exchangeSystemOsh:
				adminGroupOsh = ObjectStateHolder('exchange_administrative_group')
				adminGroupOsh.setAttribute('data_name' , adminGroupName)
				adminGroupOsh.setContainer(exchangeSystemOsh)
				OSHVResult.add(adminGroupOsh)
				OSHVResult.add(modeling.createLinkOSH('member', adminGroupOsh, exchangeServerOsh))

			createServerRoles(exchangeServerOsh, ExchangeServer.ServerRole, OSHVResult)
			dagList = []
			clusteredMailBox = None
			try:
				dagList = ExchangeServer.dagList
				if not dagList:
					raise ValueError('Failed getting DAG information')
			except:
				logger.debugException('')
			else:
				OSHVResult.addAll(TopologyBuilder(None, None, None, None).buildDagRelatedTopology(exchangeServerOsh, dagList))
				
			try:
				clusteredMailBox = ExchangeServer.clusteredMailBox
				if not clusteredMailBox:
					raise ValueError('Failed getting Clustered Mailbox')
			except:
				logger.debugException('')
			else:
				setattr(clusteredMailBox, "exchOrgName", exchangeSystemName)
				OSHVResult.addAll(TopologyBuilder(None, None, None, None).buildClusteredMailBoxRelatedTopology(exchangeServerOsh, clusteredMailBox))
			OSHVResult.add(exchangeServerOsh)
		finally:
			client.close()
	except Exception, ex:
		logger.debugException('')
		strException = str(ex.getMessage())
		errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
Ejemplo n.º 48
0
def workOnIP(Framework, ip, ports):
    OPTION_UD_UNIQUE_ID = "UD_UNIQUE_ID"
    us = UDAStatus(ip)
    us.alive = True
    alivePort = None
    logger.debug("IP %s alive:%s" % (ip, us.alive))
    if us.alive:
        for port in ports:
            us.portAlive = detectPortAvailable(ip, port)
            if us.portAlive:
                alivePort = port
                break

        logger.debug("Port alive %s on IP:Port %s:%s" % (us.portAlive, us.ip, str(alivePort) ))
        #set computerName by ping -a
        us.computerName = detectHostnameWithPing(ip)
        if us.portAlive:
            client = detectUDAAvailable(Framework, ip)
            if client:
                us.udaAlive = True
                logger.debug("UDA alive %s on IP %s" % (us.udaAlive, us.ip))
                try:
                    us.isDDMI = detectDDMIAgent(Framework, client, us)
                    logger.debug("UDA is DDMI %s on IP %s" % (us.isDDMI, us.ip))
                    if not us.isDDMI:
                        us.isNative = True #detectUDANative(Framework, client, us)
                        logger.debug("UDA is native %s on IP %s" % (us.isNative, us.ip))
                        us.isFIPSEnabled = detectFIPSMode(client)

                        if isDupUDUniqueId(us.UDUniqueId):
                            logger.debug("old uuid ", us.UDUniqueId)
                            uduid = UUID.randomUUID()
                            logger.debug("generate new uuid ", uduid)
                            options = HashMap()
                            options.put(OPTION_UD_UNIQUE_ID, str(uduid))
                            client.setOptionsMap(options)
                            clientOptions = client.getOptionsMap()
                            uduid = clientOptions.get(OPTION_UD_UNIQUE_ID)
                            logger.debug("get new uuid ", uduid)
                            us.UDUniqueId = uduid


                except:
                    msg = logger.prepareJythonStackTrace('')
                    errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)
                    pass
                finally:
                    try:
                        client.close()
                    except:
                        pass
    return us
Ejemplo n.º 49
0
def DiscoveryMain(Framework):
    properties = Properties()

    properties.setProperty('timeoutDiscover', Framework.getParameter('timeoutDiscover'))
    properties.setProperty('retryDiscover', Framework.getParameter('retryDiscover'))
    properties.setProperty('pingProtocol', Framework.getParameter('pingProtocol'))
    properties.setProperty('threadPoolSize', Framework.getParameter('threadPoolSize'))

    excludePatterns = icmp_utils.preparePatterns(Framework.getParameter('excludePatternsList'))
    
    virtualMode = Framework.getParameter('virtualModeDiscover').lower() == "true"
    rangeString = Framework.getParameter('range') or 'NA'
    probeName = Framework.getDestinationAttribute('probeName')
    ignoreClientType = getGlobalSetting().getPropertyStringValue('pingClientTypeIp', "False").lower() == "false"
    maxAllowedIPv6CountPerRange = long(getGlobalSetting().getPropertyStringValue('maxPingIPv6CountPerRange', str(DEFAULT_MAX_PING_IPV6_COUNT_PER_RANGE)))

    logger.debug("Max allowed IPv6 range size:", maxAllowedIPv6CountPerRange)
    isPingIPv4, isPingIPv6 = getIPSupport(Framework)

    try:
        client = Framework.createClient(ClientsConsts.ICMP_PROTOCOL_NAME, properties)
        try:
            totalReportedIps = 0
            selectedRangeList = _convertToRanges(rangeString)
            probeRanges = icmp_utils.getProbeRanges(selectedRangeList, probeName, Framework, isPingIPv4, isPingIPv6)

            logger.info('Start working on total probe ranges: ', len(probeRanges))
            logger.info('ignoreClientType = ', ignoreClientType)
            #probeRanges = getDataCenterIPRanges(probeRanges)
            for probeRange in probeRanges:
                rangeSize = long(probeRange.getRangeSize())
                if rangeSize > maxAllowedIPv6CountPerRange:
                    logger.reportWarning(
                        "The size of IPv6 range (%s) is %d, exceeds the max range size %d, will skip it." % (
                            probeRange.toRangeString(), rangeSize, maxAllowedIPv6CountPerRange))
                    continue
                totalReportedIps += icmp_utils.pingIPsInRange(Framework, client, probeRange, virtualMode,
                                                              excludePatterns=excludePatterns,ignoreClientType=ignoreClientType)
                Framework.saveState(probeRange.toRangeString())
            logger.debug('Total reported IPs %s ' % totalReportedIps)
            logger.info('Finished working on all Probes Ranges..')

            Framework.clearState()
            if not totalReportedIps:
                logger.reportWarning("No live IPs found in probe ranges")
        finally:
            client.close()
    except:
        msg = logger.prepareJythonStackTrace('')
        errormessages.resolveAndReport(msg, ClientsConsts.ICMP_PROTOCOL_NAME, Framework)
    return ObjectStateHolderVector()
Ejemplo n.º 50
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    logger.debug(" ###### Connecting to EView 400 client")
    codePage = Framework.getCodePage()
    properties = Properties()
    properties.put(BaseAgent.ENCODING, codePage)

    localshell = None
    try:
        client = Framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
        localshell = shellutils.ShellUtils(client, properties, ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME, Framework)
        logger.error(exInfo)
Ejemplo n.º 51
0
def start_srvrmgr_discovery(client, ip, port, credentialsId, Framework, OSHVResult):
	try:
		logger.debug('connected to gateway')
		username = client.getUserName()
		enterprise = client.getEnterprise()
		srvrmgrPath = client.getServerManagerPath()
		siebelGatewayOSH = makeSiebelgatewayOSH(client, username, enterprise, srvrmgrPath, credentialsId, ip, port, Framework)
		siebelsiteOSH = makesiebelsiteOSH(enterprise, credentialsId, ip)
		enterpriseLink = modeling.createLinkOSH('member', siebelsiteOSH, siebelGatewayOSH)
		OSHVResult.add(siebelGatewayOSH)
		OSHVResult.add(siebelsiteOSH)
		OSHVResult.add(enterpriseLink)
	except Exception, ex:
		strException = str(ex.getMessage())
		errormessages.resolveAndReport(strException, PROTOCOL_NAME, Framework)
		logger.debugException('')
Ejemplo n.º 52
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    protocol = Framework.getDestinationAttribute("Protocol")
    try:
        propertyFileName = Framework.getRequiredParameterValue(PARAM_PROPERTY_FILE)
        dataSource = PropertyFileDataSource(propertyFileName, Framework)
        bulkSize = Framework.getParameter(import_utils.PARAM_BULK_SIZE)
        flushObjects = Framework.getParameter(import_utils.PARAM_FLUSH_OBJECTS)

        if flushObjects and (flushObjects.lower() == "true"):
            import_utils.importFlushingCis(dataSource, OSHVResult, Framework, bulkSize)
        else:
            import_utils.importCis(dataSource, OSHVResult, Framework)
    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)
Ejemplo n.º 53
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    # which is needed when running a remote command involving special characters
    properties = Properties()

    codePage = Framework.getDestinationAttribute("codepage")
    if (codePage != None) and (codePage != "NA"):
        properties.setProperty(BaseAgent.ENCODING, codePage)

    properties.setProperty("QUOTE_CMD", "true")
    shellUtils = None
    try:
        shellUtils = shellutils.ShellUtils(Framework, properties)
    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, resolveProtocol(shellUtils, Framework), Framework)
Ejemplo n.º 54
0
def DiscoveryMain(Framework):
    """
    @type Framework: com.hp.ucmdb.discovery.probe.services.dynamic.core.DynamicServiceFrameworkImpl
    """
    OSHVResult = ObjectStateHolderVector()

    protocol = Framework.getDestinationAttribute('Protocol')
    hostId = Framework.getDestinationAttribute('hostId')
    shell = None

    try:
        client = Framework.createClient()
        shell = shellutils.ShellUtils(client)

    except Exception, ex:
        exInfo = ex.getMessage()
        errormessages.resolveAndReport(exInfo, protocol, Framework)