def __buildServerApplicationOsh(self, citName, server, productName=None, dbType=None, platform=None): r'''@types: str, db.DatabaseServer, str, str, db_platform.Platform -> ObjectStateHolderVector @param citName: any inheritor of 'database' CIT ''' osh = ObjectStateHolder(citName) if server.instance: osh.setAttribute('name', server.instance) osh.setAttribute('database_dbsid', server.instance) if not productName and platform: productName = platform.productName if not dbType and platform: dbType = platform.dbType vendor = platform and platform.vendor or server.vendor if vendor: osh.setStringAttribute('vendor', vendor) ip = server.address if ip and ip_addr.isValidIpAddress(ip): osh.setAttribute('application_ip', str(ip)) if server.getPort(): osh.setAttribute('application_port', server.getPort()) if server.getDescription(): osh.setAttribute('description', server.getDescription()) if server.getVersion(): osh.setAttribute('version', server.getVersion()) if server.getVersionDescription(): osh.setAttribute('application_version', server.getVersionDescription()) if server.startTime: osh.setAttribute('startup_time', server.startTime) if server.installationPath: osh.setAttribute('application_path', server.installationPath) osh.setAttribute('database_dbtype', dbType) osh.setAttribute('application_category', 'Database') if productName: modeling.setApplicationProductName(osh, applicationName=productName) osh.setAttribute('discovered_product_name', productName) return osh
def reportDomainControllers(self, resultsVector): if self.domainFqdn: resolver = DNSResolver(self.client) ipList = resolver.resolveIpByNsLookup(self.domainFqdn) for ipAddress in ipList: logger.debug("Reporting Domain Controller for ip: " + ipAddress) hostOsh = modeling.createHostOSH(ipAddress) domainControllerOsh = modeling.createApplicationOSH("domaincontroller", "DomainController", hostOsh) modeling.setApplicationProductName(domainControllerOsh, "domain_controller") resultsVector.add(hostOsh) resultsVector.add(domainControllerOsh)
def reportDomainControllers(self, resultsVector): if self.domainFqdn: resolver = DNSResolver(self.client) ipList = resolver.resolveIpByNsLookup(self.domainFqdn) for ipAddress in ipList: logger.debug('Reporting Domain Controller for ip: ' + ipAddress) hostOsh = modeling.createHostOSH(ipAddress) domainControllerOsh = modeling.createApplicationOSH('domaincontroller', "DomainController", hostOsh) modeling.setApplicationProductName(domainControllerOsh,'domain_controller') resultsVector.add(hostOsh) resultsVector.add(domainControllerOsh)
def makeSiebelgatewayOSH(client, username, enterprise, srvrmgrPath, credentialsId, ip, port, Framework): # container host of siebel app containerHostOSH = modeling.createHostOSH(ip) # siebel gateway application gatewayOSH = modeling.createApplicationOSH('siebel_gateway', ip, containerHostOSH, 'Enterprise App', 'oracle_corp') gatewayOSH.setAttribute('site', enterprise) gatewayOSH.setAttribute('application_ip', ip) gatewayOSH.setAttribute('application_username', username) gatewayOSH.setAttribute('srvrmgr_path', srvrmgrPath) gatewayOSH.setAttribute('credentials_id', credentialsId) if port: gatewayOSH.setIntegerAttribute('application_port', port) #9.0 workaround versionAsDouble = logger.Version().getVersion(Framework) if versionAsDouble >= 9: gatewayOSH.removeAttribute('data_name') gatewayOSH.setAttribute('name', ip) modeling.setApplicationProductName(gatewayOSH, 'Siebel Gateway Name Server') # get DB (Data Source) Attributes cmd = 'list parameter DSConnectString for named subsystem GatewayDataSrc' gtwydsconnstrTblTxt = client.executeCmd( cmd) #@@CMD_PERMISION siebel protocol execution gtwydsconnstrTbl = siebel_common.makeTable(gtwydsconnstrTblTxt) if gtwydsconnstrTbl == None: raise 'Failed to execute command: %s ;result %s ' % ( cmd, gtwydsconnstrTblTxt) gtwydsconnstr = gtwydsconnstrTbl[0][0][1] gatewayOSH.setAttribute('gtwy_ds_conn_str', gtwydsconnstr) logger.debug('DSConnectString:', gtwydsconnstr) cmd = 'list parameters DSSQLStyle for named subsystem GatewayDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: cmd = 'list parameters DSSQLStyle for named subsystem ServerDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: cmd = 'list advanced params DSSQLStyle for named subsystem ServerDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: errorMSG = 'Failed to check gateway database type' logger.debugException(errorMSG) Framework.reportWarning(errorMSG) return gatewayOSH
def buildListener(self, listener): listenerOsh = ObjectStateHolder('oracle_listener') listenerOsh.setStringAttribute('vendor', 'oracle_corp') listenerOsh.setStringAttribute('application_category', 'Database') if listener.getName(): listenerOsh.setStringAttribute('listener_name', listener.getName()) listenerOsh.setStringAttribute('name', listener.getName()) if listener.version: listenerOsh.setStringAttribute('application_version', listener.version) listenerOsh.setAttribute('discovered_product_name', 'TNS Listener') modeling.setApplicationProductName(listenerOsh, applicationName='Oracle DB') return listenerOsh
def createGatewayOsh(ip, port, resultsVector, framework): gatewayHostOsh = modeling.createHostOSH(ip) resultsVector.add(gatewayHostOsh) gatewayOsh = modeling.createApplicationOSH('siebel_gateway', ip, gatewayHostOsh, vendor = 'oracle_corp') gatewayOsh.setAttribute('application_port', int(port)) #9.0 workaround versionAsDouble = logger.Version().getVersion(framework) if versionAsDouble >= 9: gatewayOsh.removeAttribute('data_name') gatewayOsh.setAttribute('name', ip) modeling.setApplicationProductName(gatewayOsh, 'Siebel Gateway Name Server') return gatewayOsh
def buildJmsMqServer(self, server): r'@types: jms.MqServer -> ObjectStateHolder' osh = ObjectStateHolder('messaging_server') ip = server.address if ip and netutils.isValidIp(ip): osh.setAttribute('application_ip', ip) osh.setAttribute('name', server.getName()) self._setNotNoneOshAttributeValue(osh, 'application_port', server.getPort()) osh.setAttribute('application_category', 'Messaging') # Not a proper place where to make such decisions on vendor name # but regarding of synthetic case of modeling messaging server # from non-related domain JEE considered as temporary solution if server.vendorName and server.vendorName.lower().count('ibm'): osh.setAttribute('vendor', 'ibm_corp') modeling.setApplicationProductName(osh,'IBM WebSphere MQ') return osh
def buildJmsMqServer(self, server): r'@types: jms.MqServer -> ObjectStateHolder' osh = ObjectStateHolder('messaging_server') ip = server.address if ip and netutils.isValidIp(ip): osh.setAttribute('application_ip', ip) osh.setAttribute('name', server.getName()) self._setNotNoneOshAttributeValue(osh, 'application_port', server.getPort()) osh.setAttribute('application_category', 'Messaging') # Not a proper place where to make such decisions on vendor name # but regarding of synthetic case of modeling messaging server # from non-related domain JEE considered as temporary solution if server.vendorName and server.vendorName.lower().count('ibm'): osh.setAttribute('vendor', 'ibm_corp') modeling.setApplicationProductName(osh, 'IBM WebSphere MQ') return osh
def makeSiebelgatewayOSH(client, username, enterprise, srvrmgrPath, credentialsId, ip, port, Framework): # container host of siebel app containerHostOSH = modeling.createHostOSH(ip) # siebel gateway application gatewayOSH = modeling.createApplicationOSH('siebel_gateway', ip, containerHostOSH, 'Enterprise App', 'oracle_corp') gatewayOSH.setAttribute('site', enterprise) gatewayOSH.setAttribute('application_ip', ip) gatewayOSH.setAttribute('application_username', username) gatewayOSH.setAttribute('srvrmgr_path', srvrmgrPath) gatewayOSH.setAttribute('credentials_id',credentialsId) if port: gatewayOSH.setIntegerAttribute('application_port', port) #9.0 workaround versionAsDouble = logger.Version().getVersion(Framework) if versionAsDouble >= 9: gatewayOSH.removeAttribute('data_name') gatewayOSH.setAttribute('name', ip) modeling.setApplicationProductName(gatewayOSH, 'Siebel Gateway Name Server') # get DB (Data Source) Attributes cmd = 'list parameter DSConnectString for named subsystem GatewayDataSrc' gtwydsconnstrTblTxt = client.executeCmd(cmd)#@@CMD_PERMISION siebel protocol execution gtwydsconnstrTbl = siebel_common.makeTable(gtwydsconnstrTblTxt) if gtwydsconnstrTbl == None: raise 'Failed to execute command: %s ;result %s ' % (cmd,gtwydsconnstrTblTxt) gtwydsconnstr = gtwydsconnstrTbl[0][0][1] gatewayOSH.setAttribute('gtwy_ds_conn_str', gtwydsconnstr) logger.debug('DSConnectString:', gtwydsconnstr) cmd = 'list parameters DSSQLStyle for named subsystem GatewayDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: cmd = 'list parameters DSSQLStyle for named subsystem ServerDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: cmd = 'list advanced params DSSQLStyle for named subsystem ServerDataSrc' gtwydstype = getDataSourceType(client, cmd, gatewayOSH) if gtwydstype == None: errorMSG = 'Failed to check gateway database type' logger.debugException(errorMSG) Framework.reportWarning(errorMSG) return gatewayOSH
def createGatewayOsh(ip, port, resultsVector, framework): gatewayHostOsh = modeling.createHostOSH(ip) resultsVector.add(gatewayHostOsh) gatewayOsh = modeling.createApplicationOSH('siebel_gateway', ip, gatewayHostOsh, vendor='oracle_corp') gatewayOsh.setAttribute('application_port', int(port)) #9.0 workaround versionAsDouble = logger.Version().getVersion(framework) if versionAsDouble >= 9: gatewayOsh.removeAttribute('data_name') gatewayOsh.setAttribute('name', ip) modeling.setApplicationProductName(gatewayOsh, 'Siebel Gateway Name Server') return gatewayOsh
def createOsh(self, serverDto, containerOsh, functionality=None): citName = 'domaincontroller' name = "DomainController" osh = modeling.createApplicationOSH(citName, name, containerOsh, CATEGORY, VENDOR) modeling.setApplicationProductName(osh, 'domain_controller') #osh.setAttribute('domainname', serverDto.name) if serverDto.credentialId: osh.setAttribute('credentials_id', serverDto.credentialId) if serverDto.ipAddress: osh.setAttribute('application_ip', serverDto.ipAddress) if serverDto.port: osh.setIntegerAttribute('application_port', serverDto.port) if serverDto.username: osh.setAttribute('application_username', serverDto.username) if serverDto.fullVersion: osh.setAttribute('application_version', serverDto.fullVersion) if functionality and str(functionality).isdigit(): osh.setAttribute('domaincontroller_functionality', int(functionality)) if serverDto.siteName: osh.setAttribute('sitename', serverDto.siteName) return osh
def makeAppServer(client, username, enterprise, serverObj, serverDataRow, siteOSH, Framework, OSHVResult): # init return value logger.debug('server:', string.join(serverObj), ' dataRow:', serverDataRow) datalist = serverObj sblsvrName = datalist[0] logger.debug('sblsvrName:', sblsvrName) hostName = datalist[1] installDir = datalist[2] sblmgrPID = datalist[3] serverID = datalist[9] # if no PID, server is not running. send an event on it # the message of the event will be everything that follows # the PID field if string.strip(sblmgrPID) == '': logger.debug('problem server:', serverDataRow) runningServer = 0 logger.debug('app server', sblsvrName, ' is not Running') else: runningServer = 1 # called status, but actually version details status = datalist[8] logger.debug('status:', status) versionTokens = status.split() version = versionTokens[0] build = versionTokens[1] lang = versionTokens[2] # host logger.debug('building host:', hostName) try: ip = netutils.getHostAddress(hostName) logger.debug('found ip:', ip, ' for hostName:', hostName) if ip == None: return None if netutils.isLocalIp(ip): logger.debug('got loopback ip, probably error.') return None appServerHostOSH = modeling.createHostOSH(ip) except: logger.errorException('failed to convert host name:', hostName, ' to IP') return None # siebel application server appServerOSH = modeling.createApplicationOSH('siebel_app_server', sblsvrName, appServerHostOSH, 'Enterprise App', 'oracle_corp') appServerOSH.setAttribute('application_ip', ip) appServerOSH.setAttribute('application_username', username) appServerOSH.setAttribute('install_dir', installDir) appServerOSH.setAttribute('svr_id',serverID) modeling.setAppServerType(appServerOSH) #9.0 workaround versionAsDouble = logger.Version().getVersion(Framework) if versionAsDouble >= 9: appServerOSH.removeAttribute('data_name') appServerOSH.setAttribute('name', sblsvrName) modeling.setApplicationProductName(appServerOSH, 'Siebel Server') OSHVResult.add(appServerHostOSH) OSHVResult.add(appServerOSH) if runningServer: appServerOSH.setAttribute('version', version) appServerOSH.setAttribute('application_version', version) appServerOSH.setAttribute('build', build) appServerOSH.setAttribute('lang', lang) # NOTE: setting the current app server so that all info will be only # for it prompt = client.executeCmd(string.join(['set server ', sblsvrName]), 5000)#@@CMD_PERMISION siebel protocol execution logger.debug(prompt) # get component groups (and components for each group) for this server # NOTE: as far as we know there can't be components that are not under a group # if such a situation can exist we won't find such 'leaf' components # with the current code # # makeComponentGroups(client, appServerOSH, ip, OSHVResult, enterprise, siteOSH) if version[0] == '7' or version[0] == '8': # get DB (Data Source) Attributes # table[0][0][1] means: # [0] - first row (should be only one, we are inside a server context) # [0] - first column: the parsed fields (second column is original row for error purposes) # [1] - second value in the parsed fields try: svrdsconnstrTblTxt = client.executeCmd('list parameter DSConnectString for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution svrdsconnstrTbl = siebel_common.makeTable(svrdsconnstrTblTxt) svrdsconnstr = string.upper(svrdsconnstrTbl[0][0][1]) logger.debug('svrdsconnstr:', svrdsconnstr) appServerOSH.setAttribute('srv_ds_conn_str', svrdsconnstr) except: error_message = 'failed to get DSConnectString (to set attribute srv_ds_conn_str) on server' logger.debug(error_message) Framework.reportWarning(error_message) try: svrdstypeTblTxt = client.executeCmd('list parameters DSSQLStyle for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt) if svrdstypeTbl: svrdstype = svrdstypeTbl[0][0][1] else: svrdstypeTblTxt = client.executeCmd('list parameters DSDLLName for named subsystem ServerDataSrc')#@@CMD_PERMISION siebel protocol execution svrdstypeTbl = siebel_common.makeTable(svrdstypeTblTxt) svrdstype = DLL_TO_SQL_TYPE_MAP[svrdstypeTbl[0][0][1]] logger.debug('svrdstype:', svrdstype) appServerOSH.setAttribute('svr_ds_type', svrdstype) except: error_message = 'failed to get DSSQLStyle (to set attribute svr_ds_type) on server' logger.debugException(error_message) Framework.reportWarning(error_message) serverType = getSiebelServerType(client) if serverType: appServerOSH.setStringAttribute('data_description', serverType) else: logger.warn("Cannot determine the type of server '%s', no required components were found" % sblsvrName) if version[0] == '6': # in Siebel 2000 (tested with 6.3), we can't obtain some of the parameters using command line API # get missing attributes from configuration file logger.info('Datasource parameters are not supported in version ', version) logger.info('Please run SIEBEL_DIS_APP_SERVER_CONFIG pattern to get server datasource attributes') try: odbcDSNTblTxt = client.executeCmd('list param connect')#@@CMD_PERMISION siebel protocol execution odbcDSNTbl = siebel_common.makeTable(odbcDSNTblTxt) odbcDSN = odbcDSNTbl[0][0][1] logger.debug('odbcDSN:', odbcDSN) appServerOSH.setAttribute('odbc_dsn', odbcDSN) except: error_message = 'failed to get ODBC DSN (connect param (to set attribute odbc_dsn) on server' logger.debug(error_message) Framework.reportWarning(error_message) # NOTE: unsetting the current app server prompt = client.executeCmd('unset server', 3000)#@@CMD_PERMISION siebel protocol execution logger.debug(prompt) return appServerOSH
def processConnections(ls, lparOsh, regiondict, subsystemOSH, Framework): vector = ObjectStateHolderVector() # Check each region for CICS to DB2 Connections for region in regiondict.keys(): command = concatenate(_CMD_F_CEMT_I_DB2CONN % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug ('In DB2CONN ===> ',line) # Skip the CICS regions that are not up m = re.search('IEE341I', line) if (m): break # If the connection is not connected then we skip it m = re.search('Connectst\((.+)\)', line) if (m): connected = m.group(1).strip() if connected == 'Notconnected': break # If we find a DB2GroupID then we have a connection using a sysplex to DB2 Sharing Group m = re.search('Db2groupid\((.+)\)',line) if (m): groupid = m.group(1).strip() if isNotNull(groupid): #logger.debug ('Found DB2 Group ID:',groupid) regionOSH = regiondict[region] str_name = 'name' db2sharegroupOSH = ObjectStateHolder('db2_datasharing_group') db2sharegroupOSH.setAttribute(str_name, groupid ) vector.add (db2sharegroupOSH) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, db2sharegroupOSH)) # If we find a DB2id then we have a direct connection to a DB2 Subsystem m = re.search('Db2id\((.+)\)',line) if (m): db2id = m.group(1).strip() if isNotNull(db2id): #logger.debug ('Found DB2 ID:',db2id) regionOSH = regiondict[region] str_name = 'name' str_disc_name = 'discovered_product_name' db2subsystemOSH = ObjectStateHolder('mainframe_subsystem') db2subsystemOSH.setAttribute(str_name, db2id ) db2subsystemOSH.setAttribute(str_disc_name, db2id ) db2subsystemOSH.setContainer(lparOsh) vector.add (db2subsystemOSH) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, db2subsystemOSH)) # Now Test each region for CICS to MQ Connections for region in regiondict.keys(): # Check the version of CICS to see if it is greater than V4. Inquire MQCONN is only supported on V4 or higher cicsversion = 0 command = concatenate(_CMD_F_CEMT_I_SYSTEM % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug (line) m = re.search('Cicstslevel\((\d\d).+',line) if (m): cicsversion = m.group(1).strip() # Skip the region if we are running CICS version < 4. # MQCONN Command only works on CICS >= 4 if int(cicsversion) < 4: break command = concatenate(_CMD_F_CEMT_I_MQCONN % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug ('In MQCONN ===> ',line) # Skip the CICS regions that are not up m = re.search('IEE341I', line) if (m): break # If the connection is not connected then we skip it m = re.search('Connectst\((.+)\)', line) if (m): connected = m.group(1).strip() if connected != 'Connected': break # If we find a MQ connected to this region build the link m = re.search('Mqqmgr\((.+)\)',line) if (m): mqmgr = m.group(1).strip() if isNotNull(mqmgr): #logger.debug ('Found MQMGR: ',mqmgr) regionOSH = regiondict[region] str_name = 'name' # Build Websphere MQ OSH for this MQ Mqname = 'IBM WebSphere MQ ' MqOSH = ObjectStateHolder('webspheremq') MqOSH.setAttribute(str_name, Mqname) MqOSH.setAttribute('vendor', 'ibm_corp') MqOSH.setAttribute('application_category', 'Messaging') modeling.setApplicationProductName(MqOSH,'IBM WebSphere MQ') MqOSH.setContainer(lparOsh) vector.add(MqOSH) mqQMGROsh = ObjectStateHolder('mqqueuemanager') mqQMGROsh.setAttribute(str_name, mqmgr) mqQMGROsh.setContainer(MqOSH) vector.add (mqQMGROsh) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, mqQMGROsh )) return vector