Beispiel #1
0
def uninstall(action, distDir, wasRoot):
    log(VERBOSE_, "uninstall: " + action + " " + distDir)
    log(VERBOSE_, "uninstall: " + wasRoot + " ...")

    ############### FIND APPLICATIONS ####################
    applicationModels = getApplications(distDir)
    for applicationModel in applicationModels:
        log(INFO_, "uninstall: Deployment applicationModel=" + `applicationModel.name`)

        ################## PRE-VALIDATE APPLICATIONS (exists) ####################
    PreValidateApplicationsExist(applicationModels)

    ############### CALCULATE AFFECTED NODES ####################
    calculateAffectedNodes(action, wasRoot, applicationModels)

    ################## PRE-VALIDATE NODES and SERVERS ####################
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)
    ValidateSynched(Globals.uniqueNodesContainedServers)

    listApplications()

    #endFor
    for item in Globals.appsNodesServers:
        applicationModel = item[0]
        appExists = checkIfAppExists(applicationModel)
        if appExists:
            StopApplicationOnNodesAndServers(applicationModel, item[1])
            uninstallEAR(applicationModel)
            #endIf
        #endFor

    listApplications()
    configSave()
    for applicationModel in applicationModels:
        log(INFO_, "DONE: uninstall application=" + `applicationModel.name`)
Beispiel #2
0
def syncRippleStartDone(distDir, wasRoot):
    applicationModels = getApplications(distDir, "*.xml.done")
    applicationModels.extend(getApplications(distDir, "*.xml.confirmed"))
    calculateAffectedNodes("update", wasRoot, applicationModels)
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)
    syncRippleStart("update", applicationModels)
    configSave()
def syncRippleStartDone(distDir, wasRoot):
    applicationModels = getApplications(distDir, "*.xml.done")
    applicationModels.extend(getApplications(distDir, "*.xml.confirmed"))
    calculateAffectedNodes("update", wasRoot, applicationModels)
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)
    syncRippleStart("update", applicationModels)
    configSave()
def uninstall(action, distDir, wasRoot):
    log(VERBOSE_, "uninstall: " + action + " " + distDir)
    log(VERBOSE_, "uninstall: " + wasRoot + " ...")

    ############### FIND APPLICATIONS ####################
    applicationModels = getApplications(distDir)
    for applicationModel in applicationModels:
        log(
            INFO_, "uninstall: Deployment applicationModel=" +
            ` applicationModel.name `)

        ################## PRE-VALIDATE APPLICATIONS (exists) ####################
    PreValidateApplicationsExist(applicationModels)

    ############### CALCULATE AFFECTED NODES ####################
    calculateAffectedNodes(action, wasRoot, applicationModels)

    ################## PRE-VALIDATE NODES and SERVERS ####################
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)
    ValidateSynched(Globals.uniqueNodesContainedServers)

    listApplications()

    #endFor
    for item in Globals.appsNodesServers:
        applicationModel = item[0]
        appExists = checkIfAppExists(applicationModel)
        if appExists:
            StopApplicationOnNodesAndServers(applicationModel, item[1])
            uninstallEAR(applicationModel)
            #endIf
        #endFor

    listApplications()
    configSave()
    for applicationModel in applicationModels:
        log(INFO_, "DONE: uninstall application=" + ` applicationModel.name `)
Beispiel #5
0
def installOrUpdate(action, distDir, wasRoot):
    log(VERBOSE_, "installOrUpdate: " + action + " " + distDir)
    log(VERBOSE_, "installOrUpdate: " + wasRoot + " ...")
    applicationModels = getApplications(distDir)
    ################## PRE-VALIDATE Application TARGETS+SETTINGS files ####################
    if action == "install":
        PreValidateApplicationsAbsent(applicationModels)
    else:
        PreValidateApplicationsExist(applicationModels)
        #endElse

    ############### CALCULATE AFFECTED NODES ####################
    calculateAffectedNodes(action, wasRoot, applicationModels)

    ################## PRE-VALIDATE NODES and SERVERS ####################
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)

    ############### PREPARE AFFECTED NODES ####################
    #if ((action == "update")):
    #        Globals.nodesAutosyncs = saveAndDisableAutosync(action, Globals.uniqueNodesContainedServers)
    #        log(INFO_, "installOrUpdate: RESULT: nodesAutosyncs="+`Globals.nodesAutosyncs`)
    #endIf

    ############### INSTALL APPLICATION AND CONFIGURE ####################
    applicationModels = installAndConfigureApps(action, distDir, wasRoot, applicationModels)
    calculateAffectedNodes(action, wasRoot, applicationModels)

    for item in Globals.appsNodesServers:
        for nodeServer in item[1]:
            nodeName = nodeServer.nodeName
            serverName = nodeServer.serverName
            if len(nodeServer.jvmAttributes) > 0:
                jvmAttributes = []
                for jvmAttribute in nodeServer.jvmAttributes:
                    log(INFO_,
                        "jvmAttribute " + nodeName + ":" + serverName + "(" + jvmAttribute.name + ")=" + jvmAttribute.value)
                    jvmAttributes.append([jvmAttribute.name, jvmAttribute.value])
                jvmID = getJvmID(nodeName, serverName)
                modifyJvmAttrs(jvmID, jvmAttributes)

    configSave()

    ################## SYNC NODES (DISTRIBUTE APPS) ####################
    log(MAJOR_, "installOrUpdate: syncRippleStart of affected nodes ...")
    syncRippleStart(action, applicationModels)
    log(MAJOR_, "installOrUpdate: syncRippleStart of affected nodes DONE.")

    ################## START INSTALLED APPLICATIONS ####################
    if action == "install":
        for item in Globals.appsNodesServers:
            applicationModel = item[0]
            StartApplicationOnNodesAndServers(applicationModel, item[1])
            #endFor
        #endIf

    ############### RESTORE AFFECTED NODES ####################
    #if ((action == "update")):
    #        log(DEBUG_, "installOrUpdate: nodesAutosyncs="+`Globals.nodesAutosyncs`)
    #        restoreAutosync(action, Globals.nodesAutosyncs)
    #endIf
    configSave()

    ################## TEST: Skipped for now, only on confirm ##
    testApplication(applicationModels)

    highlight(MAJOR_, "installOrUpdate: DONE.")
def installAndConfigureApps( action, distDir, wasRoot, applicationModels ):
    log(INFO_, "")
    log(MAJOR_, "installAndConfigureApps: applicationModels=" + `applicationModels` + " ...")

    listApplications()
    result = []

    ################ INSTALL (or UPDATE) AND CONFIGURE ##############
    for applicationModel in applicationModels:
        try:
            if applicationModel.file.startswith("/"):
                appPath = applicationModel.file
            else:
                appPath = distDir + "/" + applicationModel.file
            if not validateEAR(appPath):
                continue

            ################ READ APP INSTALL OPTIONS (from .settings) ##############
            installOptions = ""
            for installOption in applicationModel.installOptions:
                installOptions = installOptions + " " + installOption
                ################ INSTALL ##############
            nodeName = ""
            serverName = ""
            if len(applicationModel.servers) > 0:
                appNodeServerPair = applicationModel.servers[0]
                nodeName = appNodeServerPair.nodeName
                serverName = appNodeServerPair.serverName
                #endIf
            clusterName = ""
            if len(applicationModel.clusters) > 0:
                clusterName = applicationModel.clusters[0].clusterName
                #endIf
            if action == "install":
                appExists = checkIfAppExists(applicationModel)
                if appExists:
                    msg = "application=" + applicationModel.name + " EXISTS, CANNOT install with same name"
                    fail(msg)
                    highlight(ERROR_,
                        "application=" + applicationModel.name + " EXISTS, will process SETTINGS and TARGETS")
                else:
                    installEAR(action, appPath, applicationModel, clusterName, nodeName, serverName, installOptions)
                    #endElse
            elif action == "update":
                appExists = checkIfAppExists(applicationModel)
                if appExists:
                    installEAR(action, appPath, applicationModel, clusterName, nodeName, serverName, installOptions)
                else:
                    msg = "application=" + applicationModel.name + " DOES NOT EXIST, will INSTALL instead of UPDATE"
                    log(WARNING_, msg)
                    installEAR("install", appPath, applicationModel, clusterName, nodeName, serverName, installOptions)
                    #endElse
                #endIf

            ################ CONFIG SETTINGS ##############
            applySettings(applicationModel)

            ################ VALIDATE INSTALLED APPLICATION ##############
            validateApplication(applicationModel)
        except AdminException, e:
            log(WARNING_, "AdminException=" + e.message)
            WebSphere.AdminConfig.reset()

        else:
            configSave()
            syslog("info", "successful %s:%s:%s:%s" % (
            action, applicationModel.serviceCall, applicationModel.name, applicationModel.version))
            execScript(applicationModel, "afterInstall")
            os.rename(applicationModel.configFile, applicationModel.configFile + '.done')
            applicationModel.configFile = applicationModel.configFile + '.done'
            result.append(applicationModel)
def installAndConfigureApps(action, distDir, wasRoot, applicationModels):
    log(INFO_, "")
    log(
        MAJOR_, "installAndConfigureApps: applicationModels=" +
        ` applicationModels ` + " ...")

    listApplications()
    result = []

    ################ INSTALL (or UPDATE) AND CONFIGURE ##############
    for applicationModel in applicationModels:
        try:
            if applicationModel.file.startswith("/"):
                appPath = applicationModel.file
            else:
                appPath = distDir + "/" + applicationModel.file
            if not validateEAR(appPath):
                continue

            ################ READ APP INSTALL OPTIONS (from .settings) ##############
            installOptions = ""
            for installOption in applicationModel.installOptions:
                installOptions = installOptions + " " + installOption
                ################ INSTALL ##############
            nodeName = ""
            serverName = ""
            if len(applicationModel.servers) > 0:
                appNodeServerPair = applicationModel.servers[0]
                nodeName = appNodeServerPair.nodeName
                serverName = appNodeServerPair.serverName
                #endIf
            clusterName = ""
            if len(applicationModel.clusters) > 0:
                clusterName = applicationModel.clusters[0].clusterName
                #endIf
            if action == "install":
                appExists = checkIfAppExists(applicationModel)
                if appExists:
                    msg = "application=" + applicationModel.name + " EXISTS, CANNOT install with same name"
                    fail(msg)
                    highlight(
                        ERROR_, "application=" + applicationModel.name +
                        " EXISTS, will process SETTINGS and TARGETS")
                else:
                    installEAR(action, appPath, applicationModel, clusterName,
                               nodeName, serverName, installOptions)
                    #endElse
            elif action == "update":
                appExists = checkIfAppExists(applicationModel)
                if appExists:
                    installEAR(action, appPath, applicationModel, clusterName,
                               nodeName, serverName, installOptions)
                else:
                    msg = "application=" + applicationModel.name + " DOES NOT EXIST, will INSTALL instead of UPDATE"
                    log(WARNING_, msg)
                    installEAR("install", appPath, applicationModel,
                               clusterName, nodeName, serverName,
                               installOptions)
                    #endElse
                #endIf

            ################ CONFIG SETTINGS ##############
            applySettings(applicationModel)

            ################ VALIDATE INSTALLED APPLICATION ##############
            validateApplication(applicationModel)
        except AdminException, e:
            log(WARNING_, "AdminException=" + e.message)
            WebSphere.AdminConfig.reset()

        else:
            configSave()
            syslog(
                "info", "successful %s:%s:%s:%s" %
                (action, applicationModel.serviceCall, applicationModel.name,
                 applicationModel.version))
            execScript(applicationModel, "afterInstall")
            os.rename(applicationModel.configFile,
                      applicationModel.configFile + '.done')
            applicationModel.configFile = applicationModel.configFile + '.done'
            result.append(applicationModel)
def installOrUpdate(action, distDir, wasRoot):
    log(VERBOSE_, "installOrUpdate: " + action + " " + distDir)
    log(VERBOSE_, "installOrUpdate: " + wasRoot + " ...")
    applicationModels = getApplications(distDir)
    ################## PRE-VALIDATE Application TARGETS+SETTINGS files ####################
    if action == "install":
        PreValidateApplicationsAbsent(applicationModels)
    else:
        PreValidateApplicationsExist(applicationModels)
        #endElse

    ############### CALCULATE AFFECTED NODES ####################
    calculateAffectedNodes(action, wasRoot, applicationModels)

    ################## PRE-VALIDATE NODES and SERVERS ####################
    PreValidateNodesAndServers(Globals.uniqueNodesContainedServers)

    ############### PREPARE AFFECTED NODES ####################
    #if ((action == "update")):
    #        Globals.nodesAutosyncs = saveAndDisableAutosync(action, Globals.uniqueNodesContainedServers)
    #        log(INFO_, "installOrUpdate: RESULT: nodesAutosyncs="+`Globals.nodesAutosyncs`)
    #endIf

    ############### INSTALL APPLICATION AND CONFIGURE ####################
    applicationModels = installAndConfigureApps(action, distDir, wasRoot,
                                                applicationModels)
    calculateAffectedNodes(action, wasRoot, applicationModels)

    for item in Globals.appsNodesServers:
        for nodeServer in item[1]:
            nodeName = nodeServer.nodeName
            serverName = nodeServer.serverName
            if len(nodeServer.jvmAttributes) > 0:
                jvmAttributes = []
                for jvmAttribute in nodeServer.jvmAttributes:
                    log(
                        INFO_, "jvmAttribute " + nodeName + ":" + serverName +
                        "(" + jvmAttribute.name + ")=" + jvmAttribute.value)
                    jvmAttributes.append(
                        [jvmAttribute.name, jvmAttribute.value])
                jvmID = getJvmID(nodeName, serverName)
                modifyJvmAttrs(jvmID, jvmAttributes)

    configSave()

    ################## SYNC NODES (DISTRIBUTE APPS) ####################
    log(MAJOR_, "installOrUpdate: syncRippleStart of affected nodes ...")
    syncRippleStart(action, applicationModels)
    log(MAJOR_, "installOrUpdate: syncRippleStart of affected nodes DONE.")

    ################## START INSTALLED APPLICATIONS ####################
    if action == "install":
        for item in Globals.appsNodesServers:
            applicationModel = item[0]
            StartApplicationOnNodesAndServers(applicationModel, item[1])
            #endFor
        #endIf

    ############### RESTORE AFFECTED NODES ####################
    #if ((action == "update")):
    #        log(DEBUG_, "installOrUpdate: nodesAutosyncs="+`Globals.nodesAutosyncs`)
    #        restoreAutosync(action, Globals.nodesAutosyncs)
    #endIf
    configSave()

    ################## TEST: Skipped for now, only on confirm ##
    testApplication(applicationModels)

    highlight(MAJOR_, "installOrUpdate: DONE.")