def _discover(client, framework, dns_resolver, cred_id, dbname, port): r'@types: Client, db2_flow.RichFramework, dns_resolver.Resolver, str, str, str -> list[osh], list[osh], list[errorobject.ErrorObject]' warnings = [] oshs = [] executor = ChainedCmdlet(SqlCommandExecutor(client), command.cmdlet.produceResult) version, warnings_ = discover_or_warn( ('db2 version', db2_sql_discoverer.get_db2_version, executor), ) warnings.extend(warnings_) discoverer = db2_sql_discoverer.registry.get_discoverer(version) version = version and db2_topology.build_version_pdo(version) dbname_, svcename, host, instance_name, warnings_ = discover_or_warn( ('db2 database name', discoverer.get_current_dbname, executor), ('db2 database svcename', discoverer.get_current_svcename, executor), ('db2 instance host', discoverer.get_instance_host, executor, dns_resolver), ('db2 instance name', discoverer.get_instance_name, executor), ) warnings.extend(warnings_) oshs_, db_oshs = _report_remote(host, svcename, instance_name, version, dbname_) oshs.extend(oshs_) return db_oshs, oshs, warnings
def _discover(client, framework, dns_resolver, cred_id, dbname, port): r'@types: Client, db2_flow.RichFramework, dns_resolver.Resolver, str, str, str -> list[osh], list[osh], list[errorobject.ErrorObject]' warnings = [] oshs = [] executor = ChainedCmdlet(SqlCommandExecutor(client), command.cmdlet.produceResult) version, warnings_ = discover_or_warn(('db2 version', db2_sql_discoverer.get_db2_version, executor),) warnings.extend(warnings_) discoverer = db2_sql_discoverer.registry.get_discoverer(version) version = version and db2_topology.build_version_pdo(version) dbname_, svcename, host, instance_name, warnings_ = discover_or_warn( ('db2 database name', discoverer.get_current_dbname, executor), ('db2 database svcename', discoverer.get_current_svcename, executor), ('db2 instance host', discoverer.get_instance_host, executor, dns_resolver), ('db2 instance name', discoverer.get_instance_name, executor), ) warnings.extend(warnings_) oshs_, db_oshs = _report_remote(host, svcename, instance_name, version, dbname_) oshs.extend(oshs_) return db_oshs, oshs, warnings
def _discover(client, dns_resolver, cred_id, ip, config): warnings = [] executor = ChainedCmdlet(db2_sql_base_discoverer.SqlCommandExecutor(client), command.cmdlet.produceResult) db2_version, warnings_ = discover_or_warn(('db2 version', db2_sql_discoverer.get_db2_version, executor),) warnings.extend(warnings_) discoverer = db2_sql_discoverer.registry.get_discoverer(db2_version) version_info, warnings_ = discover_or_warn( ('db2 version description', discoverer.get_db2_version_info, executor), ) warnings.extend(warnings_) (tablespaces, containers, sessions, schemas, partition_groups, partitions, partition_name_pg_name_pairs, buffer_pools_by_partition_nr, warnings_) = discover_or_warn( ('tablespaces', discoverer.get_tablespaces, executor), ('containers', discoverer.get_containers, executor), ('sessions', discoverer.get_db_sessions, executor, config.db_name), ('schemas', discoverer.get_schemas, executor), ('partition groups', discoverer.get_partition_groups, executor), ('partitions', discoverer.get_partitions, executor), ('partition to partition group relation', discoverer.get_partition_number_to_pg_name_relation, executor), ('buffer pools', discoverer.get_buffer_pools, executor), ) warnings.extend(warnings_) tables = () if config.discover_tables: tables, warnings_ = discover_or_warn( ('tables', discoverer.get_tables, executor), ) warnings.extend(warnings_) instance_name, svcename = None, None if not config.db2_id or not config.ipse_id: instance_name, svcename, warnings_ = discover_or_warn( ('db2 instance name', discoverer.get_instance_name, executor), ('db2 database svcename', discoverer.get_current_svcename, executor),) warnings.extend(warnings_) partition_nr_by_container = {} for tbsp_id, container_name, partition_nr in containers: partition_nr_by_container[container_name] = partition_nr containers_by_tablespace_id = groupby(containers, first, second) containers = map(second, containers) mountpoint_by_container = dict(zip(containers, map(parse_mountpoint_from_path, containers))) resolve_ips = safeFunc(dns_resolver.resolve_ips) get_host = fptools.safeFunc(db2_discoverer.get_host) partitions = ((partition, get_host(hostname, resolve_ips), port, switch_name) for partition, hostname, port, switch_name in partitions) pg_names_by_partition_number = groupby(partition_name_pg_name_pairs, first, second) partition_numbers_by_pg_name = groupby(partition_name_pg_name_pairs, second, first) if config.discover_tables and not config.discover_system_tables: tables = ifilterfalse(comp(discoverer.is_reserved_schema_name, third), tables) default_client_program = comp(operator.not_, discoverer.is_default_client_program_name, process.Process.getName, discoverer.Session.client_process.fget) sessions = ifilter(default_client_program, sessions) version = db2_version and db2_topology.build_version_pdo(db2_version) oshs = _report(ip, config, version_info, partition_groups, partitions, pg_names_by_partition_number, buffer_pools_by_partition_nr, tablespaces, partition_numbers_by_pg_name, mountpoint_by_container, containers_by_tablespace_id, partition_nr_by_container, schemas, tables, sessions, instance_name, svcename, version) return oshs, warnings