in scripts/cpd_install.py [0:0]
def main(self,argv):
methodName = "main"
self.rc = 0
try:
beginTime = Utilities.currentTimeMillis()
cmdLineArgs = Utilities.getInputArgs(self.ArgsSignature,argv[1:])
trace, logFile = self._configureTraceAndLogging(cmdLineArgs)
self.region = cmdLineArgs.get('region')
if (logFile):
TR.appendTraceLog(logFile)
if (trace):
TR.info(methodName,"Tracing with specification: '%s' to log file: '%s'" % (trace,logFile))
logFilePath = os.path.join(self.logsHome,"icpd_install.log")
with open(logFilePath,"a+") as icpdInstallLogFile:
self.stackId = cmdLineArgs.get('stackid')
self.stackName = cmdLineArgs.get('stack-name')
self.amiID = environ.get('AMI_ID')
self.cpdSecret = environ.get('CPD_SECRET')
self.ocpSecret = environ.get('OCP_SECRET')
self.cpdbucketName = environ.get('ICPDArchiveBucket')
self.ICPDInstallationCompletedURL = environ.get('ICPDInstallationCompletedURL')
TR.info(methodName, "amiID %s "% self.amiID)
TR.info(methodName, "cpdbucketName %s "% self.cpdbucketName)
TR.info(methodName, "ICPDInstallationCompletedURL %s "% self.ICPDInstallationCompletedURL)
TR.info(methodName, "cpdSecret %s "% self.cpdSecret)
TR.info(methodName, "ocpSecret %s "% self.ocpSecret)
self.__init(self.stackId,self.stackName, icpdInstallLogFile)
self.zones = Utilities.splitString(self.AvailabilityZones)
TR.info(methodName," AZ values %s" % self.zones)
TR.info(methodName,"RedhatPullSecret %s" %self.RedhatPullSecret)
secret = self.RedhatPullSecret.split('/',1)
TR.info(methodName,"Pull secret %s" %secret)
self.pullSecret = "/ibm/pull-secret"
s3_cp_cmd = "aws s3 cp "+self.RedhatPullSecret+" "+self.pullSecret
TR.info(methodName,"s3 cp cmd %s"%s3_cp_cmd)
call(s3_cp_cmd, shell=True,stdout=icpdInstallLogFile)
self.getSecret(icpdInstallLogFile)
ocpstart = Utilities.currentTimeMillis()
self.installOCP(icpdInstallLogFile)
ocpend = Utilities.currentTimeMillis()
self.printTime(ocpstart, ocpend, "Installing OCP")
self.installWKC = Utilities.toBoolean(self.WKC)
self.installWSL = Utilities.toBoolean(self.WSL)
self.installDV = Utilities.toBoolean(self.DV)
self.installWML = Utilities.toBoolean(self.WML)
self.installOSWML = Utilities.toBoolean(self.OpenScale)
self.installCDE = Utilities.toBoolean(self.CDE)
self.installSpark= Utilities.toBoolean(self.Spark)
if(self.installOSWML):
self.installWML=True
storagestart = Utilities.currentTimeMillis()
if(self.StorageType=='OCS'):
self.configureOCS(icpdInstallLogFile)
elif(self.StorageType=='Portworx'):
TR.info(methodName,"PortworxSpec %s" %self.PortworxSpec)
spec = self.PortworxSpec.split('/',1)
TR.info(methodName,"spec %s" %spec)
self.spec = "/ibm/templates/px/px-spec.yaml"
s3_cp_cmd = "aws s3 cp "+self.PortworxSpec+" "+self.spec
TR.info(methodName,"s3 cp cmd %s"%s3_cp_cmd)
call(s3_cp_cmd, shell=True,stdout=icpdInstallLogFile)
self.configurePx(icpdInstallLogFile)
elif(self.StorageType=='EFS'):
self.EFSDNSName = environ.get('EFSDNSName')
self.EFSID = environ.get('EFSID')
self.configureEFS()
storageend = Utilities.currentTimeMillis()
self.printTime(storagestart, storageend, "Installing storage")
self.installCPD(icpdInstallLogFile)
self.updateSecret(icpdInstallLogFile)
self.exportResults(self.stackName+"-OpenshiftURL", "https://"+self.openshiftURL, icpdInstallLogFile)
self.exportResults(self.stackName+"-CPDURL", "https://"+self.cpdURL, icpdInstallLogFile)
#endWith
except Exception as e:
TR.error(methodName,"Exception with message %s" %e)
self.rc = 1
finally:
try:
# Copy icpHome/logs to the S3 bucket for logs.
self.logExporter.exportLogs("/var/log/")
self.logExporter.exportLogs("/ibm/cpd-cli-workspace/Logs")
self.logExporter.exportLogs("%s" % self.logsHome)
except Exception as e:
TR.error(methodName,"ERROR: %s" % e, e)
self.rc = 1
#endTry
endTime = Utilities.currentTimeMillis()
elapsedTime = (endTime - beginTime)/1000
etm, ets = divmod(elapsedTime,60)
eth, etm = divmod(etm,60)
if (self.rc == 0):
success = 'true'
status = 'SUCCESS'
TR.info(methodName,"SUCCESS END CPD Install AWS ICPD Quickstart. Elapsed time (hh:mm:ss): %d:%02d:%02d" % (eth,etm,ets))
self.updateStatus(status)
else:
success = 'false'
status = 'FAILURE: Check logs in S3 log bucket or on the Boot node EC2 instance in /ibm/logs/icpd_install.log and /ibm/logs/post_install.log'
TR.info(methodName,"FAILED END CPD Install AWS ICPD Quickstart. Elapsed time (hh:mm:ss): %d:%02d:%02d" % (eth,etm,ets))
self.updateStatus(status)
#endIf
try:
data = "%s: IBM Cloud Pak installation elapsed time: %d:%02d:%02d" % (status,eth,etm,ets)
check_call(['cfn-signal',
'--success', success,
'--id', self.stackId,
'--reason', status,
'--data', data,
self.ICPDInstallationCompletedURL
])
except CalledProcessError as e:
TR.error(methodName, "ERROR return code: %s, Exception: %s" % (e.returncode, e), e)
raise e