def triggered_on_ipse_only(client, framework, dns_resolver, cred_id, ip, dbname, port, ipse_id): db_oshs, oshs, warnings = _discover(client, framework, dns_resolver, cred_id, dbname, port) config = DiscoveryConfig(framework, cred_id) reporter = db2_topology.Reporter() link_reporter = db2_topology.LinkReporter() node_osh = modeling.createOshByCmdbId('node', config.host_id) oshs.append(node_osh) instance = db.DatabaseServer(ip, port) inst_osh, _, _, vector = reporter.reportServerAndDatabases( instance, node_osh) oshs.extend(vector) alias_osh = reporter.reportDbAlias(dbname, inst_osh) db2_topology.Builder.update_credential_id(alias_osh, cred_id) oshs.append(alias_osh) if db_oshs: db_osh = db_oshs.pop() realization_osh = link_reporter.report_realization(alias_osh, db_osh) oshs.append(realization_osh) return oshs, warnings
def _report_ipse(config, ip, svcename, container, db_osh): oshs = [] endpoint_osh = None if config.ipse_id: endpoint_osh = modeling.createOshByCmdbIdString('ip_service_endpoint', config.ipse_id) oshs.append(endpoint_osh) else: port = resolve_svcename_to_port_nr(svcename) if port: db2_reporter = db2_topology.Reporter() link_reporter = db2_topology.LinkReporter() endpoint_osh = db2_reporter.reportDb2IpServiceEndpoint(ip, port, container) oshs.append(link_reporter.report_usage(db_osh, endpoint_osh)) oshs.append(endpoint_osh) return endpoint_osh, oshs
def triggered_on_alias(client, framework, dns_resolver, cred_id, ip, dbname, port, alias_id): db_oshs, oshs, warnings = _discover(client, framework, dns_resolver, cred_id, dbname, port) if db_oshs: db_osh = db_oshs.pop() reporter = db2_topology.LinkReporter() alias_osh = modeling.createOshByCmdbId('db2_alias', alias_id) db2_topology.Builder.update_credential_id(alias_osh, cred_id) oshs.append(alias_osh) realization_osh = reporter.report_realization(alias_osh, db_osh) oshs.append(realization_osh) return oshs, warnings
def _report_instance(config, instance_name, version, db_osh, node_osh, endpoint_osh=None): instance_osh = None oshs = [] if config.db2_id: instance_osh = modeling.createOshByCmdbIdString('db2_instance', config.db2_id) oshs.append(instance_osh) elif instance_name: db2_builder = db2_topology.Builder() db2_reporter = db2_topology.Reporter(db2_builder) db2 = db.DatabaseServer(instance=instance_name, version=version) instance_osh, _, oshs_ = db2_reporter.reportServer(db2, node_osh) oshs.extend(oshs_) link_reporter = db2_topology.LinkReporter() oshs.append(link_reporter.report_lifecycle(db_osh, instance_osh)) if endpoint_osh: oshs.append(link_reporter.report_usage(instance_osh, endpoint_osh)) return instance_osh, oshs
def _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, inst_name=None, svcename=None, version=None): oshs = [] add_all_to_result = Fn(_add_vector_and_return, oshs, fptools._) add_to_result = Fn(_add_osh_and_return, oshs, fptools._) link_reporter = db2_topology.LinkReporter() report_usage_link = comp(add_to_result, link_reporter.report_usage) report_client_server_link = comp(add_to_result, link_reporter.report_client_server) report_dbclient_link = comp(add_to_result, link_reporter.report_dbclient) host_reporter = db2_host.Reporter(db2_host.Builder()) report_host = comp(add_to_result, modeling.createHostOSH, str) process_reporter = process.Reporter() report_process = Fn(process_reporter.report, fptools._, fptools._, process.ProcessBuilder()) report_process = comp(add_all_to_result, report_process) host_osh = modeling.createOshByCmdbIdString('node', config.host_id) db_osh = modeling.createOshByCmdbIdString('db2_database', config.db_id) oshs.append(host_osh) oshs.append(db_osh) endpoint_osh, oshs_ = _report_ipse(config, ip, svcename, host_osh, db_osh) oshs.extend(oshs_) db2_rs_osh, oshs_ = _report_instance(config, inst_name, version, db_osh, host_osh, endpoint_osh) oshs.extend(oshs_) if version_info: if db2_rs_osh: db2_topology.SoftwareBuilder.updateVersionDescription(db2_rs_osh, str(version_info)) db2_topology.SoftwareBuilder.updateVersionDescription(db_osh, str(version_info)) db2_reporter = db2_topology.Reporter() report_dbschema = Fn(db2_reporter.reportDbSchema, fptools._, db_osh) report_dbschema = comp(add_to_result, report_dbschema) report_datafile = comp(add_all_to_result, db2_reporter.reportDatafile) report_tablespace = comp(add_all_to_result, db2_reporter.reportTablespace) report_table = comp(add_all_to_result, db2_reporter.reportTable) report_partition_group = Fn(db2_reporter.reportPartitionGroup, fptools._, db_osh) report_partition_group = comp(add_to_result, report_partition_group) report_partition = comp(add_all_to_result, db2_reporter.reportPartition) report_buffer_pool = comp(add_all_to_result, Fn(db2_reporter.reportBufferPool, fptools._, db_osh, fptools._,)) file_system_builder = db2_topology.FileSystemBuilder() file_system_reporter = db2_topology.FileSystemReporter(file_system_builder) report_file_system = comp(add_to_result, file_system_reporter.report_file_system) pg_osh_by_pg_name = _report_pgs(partition_groups, report_partition_group) partition_osh_by_number, node_osh_by_partition_nr = _report_partitions(partitions, db2_rs_osh, oshs, pg_names_by_partition_number, pg_osh_by_pg_name, report_partition, host_reporter) bp_osh_by_partition_nr_and_bp_id = _report_bufferpools(buffer_pools_by_partition_nr, partition_osh_by_number, report_buffer_pool) container_oshes_by_tablespace = _report_data_files(mountpoint_by_container, containers_by_tablespace_id, partition_nr_by_container, tablespaces, partition_osh_by_number, node_osh_by_partition_nr, report_datafile, report_file_system) tablespace_osh_by_tablespace = _report_tablespaces(tablespaces, db_osh, pg_osh_by_pg_name, partition_numbers_by_pg_name, bp_osh_by_partition_nr_and_bp_id, container_oshes_by_tablespace, report_tablespace, report_usage_link) schema_osh_by_name = {} for schema in schemas: schema_osh_by_name[schema.name] = report_dbschema(schema) for table, tablespace, schema_name, owner in tables: table_pdo = db2_topology.Builder.TablePdo(table.name, owner) tablespace_osh = tablespace_osh_by_tablespace.get(tablespace) schemaOsh = schema_osh_by_name.get(schema_name) if schemaOsh: report_table(table_pdo, schemaOsh, tablespaceOsh=tablespace_osh) else: logger.warn("Schema '%s' not found, table '%s' is not reported" % (schema_name, table.name)) port = config.port or resolve_svcename_to_port_nr(svcename) _report_sessions(sessions, endpoint_osh, db2_rs_osh, port, report_host, report_process, report_client_server_link, report_dbclient_link) return oshs