def installCPD()

in scripts/cpd_install.py [0:0]


    def installCPD(self,icpdInstallLogFile):
        """
        creates a OC project with user defined name
        Downloads binary file from S3 and extracts it to /ibm folder
        installs user selected services using transfer method
        """
        cloudctl_destPath = "/ibm/cloudctl-linux-amd64.tar.gz"
        cloudctl_sig_destPath = "/ibm/cloudctl-linux-amd64.tar.gz.sig"
        cp_datacore_destPath = "/ibm/ibm-cp-datacore.tgz"
        methodName = "installCPD"

        self.getS3Object(bucket=self.cpdbucketName, s3Path="3.5.2/cloudctl-linux-amd64.tar.gz", destPath=cloudctl_destPath)
        self.getS3Object(bucket=self.cpdbucketName, s3Path="3.5.2/cloudctl-linux-amd64.tar.gz.sig", destPath=cloudctl_sig_destPath)
        self.getS3Object(bucket=self.cpdbucketName, s3Path="3.5.2/ibm-cp-datacore-1.3.3.tgz", destPath=cp_datacore_destPath)

        untar_cmd = "sudo tar -xvf "+cloudctl_destPath+" -C /usr/bin"
        TR.info(methodName,"untarcmd =%s"%untar_cmd)
        call(untar_cmd,shell=True,stdout=icpdInstallLogFile)        
        untar_datacore_cmd = "tar -xf "+cp_datacore_destPath
        TR.info(methodName,"untar_datacore_cmd =%s"%untar_datacore_cmd)
        call(untar_datacore_cmd,shell=True,stdout=icpdInstallLogFile)

        default_route = "oc get route default-route -n openshift-image-registry --template='{{ .spec.host }}'"
        TR.info(methodName,"Get default route  %s"%default_route)
        try:
            self.regsitry = check_output(['bash','-c', default_route]) 
            TR.info(methodName,"Completed %s command with return value %s" %(default_route,self.regsitry))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    

        self.ocpassword = self.readFileContent("/ibm/installDir/auth/kubeadmin-password").rstrip("\n\r")
        try:
            oc_login = "oc login -u kubeadmin -p "+self.ocpassword
            retcode = call(oc_login,shell=True, stdout=icpdInstallLogFile)
            TR.info(methodName,"Log in to OC with admin user %s"%retcode)
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    

        oc_new_project ="oc new-project cpd-meta-ops"
        try:
            retcode = call(oc_new_project,shell=True, stdout=icpdInstallLogFile)
            TR.info(methodName,"Create meta ops project cpd-meta-ops,retcode=%s" %(retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))

        self.installOperator(icpdInstallLogFile)
        oc_new_project ="oc new-project "+self.Namespace
        try:
            retcode = call(oc_new_project,shell=True, stdout=icpdInstallLogFile)
            TR.info(methodName,"Create new project with user defined project name %s,retcode=%s" %(self.Namespace,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    

        #self.token = self.getToken(icpdInstallLogFile)
        if(self.StorageType=='OCS'):
            self.storageClass = "ocs-storagecluster-cephfs"
            self.storageOverrideFile = "/ibm/override_ocs.yaml"
            self.storageOverride = "ocs"
        elif(self.StorageType=='Portworx'):    
            self.storageClass = "portworx-shared-gp3"
            self.storageOverrideFile = "/ibm/override_px.yaml"
            self.storageOverride = "portworx"
        elif(self.StorageType=='EFS'):
            self.storageClass = "aws-efs"
            self.storageOverride = ""
        litestart = Utilities.currentTimeMillis()
        TR.info(methodName,"Start installing Lite package")
        self.installAssemblies("lite",icpdInstallLogFile)
        liteend = Utilities.currentTimeMillis()
        self.printTime(litestart, liteend, "Installing Lite")

        get_cpd_route_cmd = "oc get route -n "+self.Namespace+ " | grep '"+self.Namespace+"' | awk '{print $2}'"
        TR.info(methodName, "Get CPD URL")
        try:
            self.cpdURL = check_output(['bash','-c', get_cpd_route_cmd]) 
            TR.info(methodName, "CPD URL retrieved %s"%self.cpdURL)
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    
        self.manageUser(icpdInstallLogFile)
        

        
        

        if(self.installDV):
            TR.info(methodName,"Start installing DV package")
            dvstart = Utilities.currentTimeMillis()
            self.installAssemblies("dv",icpdInstallLogFile)
            dvend = Utilities.currentTimeMillis()
            TR.info(methodName,"DV package installation completed")
            self.printTime(dvstart, dvend, "Installing DV")    
        
        if(self.installWSL):

            TR.info(methodName,"Start installing WSL package")
            wslstart = Utilities.currentTimeMillis()
            self.installAssemblies("wsl",icpdInstallLogFile)
            wslend = Utilities.currentTimeMillis()
            TR.info(methodName,"WSL package installation completed")
            self.printTime(wslstart, wslend, "Installing WSL")
        
        if(self.installWML):
            TR.info(methodName,"Start installing WML package")
            wmlstart = Utilities.currentTimeMillis()
            self.installAssemblies("wml",icpdInstallLogFile)
            wmlend = Utilities.currentTimeMillis()
            TR.info(methodName,"WML package installation completed")
            self.printTime(wmlstart, wmlend, "Installing WML")

        if(self.installSpark):
            TR.info(methodName,"Start installing Spark AE package")
            sparkstart = Utilities.currentTimeMillis()
            self.installAssemblies("spark",icpdInstallLogFile)
            sparkend = Utilities.currentTimeMillis()
            TR.info(methodName,"Spark AE  package installation completed")
            self.printTime(sparkstart, sparkend, "Installing Spark AE")   
        if(self.installWKC):
            TR.info(methodName,"Start installing WKC package")
            wkcstart = Utilities.currentTimeMillis()
            self.installAssemblies("wkc",icpdInstallLogFile)
            wkcend = Utilities.currentTimeMillis()
            TR.info(methodName,"WKC package installation completed")
            self.printTime(wkcstart, wkcend, "Installing WKC")

        if(self.installOSWML):
            TR.info(methodName,"Start installing AI Openscale package")
            aiostart = Utilities.currentTimeMillis()
            self.installAssemblies("aiopenscale",icpdInstallLogFile)
            aioend = Utilities.currentTimeMillis()
            TR.info(methodName,"AI Openscale package installation completed")
            self.printTime(aiostart, aioend, "Installing AI Openscale")    

        if(self.installCDE):
            TR.info(methodName,"Start installing Cognos Dashboard package")
            cdestart = Utilities.currentTimeMillis()
            self.installAssemblies("cde",icpdInstallLogFile)
            cdeend = Utilities.currentTimeMillis()
            TR.info(methodName,"Cognos Dashboard package installation completed")
            self.printTime(cdestart, cdeend, "Installing Cognos Dashboard")  
        TR.info(methodName,"Installed all packages.")