def configurePx()

in scripts/cpd_install.py [0:0]


    def configurePx(self, icpdInstallLogFile):
        methodName = "configurePx"
        TR.info(methodName,"  Start configuration of Portworx for CPD")
        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.ocr = check_output(['bash','-c', default_route]) 
            TR.info(methodName,"Completed %s command with return value %s" %(default_route,self.ocr))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    

        create_secret_cmd = "oc create secret docker-registry regcred --docker-server="+self.ocr+"  --docker-username=kubeadmin --docker-password="+self.ocpassword+" -n kube-system"
        TR.info(methodName,"Create OC secret for PX installation  %s"%create_secret_cmd)
        try:
            retcode = check_output(['bash','-c', create_secret_cmd]) 
            TR.info(methodName,"Completed %s command with return value %s" %(create_secret_cmd,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    

        self.preparePXInstall(icpdInstallLogFile)
        time.sleep(30)
        self.updateScc(icpdInstallLogFile)
        time.sleep(30)
        self.labelNodes(icpdInstallLogFile)
        time.sleep(30)
        label_cmd = "oc get nodes --show-labels  | grep 'node-role.kubernetes.io/compute=true'"
        TR.info(methodName,"Run label_cmd command %s"%label_cmd)
        try:
            retcode = check_output(['bash','-c', label_cmd]) 
            TR.info(methodName,"Completed %s command with return value %s" %(label_cmd,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    
        time.sleep(30)
        px_install_cmd = "oc apply -f /ibm/templates/px/px-install.yaml"
        TR.info(methodName,"Run px-install command %s"%px_install_cmd)
        try:
            retcode = check_output(['bash','-c', px_install_cmd]) 
            TR.info(methodName,"Completed %s command with return value %s" %(px_install_cmd,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    
        time.sleep(180)
        
        px_spec_cmd = "oc create -f /ibm/templates/px/px-spec.yaml"
        TR.info(methodName,"Run px-spec command %s"%px_spec_cmd)
        try:
            retcode = check_output(['bash','-c', px_spec_cmd]) 
            TR.info(methodName,"Completed %s command with return value %s" %(px_spec_cmd,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    
        time.sleep(300)

        create_px_sc = "sudo sh /ibm/templates/px/px-storageclasses.sh"
        TR.info(methodName,"Run px sc command %s"%create_px_sc)
        try:
            retcode = check_output(['bash','-c', create_px_sc]) 
            TR.info(methodName,"Completed %s command with return value %s" %(create_px_sc,retcode))
        except CalledProcessError as e:
            TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))    
        
        self.setpxVolumePermission(icpdInstallLogFile)

        TR.info(methodName,"Configuration of Portworx for CPD completed")