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) # Prepare directory to unpack package unzippedPackagePath = createDirectoriesRecursively( scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage" ) # Extract CRM package into tmp dir ExtractZipToDir(module.moduleFilename, unzippedPackagePath) # Get Version, Revision information versionInfo, revisionInfo = getVersionAndRevisionInfo( module.versionInformationRegex, module.revisionInformationRegex, unzippedPackagePath, module.relativeVersionInformationPath, ) module.executionContext["unzippedPackagePath"] = unzippedPackagePath module.executionContext["versionInfo"] = versionInfo module.executionContext["revisionInfo"] = revisionInfo module.executionContext["guid"] = guid
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 ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier) # If process exists... if pid: # Kill process using pid killProcess(pid) # Construct the email notification emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress) emailRecipients = module.emailNotificationRecipientList emailSubject = "Server KILL: " + module.subModule.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = killApplicationServerNotificationTemplate(module.name, getCurrentHostname(), guid) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort)
def __init__(self, module): """ Constructor """ ActionBundle.__init__(self, module) unzippedPackagePath = module.executionContext["unzippedPackagePath"] versionInfo = module.executionContext["versionInfo"] revisionInfo = module.executionContext["revisionInfo"] guid = module.executionContext["guid"] # Compose Oracle DB Connection String oracleConnectionString = "%s/%s@%s" % ( extractOracleDatabaseCredentials( module.name, lib.OptParser.options.envprops, "VNA_CRM_USERNAMEBASE", "VNA_CRM_PASSWORDBASE", "DBConnectionString", ) ) # Run DB init script(s) for dbInitScript in module.relativeDatabaseInitFiles: appendRequiredStringsToOracleSQLFile(unzippedPackagePath + scriptGlobals.osDirSeparator + dbInitScript) RunOracleScriptFromFile( unzippedPackagePath + scriptGlobals.osDirSeparator + dbInitScript, oracleConnectionString ) # Add LOG table RunOracleScriptFromFile(scriptGlobals.oracleLogTemplateFile, oracleConnectionString) # Log DB init script(s) for dbInitScript in module.relativeDatabaseInitFiles: logOracleScriptInDBLog( dbInitScript, guid, lib.OptParser.options.action, module.name, versionInfo, revisionInfo, oracleConnectionString, ) # 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: logOracleScriptInDBLog( patch, guid, lib.OptParser.options.action, module.name, versionInfo, revisionInfo, oracleConnectionString, )
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) # Configure marketing-suite-admin.properties using envprops # Configure mgage.properties using envprops for k, v in module.relativeConfigurationFiles.items(): exactExtractedLocation = module.subModule.unzippedPackagePath + scriptGlobals.osDirSeparator + k ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, exactExtractedLocation) CheckFileConfigurationIsComplete(exactExtractedLocation) # Copy marketing-suite-admin.properties to conf # Copy mgage.properties to conf # Copy jboss-log4j.xml to conf for k, v in module.relativeConfigurationFiles.items(): exactExtractedLocation = module.subModule.unzippedPackagePath + scriptGlobals.osDirSeparator + k exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
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) # Prepare directory to unpack package module.subModule.unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage") # Extract MS Admin package into tmp dir ExtractZipToDir(module.moduleFilename, module.subModule.unzippedPackagePath) # Prepare directory to unpack package module.subModule.previousVersionBackupPath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "previousVersionBackup") # Extract new MANIFEST.MF ExtractFileFromZipToDir(module.subModule.unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeWarPath, module.relativeVersionInformationPath, module.subModule.unzippedPackagePath) # Prepare directory to keep backups # Since MS 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)
def __init__(self, module): ''' Constructor ''' ActionBundle.__init__(self, module) # Initialize application server object # appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) # Generate a unique ActionBundle execution id guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) # Check if Server is running if getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier): die("\n\nThe " + module.subModule.name + " server at '" + module.targetDeploymentPath + "' is up. Installation will not continue\n") # Run script moduleDeployPath = module.targetDeploymentPath + "/" + module.subModule.name path2 = moduleDeployPath + "/" + module.subModule.installUpdateScript ChangePathPermissions(path2, 0744) path2=path2 + " CREATE YES " ExecuteOSCommand(path2, None) # Find version/revision info manifestFilePath=moduleDeployPath + "/META-INF/MANIFEST.MF" versionInfo = grepFile(module.versionInformationRegex, manifestFilePath) buildInfo = grepFile(module.buildInformationRegex, manifestFilePath) revisionInfo = grepFile(module.revisionInformationRegex, manifestFilePath) versionInfo = (versionInfo.replace(module.versionInformationRegex, "")).strip() if buildInfo != None: buildInfo = (buildInfo.replace(module.buildInformationRegex, "")).strip() revisionInfo = (revisionInfo.replace(module.revisionInformationRegex, "")).strip() # Construct the email notification emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress) emailRecipients = scriptGlobals.globalNotificationEmailList emailSubject = "MSM Installation: " + module.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = detailedCleanInstallationReportTemplate(module.subModule.name, versionInfo, lib.OptParser.options.action, getCurrentHostname(), os.getcwd(), guid, " ".join(platform.uname()), getpass.getuser(), buildInfo, revisionInfo, lib.OptParser.options.envprops, scriptGlobals.workingDir) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort)
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 deleteFile(fileName): log.info("Attempting to remove " + fileName + "...") if glob.glob(fileName): for name in glob.glob(fileName): log.debug("Removing " + name + "...") DeleteDirOrFile(name) else: log.info("Path does not exist: " + fileName)
def __init__(self, moduleFilename, modulePropertiesFilename, environmentPropertiesFilename): ''' Constructor ''' self.moduleFilename = moduleFilename self.name = readPropertyFromPropertiesFile("name", scriptGlobals.moduleSectionName, modulePropertiesFilename) log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
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 __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)
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 standalone is running if getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier): die("\n\nThe " + module.subModule.name + " server at '" + module.targetDeploymentPath + "' is up. Configuration will not continue\n") # Check if module is already installed for k, v in module.relativeCopyableFilesOrFolders.items(): exactLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v if not os.path.isdir(exactLocation): die(module.subModule.name + " is Not already installed to:" + module.targetDeploymentPath + ". Maybe you want to make a clean Installation !!") # Get Previous Hudson data previousManifilePath = module.targetDeploymentPath + scriptGlobals.osDirSeparator + module.subModule.name + scriptGlobals.osDirSeparator + "META-INF" + scriptGlobals.osDirSeparator + "MANIFEST.MF" previousVersionInfo = grepFile(module.versionInformationRegex, previousManifilePath) previousBuildInfo = grepFile(module.buildInformationRegex, previousManifilePath) previousRevisionInfo = grepFile(module.revisionInformationRegex, previousManifilePath) previousRevisionInfo = (previousRevisionInfo.replace(module.revisionInformationRegex, "")).strip() previousVersionInfo = (previousVersionInfo.replace(module.versionInformationRegex, "")).strip() if previousBuildInfo != None: previousBuildInfo = (previousBuildInfo.replace(module.buildInformationRegex, "")).strip() # Construct the email notification emailSender = readPropertyFromPropertiesFileWithFallback("emailNotificationSenderAddress", scriptGlobals.scriptVarSectionName, lib.OptParser.options.envprops, scriptGlobals.emailNotificationSenderAddress) emailRecipients = scriptGlobals.globalNotificationEmailList emailSubject = "MSM Installation: " + module.name + "@"+ getCurrentHostname() + " (" + module.friendlyServerName + ")" emailText = detailedCleanInstallationReportTemplate(module.subModule.name, previousVersionInfo, lib.OptParser.options.action, getCurrentHostname(), os.getcwd(), guid, " ".join(platform.uname()), getpass.getuser(), previousBuildInfo, previousRevisionInfo, lib.OptParser.options.envprops, scriptGlobals.workingDir) # Email all required parties SendEmail(emailSender, emailRecipients, emailSubject, emailText, scriptGlobals.smtpHost, scriptGlobals.smtpPort) # end
def __init__(self, module): ''' Constructor ''' appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, appServer.processIdentifier) if pid: log.info("Process found running from path '" + module.targetDeploymentPath + "' with pid '" + pid + "'.") else: log.info("Process running from path '" + module.targetDeploymentPath + "' was not found.")
def __init__(self, module): ''' Constructor ''' # appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) pid = getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, module.subModule.processIdentifier) if pid: log.info("\n\n################################### " + module.subModule.name + " is Up with pid '" + pid + " ###################################\n") else: log.info("\n\n################################### " + module.subModule.name + " is Down ###################################\n")
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")
def backupFileOrDirIfExists(location,backupPath): if os.path.isfile(location) or os.path.isdir(location): if len(location)==0: return if location[len(location)-1]==scriptGlobals.osDirSeparator: location=location[:-1] i = rfind(location, scriptGlobals.osDirSeparator) if i > -1: backupLocation = backupPath+scriptGlobals.osDirSeparator+location[i+1:] else: backupLocation = backupPath+scriptGlobals.osDirSeparator+location log.info('Backing-up "'+location+'" to "'+backupLocation+'"') AltMoveDirOrFile(location,backupLocation)
def getDbUpdateScriptsToRun(version, dbUpdateConfigParser): version = getCleanVersionNumber(version) log.debug("Retrieving scripts for version " + version) scripts = [] brachesDefault = [] branches = dbUpdateConfigParser.sections() for branch in branches: log.debug(" Checking branch section " + branch) if isVersionInBranch(version, branch): log.debug(" Matches branch section " + branch) versionPatterns = dbUpdateConfigParser.options(branch) filesStr = None defaultFilesStr = None for vpat in versionPatterns: log.debug(" Checking version pattern " + vpat) if vpat.strip().lower() == 'default': defaultFilesStr = dbUpdateConfigParser.get(branch, vpat) elif re.match(vpat, version): log.debug(" Matches version pattern " + vpat) filesStr = dbUpdateConfigParser.get(branch, vpat) if filesStr.strip().lower() == 'unsupported' : log.debug(" Version not supported") return False, scripts, brachesDefault break if filesStr is not None: files = filesStr.split(':') elif defaultFilesStr is not None: log.debug(" Matches default version") if defaultFilesStr.strip().lower() == 'unsupported' : log.debug(" Version not supported") return False, scripts, brachesDefault log.info("WARNING: Default migration scripts for branch "+branch+" have been added for execution") brachesDefault.append(branch) files = defaultFilesStr.split(':') else: return False, scripts, brachesDefault for f in files: if f[0] == '@': log.debug(" Found reference to version " + f) found, moreScripts, moreDefault = getDbUpdateScriptsToRun(f[1:], dbUpdateConfigParser) if found: scripts.extend(moreScripts) brachesDefault.extend(moreDefault) else: return False, scripts, brachesDefault else: log.debug(" Found script " + f) scripts.append(f) return True, scripts, brachesDefault return False, scripts, brachesDefault
def __init__(self, module): """ Constructor """ ActionBundle.__init__(self, module) previousVersionBackupPath = module.executionContext["previousVersionBackupPath"] versionInfo = module.executionContext["versionInfo"] revisionInfo = module.executionContext["revisionInfo"] previousVersionInfo, previousRevisionInfo = getVersionAndRevisionInfo( module.versionInformationRegex, module.revisionInformationRegex, previousVersionBackupPath, module.relativeVersionInformationPath, ) majorVersionInfo = versionInfo[versionInfo.find("-") + 1 : findNthSubstring(versionInfo, ".", 3)] # Compare current and new versions log.info("Version currently installed : " + previousVersionInfo) log.info("Revision currently installed : " + previousRevisionInfo) log.info("Version to be installed : " + versionInfo) log.info("Revision to be installed : " + revisionInfo) module.executionContext["majorVersionInfo"] = majorVersionInfo module.executionContext["previousVersionInfo"] = previousVersionInfo module.executionContext["previousRevisionInfo"] = previousRevisionInfo
def __init__(self, module): ''' Constructor ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) # Check if Application Server is running appServer = ApplicationServer(module, scriptGlobals.appsrvProperties) if getProcessPIDByPathAndIdentifier(module.targetDeploymentPath, appServer.processIdentifier): die("The Application Server at '" + module.targetDeploymentPath + "' is up. Rollback will not continue.") # Deserialize objects and pass them to executedActionList scriptGlobals.executedActionList = deserializeListFromFile(lib.OptParser.options.rollback) # Raise dummy exception raise RollbackTriggerException
def __init__(self, module): ''' Constructor ''' guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) # Check if server is running if getProcessPIDByPath(module.targetDeploymentPath): die("The server at '" + module.targetDeploymentPath + "' is up. Rollback will not continue.") # Deserialize objects and pass them to executedActionList log.info("Using '" + lib.OptParser.options.rollback + "' to perform Manual Rollback") scriptGlobals.executedActionList = deserializeListFromFile(lib.OptParser.options.rollback) # Raise dummy exception to enter the Rollback mechanism raise RollbackTriggerException
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): ''' Constructor ''' ActionBundle.__init__(self, module) # Generate a unique ActionBundle execution id guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) # Copy marketing-suite-admin.war to deploy for k, v in module.relativeCopyableFilesOrFolders.items(): exactExtractedLocation = module.subModule.unzippedPackagePath + scriptGlobals.osDirSeparator + k exactTargetLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v CopyDirOrFile(exactExtractedLocation, exactTargetLocation)
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) log.info(self.__class__.__name__ + " '" + self.name + "' initialized")
def __init__(self, module): ''' Constructor ''' ActionBundle.__init__(self, module) euclidModule = module.subModule guid = generateGUID() log.info("Unique ActionBundle execution ID generated: " + guid) unzippedPackagePath = createDirectoriesRecursively(scriptGlobals.workingDir + scriptGlobals.osDirSeparator + "unzippedPackage") 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) print "\n------ UPDATE VERSION INFO ------" print "Currently installed: " + installedVersionInfo[0] + " (" + installedVersionInfo[1] + ")" print " To be installed: " + newVersionInfo[0] + " (" + newVersionInfo[1] + ")\n"
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)
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")
def __init__(self, module): ''' Constructor ''' ActionBundle.__init__(self, module) unzippedPackagePath = module.subModule.unzippedPackagePath propertiesFileName = "upgrade-configuration.properties" # Run migration jars ls = os.listdir(unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath) ls.sort() for zipFile in ls: # Extract MS Admin package into tmp dir ExtractZipToDir(unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath + scriptGlobals.osDirSeparator + zipFile, unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath) #Get jar name from zip name jarFile = zipFile[:-4] + ".jar" # extract properties to current dir ExtractFileFromZipToDir(unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath + scriptGlobals.osDirSeparator + jarFile, propertiesFileName, ".") # configure properties ConfigureTemplateFile(module.name, lib.OptParser.options.envprops, propertiesFileName) CheckFileConfigurationIsComplete(propertiesFileName) # add configured properties to zip ExecuteOSCommand("zip -r " + unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath + scriptGlobals.osDirSeparator + jarFile + " " + propertiesFileName, '') # delete properties from current dir DeleteDirOrFile(propertiesFileName); # run migration jar jarCommand = "java -jar " + unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.relativeJarFilesPath + scriptGlobals.osDirSeparator + jarFile log.info("Jar file " + jarFile + "will be executed with the following command \n" + jarCommand) ExecuteOSCommand(jarCommand, '')
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) previousVersionBackupPath = module.subModule.previousVersionBackupPath unzippedPackagePath = module.subModule.unzippedPackagePath # Backup marketing-admin-webapp.war from deploy/ # Backup esb.jar from deploy/ # Backup ROOT.WAR/crossdmain.xml from deploy/ROOT.WAR log.info("######################## COPY ALL COPYABLE FILES ########################") for k, v in module.relativeCopyableFilesOrFolders.items(): exactLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v exactBackupLocation = module.subModule.previousVersionBackupPath + scriptGlobals.osDirSeparator + k CopyDirOrFile2(exactLocation, exactBackupLocation) # Backup marketing-suite-deployment.properties from conf # Backup mgage.properties from conf # Backup jboss-log4j.xml from conf # Backup web.xml from marketing-admin-webapp.war/WEB-INF log.info("######################## COPY ALL COPYABLE FILES ########################") for k, v in module.relativeConfigurationFiles.items(): exactLocation = module.targetDeploymentPath + scriptGlobals.osDirSeparator + v exactBackupLocation = previousVersionBackupPath + scriptGlobals.osDirSeparator + k CopyDirOrFile2(exactLocation, exactBackupLocation) log.info("######################## END OF COPY ########################") # Extract old MANIFEST.MF ExtractFileFromZipToDir(previousVersionBackupPath + scriptGlobals.osDirSeparator + module.subModule.relativeWarPath, module.relativeVersionInformationPath, previousVersionBackupPath) # Compare current and new versions log.info("Version currently installed : " + grepFile(module.versionInformationRegex, previousVersionBackupPath + scriptGlobals.osDirSeparator + "MANIFEST.MF")) log.info("Revision currently installed : " + grepFile(module.revisionInformationRegex, previousVersionBackupPath + scriptGlobals.osDirSeparator + "MANIFEST.MF")) log.info("Version to be installed : " + grepFile(module.versionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF")) log.info("Revision to be installed : " + grepFile(module.revisionInformationRegex, unzippedPackagePath + scriptGlobals.osDirSeparator + "MANIFEST.MF"))