示例#1
0
    def createConfigFileOsh(self):
        if self.fileType and self.fileType == 'xml':
            contentType = modeling.MIME_TEXT_XML
        else:
            contentType = modeling.MIME_TEXT_PLAIN

        return modeling.createConfigurationDocumentOshByFile(self, self.container, contentType)
示例#2
0
    def createConfigFileOsh(self):
        if self.fileType and self.fileType == 'xml':
            contentType = modeling.MIME_TEXT_XML
        else:
            contentType = modeling.MIME_TEXT_PLAIN

        return modeling.createConfigurationDocumentOshByFile(
            self, self.container, contentType)
    def getTopology(self):
        oshv = ObjectStateHolderVector()
        lb = modeling.createHostOSH(self.hostIp, 'lb')
        f5 = modeling.createApplicationOSH('f5_ltm', 'F5 BIG-IP LTM', lb)
        f5.setAttribute('application_version', self.version)
        oshv.add(lb)
        oshv.add(f5)
        for configFile in self.configFiles:
            oshv.add(modeling.createConfigurationDocumentOshByFile(configFile, f5, modeling.MIME_TEXT_PLAIN))

        for cluster in self.clusters:
            buildClusterOsh(oshv, f5, cluster)

        return oshv
    def process(self, context):
        r'''
         @types: applications.ApplicationSignatureContext
        '''
        shell = context.client
        fs = file_system.createFileSystem(shell)

        config = None
        configPath = getVsConfigPathFromCmdline(self._vscanRfcProcess.commandLine)

        try:
            config = fs.getFile(configPath, [file_topology.FileAttrs.NAME, file_topology.FileAttrs.PATH,
                                             file_topology.FileAttrs.CONTENT])
        except file_topology.PathNotFoundException:
            logger.debugException('Failed to get config file for virus scan')

        configOsh = modeling.createConfigurationDocumentOshByFile(config, context.application.applicationOsh)
        context.resultsVector.add(configOsh)

        pathUtils = file_system.getPath(fs)
        exePath = (self._vscanRfcProcess.executablePath
                   and pathUtils.isAbsolute(self._vscanRfcProcess.executablePath)
                   and self._vscanRfcProcess.executablePath
                   or  _discoverProcessExecutablePath(shell, self._vscanRfcProcess))
        if exePath:
            logger.debug('vscan_rfc executable path: %s' % exePath)
            vscanRfcCmd = vscan_rfc(exePath)
            vsiVersion = vscanRfcCmd.version() | cmdlet.executeCommand(shell) | cmdlet.produceResult
            if vsiVersion:
                softwareBuilder = SoftwareBuilder()
                softwareBuilder.updateVersion(context.application.applicationOsh, vsiVersion.kernelRelease)
                softwareBuilder.updateVsiVersion(context.application.applicationOsh, vsiVersion.vsiVersion)
                appVersionDescription = 'Versiontext: %s. Build release: %s. Build date: %s. Build platform: %s' % (vsiVersion.versionText, vsiVersion.buildRelease, vsiVersion.buildDate, vsiVersion.buildPlatform)

                softwareBuilder.updateVersionDescription(context.application.applicationOsh, appVersionDescription)
        else:
            logger.debug('Failed to discover path to vscan_rfc executable. No version info discovered.')
        appSignature = context.application.getApplicationComponent().getApplicationSignature()
        adjoinedTopologyCookie = _getOrCreateAdjoinedTopologyCookie(appSignature)

        adjoinedTopologyCookie.virusScanOsh = context.application.applicationOsh

        adjoinedTopologyReporter = _VirusScanAdjoinedTopologyReporter()
        if adjoinedTopologyReporter.isDataEnough(adjoinedTopologyCookie):
            context.resultsVector.addAll(adjoinedTopologyReporter.reportApplicationComponentsLinks(adjoinedTopologyCookie.virusScanOsh, \
                                              adjoinedTopologyCookie.sapGatewayOsh))
        else:
            logger.debug('Data is not enough for building adjoined topology from VirusScanPlugin')
示例#5
0
    def getTopology(self):
        oshv = ObjectStateHolderVector()
        lb = modeling.createHostOSH(self.hostIp, 'lb')
        f5 = modeling.createApplicationOSH('f5_ltm', 'F5 BIG-IP LTM', lb)
        f5.setAttribute('application_version', self.version)
        oshv.add(lb)
        oshv.add(f5)
        for configFile in self.configFiles:
            oshv.add(
                modeling.createConfigurationDocumentOshByFile(
                    configFile, f5, modeling.MIME_TEXT_PLAIN))

        for cluster in self.clusters:
            buildClusterOsh(oshv, f5, cluster)

        return oshv
 def _discoverConfiguration(self, process, binPath, appOsh):
     '''
     @types: Process, str, osh -> list[osh]
     @param binPath: main process binary path
     '''
     oshs = []
     cmdline = process.commandLine
     pfPath = sap_discoverer.getProfilePathFromCommandline(cmdline)
     logger.debug('Config File Path %s' % pfPath)
     configFile = getConfigFile(self.shell, pfPath)
     if configFile:
         configDocOsh = modeling.createConfigurationDocumentOshByFile(configFile, appOsh)
         oshs.append(configDocOsh)
         sysName = self.getSapSystemValues(configFile.content).get('sysName')
         if sysName:
             configs = self._discoverGatewayConfigs(sysName, binPath, appOsh)
             oshs.extend(first(configs))
     return oshs
 def _discoverConfiguration(self, process, binPath, appOsh):
     '''
     @types: Process, str, osh -> list[osh]
     @param binPath: main process binary path
     '''
     oshs = []
     cmdline = process.commandLine
     pfPath = sap_discoverer.getProfilePathFromCommandline(cmdline)
     logger.debug('Config File Path %s' % pfPath)
     configFile = getConfigFile(self.shell, pfPath)
     if configFile:
         configDocOsh = modeling.createConfigurationDocumentOshByFile(
             configFile, appOsh)
         oshs.append(configDocOsh)
         sysName = self.getSapSystemValues(
             configFile.content).get('sysName')
         if sysName:
             configs = self._discoverGatewayConfigs(sysName, binPath,
                                                    appOsh)
             oshs.extend(first(configs))
     return oshs
示例#8
0
class SapHostAgentPlugin(Plugin):
    def __init__(self):
        Plugin.__init__(self)
        self.shell = None

    def isApplicable(self, context):
        process = (context.application.getProcess('saphostexec')
                   or context.application.getProcess('saphostexec.exe'))
        return process and 1 or 0

    def process(self, context):
        self.shell = context.client
        applicationOsh = context.application.applicationOsh

        process = (context.application.getProcess('saphostexec')
                   or context.application.getProcess('saphostexec.exe'))
        logger.debug('Got process %s' % process)
        logger.debug('Process path is %s' % process.executablePath)
        binPath = re.match('(.*)saphostexec', process.executablePath, re.DOTALL)
        versionData = None
        if binPath:
            try:
                versionData = self.getVersionData(binPath.group(1))
            except Exception, e:
                logger.warn("Failed to get version: %s" % e)
        if versionData:
            self.setVersionData(versionData, applicationOsh)

        processes = context.application.getProcesses()
        for process in processes:
            parameters = process.commandLine
            logger.debug('Process Command line "%s"' % process.commandLine )
            filePath = self.findConfigFilePath(parameters)
            logger.debug('Config File Path %s' % filePath)
            if filePath:
                configFile = self.getConfigFile(filePath)
                if configFile:
                    configDocOsh = modeling.createConfigurationDocumentOshByFile(configFile, applicationOsh)
                    context.resultsVector.add(configDocOsh)
                    return
 def discoverConfiguration(self, process, appOsh):
     '@types: Process, osh -> list[osh]'
     oshs = []
     cmdline = process.commandLine
     filePath = sap_discoverer.getProfilePathFromCommandline(cmdline)
     configFile = self.getConfigFile(filePath)
     if configFile and re.search('\n[\t ]*igs/listener/http=', configFile.content):
         configDocOsh = modeling.createConfigurationDocumentOshByFile(configFile, appOsh)
         oshs.append(configDocOsh)
         versionData = self.getVersionData(process.executablePath)
         sysData = self.getSapSystemValues(configFile.content)
         igsHome = self.getIgsHome(configFile.content)
         buildPlatform = self.getBuildPlatform(igsHome)
         if versionData:
             self.setVersionData(versionData, buildPlatform, appOsh)
         if sysData.get('sysName'):
             logger.debug('Parsed values %s' % sysData)
             ips = _resolveHostIps(self.shell, sysData.get('HOST'))
             port = sysData.get('PORT')
             logger.debug('Host IPs are %s' % ips)
             if ips and port:
                 oshs = _reportGatewayTopology(ips, port, appOsh)
     return oshs