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
lizhongxiao
OpenXG-RAN
Commits
b34e4d0a
Commit
b34e4d0a
authored
Apr 14, 2023
by
Jaroslava Fiedlerova
Committed by
Robert Schmidt
Apr 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CI Cluster module: refactor login&logout, pull cluster images
parent
98f06c59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
9 deletions
+74
-9
ci-scripts/cls_cluster.py
ci-scripts/cls_cluster.py
+59
-2
ci-scripts/main.py
ci-scripts/main.py
+14
-7
ci-scripts/xml_class_list.yml
ci-scripts/xml_class_list.yml
+1
-0
No files found.
ci-scripts/cls_cluster.py
View file @
b34e4d0a
...
...
@@ -40,6 +40,29 @@ import cls_cmd
IMAGE_REGISTRY_SERVICE_NAME
=
"image-registry.openshift-image-registry.svc"
NAMESPACE
=
"oaicicd-ran"
OCUrl
=
"https://api.oai.cs.eurecom.fr:6443"
OCRegistry
=
"default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/"
def
OC_login
(
cmd
,
ocUserName
,
ocPassword
,
ocProjectName
):
if
ocUserName
==
''
or
ocPassword
==
''
or
ocProjectName
==
''
:
HELP
.
GenericHelp
(
CONST
.
Version
)
sys
.
exit
(
'Insufficient Parameter: no OC Credentials'
)
if
OCRegistry
.
startswith
(
"http"
)
and
not
self
.
OCRegistry
.
endswith
(
"/"
):
sys
.
exit
(
f'ocRegistry
{
OCRegistry
}
should not start with http:// or https:// and end on a slash /'
)
ret
=
cmd
.
run
(
f'oc login -u
{
ocUserName
}
-p
{
ocPassword
}
--server
{
OCUrl
}
'
)
if
ret
.
returncode
!=
0
:
logging
.
error
(
'
\u001B
[1m OC Cluster Login Failed
\u001B
[0m'
)
return
False
ret
=
cmd
.
run
(
f'oc project
{
ocProjectName
}
'
)
if
ret
.
returncode
!=
0
:
logging
.
error
(
f'
\u001B
[1mUnable to access OC project
{
ocProjectName
}
\u001B
[0m'
)
OC_logout
(
cmd
)
return
False
return
True
def
OC_logout
(
cmd
):
cmd
.
run
(
f'oc logout'
)
class
Cluster
:
def
__init__
(
self
):
...
...
@@ -57,7 +80,7 @@ class Cluster:
self
.
ranAllowMerge
=
False
self
.
ranTargetBranch
=
""
self
.
cmd
=
None
self
.
imageToPull
=
''
def
_recreate_entitlements
(
self
):
# recreating entitlements, don't care if deletion fails
...
...
@@ -170,11 +193,45 @@ class Cluster:
def
_undeploy_pod
(
self
,
filename
):
self
.
cmd
.
run
(
f'oc delete -f
{
filename
}
'
)
def
PullClusterImage
(
self
,
HTML
,
RAN
):
if
self
.
imageToPull
==
''
:
HELP
.
GenericHelp
(
CONST
.
Version
)
HELP
.
EPCSrvHelp
(
self
.
imageToPull
)
sys
.
exit
(
'Insufficient eNB Parameters'
)
lIpAddr
=
self
.
eNBIPAddress
self
.
testCase_id
=
HTML
.
testCase_id
cmd
=
cls_cmd
.
getConnection
(
lIpAddr
)
succeeded
=
OC_login
(
cmd
,
self
.
OCUserName
,
self
.
OCPassword
,
self
.
OCProjectName
)
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
{
ocProjectName
}
\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
}{
self
.
OCProjectName
}
'
imageTag
=
Get_Image_Tag
(
image
,
imagePrefix
,
self
.
ranCommitID
,
self
.
ranBranch
,
self
.
ranTargetBranch
,
self
.
ranAllowMerge
)
ret
=
cmd
.
run
(
f'docker pull
{
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
)
return
False
OC_logout
(
cmd
)
cmd
.
close
()
HTML
.
CreateHtmlTestRow
(
'N/A'
,
'OK'
,
CONST
.
ALL_PROCESSES_OK
)
return
True
def
BuildClusterImage
(
self
,
HTML
):
if
self
.
ranRepository
==
''
or
self
.
ranBranch
==
''
or
self
.
ranCommitID
==
''
:
HELP
.
GenericHelp
(
CONST
.
Version
)
sys
.
exit
(
f'Insufficient Parameter: ranRepository
{
self
.
ranRepository
}
ranBranch
{
ranBranch
}
ranCommitID
{
self
.
ranCommitID
}
'
)
lIpAddr
=
self
.
eNBIPAddress
lSourcePath
=
self
.
eNBSourceCodePath
if
lIpAddr
==
''
or
lSourcePath
==
''
:
...
...
ci-scripts/main.py
View file @
b34e4d0a
...
...
@@ -38,12 +38,12 @@ import helpreadme as HELP
import
constants
as
CONST
import
cls_oaicitest
#main class for OAI CI test framework
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_static_code_analysis
#class for static code analysis
import
cls_physim1
#class PhySim for physical simulators deploy and run
import
cls_cluster
# class for building/deploying on cluster
import
cls_oaicitest
#main class for OAI CI test framework
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_static_code_analysis
#class for static code analysis
import
cls_physim1
#class PhySim for physical simulators deploy and run
import
cls_cluster
# class for building/deploying on cluster
import
sshconnection
import
epc
...
...
@@ -430,7 +430,11 @@ def GetParametersFromXML(action):
RAN
.
node
=
test
.
findtext
(
'node'
)
RAN
.
command
=
test
.
findtext
(
'command'
)
RAN
.
command_fail
=
test
.
findtext
(
'command_fail'
)
in
[
'True'
,
'true'
,
'Yes'
,
'yes'
]
elif
action
==
'Pull_Cluster_Image'
:
# CLUSTER.imageToPull.clear()
string_field
=
test
.
findtext
(
'images_to_pull'
)
if
(
string_field
is
not
None
):
CLUSTER
.
imageToPull
=
string_field
.
split
()
else
:
logging
.
warning
(
f"unknown action
{
action
}
from option-parsing point-of-view"
)
...
...
@@ -829,6 +833,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
HTML
=
ldpc
.
Run_NRulsimTest
(
HTML
,
CONST
,
id
)
if
ldpc
.
exitStatus
==
1
:
RAN
.
prematureExit
=
True
elif
action
==
'Pull_Cluster_Image'
:
if
not
CLUSTER
.
PullClusterImage
(
HTML
,
RAN
):
RAN
.
prematureExit
=
True
elif
action
==
'Build_Cluster_Image'
:
if
not
CLUSTER
.
BuildClusterImage
(
HTML
):
RAN
.
prematureExit
=
True
...
...
ci-scripts/xml_class_list.yml
View file @
b34e4d0a
-
Build_Proxy
-
Build_Cluster_Image
-
Pull_Cluster_Image
-
Build_PhySim
-
Run_LDPCTest
-
Run_LDPCt1Test
...
...
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