diff --git a/ci-scripts/cls_cluster.py b/ci-scripts/cls_cluster.py index c117df1436..570ea52dfc 100644 --- a/ci-scripts/cls_cluster.py +++ b/ci-scripts/cls_cluster.py @@ -126,8 +126,6 @@ class Cluster: self.ranAllowMerge = False self.ranTargetBranch = "" self.cmd = None - self.imageToPull = '' - self.testSvrId = None def _recreate_entitlements(self): # recreating entitlements, don't care if deletion fails @@ -240,44 +238,30 @@ class Cluster: def _undeploy_pod(self, filename): self.cmd.run(f'oc delete -f {filename}') - def PullClusterImage(self, HTML): - if self.testSvrId == None: self.testSvrId = self.eNBIPAddress - if self.imageToPull == '': - HELP.GenericHelp(CONST.Version) - raise ValueError('Insufficient Parameter') - logging.debug(f'Pull OC image {self.imageToPull} to server {self.testSvrId}') + def PullClusterImage(self, HTML, node, images): + logging.debug(f'Pull OC image {images} to server {node}') self.testCase_id = HTML.testCase_id - cmd = cls_cmd.getConnection(self.testSvrId) - logging.info(cmd.run('docker --version')) - succeeded = OC_login(cmd, self.OCUserName, self.OCPassword, CI_OC_RAN_NAMESPACE) - if not succeeded: - logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) - return False - ret = cmd.run(f'oc whoami -t | docker login -u oaicicd --password-stdin {self.OCRegistry}') - if ret.returncode != 0: - logging.error(f'\u001B[1m Unable to access OC project {CI_OC_RAN_NAMESPACE}\u001B[0m') - OC_logout(cmd) - cmd.close() - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) - return False - for image in self.imageToPull: - imagePrefix = f'{self.OCRegistry}/{CI_OC_RAN_NAMESPACE}' - tag = cls_containerize.CreateTag(self.ranCommitID, self.ranBranch, self.ranAllowMerge) - imageTag = f"{image}:{tag}" - ret = cmd.run(f'docker pull {imagePrefix}/{imageTag}') - if ret.returncode != 0: - logging.error(f'Could not pull {image} from local registry : {self.OCRegistry}') - OC_logout(cmd) - cmd.close() - HTML.CreateHtmlTestRow('msg', 'KO', CONST.ALL_PROCESSES_OK) + with cls_cmd.getConnection(node) as cmd: + succeeded = OC_login(cmd, self.OCUserName, self.OCPassword, CI_OC_RAN_NAMESPACE) + if not succeeded: + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) return False - cmd.run(f'docker tag {imagePrefix}/{imageTag} oai-ci/{imageTag}') - cmd.run(f'docker rmi {imagePrefix}/{imageTag}') - OC_logout(cmd) - cmd.close() - HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) - return True + ret = cmd.run(f'oc whoami -t | docker login -u oaicicd --password-stdin {self.OCRegistry}') + if ret.returncode != 0: + logging.error(f'cannot authenticate at registry') + OC_logout(cmd) + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) + return False + tag = cls_containerize.CreateTag(self.ranCommitID, self.ranBranch, self.ranAllowMerge) + registry = f'{self.OCRegistry}/{CI_OC_RAN_NAMESPACE}' + success, msg = cls_containerize.Containerize.Pull_Image(cmd, images, tag, registry, None, None) + OC_logout(cmd) + param = f"on node {node}" + if success: + HTML.CreateHtmlTestRowQueue(param, 'OK', [msg]) + else: + HTML.CreateHtmlTestRowQueue(param, 'KO', [msg]) + return success def BuildClusterImage(self, HTML): if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': diff --git a/ci-scripts/main.py b/ci-scripts/main.py index cb845592b7..195dac0f9c 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -397,13 +397,9 @@ def ExecuteActionWithParam(action): success = cls_oaicitest.Custom_Script(HTML, node, script, command_fail) elif action == 'Pull_Cluster_Image': - string_field = test.findtext('images_to_pull') - if (string_field is not None): - CLUSTER.imageToPull = string_field.split() - string_field = test.findtext('test_svr_id') - if (string_field is not None): - CLUSTER.testSvrId = string_field - success = CLUSTER.PullClusterImage(HTML) + images = test.findtext('images').split() + node = test.findtext('node') + success = CLUSTER.PullClusterImage(HTML, node, images) else: logging.warning(f"unknown action {action}, skip step") diff --git a/ci-scripts/xml_files/container_sa_aw2s_asue.xml b/ci-scripts/xml_files/container_sa_aw2s_asue.xml index f023da8402..0617962731 100644 --- a/ci-scripts/xml_files/container_sa_aw2s_asue.xml +++ b/ci-scripts/xml_files/container_sa_aw2s_asue.xml @@ -65,7 +65,8 @@ Pull_Cluster_Image Pull Images from Cluster oaicicd-ran - oai-gnb-aw2s + oai-gnb-aw2s + avra diff --git a/ci-scripts/xml_files/container_sa_aw2s_asue_2x2.xml b/ci-scripts/xml_files/container_sa_aw2s_asue_2x2.xml index 514672df66..2a37d2bfe4 100644 --- a/ci-scripts/xml_files/container_sa_aw2s_asue_2x2.xml +++ b/ci-scripts/xml_files/container_sa_aw2s_asue_2x2.xml @@ -64,7 +64,8 @@ Pull_Cluster_Image Pull Images from Cluster oaicicd-ran - oai-gnb-aw2s + oai-gnb-aw2s + avra Create_Workspace diff --git a/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml index 215fe3ea26..367a2c5cb3 100644 --- a/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml +++ b/ci-scripts/xml_files/container_sa_fhi72_vvdn_up2.xml @@ -56,7 +56,8 @@ Pull_Cluster_Image Pull Images from Cluster oaicicd-ran - oai-gnb-fhi72 + oai-gnb-fhi72 + cacofonix Create_Workspace diff --git a/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml index 214991e117..72c8bd06bc 100644 --- a/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml @@ -46,8 +46,8 @@ Pull_Cluster_Image Pull Images from Cluster - oai-gnb - matix + oai-gnb + matix diff --git a/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml index c94c30a7b2..7fb07e577a 100644 --- a/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml @@ -46,8 +46,8 @@ Pull_Cluster_Image Pull Images from Cluster - oai-gnb - matix + oai-gnb + matix diff --git a/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml index 0ffe3044b6..e03c4533dd 100644 --- a/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml @@ -46,8 +46,8 @@ Pull_Cluster_Image Pull Images from Cluster - oai-gnb - matix + oai-gnb + matix diff --git a/ci-scripts/xml_files/container_sa_n310_nrue.xml b/ci-scripts/xml_files/container_sa_n310_nrue.xml index a358bbf5f8..1758372e1d 100644 --- a/ci-scripts/xml_files/container_sa_n310_nrue.xml +++ b/ci-scripts/xml_files/container_sa_n310_nrue.xml @@ -44,15 +44,15 @@ Pull_Cluster_Image Pull Images from Cluster - oai-gnb - avra + oai-gnb + avra Pull_Cluster_Image Pull Images from Cluster - oai-nr-ue - caracal + oai-nr-ue + caracal