Commit 8b339bb6 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova Committed by Robert Schmidt

Retag porcepix and cluster registry images to use same prefix

Allows to reuse DeployObject, CleanTestImages, etc, to be reused
regardless of image registry origin.
parent b6feedc8
...@@ -215,14 +215,16 @@ class Cluster: ...@@ -215,14 +215,16 @@ class Cluster:
return False return False
for image in self.imageToPull: for image in self.imageToPull:
imagePrefix = f'{self.OCRegistry}{self.OCProjectName}' imagePrefix = f'{self.OCRegistry}{self.OCProjectName}'
imageTag = Get_Image_Tag(image, imagePrefix, self.ranCommitID, self.ranBranch, self.ranTargetBranch, self.ranAllowMerge) imageTag = cls_containerize.ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
ret = cmd.run(f'docker pull {imageTag}') ret = cmd.run(f'docker pull {imagePrefix}/{imageTag}')
if ret.returncode != 0: if ret.returncode != 0:
logging.error(f'Could not pull {image} from local registry : {self.OCRegistry}') logging.error(f'Could not pull {image} from local registry : {self.OCRegistry}')
OC_logout(cmd) OC_logout(cmd)
cmd.close() cmd.close()
HTML.CreateHtmlTestRow('msg', 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('msg', 'KO', CONST.ALL_PROCESSES_OK)
return False return False
cmd.run(f'docker tag {imagePrefix}/{imageTag} oai-ci/{imageTag}')
cmd.run(f'docker rmi {imagePrefix}/{imageTag}')
OC_logout(cmd) OC_logout(cmd)
cmd.close() cmd.close()
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#----------------------------------------------------------- #-----------------------------------------------------------
# Import # Import
#----------------------------------------------------------- #-----------------------------------------------------------
import sys # arg import sys # arg
import re # reg import re # reg
import logging import logging
import os import os
import shutil import shutil
...@@ -47,6 +47,7 @@ from zipfile import ZipFile ...@@ -47,6 +47,7 @@ from zipfile import ZipFile
#----------------------------------------------------------- #-----------------------------------------------------------
# OAI Testing modules # OAI Testing modules
#----------------------------------------------------------- #-----------------------------------------------------------
import cls_cluster as OC
import cls_cmd import cls_cmd
import sshconnection as SSH import sshconnection as SSH
import helpreadme as HELP import helpreadme as HELP
...@@ -90,6 +91,15 @@ def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTarge ...@@ -90,6 +91,15 @@ def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTarge
logging.debug(f'Merging with the target branch: {ranTargetBranch}') logging.debug(f'Merging with the target branch: {ranTargetBranch}')
sshSession.command(f'git merge --ff origin/{ranTargetBranch} -m "Temporary merge for CI"', '\$', 30) sshSession.command(f'git merge --ff origin/{ranTargetBranch} -m "Temporary merge for CI"', '\$', 30)
def ImageTagToUse(imageName, ranCommitID, ranBranch, ranAllowMerge):
shortCommit = ranCommitID[0:8]
if ranAllowMerge:
tagToUse = f'{ranBranch}-{shortCommit}'
else:
tagToUse = f'develop-{shortCommit}'
fullTag = f'{imageName}:{tagToUse}'
return fullTag
def CopyLogsToExecutor(cmd, sourcePath, log_name): def CopyLogsToExecutor(cmd, sourcePath, log_name):
cmd.cd(f'{sourcePath}/cmake_targets') cmd.cd(f'{sourcePath}/cmake_targets')
cmd.run(f'rm -f {log_name}.zip') cmd.run(f'rm -f {log_name}.zip')
...@@ -306,7 +316,6 @@ class Containerize(): ...@@ -306,7 +316,6 @@ class Containerize():
self.registrySvrId = '' self.registrySvrId = ''
self.testSvrId = '' self.testSvrId = ''
self.imageToPull = [] self.imageToPull = []
#checkers from xml #checkers from xml
self.ran_checkers={} self.ran_checkers={}
...@@ -649,15 +658,6 @@ class Containerize(): ...@@ -649,15 +658,6 @@ class Containerize():
HTML.CreateHtmlTestRow('commit ' + tag, 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('commit ' + tag, 'OK', CONST.ALL_PROCESSES_OK)
HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize) HTML.CreateHtmlNextTabHeaderTestRow(collectInfo, allImagesSize)
def ImageTagToUse(self, imageName):
shortCommit = self.ranCommitID[0:8]
if self.ranAllowMerge:
tagToUse = f'{self.ranBranch}-{shortCommit}'
else:
tagToUse = f'develop-{shortCommit}'
fullTag = f'porcepix.sboai.cs.eurecom.fr/{imageName}:{tagToUse}'
return fullTag
def Push_Image_to_Local_Registry(self, HTML): def Push_Image_to_Local_Registry(self, HTML):
if self.registrySvrId == '0': if self.registrySvrId == '0':
lIpAddr = self.eNBIPAddress lIpAddr = self.eNBIPAddress
...@@ -680,8 +680,8 @@ class Containerize(): ...@@ -680,8 +680,8 @@ class Containerize():
logging.debug('Pushing images from server: ' + lIpAddr) logging.debug('Pushing images from server: ' + lIpAddr)
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.open(lIpAddr, lUserName, lPassWord)
imagePrefix = 'porcepix.sboai.cs.eurecom.fr'
mySSH.command('docker login -u oaicicd -p oaicicd porcepix.sboai.cs.eurecom.fr', '\$', 5) mySSH.command(f'docker login -u oaicicd -p oaicicd {imagePrefix}', '\$', 5)
if re.search('Login Succeeded', mySSH.getBefore()) is None: if re.search('Login Succeeded', mySSH.getBefore()) is None:
msg = 'Could not log into local registry' msg = 'Could not log into local registry'
logging.error(msg) logging.error(msg)
...@@ -694,9 +694,9 @@ class Containerize(): ...@@ -694,9 +694,9 @@ class Containerize():
orgTag = 'ci-temp' orgTag = 'ci-temp'
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup'] imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup']
for image in imageNames: for image in imageNames:
tagToUse = self.ImageTagToUse(image) tagToUse = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
mySSH.command(f'docker image tag {image}:{orgTag} {tagToUse}', '\$', 5) mySSH.command(f'docker image tag {image}:{orgTag} {imagePrefix}/{tagToUse}', '\$', 5)
mySSH.command(f'docker push {tagToUse}', '\$', 120) mySSH.command(f'docker push {imagePrefix}/{tagToUse}', '\$', 120)
if re.search(': digest:', mySSH.getBefore()) is None: if re.search(': digest:', mySSH.getBefore()) is None:
logging.debug(mySSH.getBefore()) logging.debug(mySSH.getBefore())
msg = f'Could not push {image} to local registry : {tagToUse}' msg = f'Could not push {image} to local registry : {tagToUse}'
...@@ -704,9 +704,9 @@ class Containerize(): ...@@ -704,9 +704,9 @@ class Containerize():
mySSH.close() mySSH.close()
HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK)
return False return False
mySSH.command(f'docker rmi {tagToUse} {image}:{orgTag}', '\$', 30) mySSH.command(f'docker rmi {imagePrefix}/{tagToUse} {image}:{orgTag}', '\$', 30)
mySSH.command('docker logout porcepix.sboai.cs.eurecom.fr', '\$', 5) mySSH.command(f'docker logout {imagePrefix}', '\$', 5)
if re.search('Removing login credentials', mySSH.getBefore()) is None: if re.search('Removing login credentials', mySSH.getBefore()) is None:
msg = 'Could not log off from local registry' msg = 'Could not log off from local registry'
logging.error(msg) logging.error(msg)
...@@ -739,25 +739,18 @@ class Containerize(): ...@@ -739,25 +739,18 @@ class Containerize():
if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '': if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
if lIpAddr != 'none': myCmd = cls_cmd.getConnection(lIpAddr)
logging.debug('Pulling images onto server: ' + lIpAddr) imagePrefix = 'porcepix.sboai.cs.eurecom.fr'
myCmd = cls_cmd.RemoteCmd(lIpAddr) response = myCmd.run(f'docker login -u oaicicd -p oaicicd {imagePrefix}')
else:
logging.debug('Pulling images locally')
myCmd = cls_cmd.LocalCmd()
cmd = 'docker login -u oaicicd -p oaicicd porcepix.sboai.cs.eurecom.fr'
response = myCmd.run(cmd)
if response.returncode != 0: if response.returncode != 0:
msg = 'Could not log into local registry' msg = 'Could not log into local registry'
logging.error(msg) logging.error(msg)
myCmd.close() myCmd.close()
HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK)
return False return False
for image in self.imageToPull: for image in self.imageToPull:
tagToUse = self.ImageTagToUse(image) tagToUse = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
cmd = f'docker pull {tagToUse}' cmd = f'docker pull {imagePrefix}/{tagToUse}'
response = myCmd.run(cmd, timeout=120) response = myCmd.run(cmd, timeout=120)
if response.returncode != 0: if response.returncode != 0:
logging.debug(response) logging.debug(response)
...@@ -766,16 +759,15 @@ class Containerize(): ...@@ -766,16 +759,15 @@ class Containerize():
myCmd.close() myCmd.close()
HTML.CreateHtmlTestRow('msg', 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('msg', 'KO', CONST.ALL_PROCESSES_OK)
return False return False
myCmd.run(f'docker tag {imagePrefix}/{tagToUse} oai-ci/{tagToUse}')
cmd = 'docker logout porcepix.sboai.cs.eurecom.fr' myCmd.run(f'docker rmi {imagePrefix}/{tagToUse}')
response = myCmd.run(cmd) response = myCmd.run(f'docker logout {imagePrefix}')
if response.returncode != 0: if response.returncode != 0:
msg = 'Could not log off from local registry' msg = 'Could not log off from local registry'
logging.error(msg) logging.error(msg)
myCmd.close() myCmd.close()
HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(msg, 'KO', CONST.ALL_PROCESSES_OK)
return False return False
myCmd.close() myCmd.close()
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
return True return True
...@@ -810,7 +802,8 @@ class Containerize(): ...@@ -810,7 +802,8 @@ class Containerize():
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup'] imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup']
for image in imageNames: for image in imageNames:
cmd = f'docker rmi {self.ImageTagToUse(image)}' imageTag = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
cmd = f'docker rmi oai-ci/{imageTag}'
myCmd.run(cmd, reportNonZero=False) myCmd.run(cmd, reportNonZero=False)
myCmd.close() myCmd.close()
...@@ -845,10 +838,10 @@ class Containerize(): ...@@ -845,10 +838,10 @@ class Containerize():
mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5) mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5)
mySSH.command('cp docker-compose.y*ml ci-docker-compose.yml', '\$', 5) mySSH.command('cp docker-compose.y*ml ci-docker-compose.yml', '\$', 5)
imagesList = ['oai-enb', 'oai-gnb', 'oai-nr-cuup'] imagesList = ['oai-enb', 'oai-gnb', 'oai-nr-cuup', 'oai-gnb-aw2s']
for image in imagesList: for image in imagesList:
imageToUse = self.ImageTagToUse(image) imageTag = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
mySSH.command(f'sed -i -e "s#image: {image}:latest#image: {imageToUse}#" ci-docker-compose.yml', '\$', 2) mySSH.command(f'sed -i -e "s#image: {image}:latest#image: oai-ci/{imageTag}#" ci-docker-compose.yml', '\$', 2)
localMmeIpAddr = EPC.MmeIPAddress localMmeIpAddr = EPC.MmeIPAddress
mySSH.command('sed -i -e "s/CI_MME_IP_ADDR/' + localMmeIpAddr + '/" ci-docker-compose.yml', '\$', 2) mySSH.command('sed -i -e "s/CI_MME_IP_ADDR/' + localMmeIpAddr + '/" ci-docker-compose.yml', '\$', 2)
...@@ -966,6 +959,7 @@ class Containerize(): ...@@ -966,6 +959,7 @@ class Containerize():
logging.debug('\u001B[1m Undeploying OAI Object from server: ' + lIpAddr + '\u001B[0m') logging.debug('\u001B[1m Undeploying OAI Object from server: ' + lIpAddr + '\u001B[0m')
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(lIpAddr, lUserName, lPassWord) mySSH.open(lIpAddr, lUserName, lPassWord)
mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5) mySSH.command('cd ' + lSourcePath + '/' + self.yamlPath[self.eNB_instance], '\$', 5)
svcName = self.services[self.eNB_instance] svcName = self.services[self.eNB_instance]
...@@ -1050,13 +1044,12 @@ class Containerize(): ...@@ -1050,13 +1044,12 @@ class Containerize():
myCmd.close() myCmd.close()
HTML.CreateHtmlTestRow('SVC not Found', 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('SVC not Found', 'KO', CONST.ALL_PROCESSES_OK)
return return
cmd = 'cp docker-compose.y*ml docker-compose-ci.yml' cmd = 'cp docker-compose.y*ml docker-compose-ci.yml'
myCmd.run(cmd, silent=self.displayedNewTags) myCmd.run(cmd, silent=self.displayedNewTags)
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup'] imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup']
for image in imageNames: for image in imageNames:
tagToUse = self.ImageTagToUse(image) tagToUse = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
cmd = f'sed -i -e "s@oaisoftwarealliance/{image}:develop@{tagToUse}@" docker-compose-ci.yml' cmd = f'sed -i -e "s@oaisoftwarealliance/{image}:develop@oai-ci/{tagToUse}@" docker-compose-ci.yml'
myCmd.run(cmd, silent=self.displayedNewTags) myCmd.run(cmd, silent=self.displayedNewTags)
self.displayedNewTags = True self.displayedNewTags = True
...@@ -1193,13 +1186,12 @@ class Containerize(): ...@@ -1193,13 +1186,12 @@ class Containerize():
ymlPath = self.yamlPath[0].split('/') ymlPath = self.yamlPath[0].split('/')
logPath = '../cmake_targets/log/' + ymlPath[1] logPath = '../cmake_targets/log/' + ymlPath[1]
myCmd = cls_cmd.LocalCmd(d = self.yamlPath[0]) myCmd = cls_cmd.LocalCmd(d = self.yamlPath[0])
cmd = 'cp docker-compose.y*ml docker-compose-ci.yml' cmd = 'cp docker-compose.y*ml docker-compose-ci.yml'
myCmd.run(cmd, silent=self.displayedNewTags) myCmd.run(cmd, silent=self.displayedNewTags)
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup'] imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru', 'oai-nr-cuup']
for image in imageNames: for image in imageNames:
tagToUse = self.ImageTagToUse(image) tagToUse = ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
cmd = f'sed -i -e "s@oaisoftwarealliance/{image}:develop@{tagToUse}@" docker-compose-ci.yml' cmd = f'sed -i -e "s@oaisoftwarealliance/{image}:develop@oai-ci/{tagToUse}@" docker-compose-ci.yml'
myCmd.run(cmd, silent=self.displayedNewTags) myCmd.run(cmd, silent=self.displayedNewTags)
self.displayedNewTags = True self.displayedNewTags = True
......
...@@ -38,12 +38,12 @@ import helpreadme as HELP ...@@ -38,12 +38,12 @@ import helpreadme as HELP
import constants as CONST import constants as CONST
import cls_oaicitest #main class for OAI CI test framework import cls_oaicitest #main class for OAI CI test framework
import cls_physim #class PhySim for physical simulators build and test import cls_physim #class PhySim for physical simulators build and test
import cls_containerize #class Containerize for all container-based operations on RAN/UE objects import cls_containerize #class Containerize for all container-based operations on RAN/UE objects
import cls_static_code_analysis #class for static code analysis import cls_static_code_analysis #class for static code analysis
import cls_physim1 #class PhySim for physical simulators deploy and run import cls_physim1 #class PhySim for physical simulators deploy and run
import cls_cluster # class for building/deploying on cluster import cls_cluster # class for building/deploying on cluster
import sshconnection import sshconnection
import epc import epc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment