def __init__(self, module):
        '''
        Constructor
        '''
        guid = generateGUID()
        log.info("Unique ActionBundle execution ID generated: " + guid)

      #  appServer = ApplicationServer(module, scriptGlobals.appsrvProperties)
        pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier)

        bin_path=module.targetDeploymentPath  + "/"  + module.subModule.name +  "/bin/"

        if pid:
            log.error("\n\nAlready existing process running from path '" + module.targetDeploymentPath + "' with pid '" + pid + "'.\n")
        else:
            # Delete all cached directories
            log.info("Proceeding to delete nohup file")
            try:
                    deleteDirOrFile(bin_path + "nohup.out")
            except OSError: # If directory doesn't exist ignore the raised error
                pass

            # Change directory to run the binary from inside the binpath
            pwd = os.getcwd()
            os.chdir(bin_path)
            ChangePathPermissions(bin_path + "start.sh", 0744)
            runProcess("nohup ./start.sh")
            os.chdir(pwd)

            # Construct the email notification
            emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress)
            emailRecipients = module.emailNotificationRecipientList
            emailSubject = "Server START: " + module.subModule.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")"
            emailText = startApplicationServerNotificationTemplate(module.name, getCurrentHostname(), guid)

            # Email all required parties
            SendEmail(emailSender,
                      emailRecipients,
                      emailSubject,
                      emailText,
                      scriptGlobals.smtpHost,
                      scriptGlobals.smtpPort)
Esempio n. 2
0
    # Initialize Pre-Execution Logic
    prelogic = initClassFromStringWithModule(module.preExecutionLogicClass, module)

    # Initialize & Execute ActionBundles
    for actionbundleClass in module.actionBundleGroupClasses[parser.options.action]:
        ab = initClassFromStringWithModule(actionbundleClass, module)

    # Initialize Post-Execution Logic
    postlogic = initClassFromStringWithModule(module.postExecutionLogicClass, module)

    #    import code; code.interact(local=locals())
except (Exception, KeyboardInterrupt):

    # Actions for rollback exist and this is not Rollback mode?
    if (len(scriptGlobals.executedActionList) > 0) and (not type(sys.exc_info()[1]) == RollbackTriggerException):
        log.error(str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1])) 
        answer = getAnswerFromUser(str(sys.exc_info()[0]) + " detected. \n\nSelect your action:\n\n(R) Rollback all actions performed so far \n(<any other key>) Show Exception & Quit")
        if (re.compile('^r$', re.I)).match(answer): rollbackActions(scriptGlobals.executedActionList)
        log.debug("Printing initial exception below")
        log.debug("If you think this error is a bug please file it here: https://jira.velti.com/jira40/browse/FW")
        raise
    # Actions for rollback exist and this is Rollback mode?
    elif (len(scriptGlobals.executedActionList) > 0) and (type(sys.exc_info()[1]) == RollbackTriggerException):
        log.info("Manual rollback mode initiated")
        rollbackActions(scriptGlobals.executedActionList)

    # No Actions for rollback exist        
    else:
        log.error(str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
        log.debug("The executed Action list has 0 elements. Nothing to Rollback.")
        log.debug("Printing initial exception below")