예제 #1
0
def resolveEndpointAddress(resolveAddressFn, endpoint):
    r'@types: (str -> list[str]), Endpoint -> list[Endpoint]'
    endpoints = []
    if sap.createIp(endpoint.getAddress()):
        return [endpoint]
    for ip in resolveAddressFn(endpoint.getAddress()):
        endpoints.append(netutils.updateEndpointAddress(endpoint, ip))
    return endpoints
예제 #2
0
def resolveEndpointAddress(resolveAddressFn, endpoint):
    r'@types: (str -> list[str]), Endpoint -> list[Endpoint]'
    endpoints = []
    if sap.createIp(endpoint.getAddress()):
        return [endpoint]
    for ip in resolveAddressFn(endpoint.getAddress()):
        endpoints.append(netutils.updateEndpointAddress(endpoint, ip))
    return endpoints
예제 #3
0
    def __parse(self, items):
        r'@types: ? -> list[InstanceInfo]'
        servers = []
        for i in xrange(items.getRowCount()):
            name = items.getCell(i, 0)
            logger.debug('server name: %s' % items.getCell(i, 0))
            logger.debug('server hostname: %s' % items.getCell(i, 1))
            logger.debug('server ip: %s' % items.getCell(i, 4))
            try:
                logger.debug("Process server: %s" % name)
                hostname, sid, number = self._decomposeServerName(name)
                # get instance name from start profile path
                startPfPath = items.getCell(i, 9)
                instancePfPath = items.getCell(i, 10)
                instance = self._extractInstanceInfoFromProfilePath(
                    sid, startPfPath or instancePfPath)
                instance = sap.Instance(instance.name,
                                        number,
                                        hostname,
                                        startPfPath=startPfPath,
                                        instancePfPath=instancePfPath)

                sapSystem = sap.System(sid)

                # host-info
                ip = sap.createIp(items.getCell(i, 4))
                hostname = items.getCell(i, 1) or hostname
                address = sap.Address(hostname, (ip, ))
                host = self.Host(address,
                                 osInfo=items.getCell(i, 2),
                                 machineType=items.getCell(i, 3))

                # server-info
                startDate = self._parseStartDate(items.getCell(i, 5))

                versionInfo = sap.VersionInfo(items.getCell(i, 6),
                                              patchLevel=items.getCell(i, 8))

                instanceInfo = self.createInstanceInfo(
                    instance,
                    sapSystem,
                    host,
                    homeDirPath=items.getCell(i, 11),
                    dbLibraryInfo=items.getCell(i, 7),
                    codePage=items.getCell(i, 12),
                    numberOfProcesses=items.getCell(i, 13),
                    versionInfo=versionInfo,
                    startDate=startDate)
                servers.append(instanceInfo)
            except Exception, e:
                logger.warnException("%s. %s" % (name, str(e)))
def _buildCentralServicesPdo(scsInstance, sapSystem):
    r'''
    @types: sap_jee_discoverer.JEEDiscovererByHTTP.ScsInstance, sap.System -> sap_jee.InstanceBuilder.InstancePdo
    @raise ValueError: Host-name of SCS is not discovered
    @raise ValueError: Wrong instance number
    '''
    port = scsInstance.messageServerPort
    hostname = scsInstance.host and scsInstance.host.name
    if not hostname:
        raise ValueError("Host-name of SCS is not discovered")
    number = sap_discoverer.parseInstNrInMsgServerPort(port)
    inst = sap.Instance('SCS', number, hostname=hostname)
    ip = sap.createIp(scsInstance.host.ip)
    return sap_jee.InstanceBuilder.InstancePdo(inst, sapSystem, ip)
예제 #5
0
    def __parse(self, items):
        r'@types: ? -> list[InstanceInfo]'
        servers = []
        for i in xrange(items.getRowCount()):
            name = items.getCell(i, 0)
            logger.debug('server name: %s' % items.getCell(i, 0))
            logger.debug('server hostname: %s' % items.getCell(i, 1))
            logger.debug('server ip: %s' % items.getCell(i, 4))
            try:
                logger.debug("Process server: %s" % name)
                hostname, sid, number = self._decomposeServerName(name)
                # get instance name from start profile path
                startPfPath = items.getCell(i, 9)
                instancePfPath = items.getCell(i, 10)
                instance = self._extractInstanceInfoFromProfilePath(sid,
                            startPfPath or instancePfPath)
                instance = sap.Instance(instance.name, number, hostname,
                                        startPfPath=startPfPath,
                                        instancePfPath=instancePfPath)

                sapSystem = sap.System(sid)

                # host-info
                ip = sap.createIp(items.getCell(i, 4))
                hostname = items.getCell(i, 1) or hostname
                address = sap.Address(hostname, (ip,))
                host = self.Host(address,
                    osInfo=items.getCell(i, 2),
                    machineType=items.getCell(i, 3))

                # server-info
                startDate = self._parseStartDate(items.getCell(i, 5))

                versionInfo = sap.VersionInfo(items.getCell(i, 6),
                                            patchLevel=items.getCell(i, 8))

                instanceInfo = self.createInstanceInfo(
                     instance, sapSystem, host,
                     homeDirPath=items.getCell(i, 11),
                     dbLibraryInfo=items.getCell(i, 7),
                     codePage=items.getCell(i, 12),
                     numberOfProcesses=items.getCell(i, 13),
                     versionInfo=versionInfo,
                     startDate=startDate)
                servers.append(instanceInfo)
            except Exception, e:
                logger.warnException("%s. %s" % (name, str(e)))
예제 #6
0
def reportScsBasedOnMsgPort(system, hostname, msgEndpoints, systemOsh, clusterOsh,
                            enqEndpoints=(), reportName=False):
    r'''
    @param reportName: influence on `name` attribute reporting. In some cases
        composite name attribute may contain not correct host information that
        has impact on reconciliation. Better do not report data we are not
        sure
    @types: sap.System, str, list[Endpoint], osh, list[Endpoint], bool -> oshv
    '''
    vector = ObjectStateHolderVector()
    if not msgEndpoints:
        logger.warn("Failed to discover SCS - no message server information")
        return vector
    ips = (map(netutils.Endpoint.getAddress, msgEndpoints)
         + map(netutils.Endpoint.getAddress, enqEndpoints))
    hostReporter = sap.HostReporter(sap.HostBuilder())
    hostOsh, hVector = hostReporter.reportHostWithIps(*ips)
    vector.addAll(hVector)

    systemOsh.setStringAttribute('data_note', 'This SAP System link to ' + hostOsh.getAttributeValue('host_key'))
    vector.add(systemOsh)

    instIp = sap.createIp(first(ips))

    msgEndpoint = first(msgEndpoints)
    number = sap_discoverer.parseInstNrInMsgServerPort(msgEndpoint.getPort())
    inst = sap.Instance('SCS', number, hostname=hostname)
    pdo = sap_jee.InstanceBuilder.InstancePdo(inst, system, ipAddress=instIp)

    scsBuilder = sap_jee.ScsInstanceBuilder(reportName=reportName)
    instReporter = sap_jee.InstanceReporter(scsBuilder)
    instOsh = instReporter.reportInstancePdo(pdo, hostOsh)
    vector.add(instOsh)

    linkReporter = sap.LinkReporter()
    vector.add(linkReporter.reportMembership(clusterOsh, instOsh))
    vector.add(linkReporter.reportMembership(systemOsh, instOsh))

    for endpoint in (msgEndpoints + enqEndpoints):
        _, eVector = sap._reportEndpointLinkedToSoftware(endpoint,
                                                        hostOsh, instOsh)
        vector.addAll(eVector)
    return vector
예제 #7
0
 def _parseIpAddress(result):
     return sap.createIp(result.getString('IPADRESS'))
def _reportInstance(sapSystem, serverInstance, systemOsh, clusterOsh,
                    sapJeeVersionInfo, knownPortsConfigFile):
    r'''
    @param sapSystem: System
    @param serverInstance: SapJEEMonitoringXmlParser.DialogInstance
    @param sapJeeVersionInfo: JEEDiscovererByHTTP.SapJ2EEVersionInfo
    @rtype: ObjectStateHolderVector
    @raise ValueError:
    '''
    instanceReporter = sap_jee.InstanceReporter(sap_jee.InstanceBuilder())
    serverReporter = sap_jee.ServerReporter(sap_jee.ServerBuilder())
    endpointReporter = netutils.EndpointReporter(netutils.ServiceEndpointBuilder())
    linkReporter = sap.LinkReporter()

    vector = ObjectStateHolderVector()
    ip = serverInstance.host.ip
    hostOsh, _, vector_ = _buildHostAndIpOshs(ip)
    vector.addAll(vector_)

    systemOsh.setStringAttribute('data_note', 'This SAP System link to ' + hostOsh.getAttributeValue('host_key'))
    vector.add(systemOsh)

    instance = _buildJavaInstance(sapSystem, serverInstance)

    instanceOsh = instanceReporter.reportInstancePdo(
            sap_jee.InstanceBuilder.InstancePdo(instance,
                                        sapSystem,
                                        sap.createIp(ip),
                                        sapJeeVersionInfo),
            hostOsh)
    vector.add(instanceOsh)
    vector.add(linkReporter.reportMembership(clusterOsh, instanceOsh))
    vector.add(linkReporter.reportMembership(systemOsh, instanceOsh))

    if serverInstance.dispatcherServer:
        dispatcherProcess = _buildDispatcher(serverInstance.dispatcherServer)
        vector.add(serverReporter.reportServer(dispatcherProcess,
                                               instance,
                                               instanceOsh))

        httpPort = serverInstance.dispatcherServer.httpPort
        p4Port = serverInstance.dispatcherServer.p4Port
        telnetPort = serverInstance.dispatcherServer.telnetPort
        isPortDefined = lambda t: t[1]
        ports = filter(isPortDefined,
                       ((ip,
                         httpPort,
                         knownPortsConfigFile.getTcpPortName(httpPort)),

                        (ip,
                         p4Port,
                         knownPortsConfigFile.getTcpPortName(p4Port)),

                        (ip,
                         telnetPort,
                         knownPortsConfigFile.getTcpPortName(telnetPort))))

        endpoints = map(lambda t: netutils.createTcpEndpoint(*t),
                        ports)

        reportEndpoint = endpointReporter.reportEndpoint
        reportEndpoint = fptools.partiallyApply(reportEndpoint,
                                                fptools._,
                                                hostOsh)

        endpointOshs = map(reportEndpoint, endpoints)
        fptools.each(vector.add, endpointOshs)

        reportUsage = linkReporter.reportUsage
        reportUsage = fptools.partiallyApply(reportUsage,
                                             instanceOsh,
                                             fptools._)

        usageOshs = map(reportUsage, endpointOshs)
        fptools.each(vector.add, usageOshs)

    for serverProcess in serverInstance.serverProcesses:
        serverProcess = _buildServerProcess(serverProcess)
        vector.add(serverReporter.reportServer(serverProcess,
                                               instance,
                                               instanceOsh))
        #note:ek:no debug port reporting for now
    return vector