def __resolve(self, policy_server_info): webseal_name, instance_name, host_str, port = policy_server_info endpoints = [] if host_str.lower() == 'localhost': host_str = self.__local_host try: host = host_base_parser.parse_from_address( host_str, self.__dns_resolver.resolve_ips) except: logger.debug('Failed to resolve host %s' % host_str) if host_str.find('.') != -1: logger.debug( 'Host is an FQDN host, will try to resolve host name') host = host_base_parser.parse_from_address( host_str.split('.')[0], self.__dns_resolver.resolve_ips) else: raise ValueError('Failed to resolve WebSeal host.') host = host_base_parser.HostDescriptor(ips=host.ips, name=None, fqdns=[]) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return webseal_topology.WebsealServerBuilder.create_pdo( name=webseal_name, instance_name=instance_name), host, endpoints
def build_webseal_server_pdo(self, webseal_server, dnsresolver): webseal_server, host, port = webseal_server endpoints = [] host = host_base_parser.parse_from_address(host, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) version = self.__parse_version(webseal_server.version) pdo = webseal_topology.WebsealServerBuilder.create_pdo(webseal_server.name, version=version, application_version=webseal_server.version) return pdo, host, endpoints
def build_junction_pdo(self, junction_info, dnsresolver): junction, servers = junction_info junction_server_pdos = [] for server in servers: endpoints = [] host = host_base_parser.parse_from_address(server.hostname, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, server.port) endpoints.append(endpoint) junction_server_pdos.append((host, endpoints)) return junction.name, junction_server_pdos
def build_policy_server_pdo(self, policy_server_info, dnsresolver, local_host): policy_server, host, port = policy_server_info endpoints = [] if host.lower() == 'localhost': host = local_host host = host_base_parser.parse_from_address(host, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return webseal_topology.PolicyServerBuilder.create_pdo(name=policy_server.name), host, endpoints
def handleDiskRow(self, fileSystem, mountedOn, size, usedSize=None): """ @param usedSize: disk used size in 1K-blocks @param size: disk size in 1K-blocks """ if mountedOn in self.mountPointToDisk: logger.reportWarning("File system object already reported for the mount point; skipping new one") logger.warn( "File system object already reported for the mount point '%s'; skipping new one (mount point: '%s'; file system: '%s')" % (mountedOn, mountedOn, fileSystem) ) return if str(size).isdigit(): sizeInMb = _kbToMb(size) else: sizeInMb = None if str(usedSize).isdigit(): usedSizeInMb = _kbToMb(usedSize) else: usedSizeInMb = None type_ = modeling.UNKNOWN_STORAGE_TYPE diskOsh = modeling.createDiskOSH( self.containerOsh, mountedOn, type_, size=sizeInMb, name=fileSystem, usedSize=usedSizeInMb ) if diskOsh: self.mountPointToDisk[mountedOn] = diskOsh self.resultVector.add(diskOsh) host_reporter = host_topology.Reporter() resolver = dns_resolver.create(shell=self.shell) try: (remoteHost, remoteMountPoint) = getRemoteHostAndMountPoint(fileSystem) if remoteHost and remoteMountPoint: if remoteHost.startswith("[") and remoteHost.endswith("]"): remoteHost = remoteHost[1:-1] host_osh = self.remoteHosts.get(remoteHost) if not host_osh: host = host_base_parser.parse_from_address(remoteHost, resolver.resolve_ips) # do not report hostname as it may be alias host_osh, _, oshs = host_reporter.report_host_with_ips(host.ips) self.remoteHosts[remoteHost] = host_osh self.resultVector.addAll(oshs) remoteShareOsh = ObjectStateHolder("networkshare") remoteShareOsh.setContainer(host_osh) remoteShareOsh.setStringAttribute("data_name", remoteMountPoint) remoteShareOsh.setStringAttribute("share_path", remoteMountPoint) self.resultVector.add(remoteShareOsh) self.resultVector.add(modeling.createLinkOSH("realization", remoteShareOsh, diskOsh)) except: stackTrace = logger.prepareFullStackTrace("Failed to link disk to the remote share.") logger.warn(stackTrace)
def __resolve(self, policy_server_info): webseal_name, instance_name, host_str, port = policy_server_info endpoints = [] if host_str.lower() == 'localhost': host_str = self.__local_host try: host = host_base_parser.parse_from_address(host_str, self.__dns_resolver.resolve_ips) except: logger.debug('Failed to resolve host %s' % host_str) if host_str.find('.') != -1: logger.debug('Host is an FQDN host, will try to resolve host name') host = host_base_parser.parse_from_address(host_str.split('.')[0], self.__dns_resolver.resolve_ips) else: raise ValueError('Failed to resolve WebSeal host.') host = host_base_parser.HostDescriptor(ips=host.ips, name=None, fqdns=[]) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return webseal_topology.WebsealServerBuilder.create_pdo(name=webseal_name, instance_name=instance_name), host, endpoints
def build_ldap_pdo(self, ldap_info, dnsresolver): ldap, host, port = ldap_info endpoints = [] if ldap.type == 'remote': host = host_base_parser.parse_from_address(host, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port, PortTypeEnum.LDAP) endpoints.append(endpoint) ldap_pdo = webseal_topology.LdapBuilder.create_pdo() return ldap_pdo, host, endpoints
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 __resolve(self, info): host, port = info endpoints = [] if host.lower() == 'localhost' or host.lower() == 'localhost.localdomain': host = self.__local_host host = host_base_parser.parse_from_address(host, self.__dns_resolver.resolve_ips) host = host_base_parser.HostDescriptor(ips=host.ips, name=None, fqdns=[]) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return (host, endpoints)
def build_policy_server_pdo(self, policy_server_info, dnsresolver, local_host): policy_server, host, port = policy_server_info endpoints = [] if host.lower() == 'localhost': host = local_host host = host_base_parser.parse_from_address(host, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return webseal_topology.PolicyServerBuilder.create_pdo( name=policy_server.name), host, endpoints
def build_webseal_server_pdo(self, webseal_server, dnsresolver): webseal_server, host, port = webseal_server endpoints = [] host = host_base_parser.parse_from_address(host, dnsresolver.resolve_ips) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) version = self.__parse_version(webseal_server.version) pdo = webseal_topology.WebsealServerBuilder.create_pdo( webseal_server.name, version=version, application_version=webseal_server.version) return pdo, host, endpoints
def __resolve(self, info): host, port = info endpoints = [] if host.lower() == 'localhost' or host.lower( ) == 'localhost.localdomain': host = self.__local_host host = host_base_parser.parse_from_address( host, self.__dns_resolver.resolve_ips) host = host_base_parser.HostDescriptor(ips=host.ips, name=None, fqdns=[]) for ip in host.ips: endpoint = netutils.createTcpEndpoint(ip, port) endpoints.append(endpoint) return (host, endpoints)
def handleDiskRow(self, fileSystem, mountedOn, size, usedSize=None): ''' @param usedSize: disk used size in 1K-blocks @param size: disk size in 1K-blocks ''' if mountedOn in self.mountPointToDisk: logger.reportWarning( 'File system object already reported for the mount point; skipping new one' ) logger.warn( "File system object already reported for the mount point '%s'; skipping new one (mount point: '%s'; file system: '%s')" % (mountedOn, mountedOn, fileSystem)) return if str(size).isdigit(): sizeInMb = _kbToMb(size) else: sizeInMb = None if str(usedSize).isdigit(): usedSizeInMb = _kbToMb(usedSize) else: usedSizeInMb = None type_ = modeling.UNKNOWN_STORAGE_TYPE diskOsh = modeling.createDiskOSH(self.containerOsh, mountedOn, type_, size=sizeInMb, name=fileSystem, usedSize=usedSizeInMb) if diskOsh: self.mountPointToDisk[mountedOn] = diskOsh self.resultVector.add(diskOsh) host_reporter = host_topology.Reporter() resolver = dns_resolver.create(shell=self.shell) try: (remoteHost, remoteMountPoint) = getRemoteHostAndMountPoint(fileSystem) if remoteHost and remoteMountPoint: if remoteHost.startswith('[') and remoteHost.endswith(']'): remoteHost = remoteHost[1:-1] host_osh = self.remoteHosts.get(remoteHost) if not host_osh: host = host_base_parser.parse_from_address( remoteHost, resolver.resolve_ips) #do not report hostname as it may be alias host_osh, _, oshs = host_reporter.report_host_with_ips( host.ips) self.remoteHosts[remoteHost] = host_osh self.resultVector.addAll(oshs) remoteShareOsh = ObjectStateHolder('networkshare') remoteShareOsh.setContainer(host_osh) remoteShareOsh.setStringAttribute('data_name', remoteMountPoint) remoteShareOsh.setStringAttribute('share_path', remoteMountPoint) self.resultVector.add(remoteShareOsh) self.resultVector.add( modeling.createLinkOSH('realization', remoteShareOsh, diskOsh)) except: stackTrace = logger.prepareFullStackTrace( 'Failed to link disk to the remote share.') logger.warn(stackTrace)
def buildHostDescriptor(self, address): return host_base_parser.parse_from_address(address, self.__dnsResolver.resolve_ips)
def buildHostDescriptor(self, address): return host_base_parser.parse_from_address( address, self.__dnsResolver.resolve_ips)