示例#1
0
 def build(self, parentOsh):
     '''Builds the Oracle iAS OSH
     @param parentOsh: root cointainer for the Oracle iAS CI
     @return: Oracle iAs OSH or None, if one of the prerequisits weren't met.
     '''
     if self.name:
         serverOsh = modeling.createJ2EEServer('oracleias', None, None, parentOsh, self.name)
         self.setApplicationIp(serverOsh)
         return serverOsh
     else:
         logger.error('Failed to create Oracle iAS OSH. Server name is not specified.')
示例#2
0
 def build(self, parentOsh):
     '''Builds the Oracle iAS OSH
     @param parentOsh: root cointainer for the Oracle iAS CI
     @return: Oracle iAs OSH or None, if one of the prerequisits weren't met.
     '''
     if self.name:
         serverOsh = modeling.createJ2EEServer('oracleias', None, None,
                                               parentOsh, self.name)
         self.setApplicationIp(serverOsh)
         return serverOsh
     else:
         logger.error(
             'Failed to create Oracle iAS OSH. Server name is not specified.'
         )
示例#3
0
    def createWebServer(self, serverHeaderStr, ip, port, hostOSH):
        #Header has the following format [Server type]/[verison] [comment]
        #This pattern assumes there is a slash (/) in the string
        matcher = re.match('([-\w ]*)/\s*([^\s]*)\s*([^\n]*)', serverHeaderStr)
    
        serverType = None
        serverVersion = None
        comment = None
        if matcher:
            serverType = matcher.group(1).strip()
            serverVersion = matcher.group(2)
            comment = matcher.group(3)
        else:
            #String does not contain a slash, regard all contents as serverType
            matcher = re.match(r"^([sS]erver:)?\s+(.+?[\d.][\d.]*\s|.*)", serverHeaderStr, re.IGNORECASE)
            if matcher:
                serverType = matcher.group(2)
    

        if serverType:
            isIIS = serverType.find('IIS')
            if self.createdServers.has_key(serverHeaderStr):
                if isIIS == -1:
                    logger.warn('WebServer of type %s was already reported. Assuming same server listens a number of ports.' % serverType)
                    logger.debug('Header is: %s.' % serverHeaderStr)
                    errobj = errorobject.createError(errorcodes.ADDITIONAL_WEBSERVER_INSTANCES_ARE_SKIPPED, None, 'WebServer of type %s was already reported. Assuming same server listens a number of ports.')
                    logger.reportWarningObject(errobj)
                return self.createdServers[serverHeaderStr]
            else:
                osh = None
                #check for application server
                if serverType.lower().count("weblogic"):
                    osh = modeling.createJ2EEServer("weblogic", ip, port, hostOSH)
                else:
                    osh = modeling.createWebServerOSH(serverType, port, 'N/A', hostOSH, 0, serverVersion)
                    osh.setBoolAttribute("root_enableageing", "true")
                    comment and osh.setAttribute('data_note', comment)
    
                osh.setAttribute('data_description',serverHeaderStr)
                osh.setAttribute('application_ip',ip)
                if isIIS >= 0: 
                    self.createdServers[serverHeaderStr] = osh
                return osh

        else:
            logger.warn("Failed to get serverType from header '%s'" % serverHeaderStr)
示例#4
0
def parseOpmnXml(opmnXML, HOST_IP, ORACLE_HOME, MANAGER_PORT, shellUtils, OSHVResult, Framework):

    builder = SAXBuilder(0)
    doc = builder.build(StringReader(opmnXML))
    root = doc.getRootElement()
    
    ucmdbVersion = modeling.CmdbClassModel().version()
    
    processManager = root.getChildren()
    
    processManagerIterator = processManager.iterator()
    while processManagerIterator.hasNext():
        currProcessManager = processManagerIterator.next()
        currElementName = currProcessManager.getName()
        
        if currElementName == 'process-manager':
            
            iasInstance = currProcessManager.getChildren()
            
            iasInstanceIterator = iasInstance.iterator()
            while iasInstanceIterator.hasNext():
                currIasInstance = iasInstanceIterator.next()
                
                if currIasInstance.getName() == 'ias-instance':

                    OracleApplicationServerName = currIasInstance.getAttributeValue('name') or currIasInstance.getAttributeValue('id') or 'Default Server'


                    discoveredHost = modeling.createHostOSH(HOST_IP)
                    
                    # Create Oracle IAS
                    oracleIASOSH = modeling.createJ2EEServer('oracleias', HOST_IP, int(MANAGER_PORT), discoveredHost, OracleApplicationServerName)
                    OSHVResult.add(oracleIASOSH)

                    iasComponent = currIasInstance.getChildren()
                    iasComponentIterator = iasComponent.iterator()
                    while iasComponentIterator.hasNext(): 
                        currIasComponent = iasComponentIterator.next()
                        if 'ias-component' == currIasComponent.getName(): 

                            groupName = currIasComponent.getAttributeValue('id')
                            
                            # Create OC4J Group
                            oc4jGroupOSH = ObjectStateHolder('oc4jgroup')
                            oc4jGroupOSH.setContainer(oracleIASOSH)
                            oc4jGroupOSH.setAttribute('data_name', groupName)
                            OSHVResult.add(oc4jGroupOSH)
                            
                            #'process-type'
                            processType = currIasComponent.getChildren()
                            processTypeIterator = processType.iterator()
                            while processTypeIterator.hasNext():
                                currProcessType = processTypeIterator.next()
                                
                                oc4jName = currProcessType.getAttributeValue('id')
                                moduleId = currProcessType.getAttributeValue('module-id')

                                if 'OC4J' == moduleId:
                                    
                                    oc4jOSH = ObjectStateHolder('oc4j')
                                    oc4jOSH.setContainer(oc4jGroupOSH)
                                    oc4jOSH.setAttribute('data_name', oc4jName)
                                    OSHVResult.add(oc4jOSH)
                                    
                                    try:
                                        serverXML = shellUtils.safecat('%s/j2ee/%s/config/server.xml' % (ORACLE_HOME, oc4jName))

                                        tg = '<application name="(\w+)"'
                                        compiled = re.compile(tg,re.S)
                                        matches = compiled.findall(serverXML)

                                        appList = {}
                                        for match in matches:
                                            if ucmdbVersion < 9:
                                                applicationOSH = modeling.createApplicationOSH('application', match, oc4jOSH)
                                            else:
                                                applicationOSH = ObjectStateHolder('oc4j_app')
                                                applicationOSH.setAttribute('data_name',match)
                                                applicationOSH.setContainer(oc4jOSH)
                                            #
                                            OSHVResult.add(applicationOSH)
                                            
                                            appList[match] = applicationOSH
                                        
                                    except:
                                        logger.debugException()
                                        logger.warn('Failed to get server.xml')
                                        
                                    # Check if it holds web service
                                    wsdlDir = shellUtils.rebuildPath('%s/j2ee/%s/application-deployments/' % (ORACLE_HOME, OracleApplicationServerName))
                                    fileMon = file_mon_utils.FileMonitor(Framework, shellUtils, OSHVResult, None, None)
                                    files = fileMon.getFilesInPath(wsdlDir, '*.wsdl')
                                    if (files == []):
                                        wsdlDir = shellUtils.rebuildPath('%s/j2ee/%s/application-deployments/' % (ORACLE_HOME, oc4jName))
                                        logger.info('Pi Debug - parseOpmnXml() - trying with wsdlDir = %s' % wsdlDir)
                                        files = fileMon.getFilesInPath(wsdlDir, '*.wsdl')
                                    wsdlDirRes = '\n'.join(files)
                                    if wsdlDirRes.find('File Not Found') != -1:
                                        # NO WSDL
                                        continue
                                    else:
                                        # WSDL
                                        handleWSDL(HOST_IP, MANAGER_PORT, wsdlDirRes, wsdlDir, appList, shellUtils, OSHVResult)
示例#5
0
def infrastructure(client,
                   OSHVResult,
                   Framework,
                   schemaName=None,
                   viewSchemaName=None):
    retOSHs = ArrayList(4)
    retOSHs.add(None)
    retOSHs.add(None)
    retOSHs.add(None)
    retOSHs.add(None)

    systemOSH = ObjectStateHolder('oraclesystem')
    systemOSH.setAttribute('data_name', client.getSid())
    systemOSH.setAttribute('oraclesystem_dbaddress', client.getIpAddress())
    modeling.setAppSystemVendor(systemOSH)

    webServerOSH = None
    nameToHostOSH = HashMap()
    hostToServerOSH = HashMap()
    hostToIpAddress = HashMap()
    databasesOSH = HashMap()

    resultSet = None
    try:
        objs = __assocWithSchemaName(['FND_OAM_APP_SYS_STATUS'], schemaName,
                                     viewSchemaName)
        # query a special table that holds Applications System Status related information
        resultSet = client.executeQuery(
            'SELECT * FROM %s' % objs)  #@@CMD_PERMISION sql protocol execution
    except:
        logger.debugException(
            'SQL query failure. "SELECT * FROM FND_OAM_APP_SYS_STATUS"')
        Framework.reportWarning('No Oracle E-Business Suite components found.')

    if resultSet:
        OSHVResult.add(systemOSH)
        retOSHs.set(0, systemOSH)
    else:
        return None

    while resultSet.next():
        name = resultSet.getString(1)
        dbSid = resultSet.getString(4)
        status = resultSet.getString(6)
        host = resultSet.getString(7)
        port = client.getPort()

        if logger.isDebugEnabled():
            logger.debug('-----------------------------')
            logger.debug('name = ', name)
            logger.debug('status = ', status)
            if host != None:
                logger.debug('host = ', host)
            else:
                logger.debug('skipping Application system with None host')
                continue
            logger.debug('-----------------------------')
        hostOSH = nameToHostOSH.get(host)
        serverOSH = hostToServerOSH.get(host)
        hostIP = hostToIpAddress.get(host)

        if not hostIP:
            hostIP = netutils.getHostAddress(host, host)

        if hostOSH == None and netutils.isValidIp(hostIP):
            hostOSH = modeling.createHostOSH(hostIP)
            OSHVResult.add(hostOSH)
            nameToHostOSH.put(host, hostOSH)
            hostToIpAddress.put(host, hostIP)

        if hostOSH == None:
            logger.warn('Failed to created host [', host, ']')
            continue

        if serverOSH == None:
            serverOSH = modeling.createJ2EEServer('oracleias', hostIP, None,
                                                  hostOSH, host)
            OSHVResult.add(serverOSH)
            hostToServerOSH.put(host, serverOSH)
            serverMemberOSH = modeling.createLinkOSH('member', systemOSH,
                                                     serverOSH)
            OSHVResult.add(serverMemberOSH)
        if name.find('WEB_SERVER') == 0 and host != None:
            webServerOSH = serverOSH
            serverOSH.setBoolAttribute('oracleias_web', 1)
        elif name.find('FORMS_SERVER') == 0 and host != None:
            serverOSH.setBoolAttribute('oracleias_form', 1)
        elif name.find('ADMIN_SERVER') == 0 and host != None:
            serverOSH.setBoolAttribute('oracleias_admin', 1)
        elif name.find('CP_SERVER') == 0 and host != None:
            serverOSH.setBoolAttribute('oracleias_concurrentprocessing', 1)
        elif name.find('DATABASE') == 0 and host != None:
            dbOSH = modeling.createDatabaseOSH('oracle', dbSid, port, hostIP,
                                               hostOSH)
            OSHVResult.add(dbOSH)
            databasesOSH.put(dbSid, dbOSH)
            memberOSH = modeling.createLinkOSH('member', systemOSH, dbOSH)
            OSHVResult.add(memberOSH)
    resultSet.close()
    try:
        systemMetrics(client, systemOSH, webServerOSH, OSHVResult, schemaName,
                      viewSchemaName)
    except:
        logger.debug("Failed to get system metrics")
    retOSHs.set(1, hostToServerOSH)
    retOSHs.set(2, nameToHostOSH)
    retOSHs.set(3, databasesOSH)
    return retOSHs
示例#6
0
def infrastructure(client, OSHVResult, Framework, schemaName = None, viewSchemaName = None):
    retOSHs = ArrayList(4)
    retOSHs.add(None)
    retOSHs.add(None)
    retOSHs.add(None)
    retOSHs.add(None)

    systemOSH = ObjectStateHolder('oraclesystem')
    systemOSH.setAttribute('data_name', client.getSid())
    systemOSH.setAttribute('oraclesystem_dbaddress', client.getIpAddress())
    modeling.setAppSystemVendor(systemOSH)
    
    webServerOSH = None
    nameToHostOSH = HashMap()
    hostToServerOSH = HashMap()
    hostToIpAddress = HashMap()
    databasesOSH = HashMap()

    resultSet = None
    try:
        objs = __assocWithSchemaName(['FND_OAM_APP_SYS_STATUS'], schemaName, viewSchemaName) 
        # query a special table that holds Applications System Status related information
        resultSet = client.executeQuery('SELECT * FROM %s' % objs)#@@CMD_PERMISION sql protocol execution
    except:
        logger.debugException('SQL query failure. "SELECT * FROM FND_OAM_APP_SYS_STATUS"')
        Framework.reportWarning('No Oracle E-Business Suite components found.')

    if resultSet:
        OSHVResult.add(systemOSH)
        retOSHs.set(0, systemOSH)
    else:
        return None
        
    while resultSet.next():
        name = resultSet.getString(1)
        dbSid = resultSet.getString(4)
        status = resultSet.getString(6)
        host = resultSet.getString(7)
        port = client.getPort()
        
        if logger.isDebugEnabled():
            logger.debug('-----------------------------')
            logger.debug('name = ', name)
            logger.debug('status = ', status)
            if host != None:
                logger.debug('host = ', host)
            else:
                logger.debug('skipping Application system with None host')
                continue
            logger.debug('-----------------------------')
        hostOSH = nameToHostOSH.get(host)
        serverOSH = hostToServerOSH.get(host)
        hostIP = hostToIpAddress.get(host)

        if not hostIP:
            hostIP = netutils.getHostAddress(host, host)

        if hostOSH == None and netutils.isValidIp(hostIP):
            hostOSH = modeling.createHostOSH(hostIP)
            OSHVResult.add(hostOSH)
            nameToHostOSH.put(host,hostOSH)
            hostToIpAddress.put(host,hostIP)

        if hostOSH == None:
            logger.warn('Failed to created host [', host, ']')
            continue

        if serverOSH == None:
            serverOSH = modeling.createJ2EEServer('oracleias', hostIP, None, hostOSH, host)
            OSHVResult.add(serverOSH)
            hostToServerOSH.put(host,serverOSH)
            serverMemberOSH = modeling.createLinkOSH('member', systemOSH, serverOSH)
            OSHVResult.add(serverMemberOSH)
        if name.find('WEB_SERVER') == 0 and host != None:
            webServerOSH = serverOSH
            serverOSH.setBoolAttribute('oracleias_web', 1)
        elif name.find('FORMS_SERVER') == 0 and host != None:
            serverOSH.setBoolAttribute('oracleias_form', 1)
        elif name.find('ADMIN_SERVER') == 0 and host != None:
            serverOSH.setBoolAttribute('oracleias_admin', 1)
        elif name.find('CP_SERVER') == 0 and host != None:            
            serverOSH.setBoolAttribute('oracleias_concurrentprocessing', 1)
        elif name.find('DATABASE') == 0 and host != None:
            dbOSH = modeling.createDatabaseOSH('oracle', dbSid, port, hostIP, hostOSH)
            OSHVResult.add(dbOSH)
            databasesOSH.put(dbSid,dbOSH)
            memberOSH = modeling.createLinkOSH('member', systemOSH, dbOSH)
            OSHVResult.add(memberOSH)
    resultSet.close()
    try:
        systemMetrics(client,systemOSH,webServerOSH, OSHVResult, schemaName, viewSchemaName)
    except:
        logger.debug("Failed to get system metrics")
    retOSHs.set(1, hostToServerOSH)
    retOSHs.set(2, nameToHostOSH)
    retOSHs.set(3, databasesOSH)
    return retOSHs