mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
CI: PullClusterImage(): harmonize code
- reuse cls_containerize.Containerize.PullImage() - pass parameter directly instead of indirectly via class - always read node name and use this instead of "sometimes" looking it up from a class member. With "sometimes" I mean that if no node name is given, it will take it from self.eNBIPAddress, which is confusing at best if we can give the node name directly - consistently put the node name in the xml file
This commit is contained in:
@@ -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 == '':
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<oc_project>oaicicd-ran</oc_project>
|
||||
<images_to_pull>oai-gnb-aw2s</images_to_pull>
|
||||
<images>oai-gnb-aw2s</images>
|
||||
<node>avra</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id="101000">
|
||||
|
||||
@@ -64,7 +64,8 @@
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<oc_project>oaicicd-ran</oc_project>
|
||||
<images_to_pull>oai-gnb-aw2s</images_to_pull>
|
||||
<images>oai-gnb-aw2s</images>
|
||||
<node>avra</node>
|
||||
</testCase>
|
||||
<testCase id="800813">
|
||||
<class>Create_Workspace</class>
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<oc_project>oaicicd-ran</oc_project>
|
||||
<images_to_pull>oai-gnb-fhi72</images_to_pull>
|
||||
<images>oai-gnb-fhi72</images>
|
||||
<node>cacofonix</node>
|
||||
</testCase>
|
||||
<testCase id="800813">
|
||||
<class>Create_Workspace</class>
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
<testCase id="111111">
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<images_to_pull>oai-gnb</images_to_pull>
|
||||
<test_svr_id>matix</test_svr_id>
|
||||
<images>oai-gnb</images>
|
||||
<node>matix</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id="100000">
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
<testCase id="111111">
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<images_to_pull>oai-gnb</images_to_pull>
|
||||
<test_svr_id>matix</test_svr_id>
|
||||
<images>oai-gnb</images>
|
||||
<node>matix</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id="100000">
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
<testCase id="111111">
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<images_to_pull>oai-gnb</images_to_pull>
|
||||
<test_svr_id>matix</test_svr_id>
|
||||
<images>oai-gnb</images>
|
||||
<node>matix</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id="100000">
|
||||
|
||||
@@ -44,15 +44,15 @@
|
||||
<testCase id="010000">
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<images_to_pull>oai-gnb</images_to_pull>
|
||||
<test_svr_id>avra</test_svr_id>
|
||||
<images>oai-gnb</images>
|
||||
<node>avra</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id="010001">
|
||||
<class>Pull_Cluster_Image</class>
|
||||
<desc>Pull Images from Cluster</desc>
|
||||
<images_to_pull>oai-nr-ue</images_to_pull>
|
||||
<test_svr_id>caracal</test_svr_id>
|
||||
<images>oai-nr-ue</images>
|
||||
<node>caracal</node>
|
||||
</testCase>
|
||||
|
||||
<testCase id = "030000">
|
||||
|
||||
Reference in New Issue
Block a user