Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangwenhui
OpenXG-RAN
Commits
1c8d2671
Commit
1c8d2671
authored
Jan 04, 2021
by
Mohammed Ismail
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cls_container] adapted to build the image on asterix and obelix
parent
f6f02181
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
78 deletions
+33
-78
ci-scripts/cls_containerize.py
ci-scripts/cls_containerize.py
+33
-78
No files found.
ci-scripts/cls_containerize.py
View file @
1c8d2671
...
...
@@ -114,53 +114,35 @@ class Containerize():
mySSH
=
SSH
.
SSHConnection
()
mySSH
.
open
(
lIpAddr
,
lUserName
,
lPassWord
)
# Checking the hostname to get adapted on cli and dockerfileprefixes
mySSH
.
command
(
'hostname'
,
'\$'
,
5
)
self
.
host
=
re
.
search
(
'obelix|asterix'
,
mySSH
.
getBefore
())
if
self
.
host
==
'obelix'
:
self
.
cli
=
'docker'
# Checking the hostname to get adapted on cli and dockerfileprefixes
mySSH
.
command
(
'hostnamectl'
,
'\$'
,
5
)
result
=
re
.
search
(
'Ubuntu|Red Hat'
,
mySSH
.
getBefore
())
self
.
host
=
result
.
group
(
0
)
if
self
.
host
==
'Ubuntu'
:
self
.
cli
=
'docker'
self
.
dockerfileprefix
=
'.ubuntu18'
elif
self
.
host
==
'
asterix
'
:
self
.
cli
=
'
sudo
podman'
elif
self
.
host
==
'
Red Hat
'
:
self
.
cli
=
'podman'
self
.
dockerfileprefix
=
'.rhel8.2'
imageNames
=
[]
if
self
.
host
==
'obelix'
:
result
=
re
.
search
(
'eNB'
,
self
.
imageKind
)
# Creating a tupple with the imageName and the DockerFile prefix pattern on obelix
result
=
re
.
search
(
'eNB'
,
self
.
imageKind
)
# Creating a tupple with the imageName and the DockerFile prefix pattern on obelix
if
result
is
not
None
:
imageNames
.
append
((
'oai-enb'
,
'eNB'
))
else
:
result
=
re
.
search
(
'gNB'
,
self
.
imageKind
)
if
result
is
not
None
:
imageNames
.
append
((
'oai-
enb'
,
'e
NB'
))
imageNames
.
append
((
'oai-
gnb'
,
'g
NB'
))
else
:
result
=
re
.
search
(
'
gNB
'
,
self
.
imageKind
)
result
=
re
.
search
(
'
all
'
,
self
.
imageKind
)
if
result
is
not
None
:
imageNames
.
append
((
'oai-gnb'
,
'gNB'
))
else
:
result
=
re
.
search
(
'all'
,
self
.
imageKind
)
if
result
is
not
None
:
imageNames
.
append
((
'oai-enb'
,
'eNB'
))
imageNames
.
append
((
'oai-gnb'
,
'gNB'
))
imageNames
.
append
((
'oai-lte-ue'
,
'lteUE'
))
imageNames
.
append
((
'oai-nr-ue'
,
'nrUE'
))
if
len
(
imageNames
)
==
0
:
imageNames
.
append
((
'oai-enb'
,
'eNB'
))
elif
self
.
host
==
'asterix'
:
result
=
re
.
search
(
'eNB'
,
self
.
imageKind
)
# Creating a tupple with the imageName and the DockerFile prefix pattern on asterix
if
result
is
not
None
:
imageNames
.
append
((
'localhost/oai-enb'
,
'eNB'
))
else
:
result
=
re
.
search
(
'gNB'
,
self
.
imageKind
)
if
result
is
not
None
:
imageNames
.
append
((
'localhost/oai-gnb'
,
'gNB'
))
else
:
result
=
re
.
search
(
'all'
,
self
.
imageKind
)
if
result
is
not
None
:
imageNames
.
append
((
'localhost/oai-enb'
,
'eNB'
))
imageNames
.
append
((
'localhost/oai-gnb'
,
'gNB'
))
imageNames
.
append
((
'localhost/oai-lte-ue'
,
'lteUE'
))
imageNames
.
append
((
'localhost/oai-nr-ue'
,
'nrUE'
))
if
len
(
imageNames
)
==
0
:
imageNames
.
append
((
'localhost/oai-enb'
,
'eNB'
))
imageNames
.
append
((
'oai-enb'
,
'eNB'
))
#imageNames.append(('oai-gnb', 'gNB'))
#imageNames.append(('oai-lte-ue', 'lteUE'))
#imageNames.append(('oai-nr-ue', 'nrUE'))
if
len
(
imageNames
)
==
0
:
imageNames
.
append
((
'oai-enb'
,
'eNB'
))
# Workaround for some servers, we need to erase completely the workspace
if
self
.
forcedWorkspaceCleanup
:
...
...
@@ -197,49 +179,22 @@ class Containerize():
mySSH
.
command
(
'git merge --ff origin/'
+
self
.
ranTargetBranch
+
' -m "Temporary merge for CI"'
,
'\$'
,
5
)
# if asterix, copy the entitlement and subscription manager configurations
if
self
.
host
==
'asterix'
:
if
self
.
host
==
'Red Hat'
:
mySSH
.
command
(
'mkdir -p tmp/ca/'
,
'\$'
,
5
)
mySSH
.
command
(
'mkdir -p tmp/entitlement/'
,
'\$'
,
5
)
mySSH
.
command
(
'sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca/'
,
'\$'
,
5
)
mySSH
.
command
(
'sudo cp /etc/pki/entitlement/*.pem tmp/entitlement/'
,
'\$'
,
5
)
# debug to be removed
for
image
,
pattern
in
imageNames
:
mySSH
.
command
(
self
.
cli
+
' image rm '
+
image
+
':'
+
imageTag
,
'\$'
,
5
)
logging
.
debug
(
mySSH
.
getBefore
())
mySSH
.
close
()
return
0
# Build the shared image
if
self
.
host
==
'obelix'
:
sharedimage
=
'ran-build'
elif
self
.
host
==
'asterix'
:
sharedimage
=
'localhost/ran-build'
mySSH
.
command
(
self
.
cli
+
' build --target '
+
sharedimage
+
' --tag '
+
sharedimage
+
':'
+
imageTag
+
' --file docker/Dockerfile.ran'
+
self
.
dockerfileprefix
+
' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1'
,
'\$'
,
800
)
# Build the target image(s)
previousImage
=
sharedimage
+
':'
+
imageTag
danglingShaOnes
=
[]
for
image
,
pattern
in
imageNames
:
# the archived Dockerfiles have "ran-build:latest" as base image
# we need to update them with proper tag
mySSH
.
command
(
'sed -i -e "s#'
+
sharedimage
+
':latest#'
+
sharedimage
+
':'
+
imageTag
+
'#" docker/Dockerfile.'
+
pattern
+
self
.
dockerfileprefix
,
'\$'
,
5
)
mySSH
.
command
(
self
.
cli
+
' build --target '
+
image
+
' --tag '
+
image
+
':'
+
imageTag
+
' --file docker/Dockerfile.'
+
pattern
+
self
.
dockerfileprefix
+
' . > cmake_targets/log/'
+
image
+
'.log 2>&1'
,
'\$'
,
600
)
# Retrieving the dangling image(s) for the log collection
mySSH
.
command
(
self
.
cli
+
' images --filter "dangling=true" --filter "since='
+
previousImage
+
'" -q | sed -e "s#^#sha=#"'
,
'\$'
,
5
)
result
=
re
.
search
(
'sha=(?P<imageShaOne>[a-zA-Z0-9\-\_]+)'
,
mySSH
.
getBefore
())
if
result
is
not
None
:
danglingShaOnes
.
append
((
image
,
result
.
group
(
'imageShaOne'
)))
previousImage
=
image
+
':'
+
imageTag
imageTag
=
'ci-temp'
# First verify if images were properly created.
status
=
True
#mySSH.close()
#return 0
sharedimage
=
'ran-build'
# Let's remove any previous run artifacts if still there
mySSH
.
command
(
self
.
cli
+
' image prune --force'
,
'\$'
,
5
)
mySSH
.
command
(
self
.
cli
' image rm '
+
sharedimage
+
':'
+
imageTag
,
'\$'
,
5
)
mySSH
.
command
(
self
.
cli
+
' image rm '
+
sharedimage
+
':'
+
imageTag
,
'\$'
,
5
)
for
image
,
pattern
in
imageNames
:
mySSH
.
command
(
self
.
cli
+
' image rm '
+
image
+
':'
+
imageTag
,
'\$'
,
5
)
# Build the shared image
mySSH
.
command
(
self
.
cli
+
' build --target '
+
sharedimage
+
' --tag '
+
sharedimage
+
':'
+
imageTag
+
' --file docker/Dockerfile.ran'
+
self
.
dockerfileprefix
+
' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1'
,
'\$'
,
8
00
)
mySSH
.
command
(
self
.
cli
+
' build --target '
+
sharedimage
+
' --tag '
+
sharedimage
+
':'
+
imageTag
+
' --file docker/Dockerfile.ran'
+
self
.
dockerfileprefix
+
' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1'
,
'\$'
,
16
00
)
# Build the target image(s)
previousImage
=
sharedimage
+
':'
+
imageTag
danglingShaOnes
=
[]
...
...
@@ -247,7 +202,7 @@ class Containerize():
# the archived Dockerfiles have "ran-build:latest" as base image
# we need to update them with proper tag
mySSH
.
command
(
'sed -i -e "s#'
+
sharedimage
+
':latest#'
+
sharedimage
+
':'
+
imageTag
+
'#" docker/Dockerfile.'
+
pattern
+
self
.
dockerfileprefix
,
'\$'
,
5
)
mySSH
.
command
(
self
.
cli
+
' build --target '
+
image
+
' --tag '
+
image
+
':'
+
imageTag
+
' --file docker/Dockerfile.'
+
pattern
+
self
.
dockerfileprefix
+
' . > cmake_targets/log/'
+
image
+
'.log 2>&1'
,
'\$'
,
6
00
)
mySSH
.
command
(
self
.
cli
+
' build --target '
+
image
+
' --tag '
+
image
+
':'
+
imageTag
+
' --file docker/Dockerfile.'
+
pattern
+
self
.
dockerfileprefix
+
' . > cmake_targets/log/'
+
image
+
'.log 2>&1'
,
'\$'
,
12
00
)
# Retrieving the dangling image(s) for the log collection
mySSH
.
command
(
self
.
cli
+
' images --filter "dangling=true" --filter "since='
+
previousImage
+
'" -q | sed -e "s#^#sha=#"'
,
'\$'
,
5
)
result
=
re
.
search
(
'sha=(?P<imageShaOne>[a-zA-Z0-9\-\_]+)'
,
mySSH
.
getBefore
())
...
...
@@ -263,7 +218,7 @@ class Containerize():
logging
.
error
(
'Could not build properly ran-build'
)
status
=
False
else
:
result
=
re
.
search
(
'Size
= (?P<size>[0-9\-]+)
bytes'
,
mySSH
.
getBefore
())
result
=
re
.
search
(
'Size
*= *(?P<size>[0-9\-]+) *
bytes'
,
mySSH
.
getBefore
())
if
result
is
not
None
:
imageSize
=
float
(
result
.
group
(
'size'
))
imageSize
=
imageSize
/
1000
...
...
@@ -284,7 +239,7 @@ class Containerize():
logging
.
error
(
'Could not build properly '
+
image
)
status
=
False
else
:
result
=
re
.
search
(
'Size
= (?P<size>[0-9\-]+)
bytes'
,
mySSH
.
getBefore
())
result
=
re
.
search
(
'Size
*= *(?P<size>[0-9\-]+) *
bytes'
,
mySSH
.
getBefore
())
if
result
is
not
None
:
imageSize
=
float
(
result
.
group
(
'size'
))
imageSize
=
imageSize
/
1000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment