Esempio n. 1
0
def _getSupportedShellProtocols(Framework):
    '''Returns names of protocols that will be used in the connection flow
    depending on the order in the list
    @types: Framework -> list[str]
    '''
    # ORDER IS IMPORTANT

    protocolOrder = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('protocolConnectionOrder', "")
    if protocolOrder:
        supportedProtocols = []
        for protocol in protocolOrder.split(','):
            if protocol.strip().lower() == ClientsConsts.SSH_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.SSH_PROTOCOL_NAME)
            elif protocol.strip().lower() == ClientsConsts.TELNET_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.TELNET_PROTOCOL_NAME)
            elif protocol.strip().lower() == ClientsConsts.NTCMD_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.NTCMD_PROTOCOL_NAME)
            else:
                logger.debug("Unknown protocol name in globalSetting:", protocol)
    else:
        supportedProtocols = [ClientsConsts.SSH_PROTOCOL_NAME,
                              ClientsConsts.TELNET_PROTOCOL_NAME,
                              ClientsConsts.NTCMD_PROTOCOL_NAME]

    # empty means last (other possible values - first, last, none)
    udaConnectionOrder = (Framework.getParameter('udaConnectionOrder') or 'last')
    if udaConnectionOrder.lower() == 'last':
        supportedProtocols.append(ClientsConsts.DDM_AGENT_PROTOCOL_NAME)
    elif udaConnectionOrder.lower() == 'first':
        supportedProtocols.insert(0, ClientsConsts.DDM_AGENT_PROTOCOL_NAME)
    else:
        logger.warn("Specified invalid parameter for the UDA connection order")
    return supportedProtocols
def get_local_databases(executor,
                        shell_interpreter,
                        instance_name,
                        db2_home_path=None):
    multiple_db2_instances = GeneralSettingsConfigFile.getInstance(
    ).getPropertyBooleanValue('multipleDB2Instances', 0)
    if multiple_db2_instances:
        file_name = '/tmp/ucmdb-temp-shell-' + str(int(
            time.time() * 1000)) + '.sh'
        db2cmdline = base_shell_discoverer.Db2.BIN_NAME
        if db2_home_path:
            db2path = base_shell_discoverer.compose_db2_bin_path(
                db2_home_path) + db2cmdline
            db2cmdline = shell_interpreter.getEnvironment().normalizePath(
                db2path)
        db2cmdline = '\'%s list db directory\'' % db2cmdline
        sh_db2cmdline = 'sh ' + file_name
        try:
            save_cmd_to_file(db2cmdline, file_name, executor)
            return base_shell_discoverer.get_local_databases(
                executor, shell_interpreter, instance_name, db2_home_path,
                sh_db2cmdline)
        except:
            return base_shell_discoverer.get_local_databases(
                executor, shell_interpreter, instance_name, db2_home_path)
        finally:
            try:
                remove_file(file_name, executor)
            except:
                logger.debug("Failed to remove temp file %s" % file_name)
    else:
        return base_shell_discoverer.get_local_databases(
            executor, shell_interpreter, instance_name, db2_home_path)
Esempio n. 3
0
def getBIOSUUID(client):
    try:
        convertToMicrosoftStandart = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('setBiosUuidToMicrosoftStandart', 'false')
        query = 'SELECT UUID from Win32_ComputerSystemProduct'
        resultSet = client.executeQuery(query)
        while resultSet.next():
            uuidValue = resultSet.getString(1)
            if (re.match(r"(0{8}-0{4}-0{4}-0{4}-0{12})", uuidValue)
                or re.match(r"([fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})", uuidValue)):
                logger.debug('Invalid UUID was received. Skipping.')
                return None
            if convertToMicrosoftStandart.lower() == 'true':
                logger.warn('BIOS UUID is reported according to Microsoft definitions since parameter setBiosUuidToMicrosoftStandart is set to True.')
                return uuidValue
            byteStyle = re.match(r"(\w{2})(\w{2})(\w{2})(\w{2})\-(\w{2})(\w{2})-(\w{2})(\w{2})(.*)", uuidValue)
#returned 00010203-0405-0607-0809-0a0b0c0d0e0f
#should be 03020100-0504-0706-0809-0a0b0c0d0e0f
            if byteStyle:
                group1 = byteStyle.group(4) + byteStyle.group(3) + byteStyle.group(2) + byteStyle.group(1)
                group2 = byteStyle.group(6) + byteStyle.group(5)
                group3 = byteStyle.group(8) + byteStyle.group(7)
                uuid = group1 + '-' + group2 + '-' + group3 + byteStyle.group(9)
                return uuid
    except:
        logger.warn('Couldn\'t retrieve Bios UUID')
Esempio n. 4
0
    def getModelAndBiosUuid(self):
        '''@types: -> HostDo
        @raise Exception: WMI query failed
        '''
        convertToMicrosoftStandart = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('setBiosUuidToMicrosoftStandart', 'false')

        hostDo = HostDo()
        queryBuilder = self._wmiProvider.getBuilder('win32_ComputerSystemProduct')
        queryBuilder.addWmiObjectProperties('uuid', 'name')
        computerProductList = self._wmiProvider.getAgent().getWmiData(queryBuilder)
        for computerProduct in computerProductList:
            if computerProduct.uuid:
                if (re.match(r"(0{8}-0{4}-0{4}-0{4}-0{12})", computerProduct.uuid) or
                     re.match(r"([fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})", computerProduct.uuid)):
                    logger.debug('Invalid UUID was received. Skipping.')
                    continue
                if convertToMicrosoftStandart.lower() == 'false':
                    #returned 00010203-0405-0607-0809-0a0b0c0d0e0f
                    #should be 03020100-0504-0706-0809-0a0b0c0d0e0f
                    byteStyle = re.match(r"(\w{2})(\w{2})(\w{2})(\w{2})\-(\w{2})(\w{2})-(\w{2})(\w{2})(.*)", computerProduct.uuid)
                    if byteStyle:
                        group1 = byteStyle.group(4) + byteStyle.group(3) + byteStyle.group(2) + byteStyle.group(1)
                        group2 = byteStyle.group(6) + byteStyle.group(5)
                        group3 = byteStyle.group(8) + byteStyle.group(7)
                        uuidFormated = group1 + '-' + group2 + '-' + group3 + byteStyle.group(9)
                        hostDo.biosUUID = uuidFormated
                    else:
                        logger.warn('UUID is not in proper format.')
                else:
                    hostDo.biosUUID = computerProduct.uuid
                    logger.warn('BIOS UUID is reported according to Microsoft definitions since parameter setBiosUuidToMicrosoftStandart is set to True.')

            hostDo.hostModel = computerProduct.name

        return hostDo
Esempio n. 5
0
    def __init__(self, Framework):
        discoverydbutils.DiscoveryDbUtils.__init__(self, Framework, ProcessDbUtils.CONTEXT)
        self.knownPortsConfigFile = Framework.getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME)
        self.applicSignConfigFile = Framework.getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_APPLICATIONSIGNATURE)
        self.pid2Process = HashMap()

        globalSettings = GeneralSettingsConfigFile.getInstance()
        self.PROCESS_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue('processExpirationTime', 60) * 1000L
def processGlassfish(context, processName):
    glassfishOsh = context.application.getOsh()

    logger.debug('Started processing')
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        serverName = None
        serverRuntime = None
        if processOriginCmd.find(
                'com.sun.enterprise.glassfish.bootstrap.ASMain') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV3(
                processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV3
        elif processOriginCmd.find('com.sun.enterprise.server.PELaunch') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV2(
                processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV2

        if serverRuntime:
            serverName = serverRuntime.findServerName()
            globalSettings = GeneralSettingsConfigFile.getInstance()
            loadExternalDTD = globalSettings.getPropertyBooleanValue(
                'loadExternalDTD', 0)

            fs = file_system.createFileSystem(context.client)
            layout = glassfish_discoverer.createServerLayout(serverRuntime, fs)
            domainXmlFile = layout.getFile(layout.getDomainXmlPath())

            xPathParser = glassfish_discoverer.XpathParser(loadExternalDTD)
            descriptor = DescriptorClass(xPathParser, domainXmlFile.content)
            domainName = descriptor.findDomainName()

            nodeName = descriptor.findNodeNameByServerName(serverName)

            if serverName and domainName:
                logger.debug('Reporting serverName %s, domainName %s' %
                             (serverName, domainName))
                glassfishOsh.setStringAttribute('j2eeserver_servername',
                                                serverName)
                modeling.setJ2eeServerAdminDomain(glassfishOsh, domainName)
                modeling.setAppServerType(glassfishOsh)
                # server full name
                nodeNamePart = nodeName and '%s_' % nodeName or ''
                fullName = '%s%s' % (nodeNamePart, serverName)
                glassfishOsh.setAttribute('j2eeserver_fullname', fullName)
            else:
                logger.debug(
                    'Glassfish details cannot be acquired, ignoring the application %s, %s'
                    % (serverName, domainName))
        else:
            logger.debug('Server runtime is not created')
    else:
        logger.debug('No process comman line found for pid: %s' %
                     process.getPid())
Esempio n. 7
0
	def __init__(self, Framework):
		discoverydbutils.DiscoveryDbUtils.__init__(self, Framework, TcpDbUtils.CONTEXT)
		self.knownPortsConfigFile = Framework.getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME)
		self.applicSignConfigFile = Framework.getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_APPLICATIONSIGNATURE)
		self.hostID = Framework.getDestinationAttribute('hostId')

		globalSettings = GeneralSettingsConfigFile.getInstance()
		#hours
		self.TCP_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue('tcpExpirationTime', 24)
		#milliseconds
		self.PORT_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue('portExpirationTime', 60) * 1000L
def isIPv6Overflow(probeRangesForIPv6):
    from com.hp.ucmdb.discovery.library.communication.downloader.cfgfiles import GeneralSettingsConfigFile
    maxAllowedIPv6Count = GeneralSettingsConfigFile.getInstance().getPropertyIntegerValue('maxPingIPv6Count', DEFAULT_MAX_PING_IPV6_COUNT)

    #only get client ip
    probeRangesForIPv6 = [x for x in probeRangesForIPv6 if x and (x.getType().equals(RangeType.CLIENT) or x.getType().equals('Client'))]
    totalIpCount = 0
    for probeRange in probeRangesForIPv6:
        totalIpCount += probeRange.getRangeSize().longValue()
    if totalIpCount > maxAllowedIPv6Count:
        logger.reportError("Total IPv6 count is %d, exceeds total max IPV6 count %d, give up running the job" % (totalIpCount, maxAllowedIPv6Count))
        return True
    else:
        return False
Esempio n. 9
0
    def __init__(self, Framework):
        discoverydbutils.DiscoveryDbUtils.__init__(self, Framework,
                                                   ProcessDbUtils.CONTEXT)
        self.knownPortsConfigFile = Framework.getConfigFile(
            CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME
        )
        self.applicSignConfigFile = Framework.getConfigFile(
            CollectorsParameters.KEY_COLLECTORS_SERVERDATA_APPLICATIONSIGNATURE
        )
        self.pid2Process = HashMap()

        globalSettings = GeneralSettingsConfigFile.getInstance()
        self.PROCESS_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue(
            'processExpirationTime', 60) * 1000L
 def _report_topology(self, osh, host_osh, db_host_osh, topology):
     '@types: osh, osh, osh, _Topology -> list[osh]'
     system = topology.system
     system_osh, oshs = self.report_system(system, osh)
     system_osh.setStringAttribute('data_note', 'This SAP System link to ' + host_osh.getAttributeValue('host_key'))
     
     #Making database reporting optional depending on global configuration according to QCCR1H100374 Keep a possibility option to discover SAP related database via Host Applications job
     do_report_database = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('reportSapAppServerDatabase', 'false')
     if do_report_database.lower() == 'true' and topology.db_info and db_host_osh:
         try:
             oshs.extend(sap_db.report_db_info(topology.db_info, system_osh, db_host_osh))
         except(Exception, JException), ve:
             msg = "Failed to report %s. %s" % (str(topology.db_info), ve)
             logger.warn(msg)
Esempio n. 11
0
def discoveryDatabases(sapUtils, systemName, systemOsh):
    r'@types: SapUtils, str, osh -> oshv'
    logger.info("Discover databases")
    database_datasource_pairs = []
    vector = ObjectStateHolderVector()
    try:
        database_datasource_pairs = getDatabaseJco(sapUtils)
    except:
        logger.warnException('Failed to get database info by DB6_DIAG_GET_SYSTEM_BASICS call')
        #Making database reporting optional depending on global configuration according to QCCR1H100374 Keep a possibility option to discover SAP related database via Host Applications job
        do_report_database = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('reportSapAppServerDatabase', 'false')
        if do_report_database and do_report_database.lower() == 'true':
            database_datasource_pairs = getDatabaseCcms(sapUtils, systemName)

    for server, datasource in database_datasource_pairs:
        vector.addAll(_reportDbServer(server, datasource, systemOsh))
    return vector
def processGlassfish(context, processName):
    glassfishOsh = context.application.getOsh()

    logger.debug('Started processing')
    process = context.application.getProcess(processName)
    processOriginCmd = process.commandLine
    if processOriginCmd is not None:
        serverName = None
        serverRuntime = None
        if processOriginCmd.find('com.sun.enterprise.glassfish.bootstrap.ASMain') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV3(processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV3
        elif processOriginCmd.find('com.sun.enterprise.server.PELaunch') != -1:
            serverRuntime = glassfish_discoverer.createServerRuntimeV2(processOriginCmd, None)
            DescriptorClass = glassfish_discoverer.DomainXmlDescriptorV2

        if serverRuntime:
            serverName = serverRuntime.findServerName()
            globalSettings = GeneralSettingsConfigFile.getInstance()
            loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 0)

            fs = file_system.createFileSystem(context.client)
            layout = glassfish_discoverer.createServerLayout(serverRuntime, fs)
            domainXmlFile = layout.getFile(layout.getDomainXmlPath())

            xPathParser = glassfish_discoverer.XpathParser(loadExternalDTD)
            descriptor = DescriptorClass(xPathParser, domainXmlFile.content)
            domainName = descriptor.findDomainName()

            nodeName = descriptor.findNodeNameByServerName(serverName)

            if serverName and domainName:
                logger.debug('Reporting serverName %s, domainName %s' % (serverName, domainName))
                glassfishOsh.setStringAttribute('j2eeserver_servername', serverName)
                modeling.setJ2eeServerAdminDomain(glassfishOsh, domainName)
                modeling.setAppServerType(glassfishOsh)
                # server full name
                nodeNamePart = nodeName and '%s_' % nodeName or ''
                fullName = '%s%s' % (nodeNamePart, serverName)
                glassfishOsh.setAttribute('j2eeserver_fullname', fullName)
            else:
                logger.debug('Glassfish details cannot be acquired, ignoring the application %s, %s' % (serverName, domainName))
        else:
            logger.debug('Server runtime is not created')
    else:
        logger.debug('No process comman line found for pid: %s' % process.getPid())
Esempio n. 13
0
    def loadXmlFile(self, path, container=None, fileContent=None):
        'str, osh, str -> Document'
        saxBuilder = SAXBuilder()
        globalSettings = GeneralSettingsConfigFile.getInstance()
        #loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 1)
        loadExternalDTD = 1
        saxBuilder.setFeature(
            "http://apache.org/xml/features/nonvalidating/load-external-dtd",
            loadExternalDTD)
        logger.debug("loadXmlFile, loadExternalDTD: ", loadExternalDTD,
                     ", path: ", path)
        if loadExternalDTD:
            saxBuilder.setEntityResolver(
                XMLExternalEntityResolver(self.fileMonitor, str(path),
                                          self.shellUtils))
            saxBuilder.setFeature(
                "http://xml.org/sax/features/use-entity-resolver2", 1)

        doc = None
        try:
            fileContent = fileContent or self.fileMonitor.getFileContent(path)
            if fileContent:
                try:
                    strContent = String(fileContent)
                    strContent = String(
                        strContent.substring(0,
                                             strContent.lastIndexOf('>') + 1))
                    doc = saxBuilder.build(
                        ByteArrayInputStream(strContent.getBytes()))
                    if container is not None:
                        cfOSH = self.createCF(container, path, fileContent)
                        if cfOSH is not None:
                            self.OSHVResult.add(cfOSH)
                except:
                    logger.debugException('Failed to load xml file:', path)

                    excMsg = traceback.format_exc()
                    logger.debug(excMsg)

        except:
            logger.debugException('Failed to get content of file:', path)

            excMsg = traceback.format_exc()
            logger.debug(excMsg)

        return doc
Esempio n. 14
0
    def getModelAndBiosUuid(self):
        '''@types: -> HostDo
        @raise Exception: WMI query failed
        '''
        convertToMicrosoftStandart = GeneralSettingsConfigFile.getInstance(
        ).getPropertyStringValue('setBiosUuidToMicrosoftStandart', 'false')

        hostDo = HostDo()
        queryBuilder = self._wmiProvider.getBuilder(
            'win32_ComputerSystemProduct')
        queryBuilder.addWmiObjectProperties('uuid', 'name')
        computerProductList = self._wmiProvider.getAgent().getWmiData(
            queryBuilder)
        for computerProduct in computerProductList:
            if computerProduct.uuid:
                if (re.match(r"(0{8}-0{4}-0{4}-0{4}-0{12})",
                             computerProduct.uuid) or re.match(
                                 r"([fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})",
                                 computerProduct.uuid)):
                    logger.debug('Invalid UUID was received. Skipping.')
                    continue
                if convertToMicrosoftStandart.lower() == 'false':
                    #returned 00010203-0405-0607-0809-0a0b0c0d0e0f
                    #should be 03020100-0504-0706-0809-0a0b0c0d0e0f
                    byteStyle = re.match(
                        r"(\w{2})(\w{2})(\w{2})(\w{2})\-(\w{2})(\w{2})-(\w{2})(\w{2})(.*)",
                        computerProduct.uuid)
                    if byteStyle:
                        group1 = byteStyle.group(4) + byteStyle.group(
                            3) + byteStyle.group(2) + byteStyle.group(1)
                        group2 = byteStyle.group(6) + byteStyle.group(5)
                        group3 = byteStyle.group(8) + byteStyle.group(7)
                        uuidFormated = group1 + '-' + group2 + '-' + group3 + byteStyle.group(
                            9)
                        hostDo.biosUUID = uuidFormated
                    else:
                        logger.warn('UUID is not in proper format.')
                else:
                    hostDo.biosUUID = computerProduct.uuid
                    logger.warn(
                        'BIOS UUID is reported according to Microsoft definitions since parameter setBiosUuidToMicrosoftStandart is set to True.'
                    )

            hostDo.hostModel = computerProduct.name

        return hostDo
Esempio n. 15
0
    def __init__(self):

        self._dynamicRulesMap = {}

        globalSettings = GeneralSettingsConfigFile.getInstance()
        clearCommandLineForProcesses = globalSettings.getPropertyStringValue('clearCommandLineForProcesses', '')
        processesToClear = re.split(r",", clearCommandLineForProcesses)
        if processesToClear:
            for processName in processesToClear:
                processName = processName and processName.strip()
                if processName:
                    processMatcher = _ProcessMatcher().byName(re.escape(processName))
                    processModifier = _ProcessModifier()
                    processModifier.setCommandLine(None)
                    processModifier.setArgumentLine(None)
                    processModifier.setExecutablePath(None)
                    self._dynamicRulesMap[processMatcher] = processModifier
Esempio n. 16
0
    def __init__(self, Framework):
        discoverydbutils.DiscoveryDbUtils.__init__(self, Framework,
                                                   TcpDbUtils.CONTEXT)
        self.knownPortsConfigFile = Framework.getConfigFile(
            CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME
        )
        self.applicSignConfigFile = Framework.getConfigFile(
            CollectorsParameters.KEY_COLLECTORS_SERVERDATA_APPLICATIONSIGNATURE
        )
        self.hostID = Framework.getDestinationAttribute('hostId')

        globalSettings = GeneralSettingsConfigFile.getInstance()
        #hours
        self.TCP_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue(
            'tcpExpirationTime', 24)
        #milliseconds
        self.PORT_EXPIRATION_PERIOD = globalSettings.getPropertyIntegerValue(
            'portExpirationTime', 60) * 1000L
Esempio n. 17
0
    def __init__(self):

        self._dynamicRulesMap = {}

        globalSettings = GeneralSettingsConfigFile.getInstance()
        clearCommandLineForProcesses = globalSettings.getPropertyStringValue(
            'clearCommandLineForProcesses', '')
        processesToClear = re.split(r",", clearCommandLineForProcesses)
        if processesToClear:
            for processName in processesToClear:
                processName = processName and processName.strip()
                if processName:
                    processMatcher = _ProcessMatcher().byName(
                        re.escape(processName))
                    processModifier = _ProcessModifier()
                    processModifier.setCommandLine(None)
                    processModifier.setArgumentLine(None)
                    processModifier.setExecutablePath(None)
                    self._dynamicRulesMap[processMatcher] = processModifier
Esempio n. 18
0
def _getSupportedShellProtocols(Framework):
    '''Returns names of protocols that will be used in the connection flow
    depending on the order in the list
    @types: Framework -> list[str]
    '''
    # ORDER IS IMPORTANT

    protocolOrder = GeneralSettingsConfigFile.getInstance(
    ).getPropertyStringValue('protocolConnectionOrder', "")
    if protocolOrder:
        supportedProtocols = []
        for protocol in protocolOrder.split(','):
            if protocol.strip().lower(
            ) == ClientsConsts.SSH_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.SSH_PROTOCOL_NAME)
            elif protocol.strip().lower(
            ) == ClientsConsts.TELNET_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.TELNET_PROTOCOL_NAME)
            elif protocol.strip().lower() == 'powercmd':
                supportedProtocols.append('powercmd')
            elif protocol.strip().lower(
            ) == ClientsConsts.NTCMD_PROTOCOL_NAME.lower():
                supportedProtocols.append(ClientsConsts.NTCMD_PROTOCOL_NAME)
            else:
                logger.debug("Unknown protocol name in globalSetting:",
                             protocol)
    else:
        supportedProtocols = [
            ClientsConsts.SSH_PROTOCOL_NAME,
            ClientsConsts.TELNET_PROTOCOL_NAME,
            ClientsConsts.NTCMD_PROTOCOL_NAME, 'powercmd'
        ]

    # empty means last (other possible values - first, last, none)
    udaConnectionOrder = (Framework.getParameter('udaConnectionOrder')
                          or 'last')
    if udaConnectionOrder.lower() == 'last':
        supportedProtocols.append(ClientsConsts.DDM_AGENT_PROTOCOL_NAME)
    elif udaConnectionOrder.lower() == 'first':
        supportedProtocols.insert(0, ClientsConsts.DDM_AGENT_PROTOCOL_NAME)
    else:
        logger.warn("Specified invalid parameter for the UDA connection order")
    return supportedProtocols
Esempio n. 19
0
    def _report_topology(self, osh, host_osh, db_host_osh, topology):
        '@types: osh, osh, osh, _Topology -> list[osh]'
        system = topology.system
        system_osh, oshs = self.report_system(system, osh)
        system_osh.setStringAttribute(
            'data_note', 'This SAP System link to ' +
            host_osh.getAttributeValue('host_key'))

        #Making database reporting optional depending on global configuration according to QCCR1H100374 Keep a possibility option to discover SAP related database via Host Applications job
        do_report_database = GeneralSettingsConfigFile.getInstance(
        ).getPropertyStringValue('reportSapAppServerDatabase', 'false')
        if do_report_database.lower(
        ) == 'true' and topology.db_info and db_host_osh:
            try:
                oshs.extend(
                    sap_db.report_db_info(topology.db_info, system_osh,
                                          db_host_osh))
            except (Exception, JException), ve:
                msg = "Failed to report %s. %s" % (str(topology.db_info), ve)
                logger.warn(msg)
def get_local_databases(executor, shell_interpreter, instance_name, db2_home_path=None):
    multiple_db2_instances = GeneralSettingsConfigFile.getInstance().getPropertyBooleanValue('multipleDB2Instances', 0)
    if multiple_db2_instances:
        file_name = '/tmp/ucmdb-temp-shell-' + str(int(time.time() * 1000)) + '.sh'
        db2cmdline = base_shell_discoverer.Db2.BIN_NAME
        if db2_home_path:
            db2path = base_shell_discoverer.compose_db2_bin_path(db2_home_path) + db2cmdline
            db2cmdline = shell_interpreter.getEnvironment().normalizePath(db2path)
        db2cmdline = '\'%s list db directory\'' % db2cmdline
        sh_db2cmdline = 'sh ' + file_name
        try:
            save_cmd_to_file(db2cmdline, file_name, executor)
            return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path, sh_db2cmdline)
        except:
            return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path)
        finally:
            try:
                remove_file(file_name, executor)
            except:
                logger.debug("Failed to remove temp file %s" % file_name)
    else:
        return base_shell_discoverer.get_local_databases(executor, shell_interpreter, instance_name, db2_home_path)
Esempio n. 21
0
    def loadXmlFile(self, path, container = None, fileContent = None):
        'str, osh, str -> Document'
        saxBuilder = SAXBuilder()
        globalSettings = GeneralSettingsConfigFile.getInstance()
        #loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 1)
        loadExternalDTD = 1
        saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", loadExternalDTD)
        logger.debug("loadXmlFile, loadExternalDTD: ", loadExternalDTD, ", path: ", path )
        if loadExternalDTD :
            saxBuilder.setEntityResolver( XMLExternalEntityResolver( self.fileMonitor, str(path), self.shellUtils ) )
            saxBuilder.setFeature("http://xml.org/sax/features/use-entity-resolver2", 1)

        doc = None
        try:
            fileContent = fileContent or self.fileMonitor.getFileContent(path)
            if fileContent:
                try:
                    strContent = String(fileContent)
                    strContent = String(strContent.substring(0, strContent.lastIndexOf('>') + 1))
                    doc = saxBuilder.build(ByteArrayInputStream(strContent.getBytes()))
                    if container is not None:
                        cfOSH = self.createCF(container, path, fileContent)
                        if cfOSH is not None:
                            self.OSHVResult.add(cfOSH)
                except:
                    logger.debugException('Failed to load xml file:', path)

                    excMsg = traceback.format_exc()
                    logger.debug( excMsg )

        except:
            logger.debugException('Failed to get content of file:', path)

            excMsg = traceback.format_exc()
            logger.debug( excMsg )

        return doc
Esempio n. 22
0
    defaultPfDoc = None
    if defaultPf:
        defaultPfDoc = IniParser.parseIniDoc(second(defaultPf))
        try:
            logger.info("Trying to discover ASCS")
            vector.addAll(_discoverAscsInPf(defaultPfDoc, system, systemOsh, oshPerInstance))
        except SapSystemInconsistentDataException, e:
            logger.debugException('')
            raise e
        except:
            logger.warn("Failed to discover ASCS in the profile")
            logger.debugException('')

    #Making database reporting optional depending on global configuration according to QCCR1H100374 Keep a possibility option to discover SAP related database via Host Applications job
    do_report_database = GeneralSettingsConfigFile.getInstance().getPropertyStringValue('reportSapAppServerDatabase', 'false')
    if do_report_database and do_report_database.lower() == 'true':
        systemType = sap.SystemType.ABAP
        system_ = None
        for name, (startPfIniDoc, instPfIniDoc) in pfSetByInstName.iteritems():
            doc = createPfsIniDoc(defaultPfDoc, startPfIniDoc, instPfIniDoc)
            system_ = system_ or sap_discoverer.parse_system_in_pf(doc)
            try:
                vector.addAll(_discoverDbsInPfs(doc, sapUtils, systemOsh))
            except Exception, e:
                logger.warn("Failed to discover DB based for %s. %s" % (name, e))
            isDs = checkDoubleStack(doc)
            systemType = isDs and sap.SystemType.DS or systemType
    
        if system_:
            system_ = sap.System(system.getName(), globalHost=system.globalHost,
Esempio n. 23
0
 def __init__(self, shell):
     '@types: Shell -> None'
     self.shell = shell
     self.namespace = None
     globalSettings = GeneralSettingsConfigFile.getInstance()
     self.useIntermediateFile = globalSettings.getPropertyBooleanValue(WmicAgent.__PROPERTY_NAME_USE_INTERMEDIATE_FILE, 0)
Esempio n. 24
0
def isJeeEnhancedTopologyEnabled():
    globalSettings = GeneralSettingsConfigFile.getInstance()
    return globalSettings.getPropertyBooleanValue('enableJeeEnhancedTopology', 0)
Esempio n. 25
0
                provider = jmx.Provider( client )
                dnsResolver = jee_discoverer.DnsResolverDecorator(
                                netutils.JavaDnsResolver(), client.getIpAddress()
                )
                jdbcResourceDiscoveryEnabled = Boolean.valueOf(Framework.getParameter('discoverJDBCResources'))
                jmsResourcesDiscoveryEnabled = Boolean.valueOf(Framework.getParameter('discoverJMSResources'))
                applicationModulesDiscoveryEnabled = Boolean.valueOf(Framework.getParameter('discoverAppResources'))

                namesOfServers = jee_connection.getParameterAsList(Framework, 'servers')
                isAmongServersToDiscover = lambda s, l = namesOfServers: not l or s.getName() in l

                namesOfApps = jee_connection.getParameterAsList(Framework, 'applications')
                isAmongApplicationsToDiscover = lambda a, l = namesOfApps: not l or a.getName() in l

                # create reporters and builders for websphere topology
                globalSettings = GeneralSettingsConfigFile.getInstance()
                enabledJeeEnhancedTopology = globalSettings.getPropertyBooleanValue('enableJeeEnhancedTopology', 0)
                if enabledJeeEnhancedTopology:
                    logger.info("Reporting of enhanced JEE topology enabled")
                    serverTopologyReporter = jee.ServerEnhancedTopologyReporter(websphere.ServerTopologyBuilder())
                    applicationReporter = jee.ApplicationEnhancedTopologyReporter(jee.ApplicationTopologyBuilder())
                    datasourceTopologyReporter = jee.EnhancedDatasourceTopologyReporter(
                                            jee.DatasourceTopologyBuilder(),
                                            dnsResolver
                    )
                    jmsTopologyReporter = jms.EnhancedTopologyReporter(jms.TopologyBuilder())
                else:
                    logger.info("Reporting of enhanced JEE topology disabled")
                    serverTopologyReporter = jee.ServerTopologyReporter(websphere.ServerTopologyBuilder())
                    applicationReporter = jee.ApplicationTopologyReporter(jee.ApplicationTopologyBuilder())
                    datasourceTopologyReporter = jee.DatasourceTopologyReporter(
Esempio n. 26
0
def isLoadExternalDtdEnabled():
    globalSettings = GeneralSettingsConfigFile.getInstance()
    return globalSettings.getPropertyBooleanValue('loadExternalDtd', 0)
Esempio n. 27
0
def isCaliperAllowed():
    globalSettings = GeneralSettingsConfigFile.getInstance()
    return globalSettings.getPropertyBooleanValue('allowCaliperOnHPUX', False)
Esempio n. 28
0
def getGlobalSetting():
    from com.hp.ucmdb.discovery.library.communication.downloader.cfgfiles import GeneralSettingsConfigFile
    return GeneralSettingsConfigFile.getInstance()
Esempio n. 29
0
    properties.put(AgentConstants.PROP_WEBLOGIC_PROTOCOL, protocolType)

    platform = jee.Platform.WEBLOGIC

    try:
        client = Framework.createClient(properties)
    except (Exception, JException), exc:
        logger.warnException("Failed to establish connection")
        jee_connection.reportError(Framework, str(exc), platform.getName())
    else:
        dnsResolver = jee_discoverer.DnsResolverDecorator(
                            netutils.JavaDnsResolver(), client.getIpAddress()
        )

        # create reporters and builders for weblogic topology
        globalSettings = GeneralSettingsConfigFile.getInstance()
        enabledJeeEnhancedTopology = globalSettings.getPropertyBooleanValue('enableJeeEnhancedTopology', 0)
        if enabledJeeEnhancedTopology:
            logger.info("Reporting of enhanced JEE topology enabled")
            serverTopologyReporter = jee.ServerEnhancedTopologyReporter(weblogic.ServerTopologyBuilder())
            applicationReporter = jee.ApplicationEnhancedTopologyReporter(jee.ApplicationTopologyBuilder())
            datasourceTopologyReporter = jee.EnhancedDatasourceTopologyReporter(
                                    jee.DatasourceTopologyBuilder(),
                                    dnsResolver
            )
            jmsTopologyReporter = jms.EnhancedTopologyReporter(jms.TopologyBuilder())
        else:
            logger.info("Reporting of enhanced JEE topology disabled")
            serverTopologyReporter = jee.ServerTopologyReporter(weblogic.ServerTopologyBuilder())
            applicationReporter = jee.ApplicationTopologyReporter(jee.ApplicationTopologyBuilder())
            datasourceTopologyReporter = jee.DatasourceTopologyReporter(
Esempio n. 30
0
def isCaliperAllowed():
    globalSettings = GeneralSettingsConfigFile.getInstance()
    return globalSettings.getPropertyBooleanValue('allowCaliperOnHPUX', False)
Esempio n. 31
0
def getGlobalSetting():
    from com.hp.ucmdb.discovery.library.communication.downloader.cfgfiles import GeneralSettingsConfigFile
    return GeneralSettingsConfigFile.getInstance()
Esempio n. 32
0
def _getGeneralSettings():
    r'@types: -> GeneralSettingsConfigFile'
    return GeneralSettingsConfigFile.getInstance()
Esempio n. 33
0
def isLoadExternalDtdEnabled():
    globalSettings = GeneralSettingsConfigFile.getInstance()
    return globalSettings.getPropertyBooleanValue('loadExternalDtd', 0)