def buildDBObjects(db_type, host_ip, db_port, db_name, db_sid, appServerOSH, OSHVResult): logger.debug('building TNS Entry ', db_type, host_ip, db_name, db_port, db_sid) oshs = [] hostOSH = modeling.createHostOSH(host_ip) oshs.append(hostOSH) dbOSH, ipseOsh, databaseOshs = None, None, None platform = db_platform.findPlatformBySignature(db_type) if not platform: logger.warn("Failed to determine platform for %s" % db_type) else: dbserver = db_builder.buildDatabaseServerPdo(db_type, db_name, host_ip, db_port) if not db_name and not db_port: builder = db_builder.Generic() else: builder = db_builder.getBuilderByPlatform(platform) dbTopologyReporter = db.TopologyReporter(builder) result = dbTopologyReporter.reportServerWithDatabases( dbserver, hostOSH, (appServerOSH, )) dbOSH, ipseOsh, databaseOshs, vector_ = result oshs.extend(vector_) OSHVResult.addAll(oshs)
def getDatabaseCcms(sapUtils, systemName): ''' Discovers Databases from Computing Center Management System @Types SapUtils, str -> list[tuple[db.DatabaseServer, jdbc.Datasource]] ''' logger.debug('Getting database details from CCMS.getDatabase') databases = sapUtils.getDatabase(systemName) databaseCount = databases.getRowCount() logger.debug('Found %s databases' % databaseCount) database_datasource_pairs = [] for i in range(databaseCount): type_ = databases.getCell(i, 1) name = databases.getCell(i, 0) host = databases.getCell(i, 3) if not type_: logger.warn("Unknown type of '%s' database at '%s'" % (name, host)) continue type_ = type_.upper() dbVersion = databases.getCell(i, 2) details = ('name:', name, ' Type:', type_, ' Version:', dbVersion, ' on Host:', host) logger.debug('Found Database with following details:', details) dbPlatform = db_platform.findPlatformBySignature(type_) if not dbPlatform: logger.debug('Unknown platform for DB type %s' % type_) port = None server = db_builder.buildDatabaseServerPdo(type_, name, host, port) server.setVersion(dbVersion) datasource = jdbc.Datasource(name) database_datasource_pairs.append((server, datasource)) return database_datasource_pairs
def buildDBObjects(db_type, host_ip, db_port, db_name, db_sid, appServerOSH, OSHVResult): logger.debug('building TNS Entry ', db_type, host_ip, db_name, db_port, db_sid) oshs = [] hostOSH = modeling.createHostOSH(host_ip) oshs.append(hostOSH) dbOSH, ipseOsh, databaseOshs = None, None, None platform = db_platform.findPlatformBySignature(db_type) if not platform: logger.warn("Failed to determine platform for %s" % db_type) else: dbserver = db_builder.buildDatabaseServerPdo(db_type, db_name, host_ip, db_port) if not db_name and not db_port: builder = db_builder.Generic() else: builder = db_builder.getBuilderByPlatform(platform) dbTopologyReporter = db.TopologyReporter(builder) result = dbTopologyReporter.reportServerWithDatabases(dbserver, hostOSH, (appServerOSH,)) dbOSH, ipseOsh, databaseOshs, vector_ = result oshs.extend(vector_) OSHVResult.addAll(oshs)
def report_db_info(info, system_osh, host_osh): r'''@types: sap_discoverer.DbInfo, osh, str, osh -> list[osh] @raise ValueError: Platform is not found ''' port = None server = db_builder.buildDatabaseServerPdo(info.type, info.name, info.hostname, port) _, oshs = report_db(server, host_osh, (system_osh, )) return oshs
def parse(self, url): r'''@types: str -> db.DatabaseServer @raise MalformedUrl: url cannot be parsed''' mo = self.__PATTERN.match(url) if not mo: raise MalformedUrl(url) address, port = mo.groups() return (db_builder.buildDatabaseServerPdo('hdb', None, address, port),)
def report_db_info(info, system_osh, host_osh): r'''@types: sap_discoverer.DbInfo, osh, str, osh -> list[osh] @raise ValueError: Platform is not found ''' port = None server = db_builder.buildDatabaseServerPdo(info.type, info.name, info.hostname, port) _, oshs = report_db(server, host_osh, (system_osh, )) return oshs
def buildDatabaseServerPdo(self, dsnInfo): """ :param dsnInfo: DSN Data object :type dsnInfo: odbc.DSNInfo :return: Database Server Data object :rtype: db.DatabaseServer """ address = dsnInfo.address if self.__dnsResolver and not ip_addr.isValidIpAddress(address): address = self.__dnsResolver.resolve_ips(address) if address: address = address[0] return db_builder.buildDatabaseServerPdo(dsnInfo.driver, dsnInfo.database, address, dsnInfo.port)
def buildDatabaseServerPdo(self, dsnInfo): """ :param dsnInfo: DSN Data object :type dsnInfo: odbc.DSNInfo :return: Database Server Data object :rtype: db.DatabaseServer """ address = dsnInfo.address if self.__dnsResolver and not ip_addr.isValidIpAddress(address): address = self.__dnsResolver.resolve_ips(address) if address: address = address[0] return db_builder.buildDatabaseServerPdo(dsnInfo.driver, dsnInfo.database, address, dsnInfo.port)
def _discoverDbsInPfs(doc, sapUtils, systemOsh): ''' Discover database information based on profiles @type doc: sap_discoverer.IniDocument @type sapUtils: saputils.SapUtils @type systemOsh: ObjectStateHolder @rtype: ObjectStateHoderVector ''' # database information vector = ObjectStateHolderVector() dbsInfo = filter(None, ( DbInfoPfParser.parseAbapInstanceDbInfo(doc), DbInfoPfParser.parseJavaInstanceDbInfo(doc))) for db in dbsInfo: port = None server = db_builder.buildDatabaseServerPdo(db.type, db.name, db.hostname, port) datasource = jdbc.Datasource(db.name) vector.addAll(_reportDbServer(server, datasource, systemOsh)) return vector
def getDatabaseJco(sapUtils): ''' Discovers Databases by DB6_DIAG_GET_SYSTEM_BASICS call @Types SapUtils -> list[tuple[db.DatabaseServer, jdbc.Datasource]] ''' logger.debug('Getting database details from DB6_DIAG_GET_SYSTEM_BASICS') jcoFunction = sapUtils.getJavaClient().getFunction("DB6_DIAG_GET_SYSTEM_BASICS") sapUtils.getJavaClient().execute(jcoFunction) dbName = jcoFunction.getExportParameterList().getJcoObject().getString("DBNAME") dbType = jcoFunction.getExportParameterList().getJcoObject().getString("DBSYS") dbHost = jcoFunction.getExportParameterList().getJcoObject().getString("DBSERVER") dbVersion = jcoFunction.getExportParameterList().getJcoObject().getString("DBREL") details = ('name:', dbName, ' Type:', dbType, ' Version:', dbVersion, ' on Host:', dbHost) logger.debug('Found Database with following details:', details) dbPort = None server = db_builder.buildDatabaseServerPdo(dbType, dbName, dbHost, dbPort) server.setVersion(dbVersion) return [(server, jdbc.Datasource(dbName)), ]