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
Michael Black
OpenXG-RAN
Commits
5a24210b
Commit
5a24210b
authored
Sep 14, 2021
by
hardy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if container is running
parent
7a505f75
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
ci-scripts/epc.py
ci-scripts/epc.py
+12
-5
ci-scripts/sshconnection.py
ci-scripts/sshconnection.py
+12
-0
No files found.
ci-scripts/epc.py
View file @
5a24210b
...
@@ -235,6 +235,11 @@ class EPCManagement():
...
@@ -235,6 +235,11 @@ class EPCManagement():
mySSH
.
command
(
'mkdir -p '
+
self
.
SourceCodePath
+
'/scripts'
,
'\$'
,
5
)
mySSH
.
command
(
'mkdir -p '
+
self
.
SourceCodePath
+
'/scripts'
,
'\$'
,
5
)
mySSH
.
command
(
'cd /opt/oai-cn5g-fed/docker-compose'
,
'\$'
,
5
)
mySSH
.
command
(
'cd /opt/oai-cn5g-fed/docker-compose'
,
'\$'
,
5
)
mySSH
.
command
(
'./core-network.sh start nrf spgwu'
,
'\$'
,
30
)
mySSH
.
command
(
'./core-network.sh start nrf spgwu'
,
'\$'
,
30
)
#time.sleep(10)
#response = mySSH.command3('docker inspect --format=\'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\' oai-amf', 5)
#self.MmeIPAddress = str(response[0],'utf-8')
#self.MmeIPAddress.rstrip()
#logging.debug('AMF IP Address ' + self.MmeIPAddress)
else
:
else
:
logging
.
error
(
'This option should not occur!'
)
logging
.
error
(
'This option should not occur!'
)
mySSH
.
close
()
mySSH
.
close
()
...
@@ -251,9 +256,11 @@ class EPCManagement():
...
@@ -251,9 +256,11 @@ class EPCManagement():
elif
re
.
match
(
'OAICN5G'
,
self
.
Type
,
re
.
IGNORECASE
):
elif
re
.
match
(
'OAICN5G'
,
self
.
Type
,
re
.
IGNORECASE
):
mySSH
=
SSH
.
SSHConnection
()
mySSH
=
SSH
.
SSHConnection
()
mySSH
.
open
(
self
.
IPAddress
,
self
.
UserName
,
self
.
Password
)
mySSH
.
open
(
self
.
IPAddress
,
self
.
UserName
,
self
.
Password
)
mySSH
.
command2
(
'docker inspect --format=
\'
{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}
\'
oai-amf'
,
5
)
response
=
mySSH
.
command3
(
'docker container ls -f name=oai-amf'
,
10
)
self
.
MmeIPAddress
=
str
(
mySSH
.
cmd2Results
[
0
],
'utf-8'
)
if
len
(
response
)
>
1
:
self
.
MmeIPAddress
.
rstrip
()
response
=
mySSH
.
command3
(
'docker inspect --format=
\'
{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}
\'
oai-amf'
,
10
)
tmp
=
str
(
response
[
0
],
'utf-8'
)
self
.
MmeIPAddress
=
tmp
.
rstrip
()
logging
.
debug
(
'AMF IP Address '
+
self
.
MmeIPAddress
)
logging
.
debug
(
'AMF IP Address '
+
self
.
MmeIPAddress
)
mySSH
.
close
()
mySSH
.
close
()
...
@@ -459,7 +466,7 @@ class EPCManagement():
...
@@ -459,7 +466,7 @@ class EPCManagement():
self
.
LogCollectOAICN5G
()
self
.
LogCollectOAICN5G
()
logging
.
debug
(
'Terminating OAI CN5G'
)
logging
.
debug
(
'Terminating OAI CN5G'
)
mySSH
.
command
(
'cd /opt/oai-cn5g-fed/docker-compose'
,
'\$'
,
5
)
mySSH
.
command
(
'cd /opt/oai-cn5g-fed/docker-compose'
,
'\$'
,
5
)
mySSH
.
command
(
'./core-network.sh stop nrf spgwu'
,
'\$'
,
5
)
mySSH
.
command
(
'./core-network.sh stop nrf spgwu'
,
'\$'
,
30
)
else
:
else
:
logging
.
error
(
'This should not happen!'
)
logging
.
error
(
'This should not happen!'
)
mySSH
.
close
()
mySSH
.
close
()
...
...
ci-scripts/sshconnection.py
View file @
5a24210b
...
@@ -163,6 +163,18 @@ class SSHConnection():
...
@@ -163,6 +163,18 @@ class SSHConnection():
lSsh
=
subprocess
.
Popen
([
"ssh"
,
"%s"
%
myHost
,
commandline
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
lSsh
=
subprocess
.
Popen
([
"ssh"
,
"%s"
%
myHost
,
commandline
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
self
.
cmd2Results
=
str
(
lSsh
.
stdout
.
readlines
())
self
.
cmd2Results
=
str
(
lSsh
.
stdout
.
readlines
())
def
command3
(
self
,
commandline
,
timeout
,
silent
=
False
):
if
not
silent
:
logging
.
debug
(
commandline
)
self
.
cmd2Results
=
''
myHost
=
self
.
username
+
'@'
+
self
.
ipaddress
# CAUTION: THIS METHOD IMPLIES THAT THERE ARE VALID SSH KEYS
# BETWEEN THE PYTHON EXECUTOR NODE AND THE REMOTE HOST
# OTHERWISE IT WON'T WORK
lSsh
=
subprocess
.
Popen
([
"ssh"
,
"%s"
%
myHost
,
commandline
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
return
lSsh
.
stdout
.
readlines
()
def
close
(
self
):
def
close
(
self
):
self
.
ssh
.
timeout
=
5
self
.
ssh
.
timeout
=
5
self
.
ssh
.
sendline
(
'exit'
)
self
.
ssh
.
sendline
(
'exit'
)
...
...
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