def __init__(self, module):
        '''
        Constructor
        '''
        
        ActionBundle.__init__(self, module)
  
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath):die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")    
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()    
        log.info("Unique ActionBundle execution ID generated: " + guid)    

        unzippedPackagePath = module.subModule.unzippedPackagePath

        # Import Clean DB script to Postgres DB
        dbUsername = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_OWNER", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_PASSWORD", module.name, lib.OptParser.options.envprops)
        dbHostName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_HOSTNAME", module.name, lib.OptParser.options.envprops)
        dbName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_NAME", module.name, lib.OptParser.options.envprops)
        dbPort = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_PORT", module.name, lib.OptParser.options.envprops)
        tmpC = "jdbc:postgresql://" + dbHostName + ":" + dbPort + "/" + dbName
        
        
        
        # Find version/revision info
        versionInfo = grepFile(module.versionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF")
        revisionInfo = grepFile(module.revisionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF")
        
        versionInfo = (versionInfo.replace(module.versionInformationRegex, "")).strip()
        revisionInfo = (revisionInfo.replace(module.revisionInformationRegex, "")).strip()

        # Determine last executed script in DB
        dbUsername = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_OWNER", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_PASSWORD", module.name, lib.OptParser.options.envprops)
        dbHostName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_HOSTNAME", module.name, lib.OptParser.options.envprops)
        dbName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_NAME", module.name, lib.OptParser.options.envprops)
        dbPort = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_PORT", module.name, lib.OptParser.options.envprops)
        tmpC = "jdbc:postgresql://" + dbHostName + ":" + dbPort + "/" + dbName
        result = runPostgresScript("SELECT EXECUTED_SCRIPT FROM FIREWORKS_SCRIPT_LOG WHERE EXECUTED_ON IN (SELECT MAX(EXECUTED_ON) FROM FIREWORKS_SCRIPT_LOG);", dbUsername, dbPassword, tmpC)
        lastExecutedPath, lastExecutedFilename = os.path.split(result.strip());
        log.info("According to log table, the last script executed on '" + tmpC + "' was '" + lastExecutedFilename + "'")
        
        # Run scripts on DB
        ls = os.listdir(unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath)
        ls.sort()
        found = False
        for patch in ls:
            if found: 
                #Replace Owner
                exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath + scriptGlobals.osDirSeparator + patch
                ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
                CheckFileConfigurationIsComplete(exactExtractedLocation)
                #Run Script
                RunPostgresScriptFromFile(unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath + scriptGlobals.osDirSeparator + patch, dbUsername, dbPassword, tmpC)
                # Log executed scripts                
                RunPostgresScript("INSERT INTO FIREWORKS_SCRIPT_LOG (INSTALLATION_ID, ACTION, MODULE_NAME, MODULE_VERSION, MODULE_REVISION, EXECUTED_SCRIPT, EXECUTED_ON) VALUES ('" + guid + "', '" + lib.OptParser.options.action + "', '" + module.name + "', '" + versionInfo + "', '" + revisionInfo + "', '" + patch + "', CURRENT_TIMESTAMP);", dbUsername, dbPassword, tmpC)                
            if  lastExecutedFilename.find(patch) > -1: found = True
 def __init__(self, moduleFileName, modulePropertiesFilename, environmentPropertiesFilename ):
     '''
     Constructor
     '''
 
     self.moduleFilename = moduleFileName
     self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     self.relativeWarPath = readPropertyFromPropertiesFile("relativeWarPath", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     self.relativeJarFilesPath = readPropertyFromPropertiesFile("relativeJarFilesPath", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
    def __init__(self, module):
        '''
        Constructor
        '''
        
        ActionBundle.__init__(self, module)
  
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath):die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")    
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()    
        log.info("Unique ActionBundle execution ID generated: " + guid)    

        unzippedPackagePath = module.subModule.unzippedPackagePath

        # Import Clean DB script to Postgres DB
        dbUsername = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_OWNER", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_PASSWORD", module.name, lib.OptParser.options.envprops)
        dbHostName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_HOSTNAME", module.name, lib.OptParser.options.envprops)
        dbName = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_DB_NAME", module.name, lib.OptParser.options.envprops)
        dbPort = readPropertyFromPropertiesFile("TARGET_POSTGRES_SRV_PORT", module.name, lib.OptParser.options.envprops)
        tmpC = "jdbc:postgresql://" + dbHostName + ":" + dbPort + "/" + dbName
        
        # Run DB init script(s)
        for dbInitScript in module.relativeDatabaseInitFiles:
            # Replace Owner on init scripts             
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + dbInitScript
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
            RunPostgresScriptFromFile(unzippedPackagePath + scriptGlobals.osDirSeparator + dbInitScript, dbUsername, dbPassword, tmpC)
            
        # Replace Owner on postgresLogTemplate            
        ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, scriptGlobals.postgresLogTemplateFile)
        # Add LOG table
        RunPostgresScriptFromFile(scriptGlobals.postgresLogTemplateFile, dbUsername, dbPassword, tmpC)
        
        # Find version/revision info
        versionInfo = grepFile(module.versionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF")
        revisionInfo = grepFile(module.revisionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF")
        
        versionInfo = (versionInfo.replace(module.versionInformationRegex, "")).strip()
        revisionInfo = (revisionInfo.replace(module.revisionInformationRegex, "")).strip()

        # Add one row per script executed in LOG table        
        for dbInitScript in module.relativeDatabaseInitFiles:
            lastExecutedPath, lastExecutedFilename = os.path.split(dbInitScript) 
            RunPostgresScript("INSERT INTO FIREWORKS_SCRIPT_LOG (INSTALLATION_ID, ACTION, MODULE_NAME, MODULE_VERSION, MODULE_REVISION, EXECUTED_SCRIPT, EXECUTED_ON) VALUES ('" + guid + "', '" + lib.OptParser.options.action + "', '" + module.name + "', '" + versionInfo + "', '" + revisionInfo + "', '" + lastExecutedFilename + "', CURRENT_TIMESTAMP);", dbUsername, dbPassword, tmpC)        

        # Already existing upgrade scripts must be logged because in the upcoming upgrade we need to run from there on
        log.info("Existing SQL patches will be logged in the log table so that the script will not run them again if you decise to update this version to latest")
        ls = os.listdir(unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath)
        ls.sort()
        for patch in ls:               
            RunPostgresScript("INSERT INTO FIREWORKS_SCRIPT_LOG (INSTALLATION_ID, ACTION, MODULE_NAME, MODULE_VERSION, MODULE_REVISION, EXECUTED_SCRIPT, EXECUTED_ON) VALUES ('" + guid + "', '" + lib.OptParser.options.action + "', '" + module.name + "', '" + versionInfo + "', '" + revisionInfo + "', '" + patch + "', CURRENT_TIMESTAMP);", dbUsername, dbPassword, tmpC)                
Пример #4
0
    def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename):
        '''
        Constructor
        '''
        self.moduleFilename = moduleFilename
        self.name = readPropertyFromPropertiesFile("subModuleName", scriptGlobals.moduleSectionName, modulePropertiesFilename)
        self.launchType = readPropertyFromPropertiesFile("launchType", scriptGlobals.moduleSectionName, modulePropertiesFilename)
        self.processIdentifier = readPropertyFromPropertiesFile("processIdentifier",  scriptGlobals.moduleSectionName, modulePropertiesFilename)
        self.installUpdateScript = readPropertyFromPropertiesFile("installUpdateScript",  scriptGlobals.moduleSectionName, modulePropertiesFilename)
        Module.buildInformationRegex = readPropertyFromPropertiesFile("buildInformationRegex", scriptGlobals.moduleSectionName, modulePropertiesFilename)

        log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
    def __init__(self, moduleFileName, modulePropertiesFilename, environmentPropertiesFilename ):
        '''
        Constructor
        '''
    
        self.moduleFilename = moduleFileName
        self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)
        self.relativeWarPath = readPropertyFromPropertiesFile("relativeWarPath", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.absolutCopyableFilesOrFolders = readPropertyFromPropertiesFile("absolutCopyableFilesOrFolders", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.absolutCopyableFilesOrFolders = dict(item.split("=") for item in self.absolutCopyableFilesOrFolders.split(";"))
     
        log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
Пример #6
0
    def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename):
        '''
        Constructor
        '''
        self.moduleFilename = moduleFilename
        self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)        
        self.CMSHost = readPropertyFromPropertiesFile("VNACmsHost", self.name, environmentPropertiesFilename)
        self.CMSPort = readPropertyFromPropertiesFile("VNACmsPort", self.name, environmentPropertiesFilename)
        self.CMSUser = readPropertyFromPropertiesFile("VNACmsUser", self.name, environmentPropertiesFilename)
        self.CMSStructureFilename = readPropertyFromPropertiesFile("CMSStructureFilename", scriptGlobals.moduleSectionName, modulePropertiesFilename)
        

        
                
        
        log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
    def __init__(self, module, applicationServerPropertiesFilename):
        '''
        Constructor
        '''

        if module.launchType != "standalone":
            self.appServerName = module.launchType
            self.startCommand = readPropertyFromPropertiesFile("startCommand", self.appServerName, applicationServerPropertiesFilename)
            self.shutdownCommand = readPropertyFromPropertiesFile("shutdownCommand", self.appServerName, applicationServerPropertiesFilename)
            self.binPath = readPropertyFromPropertiesFile("binPath", self.appServerName, applicationServerPropertiesFilename)
            self.configurationLocation = readPropertyFromPropertiesFile("configurationLocation", self.appServerName, applicationServerPropertiesFilename)
            self.deployLocation = readPropertyFromPropertiesFile("deployLocation", self.appServerName, applicationServerPropertiesFilename)
            self.relativeCacheFolders = readPropertyFromPropertiesFile("relativeCacheFolders", self.appServerName, applicationServerPropertiesFilename)
            self.processIdentifier = readPropertyFromPropertiesFile("processIdentifier", self.appServerName, applicationServerPropertiesFilename)
        else:
            self.processIdentifier = module.subModule.processIdentifier
            self.appServerName = module.subModule.name

        # Custom JBOSS profile requested by my friend Chris Skopelitis :-)
        if self.appServerName == "jboss": 
            profile = module.targetDeploymentProfile
            self.deployLocation = self.deployLocation % (profile)
            self.configurationLocation = self.configurationLocation % (profile)  
            self.relativeCacheFolders = sprintfOnListValues(self.relativeCacheFolders.split(","), profile)

        log.info("ApplicationServer '" + self.appServerName + "' class initialized using '" + applicationServerPropertiesFilename + "' conf file")
    def __init__(self, module):
        '''
        Constructor
        '''
        ActionBundle.__init__(self, module)
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()
        log.info("Unique ActionBundle execution ID generated: " + guid)
        
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath): die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")        
        
        # Prepare directory to unpack package
        unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage")
        
        # Since Builder is deployed on JBOSS some paths have an %s to allow a configurable 
        # profile, so do a little sprintf to fix them
        sprintfOnDictionaryValues(module.relativeConfigurationFiles, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(module.relativeCopyableFilesOrFolders, module.targetDeploymentProfile)
        sprintfOnListValues(module.subModule.relativeCleanUpFiles, module.targetDeploymentProfile)
        
        # Extract Builder package into tmp dir
        ExtractZipToDir(module.moduleFilename, unzippedPackagePath)
        
    
        # Do this again in case new settings have been added
        # Configure m-web-builder.properties using envprops
        # Configure mgage.properties using envprops
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        
        # Copy m-web-builder.properties to conf
        # Copy mgage.properties to conf
        # Copy jboss-log4j.xml to conf
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)       

        # Clean up files that might have been left over from previous manuall installations
        cleanUp(module)
        
        # Copy artifacts to profile
        for k, v in module.relativeCopyableFilesOrFolders.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
                
        # Install Plugins    
        staticFolder = readPropertyFromPropertiesFile("STATIC_FOLDER", module.name, lib.OptParser.options.envprops)  
        installDefaultPlugins(staticFolder, unzippedPackagePath, module)
def extractOracleDatabaseCredentials(
    moduleName, envprops, usernameFieldName, passwordFieldName, connectionStringFieldName
):
    # Import Clean DB script to Oracle DB
    dbUsername = readPropertyFromPropertiesFile(usernameFieldName, moduleName, envprops)
    dbPassword = readPropertyFromPropertiesFile(passwordFieldName, moduleName, envprops)

    tmpC = readPropertyFromPropertiesFile(connectionStringFieldName, moduleName, envprops)

    # If string is Clustered string
    if tmpC.lower().find("description") > 0:
        dbConnectionString = tmpC
    else:
        dbHost = tmpC[0 : tmpC.find(":")]
        dbPort = tmpC[tmpC.find(":") + 1 : tmpC.rfind(":")]
        dbSID = tmpC[tmpC.rfind(":") + 1 : len(tmpC)]
        dbConnectionString = (
            "(DESCRIPTION=(LOAD_BALANCE=yes)(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SID=%s)))"
            % (dbHost, dbPort, dbSID)
        )

    return (dbUsername, dbPassword, dbConnectionString)
Пример #10
0
 def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename):
     '''
     Constructor
     '''
     self.moduleFilename = moduleFilename
     self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)        
     self.targetDeploymentPath = readPropertyFromPropertiesFile("TARGET_DEPLOYMENT_PATH", self.name, environmentPropertiesFilename)
     self.targetDeploymentProfile = readPropertyFromPropertiesFile("TARGET_DEPLOYMENT_PROFILE", self.name, environmentPropertiesFilename)        
     self.euclidConfigDir = readPropertyFromPropertiesFile("EUCLID_CONFIG_DIR", self.name, environmentPropertiesFilename)
     
     self.relativeMergableConfigurationFiles = readPropertyFromPropertiesFile("relativeMergableConfigurationFiles", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     self.relativeMergableConfigurationFiles = dict(item.split("=") for item in self.relativeMergableConfigurationFiles.split(";") if len(item)>0)
     
     self.relativeWarsToBeExploded = readPropertyFromPropertiesFile("relativeWarsToBeExploded", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     self.relativeWarsToBeExploded = dict(item.split("=") for item in self.relativeWarsToBeExploded.split(";") if len(item)>0)
     
     self.relativeDatabaseUpgrateDescriptionFilePath = readPropertyFromPropertiesFile("relativeDatabaseUpgrateDescriptionFilePath", scriptGlobals.moduleSectionName, modulePropertiesFilename)
      
     log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
Пример #11
0
 def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename):
     '''
     Constructor
     '''
     self.moduleFilename = moduleFilename
     self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     
     self.pluginBinaries = readPropertyFromPropertiesFile("pluginBinaries", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     
     pl=readPropertyFromPropertiesFile("pluginNames", scriptGlobals.moduleSectionName, modulePropertiesFilename) 
     self.pluginList = pl.split(",")
                 
     self.pluginInstalledModulesFolder = readPropertyFromPropertiesFile("pluginInstalledModulesFolder", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     
     self.pluginInstallationFolder = readPropertyFromPropertiesFile("pluginInstallationFolder", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     
     rCF = readPropertyFromPropertiesFile("relativeCleanUpFiles", scriptGlobals.moduleSectionName, modulePropertiesFilename)
     self.relativeCleanUpFiles = rCF.split(",")     
                      
     log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
Пример #12
0
    def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename):
        '''
        Constructor
        '''
        self.moduleFilename = moduleFilename
        self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename)        
        self.subModule = initModuleClassFromString(readPropertyFromPropertiesFile("moduleClass", scriptGlobals.moduleSectionName, modulePropertiesFilename), self.moduleFilename, modulePropertiesFilename, environmentPropertiesFilename)        
        self.launchType = readPropertyFromPropertiesFile("launchType", scriptGlobals.moduleSectionName, modulePropertiesFilename)

        self.preExecutionLogicClass = readPropertyFromPropertiesFileWithFallback("preExecutionLogicClass", scriptGlobals.moduleSectionName, modulePropertiesFilename, "preexeclogic.GenericPreExecLogic.GenericPreExecLogic")
        self.postExecutionLogicClass = readPropertyFromPropertiesFileWithFallback("postExecutionLogicClass", scriptGlobals.moduleSectionName, modulePropertiesFilename, "postexeclogic.GenericPostExecLogic.GenericPostExecLogic")

#        self.moduleCleanAB = readPropertyFromPropertiesFile("moduleCleanAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleUpdateAB = readPropertyFromPropertiesFile("moduleUpdateAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleStartAB = readPropertyFromPropertiesFile("moduleStartAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleStopAB = readPropertyFromPropertiesFile("moduleStopAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleRestartAB = readPropertyFromPropertiesFile("moduleRestartAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleKillAB = readPropertyFromPropertiesFile("moduleKillAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleStatusAB = readPropertyFromPropertiesFile("moduleStatusAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleInfoAB = readPropertyFromPropertiesFile("moduleInfoAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleLogAB = readPropertyFromPropertiesFile("moduleLogAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)
#        self.moduleRollbackAB = readPropertyFromPropertiesFileWithFallback("moduleRollbackAB", scriptGlobals.moduleSectionName, modulePropertiesFilename, "actionbundles.GenericActionBundles.GenericRollbackAB")
#        self.moduleDebugAB = readPropertyFromPropertiesFile("moduleDebugAB", scriptGlobals.moduleSectionName, modulePropertiesFilename)

        self._actionBundleGroupWrappers = eval(readPropertyFromPropertiesFile("actionBundleGroupWrappers", scriptGlobals.moduleSectionName, modulePropertiesFilename))

        # Create internal actionbundle class structure
        self.actionBundleGroupClasses = {}

        # Using actionBundleGroupClasses create an internal dictionary with nested lists called actionBundleGroupClasses
        # For each action wrapper
        for k, v in self._actionBundleGroupWrappers.items():
            self.actionBundleGroupClasses[k] = []
            vs = v.split(",")
            for i in vs:
                # If value isnt empty then proceed
                if not i.strip() == '':
                    print "i is '" + i + "' "
                    # get python classnames that will be instantiated
                    className = readPropertyFromPropertiesFile(i.strip(), scriptGlobals.moduleSectionName, modulePropertiesFilename)
                    self.actionBundleGroupClasses[k].append(className)


        # File/Folder locations
        self._locations = eval(readPropertyFromPropertiesFile("locations", scriptGlobals.moduleSectionName, modulePropertiesFilename))

        self.relativeConfigurationFiles         = self._locations['relativeConfigurationFiles']
        self.relativeCopyableFilesOrFolders     = self._locations['relativeCopyableFilesOrFolders']
        self.relativeBackupOnlyFilesOrFolders   = self._locations['relativeBackupOnlyFilesOrFolders']
        self.relativeDatabaseInitFiles          = (self._locations['relativeDatabaseInitFiles']).split(',')
        self.relativeDatabaseUpgradeFilePath    = self._locations['relativeDatabaseUpgradeFilePath']
        self.relativeVersionInformationPath     = self._locations['relativeVersionInformationPath']
        self.relativeLogFilePath                = self._locations['relativeLogFilePath']
        self.relativeModulePropertiesPath       = self._locations['relativeModulePropertiesPath']

        self.versionInformationRegex = readPropertyFromPropertiesFile("versionInformationRegex", scriptGlobals.moduleSectionName, modulePropertiesFilename)
        self.revisionInformationRegex = readPropertyFromPropertiesFile("revisionInformationRegex", scriptGlobals.moduleSectionName, modulePropertiesFilename)        


        self.targetDeploymentPath = readPropertyFromPropertiesFile("TARGET_DEPLOYMENT_PATH", self.name, environmentPropertiesFilename)
        self.targetDeploymentProfile = readPropertyFromPropertiesFile("TARGET_DEPLOYMENT_PROFILE", self.name, environmentPropertiesFilename)        
        self.emailNotificationRecipientList = readPropertyFromPropertiesFileWithFallback("EMAIL_NOTIFICATION_RECIPIENT_LIST", self.name, environmentPropertiesFilename, "").split(",")
        self.friendlyServerName = readPropertyFromPropertiesFileWithFallback("FRIENDLY_SERVER_NAME", self.name, environmentPropertiesFilename, "n/a")
        
        self.executionContext = {}

        log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
Пример #13
0
    def __init__(self, module):
        """
        Constructor
        """
        # Initialize application server object
        appServer = ApplicationServer(module, scriptGlobals.appsrvProperties)

        # Check if JBOSS is running
        if getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, appServer.processIdentifier):
            die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")

        # Since CRM is deployed on JBOSS some paths have an %s to allow a configurable
        # profile, so do a little sprintf to fix them
        sprintfOnDictionaryValues(module.relativeConfigurationFiles, module.targetDeploymentProfile)
        sprintfOnDictionaryValues(module.relativeCopyableFilesOrFolders, module.targetDeploymentProfile)

        # Prepare directory to keep backups
        previousVersionBackupPath = createDirectoriesRecursively(
            scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "previousVersionBackup"
        )

        # Backup crm-deployment.properties from conf
        # Backup mgage.properties from conf
        # Backup jboss-log4j.xml from conf
        for k, v in module.relativeConfigurationFiles.items():
            exactLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
            exactBackupLocation = previousVersionBackupPath + scriptGlobals.osDirSeparator + k
            copyDirOrFile(exactLocation, exactBackupLocation)  # we do not to have do/undo actions for such operation

        # Backup crm-dtds from docs/dtd
        # Backup crm.war from deploy
        # Backup esb.jar from deploy/
        # Backup ROOT.WAR/crossdmain.xml from deploy/ROOT.WAR
        for k, v in module.relativeCopyableFilesOrFolders.items():
            exactLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
            exactBackupLocation = previousVersionBackupPath + scriptGlobals.osDirSeparator + k
            copyDirOrFile(exactLocation, exactBackupLocation)  # we do not to have do/undo actions for such operation

        # Prepare directory to unpack package
        unzippedPackagePath = createDirectoriesRecursively(
            scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage"
        )

        # Extract CRM package into tmp dir
        ExtractZipToDir(module.moduleFilename, unzippedPackagePath)

        # Determine last executed script in DB
        dbUsername = readPropertyFromPropertiesFile("VNA_CRM_USERNAMEBASE", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("VNA_CRM_PASSWORDBASE", module.name, lib.OptParser.options.envprops)

        tmpC = readPropertyFromPropertiesFile("DBConnectionString", module.name, lib.OptParser.options.envprops)

        # If string is Clustered string
        if tmpC.lower().find("description") > 0:
            dbConnectionString = tmpC
        else:
            dbHost = tmpC[0 : tmpC.find(":")]
            dbPort = tmpC[tmpC.find(":") + 1 : tmpC.rfind(":")]
            dbSID = tmpC[tmpC.rfind(":") + 1 : len(tmpC)]
            dbConnectionString = (
                "(DESCRIPTION=(LOAD_BALANCE=yes)(ADDRESS=(PROTOCOL=TCP)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SID=%s)))"
                % (dbHost, dbPort, dbSID)
            )

        finalConnectionString = "%s/%s@%s" % (dbUsername, dbPassword, dbConnectionString)

        result = runOracleScript(
            "SELECT EXECUTED_SCRIPT FROM FIREWORKS_SCRIPT_LOG WHERE EXECUTED_ON IN (SELECT MAX(EXECUTED_ON) FROM FIREWORKS_SCRIPT_LOG);",
            finalConnectionString,
            False,
            True,
        )
        lastExecutedPath, lastExecutedFilename = os.path.split(result.strip())

        currentVersion = grepFile(
            module.versionInformationRegex,
            previousVersionBackupPath + scriptGlobals.osDirSeparator + module.relativeVersionInformationPath,
        )
        newVersion = grepFile(
            module.versionInformationRegex,
            unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeVersionInformationPath,
        )
        currentRevision = grepFile(
            module.revisionInformationRegex,
            previousVersionBackupPath + scriptGlobals.osDirSeparator + module.relativeVersionInformationPath,
        )
        newRevision = grepFile(
            module.revisionInformationRegex,
            unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeVersionInformationPath,
        )

        currentVersion = (currentVersion.replace(module.versionInformationRegex, "")).strip()
        newVersion = (newVersion.replace(module.versionInformationRegex, "")).strip()
        currentRevision = (currentRevision.replace(module.revisionInformationRegex, "")).strip()
        newRevision = (newRevision.replace(module.revisionInformationRegex, "")).strip()
        currentDirSize = getDirectoryRecursiveSize(previousVersionBackupPath)
        newDirSize = getDirectoryRecursiveSize(unzippedPackagePath)

        # Information Header
        log.info(informationAsciiHeader())

        labels = ("", "Currently Installed Module", "Module To Be Installed")
        data = """Version, %s, %s
           Revision, %s, %s
           Dir Size, %s, %s           
        """ % (
            currentVersion,
            newVersion,
            currentRevision,
            newRevision,
            currentDirSize,
            newDirSize,
        )

        rows = [row.strip().split(",") for row in data.splitlines()]
        log.info("\n\n" + indent([labels] + rows, hasHeader=True))
        log.info("Last script executed on '" + finalConnectionString + "' was '" + lastExecutedFilename + "'")
    def __init__(self, module):
        '''
        Constructor
        '''
        ActionBundle.__init__(self, module)
        euclidModule = module.subModule
        
        # Generate a unique ActionBundle execution id
        guid = generateGUID()
        log.info("Unique ActionBundle execution ID generated: " + guid)
        
        # Check if JBOSS is running
        if getProcessPIDByPath(module.targetDeploymentPath): die("The JBOSS server at '" + module.targetDeploymentPath + "' is up. Installation will not continue")        
        
        # Prepare directory to unpack package
        unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage")
        
        # Prepare backup directory
        backupPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "backup")
        
        # Prepare explode wars directory
        explodePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "explode")
        
        # Prepare configuration directory
        configDirectoryPath = createDirectoriesRecursively(euclidModule.euclidConfigDir)
        
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # config dir, so do a little sprintf to fix them
        sprintfOnDictionaryValues(module.relativeConfigurationFiles, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeMergableConfigurationFiles, euclidModule.euclidConfigDir)
        # Since Euclid is deployed on JBOSS some paths have an %s to allow a configurable 
        # server profile, so do a little sprintf to fix them   
        sprintfOnDictionaryValues(module.relativeCopyableFilesOrFolders, module.targetDeploymentProfile) 
        sprintfOnDictionaryValues(euclidModule.relativeWarsToBeExploded, module.targetDeploymentProfile)

        # Extract package into tmp dir
        ExtractZipToDir(module.moduleFilename, unzippedPackagePath)
        
        versionTmpPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "tmp")
        installedWarPath = module.targetDeploymentPath + scriptGlobals.osDirSeparator + "server" + scriptGlobals.osDirSeparator + module.targetDeploymentProfile + scriptGlobals.osDirSeparator + "deploy" + scriptGlobals.osDirSeparator + module.name + ".war"
        installedVersionInfo = getVersionInfoFromWar(installedWarPath, module.relativeVersionInformationPath, module.versionInformationRegex, module.revisionInformationRegex, versionTmpPath)
        newWarPath = unzippedPackagePath + scriptGlobals.osDirSeparator + "bin" + scriptGlobals.osDirSeparator + module.name + ".war"
        newVersionInfo = getVersionInfoFromWar(newWarPath, module.relativeVersionInformationPath, module.versionInformationRegex, module.revisionInformationRegex, versionTmpPath)
        log.info("\n------ UPDATE VERSION INFO ------------------------" + 
                 "\nCurrently installed: " + installedVersionInfo[0] + " (" + installedVersionInfo[1] + ")" + 
                 "\n    To be installed: " + newVersionInfo[0] + " (" + newVersionInfo[1] + ")" +
                 "\n---------------------------------------------------")
        versionSameOrNewer=False
        if compareVersions(newVersionInfo[0], installedVersionInfo[0]) < 0 :
            versionSameOrNewer=True
            continueOrCancel("\nWARNING: Installed version is newer! If you continue the installation DB migration will not be executed.")
        elif compareVersions(newVersionInfo[0], installedVersionInfo[0]) == 0 :
            versionSameOrNewer=True
            continueOrCancel("\nWARNING: Same version already installed! If you continue the installation DB migration will not be executed.")
        
        # Configure relativeConfigurationFiles
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "false", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Configure relativeMergableConfigurationFiles
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation)
            replaceInsensitiveStringInFile("${CREATE_SCHEMA}", "false", exactExtractedLocation)
            CheckFileConfigurationIsComplete(exactExtractedLocation)
        
        # Explode wars
#        for k, v in euclidModule.relativeWarsToBeExploded.items():
#            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
#            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
#            backupFileOrDirIfExists(exactTargetLocation,backupPath)
#            ExtractZipToDir(exactExtractedLocation, exactTargetLocation)
        for k, v in euclidModule.relativeWarsToBeExploded.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            i = rfind(k, scriptGlobals.osDirSeparator)
            if i > -1: 
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k[i+1:]
            else:
                tmpExplodeWarLocation = explodePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            createDirectoriesRecursively(tmpExplodeWarLocation)
            ExtractZipToDir(exactExtractedLocation, tmpExplodeWarLocation)
            AltMoveDirOrFile(tmpExplodeWarLocation,exactTargetLocation)
        
        # Copy config files
        for k, v in module.relativeConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation) 
            
        # Copy merge config files and copy (just copy for now)
        for k, v in euclidModule.relativeMergableConfigurationFiles.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
#            secondaryFileName = unzippedPackagePath + scriptGlobals.osDirSeparator + k
#            mergedFileName = secondaryFileName+".merged"
#            primaryFileName = v 
#            MergeSectionlessConfigFiles(primaryFileName, secondaryFileName, mergedFileName)
#            CopyDirOrFile(mergedFileName, primaryFileName)      

        # Copy other files
        for k, v in module.relativeCopyableFilesOrFolders.items():
            exactExtractedLocation = unzippedPackagePath + scriptGlobals.osDirSeparator + k
            exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v 
            backupFileOrDirIfExists(exactTargetLocation,backupPath)
            CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
        
        #Construct DB connection string
        if versionSameOrNewer:
            log.info("Skipping DB migration scripts execution!")
            return
        dbUsername = readPropertyFromPropertiesFile("DB_CONNECTION_USERNAME", module.name, lib.OptParser.options.envprops)
        dbPassword = readPropertyFromPropertiesFile("DB_CONNECTION_PASSWORD", module.name, lib.OptParser.options.envprops)
        connUrl = readPropertyFromPropertiesFile("DB_CONNECTION_URL", module.name, lib.OptParser.options.envprops)
        finalConnectionString = string.replace(connUrl, '@', dbUsername + '/' + dbPassword + '@', 1)
        
        # Execute DB migration scripts
        confParser = ConfigParser.ConfigParser()
        confParser.read(unzippedPackagePath + scriptGlobals.osDirSeparator + euclidModule.relativeDatabaseUpgrateDescriptionFilePath)
        ok, scripts, default = getDbUpdateScriptsToRun(installedVersionInfo[0], confParser)
        if ok == False:
            continueOrCancel("\nERROR: This installer does not support updating from " + installedVersionInfo[0] + " version!")
        elif len(default)>0:
            log.info('DB update scripts to be executed:\n' + string.join(scripts, ", "))
            continueOrCancel("\nWARNING: Default DB update scripts are used for branch(es) " + string.join(default,", ") + ". This is probably probably OK, but you should make sure that the currently installed version is supported by the update procedure (please read the deployment instructions or consult with the development team).")
        else:
            log.info('DB update scripts to be executed:\n' + string.join(scripts, ", "))
        baseDbScriptPath = unzippedPackagePath + scriptGlobals.osDirSeparator + module.relativeDatabaseUpgradeFilePath + scriptGlobals.osDirSeparator
        for script in scripts:
            #print "Execute: " + baseDbScriptPath + script
            RunOracleScriptFromFile(baseDbScriptPath + script, finalConnectionString)