def getClusters(self, clustersParentElement): clusterElList = clustersParentElement.getChildren('Cluster') clusters = [] for clusterEl in clusterElList: tomcatClusterOsh = ObjectStateHolder('tomcatcluster') tomcatClusterOsh.setAttribute('data_name', 'Apache Tomcat Cluster') modeling.setAppSystemVendor(tomcatClusterOsh) mcastAddress = '228.0.0.4' mcastPort = '45564' membership = clusterEl.getChild('Membership') if membership is not None: try: address = membership.getAttributeValue('mcastAddr') mcastAddress = address except: logger.debug('Failed to fetch mcast address, using default ', mcastAddress) try: port = membership.getAttributeValue('mcastPort') mcastPort = port except: logger.debug('Failed to fetch mcast port, using default ', mcastPort) tomcatClusterOsh.setAttribute('tomcatcluster_multicastaddress', mcastAddress) tomcatClusterOsh.setIntegerAttribute('tomcatcluster_multicastport', mcastPort) self.OSHVResult.add(tomcatClusterOsh) clusters.append(tomcatClusterOsh) return clusters
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('')
def getClusters(self, clustersParentElement): clusterElList = clustersParentElement.getChildren('Cluster') clusters = [] for clusterEl in clusterElList: tomcatClusterOsh = ObjectStateHolder('tomcatcluster') tomcatClusterOsh.setAttribute('data_name', 'Apache Tomcat Cluster') modeling.setAppSystemVendor(tomcatClusterOsh) mcastAddress = '228.0.0.4' mcastPort = '45564' membership = clusterEl.getChild('Membership') if membership is not None: try: address = membership.getAttributeValue('mcastAddr') mcastAddress = address except: logger.debug( 'Failed to fetch mcast address, using default ', mcastAddress) try: port = membership.getAttributeValue('mcastPort') mcastPort = port except: logger.debug('Failed to fetch mcast port, using default ', mcastPort) tomcatClusterOsh.setAttribute('tomcatcluster_multicastaddress', mcastAddress) tomcatClusterOsh.setIntegerAttribute('tomcatcluster_multicastport', mcastPort) self.OSHVResult.add(tomcatClusterOsh) clusters.append(tomcatClusterOsh) return clusters
def buildSapSystem(self, system): r'@types: sap.System -> ObjectStateHolder' osh = ObjectStateHolder("sap_system") osh = self.updateSystemType(osh, system.type) osh.setAttribute("data_name", system.getName()) self.updateUuid(osh, system.uuid) modeling.setAppSystemVendor(osh) return osh
def makesiebelsiteOSH(enterprise, credentialsId, ip): siebelsiteOSH = ObjectStateHolder('siebel_site') siebelsiteOSH.setAttribute('data_name', enterprise) siebelsiteOSH.setAttribute('gateway_address', ip) modeling.setAppSystemVendor(siebelsiteOSH) # todo: get enterprise params siebelsiteOSH.setAttribute('credentials_id', credentialsId) return siebelsiteOSH
def makesiebelsiteOSH(enterprise, credentialsId, ip): siebelsiteOSH = ObjectStateHolder('siebel_site') siebelsiteOSH.setAttribute('data_name', enterprise) siebelsiteOSH.setAttribute('gateway_address', ip) modeling.setAppSystemVendor(siebelsiteOSH) # todo: get enterprise params siebelsiteOSH.setAttribute('credentials_id',credentialsId) return siebelsiteOSH
def buildOracleRac(self, rac): r'@types: db.OracleRacle -> ObjectStateHolder' osh = ObjectStateHolder('rac') serviceName = rac.getName().upper() osh.setAttribute('data_name', serviceName) osh.setAttribute('rac_servicename', serviceName) # do not report 'instancescount' attribute as it may be not up to date modeling.setAppSystemVendor(osh) return osh
def create_osh(self): osh = ObjectStateHolder('mscluster') if self.name: osh.setAttribute('data_name', self.name) if self.vendor: modeling.setAppSystemVendor(osh, self.vendor) if self.version: osh.setAttribute('version', self.version) return osh
def doExchangeSystem(self, fqdn): queryBuilder = WmiQueryBuilder('Exchange_Server') queryBuilder.addWmiObjectProperties('Name', 'FQDN', 'DN', 'RoutingGroup', 'AdministrativeGroup') Exchange_Servers = self.wmiAgent.getWmiData(queryBuilder) if len(Exchange_Servers) == 0: errobj = errorobject.createError( errorcodes.EMPTY_DATA_RECEIVED, ['Exchange servers', 'WMI'], 'No Exchange servers available via WMI') logger.reportWarningObject(errobj) return for Exchange_Server in Exchange_Servers: ''' In case host name was not determined earlier, try to obtain it using Exchange_Server.FQDN property ''' if not self.exchangeServerName and fqdn == Exchange_Server.FQDN: self.exchangeServerName = Exchange_Server.Name exchangeSystemOsh = ObjectStateHolder('exchangesystem') exchangeSystemOsh.setAttribute( 'data_name', extractOrganizationNameFromDn(Exchange_Server.DN)) modeling.setAppSystemVendor(exchangeSystemOsh) self.add(exchangeSystemOsh) administrativeGroupOsh = ObjectStateHolder( 'exchange_administrative_group') administrativeGroupOsh.setAttribute( 'data_name', Exchange_Server.AdministrativeGroup) administrativeGroupOsh.setContainer(exchangeSystemOsh) self.add(administrativeGroupOsh) routingGroupOsh = ObjectStateHolder('routing_group') routingGroupOsh.setAttribute('data_name', Exchange_Server.RoutingGroup) routingGroupOsh.setContainer(administrativeGroupOsh) self.add(routingGroupOsh) if self.exchangeServerName and self.exchangeServerName.lower( ) == Exchange_Server.Name.lower(): self.add( modeling.createLinkOSH('member', administrativeGroupOsh, self.exchangeServerOsh)) self.add( modeling.createLinkOSH('member', routingGroupOsh, self.exchangeServerOsh)) self.add( modeling.createLinkOSH('member', exchangeSystemOsh, self.exchangeServerOsh)) self.exchangeSystemOsh = exchangeSystemOsh
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)
def build(self): ''' Creates serviceguardcluster OSH @returns: instance of serviceguardcluster OSH ''' if self.name: self.osh = ObjectStateHolder('serviceguardcluster') self.osh.setAttribute('data_name', self.name) modeling.setAppSystemVendor(self.osh) if self.version: self.osh.setStringAttribute('version', self.version) return self.osh
def createRacOSH(racName, instancesNumber, serviceName, version): racOSH = ObjectStateHolder("rac") racOSH.setAttribute("data_name", racName) racOSH.setAttribute("rac_servicename", serviceName) if instancesNumber: try: racOSH.setIntegerAttribute("instancescount", int(instancesNumber)) except: logger.warn("Number of instances appeared to be a non integer value: %s" % instancesNumber) modeling.setAppSystemVendor(racOSH) if version: racOSH.setAttribute("version", version) return racOSH
def createRacOSH(racName, instancesNumber, serviceName, version): racOSH = ObjectStateHolder('rac') racOSH.setAttribute('data_name', racName) racOSH.setAttribute('rac_servicename', serviceName) if instancesNumber: try: racOSH.setIntegerAttribute('instancescount', int(instancesNumber)) except: logger.warn( 'Number of instances appeared to be a non integer value: %s' % instancesNumber) modeling.setAppSystemVendor(racOSH) if version: racOSH.setAttribute('version', version) return racOSH
def buildCluster(self, cluster): r'@types: Cluster -> ObjectStateHolder' assert cluster osh = ObjectStateHolder('mscluster') osh.setAttribute('data_name', cluster.name) modeling.setAppSystemVendor(osh) if cluster.version: osh.setAttribute('version', cluster.version) details = cluster.details if details: if details.defaultNetworkRole: osh.setAttribute('defaultNetworkRole', details.defaultNetworkRole) if details.enableEventLogReplication is not None: osh.setBoolAttribute('enableEventLogReplication', details.enableEventLogReplication) if details.quorumArbitrationTimeMax is not None: osh.setAttribute('quorumArbitrationTimeMax', int(details.quorumArbitrationTimeMax)) if details.quorumArbitrationTimeMin is not None: osh.setAttribute('quorumArbitrationTimeMin', int(details.quorumArbitrationTimeMin)) if details.enableResourceDllDeadlockDetection is not None: osh.setBoolAttribute( 'enableResourceDllDeadlockDetection', details.enableResourceDllDeadlockDetection) if details.resourceDllDeadlockTimeout is not None: osh.setAttribute('resourceDllDeadlockTimeout', int(details.resourceDllDeadlockTimeout)) if details.resourceDllDeadlockThreshold is not None: osh.setAttribute('resourceDllDeadlockThreshold', int(details.resourceDllDeadlockThreshold)) if details.resourceDllDeadlockPeriod is not None: osh.setAttribute('resourceDllDeadlockPeriod', int(details.resourceDllDeadlockPeriod)) if details.clusSvcHeartbeatTimeout is not None: osh.setAttribute('clusSvcHeartbeatTimeout', int(details.clusSvcHeartbeatTimeout)) if details.hangRecoveryAction: osh.setAttribute('hangRecoveryAction', details.hangRecoveryAction) return osh
def buildCluster(self, cluster): r'@types: Cluster -> ObjectStateHolder' assert cluster osh = ObjectStateHolder('mscluster') osh.setAttribute('data_name', cluster.name) modeling.setAppSystemVendor(osh) if cluster.version: osh.setAttribute('version', cluster.version) details = cluster.details if details: if details.defaultNetworkRole: osh.setAttribute('defaultNetworkRole', details.defaultNetworkRole) if details.enableEventLogReplication is not None: osh.setBoolAttribute('enableEventLogReplication', details.enableEventLogReplication) if details.quorumArbitrationTimeMax is not None: osh.setAttribute('quorumArbitrationTimeMax', int(details.quorumArbitrationTimeMax)) if details.quorumArbitrationTimeMin is not None: osh.setAttribute('quorumArbitrationTimeMin', int(details.quorumArbitrationTimeMin)) if details.enableResourceDllDeadlockDetection is not None: osh.setBoolAttribute('enableResourceDllDeadlockDetection', details.enableResourceDllDeadlockDetection) if details.resourceDllDeadlockTimeout is not None: osh.setAttribute('resourceDllDeadlockTimeout', int(details.resourceDllDeadlockTimeout)) if details.resourceDllDeadlockThreshold is not None: osh.setAttribute('resourceDllDeadlockThreshold', int(details.resourceDllDeadlockThreshold)) if details.resourceDllDeadlockPeriod is not None: osh.setAttribute('resourceDllDeadlockPeriod', int(details.resourceDllDeadlockPeriod)) if details.clusSvcHeartbeatTimeout is not None: osh.setAttribute('clusSvcHeartbeatTimeout', int(details.clusSvcHeartbeatTimeout)) if details.hangRecoveryAction: osh.setAttribute('hangRecoveryAction', details.hangRecoveryAction) return osh
def buildSystem(self, system): r'''@types: System -> ObjectStateHolder[bobj_system]''' osh = ObjectStateHolder('bobj_system') osh.setAttribute('name', system.name) modeling.setAppSystemVendor(osh) return osh
def parseCfgFileData(data, installPath, sarmLogFolder, shellUtils, webserverOSH, OSHVResult, HOST_ID, Framework): # create siebel web server extension siebelwseOSH = ObjectStateHolder('siebel_wse') siebelwseOSH.setContainer(webserverOSH) siebelwseOSH.setAttribute('data_name', 'Siebel WSE') siebelwseOSH.setAttribute('install_path', installPath) # try to get some general info on the SWE try: parseWSEDefaults(data, siebelwseOSH) except: logger.debug('failed getting wse defaults') OSHVResult.add(siebelwseOSH) configFileOsh = modeling.createConfigurationDocumentOSH( 'eapps.cfg', installPath, data, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, "Siebel Webserver Extention file") OSHVResult.add(configFileOsh) mapKeyToAppServers = None enableVirtualHosts = getAttribute(data, 'EnableVirtualHosts') if (enableVirtualHosts.lower() == 'true'): virtualHostsFile = getAttribute(data, 'VirtualHostsFile') if virtualHostsFile != None: virtualHostsFileData = None try: virtualHostsFileData = shellUtils.safecat(virtualHostsFile) if not virtualHostsFileData: raise ValueError except: logger.warn("Failed reading virtual host file '%s'" % virtualHostsFile) else: pattern = Pattern('([^\s]*)[\\\/]([^\s.]*).([^\s]*)') matcher = pattern.matcher(virtualHostsFile) if matcher.find() == 1: path = matcher.group(1) filename = matcher.group(2) extension = matcher.group(3) configFileName = "%s.%s" % (filename, extension) configFileOsh = modeling.createConfigurationDocumentOSH( configFileName, path, virtualHostsFileData, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, 'Load Balancer configuration file') OSHVResult.add(configFileOsh) mapKeyToAppServers = getAttributes(virtualHostsFileData, 'VirtualServer') # get web applications data apps = getApps(data) gatewayIpToOsh = {} siteNameToOsh = {} for app in apps: appName = app[app.find('[/') + 2:app.find(']')] connStr = getAttribute(app, 'ConnectString') # sample line: siebel.TCPIP.None.None://sblgw:2320/siebel/CRAObjMgr_cht/sblapp1_AS # sample line: siebel.TCPIP.None.None://cannon:2320/siebel/ERMObjMgr_chs/cannon gtwyHost = '' gtwyPort = '' siebelSite = '' componentName = '' appSvrName = '' appSvrIP = '' ip = '' tokens = connStr.split('/') numOfTokens = len(tokens) if numOfTokens > 2: if (enableVirtualHosts.lower() == 'true'): appServers = mapKeyToAppServers.get(tokens[2]) if appServers != None: serversStr = appServers.split(';') for serverStr in serversStr: if serverStr != '': serverStrTokens = serverStr.split(':') if appSvrName != '': appSvrName += ',' if appSvrIP != '': appSvrIP += ',' serverName = serverStrTokens[1] appSvrName += serverName appSvrIP += netutils.getHostAddress( serverName, serverName) else: gtwyConn = tokens[2].split(':') gtwyHost = gtwyConn[0] gtwyPort = gtwyConn[1] if not netutils.isValidIp(gtwyHost): ip = resolveHostname(gtwyHost, shellUtils, '') else: ip = gtwyHost if numOfTokens > 3: siebelSite = tokens[3] if numOfTokens > 4: componentName = tokens[4] if numOfTokens > 5: appSvrName = tokens[5] else: if appSvrIP == '': appSvrIP = ip gtwyHost = None if gtwyHost and ip and not gatewayIpToOsh.has_key(ip): gatewayOsh = createGatewayOsh(ip, gtwyPort, OSHVResult, Framework) OSHVResult.add(gatewayOsh) routeLinkOSH = modeling.createLinkOSH('depend', gatewayOsh, siebelwseOSH) OSHVResult.add(routeLinkOSH) gatewayIpToOsh[ip] = gatewayOsh if siebelSite and not siteNameToOsh.has_key(siebelSite): logger.debug('found siebel site:', siebelSite) siteOSH = ObjectStateHolder('siebel_site') siteOSH.setAttribute('gateway_address', ip) siteOSH.setAttribute('data_name', siebelSite) modeling.setAppSystemVendor(siteOSH) OSHVResult.add(siteOSH) siteNameToOsh[siebelSite] = siteOSH # create a siebel application object webappOSH = ObjectStateHolder('siebel_web_app') webappOSH.setAttribute('data_name', appName) webappOSH.setAttribute('site', siebelSite) webappOSH.setAttribute('app_srv_name', appSvrName) webappOSH.setAttribute('app_srv_ip', appSvrIP) webappOSH.setAttribute('component_name', componentName) # application contained in webserver extension webappOSH.setContainer(siebelwseOSH) OSHVResult.add(webappOSH)
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)
def buildDomainOsh(self, domain): '@types: jee.Domain -> ObjectStateHolder' osh = jee.ServerTopologyBuilder.buildDomainOsh(self, domain) modeling.setAppSystemVendor(osh, 'oracle_corp') return osh
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
def mainFunction(resBuffer, cfPath, shUtils, OSHVResult, protocol, Framework, lastUpdateTime): # Parsing the main.cf file by a reg exp that returns (Element type, name and properties) reg = '(\w+)\s([^\s]+)\s\(([^\)]+)\)' compiled = re.compile(reg) matches = compiled.findall(resBuffer) clusterName = None groupName = None veritasclusterOSH = None vcsGroupOSH = None clusterDeviceOSH = None resourceNameToOSH = {} nodeNameToOSH = {} nodeNameToFSSWOSH = {} for match in matches: element_type = match[0].strip() element_name = match[1].strip() element_prop = match[2].strip() # Handle the cluster element if element_type == 'cluster': clusterName = element_name veritasclusterOSH = ObjectStateHolder('veritascluster') veritasclusterOSH.setAttribute('data_name', clusterName) modeling.setAppSystemVendor(veritasclusterOSH) OSHVResult.add(veritasclusterOSH) # Create configuration file object containing the zipped main.cf configFileOsh = modeling.createConfigurationDocumentOSH( "main.cf.properties", "NA", resBuffer, veritasclusterOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, 'main.cf') OSHVResult.add(configFileOsh) # Handle the system element (Cluster nodes) elif element_type == 'system': nodeName = element_name hostOSH = shUtils.resolveHost(nodeName.strip()) if hostOSH == None: continue hostOSH.setAttribute('host_hostname', nodeName) OSHVResult.add(hostOSH) clusterSoftware = modeling.createClusterSoftwareOSH( hostOSH, 'Veritas Cluster SW') memberOSH = modeling.createLinkOSH('member', veritasclusterOSH, clusterSoftware) OSHVResult.add(clusterSoftware) OSHVResult.add(memberOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): # create config file object containing the zipped cf file and link it to host configFileName = "%s.properties" % nodeName configFileOsh = modeling.createConfigurationDocumentOSH( configFileName, "NA", element_prop, clusterSoftware, modeling.MIME_TEXT_PLAIN, lastUpdateTime, nodeName) OSHVResult.add(configFileOsh) # add hostosh to nodenames map so it will be easy to access later based on nodename nodeNameToOSH[nodeName] = hostOSH nodeNameToFSSWOSH[nodeName] = clusterSoftware # Handle the group element elif element_type == 'group': groupName = element_name clusterDeviceOSH = ObjectStateHolder('clusteredservice') clusterDeviceOSH.setAttribute('data_name', groupName) clusterName = veritasclusterOSH.getAttribute( 'data_name').getValue() clusterDeviceOSH.setAttribute('host_key', '%s:%s' % (clusterName, groupName)) clusterDeviceOSH.setBoolAttribute('host_iscomplete', 1) containsOSH = modeling.createLinkOSH('contained', veritasclusterOSH, clusterDeviceOSH) OSHVResult.add(clusterDeviceOSH) OSHVResult.add(containsOSH) # for clusterSoftware in clusterSoftwares: # runOSH = modeling.createLinkOSH('run', clusterSoftware, clusterDeviceOSH) # OSHVResult.add(runOSH) # create group object and link it to the cluster vcsGroupOSH = ObjectStateHolder('vcsgroup') vcsGroupOSH.setAttribute('data_name', groupName) vcsGroupOSH.setContainer(clusterDeviceOSH) OSHVResult.add(vcsGroupOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): # create config file object containing the current group related section in cf file, zipped and link it to cluster configFileName = "%s.properties" % groupName configFileOsh = modeling.createConfigurationDocumentOSH( configFileName, "NA", element_prop, vcsGroupOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, groupName) OSHVResult.add(configFileOsh) m = re.search('SystemList\s*\=\s*\{(.*)\}', element_prop, re.M) if m: systemList = m.group(1) systemsWithPriorities = getSystemsWithPriorities(systemList) for nodeName, priority in systemsWithPriorities.items(): if nodeNameToFSSWOSH.has_key(nodeName): clusterSoftware = nodeNameToFSSWOSH[nodeName] ownerOSH = modeling.createLinkOSH( 'potentially_run', clusterSoftware, clusterDeviceOSH) if priority == 0: ownerOSH.setAttribute('data_name', 'Preferred Owner') ownerOSH.setBoolAttribute('is_owner', 1) else: ownerOSH.setAttribute('data_name', 'Alternate Owner') ownerOSH.setBoolAttribute('is_owner', 0) OSHVResult.add(ownerOSH) # Handle the resource element elif element_type != None: if vcsGroupOSH == None: continue resourceName = element_name vcsresourceOSH = ObjectStateHolder('vcsresource') vcsresourceOSH.setAttribute('data_name', resourceName) vcsresourceOSH.setAttribute('type', element_type) vcsresourceOSH.setContainer(vcsGroupOSH) OSHVResult.add(vcsresourceOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): (zippedBytes, checksumValue, dataLength) = modeling.processBytesAttribute(element_prop) vcsresourceOSH.setBytesAttribute('resource_properties', zippedBytes) resourceNameToOSH[resourceName] = vcsresourceOSH # Create the real resource element behine the vcs resource and link the two objects with a depend link handleResource(element_name, element_type, element_prop, vcsresourceOSH, nodeNameToOSH, OSHVResult, clusterDeviceOSH) # Handle the resources dependencies reg = '([\w-]+)\srequires\s([\w-]+)' compiled = re.compile(reg) matches = compiled.findall(resBuffer) for match in matches: depended = match[0].strip() master = match[1].strip() # link each resource with the resource it depends on dependOSH = modeling.createLinkOSH('depend', resourceNameToOSH[depended], resourceNameToOSH[master]) OSHVResult.add(dependOSH) # Handle the CF included files reg = 'include\s\"(.*)\"' compiled = re.compile(reg) matches = compiled.findall(resBuffer) for match in matches: cfFileName = match.strip() try: includeFilePath = cfPath + cfFileName currCFBuffer = shUtils.safecat(includeFilePath) except: errorMessage = 'Failed to handle include file %s' % includeFilePath logger.debugException(errorMessage) errobj = errorobject.createError( errorcodes.FAILED_HANDLING_INCLUDE_FILE, [includeFilePath], errorMessage) logger.reportWarningObject(errobj) if not shUtils.getLastCmdReturnCode(): currCFBuffer = currCFBuffer.strip() if (currCFBuffer != None) and (currCFBuffer != ''): # create configuration file object with the included cf file zipped configFileName = "%s.properties" % cfFileName configFileOsh = modeling.createConfigurationDocumentOSH( configFileName, "NA", currCFBuffer, veritasclusterOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, cfFileName) OSHVResult.add(configFileOsh)
def buildDomainOsh(self, domain): r'@types: jee.Domain -> ObjectStateHolder' osh = jee.ServerTopologyBuilder.buildDomainOsh(self, domain) modeling.setAppSystemVendor(osh, 'bea_systems_ltd') return osh
def parseCfgFileData(data, installPath, sarmLogFolder, shellUtils, webserverOSH, OSHVResult, HOST_ID, Framework): # create siebel web server extension siebelwseOSH = ObjectStateHolder('siebel_wse') siebelwseOSH.setContainer(webserverOSH) siebelwseOSH.setAttribute('data_name', 'Siebel WSE') siebelwseOSH.setAttribute('install_path', installPath) # try to get some general info on the SWE try: parseWSEDefaults(data, siebelwseOSH) except: logger.debug('failed getting wse defaults') OSHVResult.add(siebelwseOSH) configFileOsh = modeling.createConfigurationDocumentOSH('eapps.cfg', installPath, data, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, "Siebel Webserver Extention file") OSHVResult.add(configFileOsh) mapKeyToAppServers = None enableVirtualHosts = getAttribute(data, 'EnableVirtualHosts') if (enableVirtualHosts.lower() == 'true'): virtualHostsFile = getAttribute(data, 'VirtualHostsFile') if virtualHostsFile != None: virtualHostsFileData = None try: virtualHostsFileData = shellUtils.safecat(virtualHostsFile) if not virtualHostsFileData: raise ValueError except: logger.warn("Failed reading virtual host file '%s'" % virtualHostsFile) else: pattern = Pattern('([^\s]*)[\\\/]([^\s.]*).([^\s]*)') matcher = pattern.matcher(virtualHostsFile) if matcher.find()== 1: path = matcher.group(1) filename = matcher.group(2) extension = matcher.group(3) configFileName = "%s.%s" % (filename, extension) configFileOsh = modeling.createConfigurationDocumentOSH(configFileName, path, virtualHostsFileData, siebelwseOSH, modeling.MIME_TEXT_PLAIN, None, 'Load Balancer configuration file') OSHVResult.add(configFileOsh) mapKeyToAppServers = getAttributes(virtualHostsFileData,'VirtualServer') # get web applications data apps = getApps(data) gatewayIpToOsh = {} siteNameToOsh = {} for app in apps: appName = app[app.find('[/')+2:app.find(']')] connStr = getAttribute(app, 'ConnectString') # sample line: siebel.TCPIP.None.None://sblgw:2320/siebel/CRAObjMgr_cht/sblapp1_AS # sample line: siebel.TCPIP.None.None://cannon:2320/siebel/ERMObjMgr_chs/cannon gtwyHost = '' gtwyPort = '' siebelSite = '' componentName = '' appSvrName = '' appSvrIP = '' ip = '' tokens = connStr.split('/') numOfTokens = len(tokens) if numOfTokens > 2: if (enableVirtualHosts.lower() == 'true'): appServers = mapKeyToAppServers.get(tokens[2]) if appServers != None: serversStr = appServers.split(';') for serverStr in serversStr: if serverStr != '': serverStrTokens = serverStr.split(':') if appSvrName != '': appSvrName += ',' if appSvrIP != '': appSvrIP += ',' serverName = serverStrTokens[1] appSvrName += serverName appSvrIP += netutils.getHostAddress(serverName, serverName) else: gtwyConn = tokens[2].split(':') gtwyHost = gtwyConn[0] gtwyPort = gtwyConn[1] if not netutils.isValidIp(gtwyHost): ip = resolveHostname(gtwyHost, shellUtils, '') else: ip = gtwyHost if numOfTokens > 3: siebelSite = tokens[3] if numOfTokens > 4: componentName = tokens[4] if numOfTokens > 5: appSvrName = tokens[5] else: if appSvrIP == '': appSvrIP = ip gtwyHost = None if gtwyHost and ip and not gatewayIpToOsh.has_key(ip): gatewayOsh = createGatewayOsh(ip, gtwyPort, OSHVResult, Framework) OSHVResult.add(gatewayOsh) routeLinkOSH = modeling.createLinkOSH('depend', gatewayOsh, siebelwseOSH) OSHVResult.add(routeLinkOSH) gatewayIpToOsh[ip] = gatewayOsh if siebelSite and not siteNameToOsh.has_key(siebelSite): logger.debug('found siebel site:', siebelSite) siteOSH = ObjectStateHolder('siebel_site') siteOSH.setAttribute('gateway_address', ip) siteOSH.setAttribute('data_name', siebelSite) modeling.setAppSystemVendor(siteOSH) OSHVResult.add(siteOSH) siteNameToOsh[siebelSite] = siteOSH # create a siebel application object webappOSH = ObjectStateHolder('siebel_web_app') webappOSH.setAttribute('data_name', appName) webappOSH.setAttribute('site', siebelSite) webappOSH.setAttribute('app_srv_name', appSvrName) webappOSH.setAttribute('app_srv_ip', appSvrIP) webappOSH.setAttribute('component_name', componentName) # application contained in webserver extension webappOSH.setContainer(siebelwseOSH) OSHVResult.add(webappOSH)
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
def mainFunction(resBuffer, cfPath, shUtils, OSHVResult, protocol, Framework, lastUpdateTime): # Parsing the main.cf file by a reg exp that returns (Element type, name and properties) reg = '(\w+)\s([^\s]+)\s\(([^\)]+)\)' compiled = re.compile(reg) matches = compiled.findall(resBuffer) clusterName = None groupName = None veritasclusterOSH = None vcsGroupOSH = None clusterDeviceOSH = None resourceNameToOSH = {} nodeNameToOSH = {} nodeNameToFSSWOSH = {} for match in matches: element_type = match[0].strip() element_name = match[1].strip() element_prop = match[2].strip() # Handle the cluster element if element_type == 'cluster': clusterName = element_name veritasclusterOSH = ObjectStateHolder('veritascluster') veritasclusterOSH.setAttribute('data_name', clusterName) modeling.setAppSystemVendor(veritasclusterOSH) OSHVResult.add(veritasclusterOSH) # Create configuration file object containing the zipped main.cf configFileOsh = modeling.createConfigurationDocumentOSH("main.cf.properties", "NA", resBuffer, veritasclusterOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, 'main.cf') OSHVResult.add(configFileOsh) # Handle the system element (Cluster nodes) elif element_type == 'system': nodeName = element_name hostOSH = shUtils.resolveHost(nodeName.strip()) if hostOSH == None: continue hostOSH.setAttribute('host_hostname', nodeName) OSHVResult.add(hostOSH) clusterSoftware = modeling.createClusterSoftwareOSH(hostOSH, 'Veritas Cluster SW') memberOSH = modeling.createLinkOSH('member', veritasclusterOSH, clusterSoftware) OSHVResult.add(clusterSoftware) OSHVResult.add(memberOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): # create config file object containing the zipped cf file and link it to host configFileName = "%s.properties" % nodeName configFileOsh = modeling.createConfigurationDocumentOSH(configFileName, "NA", element_prop, clusterSoftware, modeling.MIME_TEXT_PLAIN, lastUpdateTime, nodeName) OSHVResult.add(configFileOsh) # add hostosh to nodenames map so it will be easy to access later based on nodename nodeNameToOSH[nodeName] = hostOSH nodeNameToFSSWOSH[nodeName] = clusterSoftware # Handle the group element elif element_type == 'group': groupName = element_name clusterDeviceOSH = ObjectStateHolder('clusteredservice') clusterDeviceOSH.setAttribute('data_name', groupName) clusterName = veritasclusterOSH.getAttribute('data_name').getValue() clusterDeviceOSH.setAttribute('host_key', '%s:%s' % (clusterName, groupName)) clusterDeviceOSH.setBoolAttribute('host_iscomplete', 1) containsOSH = modeling.createLinkOSH('contained', veritasclusterOSH, clusterDeviceOSH) OSHVResult.add(clusterDeviceOSH) OSHVResult.add(containsOSH) # for clusterSoftware in clusterSoftwares: # runOSH = modeling.createLinkOSH('run', clusterSoftware, clusterDeviceOSH) # OSHVResult.add(runOSH) # create group object and link it to the cluster vcsGroupOSH = ObjectStateHolder('vcsgroup') vcsGroupOSH.setAttribute('data_name', groupName) vcsGroupOSH.setContainer(clusterDeviceOSH) OSHVResult.add(vcsGroupOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): # create config file object containing the current group related section in cf file, zipped and link it to cluster configFileName = "%s.properties" % groupName configFileOsh = modeling.createConfigurationDocumentOSH(configFileName, "NA", element_prop, vcsGroupOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, groupName) OSHVResult.add(configFileOsh) m = re.search('SystemList\s*\=\s*\{(.*)\}', element_prop, re.M) if m: systemList = m.group(1) systemsWithPriorities = getSystemsWithPriorities(systemList) for nodeName, priority in systemsWithPriorities.items(): if nodeNameToFSSWOSH.has_key(nodeName): clusterSoftware = nodeNameToFSSWOSH[nodeName] ownerOSH = modeling.createLinkOSH('potentially_run', clusterSoftware, clusterDeviceOSH) if priority == 0: ownerOSH.setAttribute('data_name', 'Preferred Owner') ownerOSH.setBoolAttribute('is_owner', 1) else: ownerOSH.setAttribute('data_name', 'Alternate Owner') ownerOSH.setBoolAttribute('is_owner', 0) OSHVResult.add(ownerOSH) # Handle the resource element elif element_type != None: if vcsGroupOSH == None: continue resourceName = element_name vcsresourceOSH = ObjectStateHolder('vcsresource') vcsresourceOSH.setAttribute('data_name', resourceName) vcsresourceOSH.setAttribute('type', element_type) vcsresourceOSH.setContainer(vcsGroupOSH) OSHVResult.add(vcsresourceOSH) element_prop = element_prop.strip() if (element_prop != '') and (len(element_prop) > 3): (zippedBytes, checksumValue, dataLength) = modeling.processBytesAttribute(element_prop) vcsresourceOSH.setBytesAttribute('resource_properties', zippedBytes) resourceNameToOSH[resourceName] = vcsresourceOSH # Create the real resource element behine the vcs resource and link the two objects with a depend link handleResource(element_name, element_type, element_prop, vcsresourceOSH, nodeNameToOSH, OSHVResult, clusterDeviceOSH) # Handle the resources dependencies reg = '([\w-]+)\srequires\s([\w-]+)' compiled = re.compile(reg) matches = compiled.findall(resBuffer) for match in matches: depended = match[0].strip() master = match[1].strip() # link each resource with the resource it depends on dependOSH = modeling.createLinkOSH('depend', resourceNameToOSH[depended], resourceNameToOSH[master]) OSHVResult.add(dependOSH) # Handle the CF included files reg = 'include\s\"(.*)\"' compiled = re.compile(reg) matches = compiled.findall(resBuffer) for match in matches: cfFileName = match.strip() try: includeFilePath = cfPath + cfFileName currCFBuffer = shUtils.safecat(includeFilePath) except: errorMessage = 'Failed to handle include file %s' % includeFilePath logger.debugException(errorMessage) errobj = errorobject.createError(errorcodes.FAILED_HANDLING_INCLUDE_FILE, [includeFilePath], errorMessage) logger.reportWarningObject(errobj) if not shUtils.getLastCmdReturnCode(): currCFBuffer = currCFBuffer.strip() if (currCFBuffer != None) and (currCFBuffer != ''): # create configuration file object with the included cf file zipped configFileName = "%s.properties" % cfFileName configFileOsh = modeling.createConfigurationDocumentOSH(configFileName, "NA", currCFBuffer, veritasclusterOSH, modeling.MIME_TEXT_PLAIN, lastUpdateTime, cfFileName) OSHVResult.add(configFileOsh)