def _discover_remote_databases(self, context, instname, db2_home_path,
                                   discoverer, executor, interpreter):
        local_dbserver_osh = context.application.applicationOsh
        get_remote_databases = safeFn(discoverer.get_remote_databases)
        node_db_pairs = get_remote_databases(executor, interpreter, instname, db2_home_path=db2_home_path) or ()

        get_node = safeFn(discoverer.get_node)
        reporter = db2_topology.Reporter()
        node_reporter = host_topology.Reporter()

        shell = context.client
        resolvers = (NsLookupDnsResolver(shell), SocketDnsResolver())
        resolve_ips_fn = FallbackResolver(resolvers).resolve_ips
        for nodename, remote_dbs in node_db_pairs:
            node = get_node(executor, interpreter, instname,
                            nodename, db2_home_path=db2_home_path)
            if node:
                host_osh = None
                address = None
                instance_name_ = None
                if node.is_local():
                    host_osh = context.hostOsh
                    address = context.application.getApplicationIp()
                    instance_name_ = node.instance_name
                else:
                    host = host_base_parser.parse_from_address(node.hostname,
                                     fptools.safeFunc(resolve_ips_fn))
                    if host and host.ips:
                        instance_name_ = node.remote_instance_name
                        address = first(host.ips)
                        host_osh, _, oshs_ = node_reporter.report_host_with_ips(host.ips)
                        context.resultsVector.addAll(oshs_)

                if host_osh:
                    get_port_fn = safeFn(discoverer.get_instance_port_by_node)
                    port = get_port_fn(executor, interpreter, node, db2_home_path=db2_home_path)

                    remote_instance = DatabaseServer(address, port)

                    remote_inst_osh, endpoint_osh, _, vector = reporter.reportServerAndDatabases(remote_instance, host_osh)
                    if instance_name_:
                        SoftwareBuilder.updateName(remote_inst_osh, instance_name_)
                        context.resultsVector.addAll(vector)
                        _, oshs = reporter.reportRemoteDatabases(remote_dbs, local_dbserver_osh, remote_inst_osh)
                        context.resultsVector.addAll(oshs)
                    else:
                        logger.debug('No instance name')
                        if endpoint_osh:
                            context.resultsVector.add(endpoint_osh)
                else:
                    logger.debug('Host is not resolved %s' % node.hostname)
            else:
                logger.debug('No node found with name %s' % nodename)
    def process(self, context):
        r'''
         @types: applications.ApplicationSignatureContext
        '''

        shell = context.client
        language = shell.getOsLanguage().bundlePostfix

        db2_instance_osh = context.application.applicationOsh

        instance_name = self.get_instance_name(context)

        if instance_name:
            db2_home_path = self.get_db2_home_path(context)
            if db2_home_path:
                version = self.get_db2_version(context)

                SoftwareBuilder.updateName(db2_instance_osh, instance_name)
                SoftwareBuilder.updateVersion(db2_instance_osh,
                                              build_version_pdo(version))
                SoftwareBuilder.updateApplciationPath(db2_instance_osh, db2_home_path)

                application_port = self.get_application_port(context)
                if application_port:
                    SoftwareBuilder.updateApplicationPort(db2_instance_osh,
                                                          application_port)

                discoverer = self.get_shell_based_discoverer(context)
                executor = discoverer.get_db2_command_executor(shell)
                interpreter = shell_interpreter.Factory().create(shell)

                base_shell_discoverer.Db2.set_db2_bundle(language)

                self._discover_local_databases(context, instance_name, application_port, db2_home_path, discoverer, executor, interpreter)

                self._discover_remote_databases(context, instance_name, db2_home_path, discoverer, executor, interpreter)

            else:
                logger.debug('No db2 home path found')
        else:
            logger.debug('Failed to discover instance instance_name')