コード例 #1
0
 def _parseInstFullInformation(self, props):
     r'@types: java.util.Properties -> sap.Instance'
     name = props.get('InstanceName')
     vmParameters = props.get('VmParameters') or ()
     inst = self._parseInst(name, vmParameters)
     if not inst:
         raise ValueError("Failed to parse instance information")
     myName = _findJavaSysParameter(vmParameters, 'SAPMYNAME')
     hostname = None
     if myName:
         _, hostname, _ = sap_discoverer.parseSystemAndInstanceDetails(myName)
     return sap.Instance(inst.getName(), inst.getNumber(), hostname)
コード例 #2
0
def _getDlgInstanceHostname(dlgInstance):
    r'@types: SapJEEMonitoringXmlParser.DialogInstance -> str'
    # very important to report valid hostname, used in instance name attribute
    # composition
    # there are two ways to get hostname
    # o parse it from NAME tag which may contain such values
    #     <inst_name> or <hostname>_<SID>_<NR> (in central instance case)
    # o use hostname from HOST tag
    hostname = dlgInstance.host.name
    name = dlgInstance.name
    try:
        _, hostname, _ = sap_discoverer.parseSystemAndInstanceDetails(name)
    except ValueError:
        pass
    return hostname
コード例 #3
0
 def _parseServerFullName(name):
     '''
     Parse server name of format
     <hostname>_<SID>_<NR>
     @return: tuple of isScs (False), NR, SID, hostname, nodeServerId as None
              or None if doesn't match expected format
     '''
     try:
         # 1)
         result = sap_discoverer.parseSystemAndInstanceDetails(name)
         system, hostname, nr = result
         sid = system.getName()
         isScs = False
         serverNodeId = None
         return isScs, hostname, sid, nr, serverNodeId
     except ValueError:
         pass
コード例 #4
0
 def _parseInstanceInfo(self, item):
     r'@types: Properties -> InstanceInfo'
     hostname = item.get('Host')
     if not hostname:
         raise ValueError("Address is not specified")
     ports = keep(item.get, self.ENDPOINT_NAMES)
     endpoints = [netutils.createTcpEndpoint(hostname, p) for p in ports]
     state = self._parseInstanceState(item.get('State'))
     instName = item.get('Caption')
     fullName = item.get('Name')
     _inst = sap_discoverer.parseInstanceFromName(instName)
     instName = _inst.name
     if fullName:
         details = sap_discoverer.parseSystemAndInstanceDetails(fullName)
         _, hostname, nr = details
     else:
         nr = _inst.number
     instanceWithHostname = sap.Instance(instName, nr, hostname=hostname)
     return self.InstanceInfo(instanceWithHostname, endpoints, state=state)
コード例 #5
0
def discoverBaseTopology(client, config):
    r'@types: BaseSapJmxClient, DiscoveryConfig -> BaseTopology, oshv'
    # x) process input data
    discoverer = sap_jee_discoverer.ClusterDiscoverer(client)
    cluster, instNames = discoverer.getClusterDetails()
    hostname = None
    # in case if there is more than one instance name, we cannot determine
    # which one has to be used as a source to get hostname
    if len(instNames) == 1:
        name = first(instNames)
        _, hostname, _ = sap_discoverer.parseSystemAndInstanceDetails(name)
    userName = Sf(client.getUserName)()

    # report system details, including cluster
    system = sap.System(cluster.getName())
    systemOSH, clusterOSH, vector = _reportSapSystem(system, userName)

    if config.isDevComponentsDiscoverEnabled:
        # discover Java Development Components
        vector.addAll(_discoverDevComponents(client, systemOSH, config))

    # Create the SAP J2EE Central Service
    vector.addAll(_discoverScs(client, system, systemOSH, clusterOSH))
    return BaseTopology(system, hostname, clusterOSH, systemOSH), vector
コード例 #6
0
def _createAnonymousInstFromFullName(name):
    r'@types: str -> sap.Instance'
    _, hostname, nr = sap_discoverer.parseSystemAndInstanceDetails(name)
    return sap.Instance('x', nr, hostname)