in scripts/cpd_install.py [0:0]
def configureOCS(self,icpdInstallLogFile):
"""
This method reads user preferences from stack parameters and configures OCS as storage classs accordingly.
Depending on 1 or 3 AZ appropriate template file is used to create machinesets.
"""
methodName = "configureOCS"
TR.info(methodName," Start configuration of OCS for CPD")
workerocs = "/ibm/templates/ocs/workerocs.yaml"
workerocs_1az = "/ibm/templates/ocs/workerocs1AZ.yaml"
if(len(self.zones)==1):
shutil.copyfile(workerocs_1az,workerocs)
self.updateTemplateFile(workerocs,'${az1}', self.zones[0])
self.updateTemplateFile(workerocs,'${ami_id}', self.amiID)
self.updateTemplateFile(workerocs,'${instance-type}', self.OCSInstanceType)
self.updateTemplateFile(workerocs,'${instance-count}', self.NumberOfOCS)
self.updateTemplateFile(workerocs,'${region}', self.region)
self.updateTemplateFile(workerocs,'${cluster-name}', self.ClusterName)
self.updateTemplateFile(workerocs, 'CLUSTERID', self.clusterID)
self.updateTemplateFile(workerocs,'${subnet-1}',self.PrivateSubnet1ID)
if(len(self.zones)>1):
self.updateTemplateFile(workerocs,'${az2}', self.zones[1])
self.updateTemplateFile(workerocs,'${az3}', self.zones[2])
self.updateTemplateFile(workerocs,'${subnet-2}',self.PrivateSubnet2ID)
self.updateTemplateFile(workerocs,'${subnet-3}',self.PrivateSubnet3ID)
create_ocs_nodes_cmd = "oc create -f "+workerocs
TR.info(methodName,"Create OCS nodes")
try:
retcode = check_output(['bash','-c', create_ocs_nodes_cmd])
time.sleep(600)
TR.info(methodName,"Created OCS nodes %s" %retcode)
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
ocs_nodes = []
get_ocs_nodes = "oc get nodes --show-labels | grep storage-node |cut -d' ' -f1 "
try:
ocs_nodes = check_output(['bash','-c',get_ocs_nodes])
nodes = ocs_nodes.split("\n")
TR.info(methodName,"OCS_NODES %s"%nodes)
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
i =0
while i < len(nodes)-1:
TR.info(methodName,"Labeling for OCS node %s " %nodes[i])
label_cmd = "oc label nodes "+nodes[i]+" cluster.ocs.openshift.io/openshift-storage=''"
try:
retcode = check_output(['bash','-c', label_cmd])
TR.info(methodName,"Label for OCS node %s returned %s" %(nodes[i],retcode))
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
i += 1
deploy_olm_cmd = "oc create -f /ibm/templates/ocs/deploy-with-olm.yaml"
TR.info(methodName,"Deploy OLM")
try:
retcode = check_output(['bash','-c', deploy_olm_cmd])
time.sleep(300)
TR.info(methodName,"Deployed OLM %s" %retcode)
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
create_storage_cluster_cmd = "oc create -f /ibm/templates/ocs/ocs-storagecluster.yaml"
TR.info(methodName,"Create Storage Cluster")
try:
retcode = check_output(['bash','-c', create_storage_cluster_cmd])
time.sleep(600)
TR.info(methodName,"Created Storage Cluster %s" %retcode)
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
install_ceph_tool_cmd = "curl -s https://raw.githubusercontent.com/rook/rook/release-1.1/cluster/examples/kubernetes/ceph/toolbox.yaml|sed 's/namespace: rook-ceph/namespace: openshift-storage/g'| oc apply -f -"
TR.info(methodName,"Install ceph toolkit")
try:
retcode = check_output(['bash','-c', install_ceph_tool_cmd])
TR.info(methodName,"Installed ceph toolkit %s" %retcode)
except CalledProcessError as e:
TR.error(methodName,"command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
TR.info(methodName,"Configuration of OCS for CPD completed")