def discoverAllInstances(client, config): r''' Can be only applied for discovery by JMX due to deserialization limitatations of WebServices client @types: BaseSapJmxClient, DiscoveryConfig -> oshv''' discoverer = sap_jee_discoverer.ClusterDiscoverer(client) clusterInfo = discoverer.getClusterInfo() cluster = clusterInfo.cluster instances = clusterInfo.instances system = sap.System(cluster.getName()) systemOsh, clusterOsh, vector = _reportSapSystem(system) linkReporter = sap.LinkReporter() ipsPerInst = zip(map(_resolveInstInfoHostname, instances), instances) hasResolvedIps = first endReporter = netutils.EndpointReporter(netutils.ServiceEndpointBuilder()) for ips, instInfo in filter(hasResolvedIps, ipsPerInst): inst = instInfo.instance instOsh, hostOsh, iVector = reportInst(inst, system, systemOsh, clusterOsh, ips, reportInstName=True) vector.addAll(iVector) resolve = sap_jee_discoverer._resolvedEndpointAddress for endp in flatten(keep(resolve, instInfo.endpoints)): endpOsh = endReporter.reportEndpoint(endp, hostOsh) vector.add(endpOsh) vector.add(linkReporter.reportUsage(instOsh, endpOsh)) return vector
def discoverAllInstancesByNamesOnly(client): r''' Can be only applied for discovery by JMX due to deserialization limitatations of WebServices client @types: BaseSapJmxClient, DiscoveryConfig -> tuple[oshv, tuple[str]]''' discoverer = sap_jee_discoverer.ClusterDiscoverer(client) cluster, instanceNames = discoverer.getClusterDetails() parseInst = Sf(_createAnonymousInstFromFullName) insts = keep(parseInst, instanceNames) system = sap.System(cluster.getName()) systemOsh, clusterOsh, vector = _reportSapSystem(system) ipsPerInst = zip(map(_resolveInstHostname, insts), insts) resolved, notResolved = partition(first, ipsPerInst) warnings = () if notResolved: warnings = ("Some instances are not reported " "due to unresolved address",) vectors = (third(reportInst(i, system, systemOsh, clusterOsh, ips)) for ips, i in resolved) each(vector.addAll, vectors) return vector, warnings