Пример #1
0
def addExistingTargets(applicationName, applicationTarget, applicationClusters, applicationServers):
    deployment = WebSphere.AdminConfig.getid("/Deployment:" + applicationName + "/")
    deployedObject = WebSphere.AdminConfig.showAttribute(deployment, "deployedObject")
    modules = wsadminToList(WebSphere.AdminConfig.showAttribute(deployedObject, "modules"))
    clusters = []
    serverNodes = []
    for module in modules:
        targetMappings = wsadminToList(WebSphere.AdminConfig.showAttribute(module, "targetMappings"))
        for targetMapping in targetMappings:
            target = WebSphere.AdminConfig.showAttribute(targetMapping, "target")
            if re.search("#ClusteredTarget", target):
                clusterName = WebSphere.AdminConfig.showAttribute(target, "name")
                if clusterName not in clusters:
                    log(INFO_, "existing clusterName: " + clusterName)
                    clusters.append(clusterName)
            elif re.search("#ServerTarget", target):
                serverName = WebSphere.AdminConfig.showAttribute(target, "name")
                nodeName = WebSphere.AdminConfig.showAttribute(target, "nodeName")
                if [nodeName, serverName] not in serverNodes:
                    log(INFO_, "existing node server: %s:%s" % (nodeName, serverName))
                    serverNodes.append([nodeName, serverName])
    for serverNode in serverNodes:
        if getServerType(serverNode[0], serverNode[1]) == "APPLICATION_SERVER":
            applicationServers.append(ServerApplicationTarget(serverNode[0], serverNode[1], applicationTarget.tests,
                applicationTarget.jvmAttributes))
    for clusterName in clusters:
        clusterTarget = ClusterApplicationTarget(clusterName, applicationTarget.tests, applicationTarget.jvmAttributes)
        clusterTarget.inactiveServers = getInactiveServers(clusterTarget)
        applicationClusters.append(clusterTarget)
Пример #2
0
def addExistingTargets(applicationName, applicationTarget, applicationClusters,
                       applicationServers):
    deployment = WebSphere.AdminConfig.getid("/Deployment:" + applicationName +
                                             "/")
    deployedObject = WebSphere.AdminConfig.showAttribute(
        deployment, "deployedObject")
    modules = wsadminToList(
        WebSphere.AdminConfig.showAttribute(deployedObject, "modules"))
    clusters = []
    serverNodes = []
    for module in modules:
        targetMappings = wsadminToList(
            WebSphere.AdminConfig.showAttribute(module, "targetMappings"))
        for targetMapping in targetMappings:
            target = WebSphere.AdminConfig.showAttribute(
                targetMapping, "target")
            if re.search("#ClusteredTarget", target):
                clusterName = WebSphere.AdminConfig.showAttribute(
                    target, "name")
                if clusterName not in clusters:
                    log(INFO_, "existing clusterName: " + clusterName)
                    clusters.append(clusterName)
            elif re.search("#ServerTarget", target):
                serverName = WebSphere.AdminConfig.showAttribute(
                    target, "name")
                nodeName = WebSphere.AdminConfig.showAttribute(
                    target, "nodeName")
                if [nodeName, serverName] not in serverNodes:
                    log(INFO_,
                        "existing node server: %s:%s" % (nodeName, serverName))
                    serverNodes.append([nodeName, serverName])
    for serverNode in serverNodes:
        if getServerType(serverNode[0], serverNode[1]) == "APPLICATION_SERVER":
            applicationServers.append(
                ServerApplicationTarget(serverNode[0], serverNode[1],
                                        applicationTarget.tests,
                                        applicationTarget.jvmAttributes))
    for clusterName in clusters:
        clusterTarget = ClusterApplicationTarget(
            clusterName, applicationTarget.tests,
            applicationTarget.jvmAttributes)
        clusterTarget.inactiveServers = getInactiveServers(clusterTarget)
        applicationClusters.append(clusterTarget)
def getModuleConfigs(application):
    moduleConfigMap = {}
    lines = WebSphere.AdminApp.listModules(application.name, "-server")
    for moduleLine in lines.split("\n"):
        moduleLine = moduleLine.rstrip() #removes any Windows "\r"
        moduleLineItems = moduleLine.split("#")
        moduleName = moduleLineItems[1].split("+")[0]
        moduleTargets = []
        for moduleTargetId in moduleLineItems[2].split("+"):
            clusterMatch = clusterRegexp.match(moduleTargetId)
            if clusterMatch:
                clusterTarget = ClusterApplicationTarget(clusterMatch.group(1))
                clusterTarget.inactiveServers = getInactiveServers(clusterTarget)
                clusterTarget.tests = []
                cluster_id = WebSphere.AdminConfig.getid("/ServerCluster:" + clusterTarget.clusterName + "/")
                members = WebSphere.AdminConfig.list("ClusterMember", cluster_id)
                members = wsadminToList(members)
                for member in members:
                    node = WebSphere.AdminConfig.showAttribute(member, "nodeName")
                    server = WebSphere.AdminConfig.showAttribute(member, "memberName")
                    log(DEBUG_,
                        "getNodeServerPairs: cluster=" + clusterTarget.clusterName + " contains node=" + node + " server=" + server)
                    inactive = 0
                    for inactiveServer in clusterTarget.inactiveServers:
                        if (node, server) == (inactiveServer.nodeName, inactiveServer.serverName):
                            inactive = 1
                    if not inactive:
                        nodeObj = WebSphere.AdminConfig.getid('/Cell:/Node:%s/' % node)
                        nodeHostName = WebSphere.AdminConfig.showAttribute(nodeObj, 'hostName')
                        defaultPort = getDefaultPort(node, server)
                        url = 'http://%s:%s/' % (nodeHostName, defaultPort)
                        clusterTarget.tests.append(ApplicationTargetTest(url, application.version))
                        if not node in nodeSyncStatus.keys():
                            nodeSync = WebSphere.AdminControl.completeObjectName("type=NodeSync,node=%s,*" % node)
                            nodeSyncStatus[node] = WebSphere.AdminControl.invoke(nodeSync, "isNodeSynchronized")
                moduleTargets.append(clusterTarget)
            else:
                nodeServerMatch = nodeServerRegexp.match(moduleTargetId)
                if nodeServerMatch:
                    serverTarget = ServerApplicationTarget(nodeServerMatch.group(1), nodeServerMatch.group(2))
                    #nodeObj=WebSphere.AdminConfig.getid('/Cell:/Node:%s/'%serverTarget.nodeName)
                    #nodeHostName=WebSphere.AdminConfig.showAttribute(nodeObj, 'hostName')
                    defaultPort = getDefaultPort(serverTarget.nodeName, serverTarget.serverName)
                    if defaultPort.endswith("43"):
                        url = 'https://%s:%s/' % (serverTarget.nodeName, defaultPort)
                    else:
                        url = 'http://%s:%s/' % (serverTarget.nodeName, defaultPort)

                    serverTarget.tests = [ApplicationTargetTest(url, application.version)]
                    moduleTargets.append(serverTarget)
        attributes = []
        for attributeKey in ["classloaderMode", "startingWeight",
                             "WebModuleConfig.sessionManagement.defaultCookieSettings.name",
                             "WebModuleConfig.sessionManagement.defaultCookieSettings.path",
                             "WebModuleConfig.sessionManagement.enable"]:
            attr = showAttribute(moduleName, "Module", attributeKey, application.name)
            if attr:
                attributes.append((attributeKey, attr))
        moduleConfigMap[moduleName] = {"targets": moduleTargets, "attributes": attributes}

    applicationAttributes = []
    for attributeKey in ["classloader.mode", "warClassLoaderPolicy",
                         "ApplicationConfig.sessionManagement.defaultCookieSettings.name",
                         "ApplicationConfig.sessionManagement.defaultCookieSettings.path",
                         "ApplicationConfig.sessionManagement.enable"]:
        attr = showAttribute(application.name, "Application", attributeKey, application.name)
        if attr:
            applicationAttributes.append((attributeKey, attr))
    return moduleConfigMap, applicationAttributes
def getModuleConfigs(application):
    moduleConfigMap = {}
    lines = WebSphere.AdminApp.listModules(application.name, "-server")
    for moduleLine in lines.split("\n"):
        moduleLine = moduleLine.rstrip()  #removes any Windows "\r"
        moduleLineItems = moduleLine.split("#")
        moduleName = moduleLineItems[1].split("+")[0]
        moduleTargets = []
        for moduleTargetId in moduleLineItems[2].split("+"):
            clusterMatch = clusterRegexp.match(moduleTargetId)
            if clusterMatch:
                clusterTarget = ClusterApplicationTarget(clusterMatch.group(1))
                clusterTarget.inactiveServers = getInactiveServers(
                    clusterTarget)
                clusterTarget.tests = []
                cluster_id = WebSphere.AdminConfig.getid(
                    "/ServerCluster:" + clusterTarget.clusterName + "/")
                members = WebSphere.AdminConfig.list("ClusterMember",
                                                     cluster_id)
                members = wsadminToList(members)
                for member in members:
                    node = WebSphere.AdminConfig.showAttribute(
                        member, "nodeName")
                    server = WebSphere.AdminConfig.showAttribute(
                        member, "memberName")
                    log(
                        DEBUG_, "getNodeServerPairs: cluster=" +
                        clusterTarget.clusterName + " contains node=" + node +
                        " server=" + server)
                    inactive = 0
                    for inactiveServer in clusterTarget.inactiveServers:
                        if (node, server) == (inactiveServer.nodeName,
                                              inactiveServer.serverName):
                            inactive = 1
                    if not inactive:
                        nodeObj = WebSphere.AdminConfig.getid(
                            '/Cell:/Node:%s/' % node)
                        nodeHostName = WebSphere.AdminConfig.showAttribute(
                            nodeObj, 'hostName')
                        defaultPort = getDefaultPort(node, server)
                        url = 'http://%s:%s/' % (nodeHostName, defaultPort)
                        clusterTarget.tests.append(
                            ApplicationTargetTest(url, application.version))
                        if not node in nodeSyncStatus.keys():
                            nodeSync = WebSphere.AdminControl.completeObjectName(
                                "type=NodeSync,node=%s,*" % node)
                            nodeSyncStatus[
                                node] = WebSphere.AdminControl.invoke(
                                    nodeSync, "isNodeSynchronized")
                moduleTargets.append(clusterTarget)
            else:
                nodeServerMatch = nodeServerRegexp.match(moduleTargetId)
                if nodeServerMatch:
                    serverTarget = ServerApplicationTarget(
                        nodeServerMatch.group(1), nodeServerMatch.group(2))
                    #nodeObj=WebSphere.AdminConfig.getid('/Cell:/Node:%s/'%serverTarget.nodeName)
                    #nodeHostName=WebSphere.AdminConfig.showAttribute(nodeObj, 'hostName')
                    defaultPort = getDefaultPort(serverTarget.nodeName,
                                                 serverTarget.serverName)
                    if defaultPort.endswith("43"):
                        url = 'https://%s:%s/' % (serverTarget.nodeName,
                                                  defaultPort)
                    else:
                        url = 'http://%s:%s/' % (serverTarget.nodeName,
                                                 defaultPort)

                    serverTarget.tests = [
                        ApplicationTargetTest(url, application.version)
                    ]
                    moduleTargets.append(serverTarget)
        attributes = []
        for attributeKey in [
                "classloaderMode", "startingWeight",
                "WebModuleConfig.sessionManagement.defaultCookieSettings.name",
                "WebModuleConfig.sessionManagement.defaultCookieSettings.path",
                "WebModuleConfig.sessionManagement.enable"
        ]:
            attr = showAttribute(moduleName, "Module", attributeKey,
                                 application.name)
            if attr:
                attributes.append((attributeKey, attr))
        moduleConfigMap[moduleName] = {
            "targets": moduleTargets,
            "attributes": attributes
        }

    applicationAttributes = []
    for attributeKey in [
            "classloader.mode", "warClassLoaderPolicy",
            "ApplicationConfig.sessionManagement.defaultCookieSettings.name",
            "ApplicationConfig.sessionManagement.defaultCookieSettings.path",
            "ApplicationConfig.sessionManagement.enable"
    ]:
        attr = showAttribute(application.name, "Application", attributeKey,
                             application.name)
        if attr:
            applicationAttributes.append((attributeKey, attr))
    return moduleConfigMap, applicationAttributes