Commit 8e8e9d67 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: fix html generation in EPC functions

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 92ce0e8d
...@@ -46,7 +46,7 @@ from multiprocessing import Process, Lock, SimpleQueue ...@@ -46,7 +46,7 @@ from multiprocessing import Process, Lock, SimpleQueue
import sshconnection as SSH import sshconnection as SSH
import helpreadme as HELP import helpreadme as HELP
import constants as CONST import constants as CONST
import html as HTML import html
#----------------------------------------------------------- #-----------------------------------------------------------
# Class Declaration # Class Declaration
...@@ -55,100 +55,99 @@ class EPCManagement(): ...@@ -55,100 +55,99 @@ class EPCManagement():
def __init__(self): def __init__(self):
self.EPCIPAddress = '' self.IPAddress = ''
self.UserName = '' self.UserName = ''
self.Password = '' self.Password = ''
self.SourceCodePath = '' self.SourceCodePath = ''
self.Type = '' self.Type = ''
self.EPC_PcapFileName = '' self.PcapFileName = ''
self.htmlObj = None
#----------------------------------------------------------- #-----------------------------------------------------------
# Setter and Getters # Setter and Getters on Public Members
#----------------------------------------------------------- #-----------------------------------------------------------
def SetIPAddress(self, ipaddress): def SetIPAddress(self, ipaddress):
self.EPCIPAddress = ipaddress self.IPAddress = ipaddress
def GetIPAddress(self): def GetIPAddress(self):
return self.EPCIPAddress return self.IPAddress
def SetUserName(self, username): def SetUserName(self, username):
self.EPCUserName = username self.UserName = username
def GetUserName(self): def GetUserName(self):
return self.EPCUserName return self.UserName
def SetPassword(self, password): def SetPassword(self, password):
self.EPCPassword = password self.Password = password
def GetPassword(self): def GetPassword(self):
return self.EPCPassword return self.Password
def SetSourceCodePath(self, sourcecodepath): def SetSourceCodePath(self, sourcecodepath):
self.EPCSourceCodePath = sourcecodepath self.SourceCodePath = sourcecodepath
def GetSourceCodePath(self): def GetSourceCodePath(self):
return self.EPCSourceCodePath return self.SourceCodePath
def SetType(self, typ): def SetType(self, kind):
self.EPCType = typ self.Type = kind
def GetType(self): def GetType(self):
return self.EPCType return self.Type
def Set_PcapFileName(self, pcapfn): def SetHtmlObj(self, obj):
self.EPC_PcapFileName = pcapfn self.htmlObj = obj
def Get_PcapFileName(self):
return self.EPC_PcapFileName
#----------------------------------------------------------- #-----------------------------------------------------------
# EPC management functions # EPC management functions
#----------------------------------------------------------- #-----------------------------------------------------------
def InitializeHSS(self): def InitializeHSS(self):
if self.EPCIPAddress == '' or self.EPCUserName == '' or self.EPCPassword == '' or self.EPCSourceCodePath == '' or self.EPCType == '': if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
HELP.GenericHelp(Version) HELP.GenericHelp(Version)
HELP.EPCSrvHelp(self.EPCIPAddress, self.EPCUserName, self.EPCPassword, self.EPCSourceCodePath, self.EPCType) HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password, self.SourceCodePath, self.Type)
sys.exit('Insufficient EPC Parameters') sys.exit('Insufficient EPC Parameters')
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
logging.debug('Using the OAI EPC Release 14 Cassandra-based HSS') logging.debug('Using the OAI EPC Release 14 Cassandra-based HSS')
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
logging.debug('\u001B[1m Launching tshark on all interfaces \u001B[0m') logging.debug('\u001B[1m Launching tshark on all interfaces \u001B[0m')
self.EPC_PcapFileName = 'epc_' + self.testCase_id + '.pcap' self.PcapFileName = 'epc_' + self.testCase_id + '.pcap'
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f ' + self.EPC_PcapFileName, '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f ' + self.PcapFileName, '\$', 5)
mySSH.command('echo $USER; nohup sudo tshark -f "tcp port not 22 and port not 53" -i any -w ' + self.EPCSourceCodePath + '/scripts/' + self.EPC_PcapFileName + ' > /tmp/tshark.log 2>&1 &', self.EPCUserName, 5) mySSH.command('echo $USER; nohup sudo tshark -f "tcp port not 22 and port not 53" -i any -w ' + self.SourceCodePath + '/scripts/' + self.PcapFileName + ' > /tmp/tshark.log 2>&1 &', self.UserName, 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S mkdir -p logs', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S mkdir -p logs', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f hss_' + self.testCase_id + '.log logs/hss*.*', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f hss_' + self.testCase_id + '.log logs/hss*.*', '\$', 5)
mySSH.command('echo "oai_hss -j /usr/local/etc/oai/hss_rel14.json" > ./my-hss.sh', '\$', 5) mySSH.command('echo "oai_hss -j /usr/local/etc/oai/hss_rel14.json" > ./my-hss.sh', '\$', 5)
mySSH.command('chmod 755 ./my-hss.sh', '\$', 5) mySSH.command('chmod 755 ./my-hss.sh', '\$', 5)
mySSH.command('sudo daemon --unsafe --name=hss_daemon --chdir=' + self.EPCSourceCodePath + '/scripts -o ' + self.EPCSourceCodePath + '/scripts/hss_' + self.testCase_id + '.log ./my-hss.sh', '\$', 5) mySSH.command('sudo daemon --unsafe --name=hss_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/hss_' + self.testCase_id + '.log ./my-hss.sh', '\$', 5)
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
logging.debug('Using the OAI EPC HSS') logging.debug('Using the OAI EPC HSS')
mySSH.command('cd ' + self.EPCSourceCodePath, '\$', 5) mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
mySSH.command('source oaienv', '\$', 5) mySSH.command('source oaienv', '\$', 5)
mySSH.command('cd scripts', '\$', 5) mySSH.command('cd scripts', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./run_hss 2>&1 | stdbuf -o0 awk \'{ print strftime("[%Y/%m/%d %H:%M:%S] ",systime()) $0 }\' | stdbuf -o0 tee -a hss_' + self.testCase_id + '.log &', 'Core state: 2 -> 3', 35) mySSH.command('echo ' + self.Password + ' | sudo -S ./run_hss 2>&1 | stdbuf -o0 awk \'{ print strftime("[%Y/%m/%d %H:%M:%S] ",systime()) $0 }\' | stdbuf -o0 tee -a hss_' + self.testCase_id + '.log &', 'Core state: 2 -> 3', 35)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
logging.debug('Using the ltebox simulated HSS') logging.debug('Using the ltebox simulated HSS')
mySSH.command('if [ -d ' + self.EPCSourceCodePath + '/scripts ]; then echo ' + self.EPCPassword + ' | sudo -S rm -Rf ' + self.EPCSourceCodePath + '/scripts ; fi', '\$', 5) mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5)
mySSH.command('mkdir -p ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('cd /opt/hss_sim0609', '\$', 5) mySSH.command('cd /opt/hss_sim0609', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f hss.log daemon.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f hss.log daemon.log', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S echo "Starting sudo session" && sudo su -c "screen -dm -S simulated_hss ./starthss"', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S echo "Starting sudo session" && sudo su -c "screen -dm -S simulated_hss ./starthss"', '\$', 5)
else: else:
logging.error('This option should not occur!') logging.error('This option should not occur!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow(self.EPCType, 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
def InitializeMME(self): def InitializeMME(self):
if self.EPCIPAddress == '' or self.EPCUserName == '' or self.EPCPassword == '' or self.EPCSourceCodePath == '' or self.EPCType == '': if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
HELP.GenericHelp(Version) HELP.GenericHelp(Version)
HELP.EPCSrvHelp(self.EPCIPAddress, self.EPCUserName, self.EPCPassword, self.EPCSourceCodePath, self.EPCType) HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password, self.SourceCodePath, self.Type)
sys.exit('Insufficient EPC Parameters') sys.exit('Insufficient EPC Parameters')
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
logging.debug('Using the OAI EPC Release 14 MME') logging.debug('Using the OAI EPC Release 14 MME')
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f mme_' + self.testCase_id + '.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f mme_' + self.testCase_id + '.log', '\$', 5)
mySSH.command('echo "./run_mme --config-file /usr/local/etc/oai/mme.conf --set-virt-if" > ./my-mme.sh', '\$', 5) mySSH.command('echo "./run_mme --config-file /usr/local/etc/oai/mme.conf --set-virt-if" > ./my-mme.sh', '\$', 5)
mySSH.command('chmod 755 ./my-mme.sh', '\$', 5) mySSH.command('chmod 755 ./my-mme.sh', '\$', 5)
mySSH.command('sudo daemon --unsafe --name=mme_daemon --chdir=' + self.EPCSourceCodePath + '/scripts -o ' + self.EPCSourceCodePath + '/scripts/mme_' + self.testCase_id + '.log ./my-mme.sh', '\$', 5) mySSH.command('sudo daemon --unsafe --name=mme_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/mme_' + self.testCase_id + '.log ./my-mme.sh', '\$', 5)
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
mySSH.command('cd ' + self.EPCSourceCodePath, '\$', 5) mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
mySSH.command('source oaienv', '\$', 5) mySSH.command('source oaienv', '\$', 5)
mySSH.command('cd scripts', '\$', 5) mySSH.command('cd scripts', '\$', 5)
mySSH.command('stdbuf -o0 hostname', '\$', 5) mySSH.command('stdbuf -o0 hostname', '\$', 5)
...@@ -157,59 +156,59 @@ class EPCManagement(): ...@@ -157,59 +156,59 @@ class EPCManagement():
logging.debug('\u001B[1;37;41m Hostname Not Found! \u001B[0m') logging.debug('\u001B[1;37;41m Hostname Not Found! \u001B[0m')
sys.exit(1) sys.exit(1)
host_name = result.group('host_name') host_name = result.group('host_name')
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./run_mme 2>&1 | stdbuf -o0 tee -a mme_' + self.testCase_id + '.log &', 'MME app initialization complete', 100) mySSH.command('echo ' + self.Password + ' | sudo -S ./run_mme 2>&1 | stdbuf -o0 tee -a mme_' + self.testCase_id + '.log &', 'MME app initialization complete', 100)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('cd /opt/ltebox/tools', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./start_mme', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./start_mme', '\$', 5)
else: else:
logging.error('This option should not occur!') logging.error('This option should not occur!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow(self.EPCType, 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
def InitializeSPGW(self): def InitializeSPGW(self):
if self.EPCIPAddress == '' or self.EPCUserName == '' or self.EPCPassword == '' or self.EPCSourceCodePath == '' or self.EPCType == '': if self.IPAddress == '' or self.UserName == '' or self.Password == '' or self.SourceCodePath == '' or self.Type == '':
HELP.GenericHelp(Version) HELP.GenericHelp(Version)
HELP.EPCSrvHelp(self.EPCIPAddress, self.EPCUserName, self.EPCPassword, self.EPCSourceCodePath, self.EPCType) HELP.EPCSrvHelp(self.IPAddress, self.UserName, self.Password, self.SourceCodePath, self.Type)
sys.exit('Insufficient EPC Parameters') sys.exit('Insufficient EPC Parameters')
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
logging.debug('Using the OAI EPC Release 14 SPGW-CUPS') logging.debug('Using the OAI EPC Release 14 SPGW-CUPS')
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f spgwc_' + self.testCase_id + '.log spgwu_' + self.testCase_id + '.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f spgwc_' + self.testCase_id + '.log spgwu_' + self.testCase_id + '.log', '\$', 5)
mySSH.command('echo "spgwc -c /usr/local/etc/oai/spgw_c.conf" > ./my-spgwc.sh', '\$', 5) mySSH.command('echo "spgwc -c /usr/local/etc/oai/spgw_c.conf" > ./my-spgwc.sh', '\$', 5)
mySSH.command('chmod 755 ./my-spgwc.sh', '\$', 5) mySSH.command('chmod 755 ./my-spgwc.sh', '\$', 5)
mySSH.command('sudo daemon --unsafe --name=spgwc_daemon --chdir=' + self.EPCSourceCodePath + '/scripts -o ' + self.EPCSourceCodePath + '/scripts/spgwc_' + self.testCase_id + '.log ./my-spgwc.sh', '\$', 5) mySSH.command('sudo daemon --unsafe --name=spgwc_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/spgwc_' + self.testCase_id + '.log ./my-spgwc.sh', '\$', 5)
time.sleep(5) time.sleep(5)
mySSH.command('echo "spgwu -c /usr/local/etc/oai/spgw_u.conf" > ./my-spgwu.sh', '\$', 5) mySSH.command('echo "spgwu -c /usr/local/etc/oai/spgw_u.conf" > ./my-spgwu.sh', '\$', 5)
mySSH.command('chmod 755 ./my-spgwu.sh', '\$', 5) mySSH.command('chmod 755 ./my-spgwu.sh', '\$', 5)
mySSH.command('sudo daemon --unsafe --name=spgwu_daemon --chdir=' + self.EPCSourceCodePath + '/scripts -o ' + self.EPCSourceCodePath + '/scripts/spgwu_' + self.testCase_id + '.log ./my-spgwu.sh', '\$', 5) mySSH.command('sudo daemon --unsafe --name=spgwu_daemon --chdir=' + self.SourceCodePath + '/scripts -o ' + self.SourceCodePath + '/scripts/spgwu_' + self.testCase_id + '.log ./my-spgwu.sh', '\$', 5)
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
mySSH.command('cd ' + self.EPCSourceCodePath, '\$', 5) mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
mySSH.command('source oaienv', '\$', 5) mySSH.command('source oaienv', '\$', 5)
mySSH.command('cd scripts', '\$', 5) mySSH.command('cd scripts', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./run_spgw 2>&1 | stdbuf -o0 tee -a spgw_' + self.testCase_id + '.log &', 'Initializing SPGW-APP task interface: DONE', 30) mySSH.command('echo ' + self.Password + ' | sudo -S ./run_spgw 2>&1 | stdbuf -o0 tee -a spgw_' + self.testCase_id + '.log &', 'Initializing SPGW-APP task interface: DONE', 30)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('cd /opt/ltebox/tools', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./start_xGw', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./start_xGw', '\$', 5)
else: else:
logging.error('This option should not occur!') logging.error('This option should not occur!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow(self.EPCType, 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow(self.Type, 'OK', CONST.ALL_PROCESSES_OK)
def CheckHSSProcess(self, status_queue): def CheckHSSProcess(self, status_queue):
try: try:
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
mySSH.command('stdbuf -o0 ps -aux | grep --color=never hss | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep --color=never hss | grep -v grep', '\$', 5)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
result = re.search('oai_hss -j', mySSH.getBefore()) result = re.search('oai_hss -j', mySSH.getBefore())
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
result = re.search('\/bin\/bash .\/run_', mySSH.getBefore()) result = re.search('\/bin\/bash .\/run_', mySSH.getBefore())
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
result = re.search('hss_sim s6as diam_hss', mySSH.getBefore()) result = re.search('hss_sim s6as diam_hss', mySSH.getBefore())
else: else:
logging.error('This should not happen!') logging.error('This should not happen!')
...@@ -225,13 +224,13 @@ class EPCManagement(): ...@@ -225,13 +224,13 @@ class EPCManagement():
def CheckMMEProcess(self, status_queue): def CheckMMEProcess(self, status_queue):
try: try:
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
mySSH.command('stdbuf -o0 ps -aux | grep --color=never mme | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep --color=never mme | grep -v grep', '\$', 5)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
result = re.search('mme -c', mySSH.getBefore()) result = re.search('mme -c', mySSH.getBefore())
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
result = re.search('\/bin\/bash .\/run_', mySSH.getBefore()) result = re.search('\/bin\/bash .\/run_', mySSH.getBefore())
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
result = re.search('mme', mySSH.getBefore()) result = re.search('mme', mySSH.getBefore())
else: else:
logging.error('This should not happen!') logging.error('This should not happen!')
...@@ -247,14 +246,14 @@ class EPCManagement(): ...@@ -247,14 +246,14 @@ class EPCManagement():
def CheckSPGWProcess(self, status_queue): def CheckSPGWProcess(self, status_queue):
try: try:
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('stdbuf -o0 ps -aux | grep --color=never spgw | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep --color=never spgw | grep -v grep', '\$', 5)
result = re.search('spgwu -c ', mySSH.getBefore()) result = re.search('spgwu -c ', mySSH.getBefore())
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
mySSH.command('stdbuf -o0 ps -aux | grep --color=never spgw | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep --color=never spgw | grep -v grep', '\$', 5)
result = re.search('\/bin\/bash .\/run_', mySSH.getBefore()) result = re.search('\/bin\/bash .\/run_', mySSH.getBefore())
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('stdbuf -o0 ps -aux | grep --color=never xGw | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep --color=never xGw | grep -v grep', '\$', 5)
result = re.search('xGw', mySSH.getBefore()) result = re.search('xGw', mySSH.getBefore())
else: else:
...@@ -271,100 +270,98 @@ class EPCManagement(): ...@@ -271,100 +270,98 @@ class EPCManagement():
def TerminateHSS(self): def TerminateHSS(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT oai_hss || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT oai_hss || true', '\$', 5)
time.sleep(2) time.sleep(2)
mySSH.command('stdbuf -o0 ps -aux | grep hss | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep hss | grep -v grep', '\$', 5)
result = re.search('oai_hss -j', mySSH.getBefore()) result = re.search('oai_hss -j', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL oai_hss || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL oai_hss || true', '\$', 5)
mySSH.command('rm -f ' + self.EPCSourceCodePath + '/scripts/my-hss.sh', '\$', 5) mySSH.command('rm -f ' + self.SourceCodePath + '/scripts/my-hss.sh', '\$', 5)
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT run_hss oai_hss || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT run_hss oai_hss || true', '\$', 5)
time.sleep(2) time.sleep(2)
mySSH.command('stdbuf -o0 ps -aux | grep hss | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep hss | grep -v grep', '\$', 5)
result = re.search('\/bin\/bash .\/run_', mySSH.getBefore()) result = re.search('\/bin\/bash .\/run_', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL run_hss oai_hss || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL run_hss oai_hss || true', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cd ' + self.EPCSourceCodePath, '\$', 5) mySSH.command('cd ' + self.SourceCodePath, '\$', 5)
mySSH.command('cd scripts', '\$', 5) mySSH.command('cd scripts', '\$', 5)
#mySSH.command('echo ' + self.EPCPassword + ' | sudo -S daemon --name=simulated_hss --stop', '\$', 5)
time.sleep(1) time.sleep(1)
#mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL hss_sim', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL hss_sim', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo screen -X -S simulated_hss quit', '\$', 5)
else: else:
logging.error('This should not happen!') logging.error('This should not happen!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
def TerminateMME(self): def TerminateMME(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI', self.EPCType, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT run_mme mme || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT run_mme mme || true', '\$', 5)
time.sleep(2) time.sleep(2)
mySSH.command('stdbuf -o0 ps -aux | grep mme | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep mme | grep -v grep', '\$', 5)
result = re.search('mme -c', mySSH.getBefore()) result = re.search('mme -c', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL run_mme mme || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL run_mme mme || true', '\$', 5)
mySSH.command('rm -f ' + self.EPCSourceCodePath + '/scripts/my-mme.sh', '\$', 5) mySSH.command('rm -f ' + self.SourceCodePath + '/scripts/my-mme.sh', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('cd /opt/ltebox/tools', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./stop_mme', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./stop_mme', '\$', 5)
else: else:
logging.error('This should not happen!') logging.error('This should not happen!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
def TerminateSPGW(self): def TerminateSPGW(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT spgwc spgwu || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT spgwc spgwu || true', '\$', 5)
time.sleep(2) time.sleep(2)
mySSH.command('stdbuf -o0 ps -aux | grep spgw | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep spgw | grep -v grep', '\$', 5)
result = re.search('spgwc -c |spgwu -c ', mySSH.getBefore()) result = re.search('spgwc -c |spgwu -c ', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL spgwc spgwu || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL spgwc spgwu || true', '\$', 5)
mySSH.command('rm -f ' + self.EPCSourceCodePath + '/scripts/my-spgw*.sh', '\$', 5) mySSH.command('rm -f ' + self.SourceCodePath + '/scripts/my-spgw*.sh', '\$', 5)
mySSH.command('stdbuf -o0 ps -aux | grep tshark | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep tshark | grep -v grep', '\$', 5)
result = re.search('-w ', mySSH.getBefore()) result = re.search('-w ', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT tshark || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT tshark || true', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S chmod 666 ' + self.EPCSourceCodePath + '/scripts/*.pcap', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S chmod 666 ' + self.SourceCodePath + '/scripts/*.pcap', '\$', 5)
elif re.match('OAI', self.EPCType, re.IGNORECASE): elif re.match('OAI', self.Type, re.IGNORECASE):
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGINT run_spgw spgw || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGINT run_spgw spgw || true', '\$', 5)
time.sleep(2) time.sleep(2)
mySSH.command('stdbuf -o0 ps -aux | grep spgw | grep -v grep', '\$', 5) mySSH.command('stdbuf -o0 ps -aux | grep spgw | grep -v grep', '\$', 5)
result = re.search('\/bin\/bash .\/run_', mySSH.getBefore()) result = re.search('\/bin\/bash .\/run_', mySSH.getBefore())
if result is not None: if result is not None:
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL run_spgw spgw || true', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S killall --signal SIGKILL run_spgw spgw || true', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cd /opt/ltebox/tools', '\$', 5) mySSH.command('cd /opt/ltebox/tools', '\$', 5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S ./stop_xGw', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S ./stop_xGw', '\$', 5)
else: else:
logging.error('This should not happen!') logging.error('This should not happen!')
mySSH.close() mySSH.close()
myHTML = HTML.HTMLManagement() if self.htmlObj is not None:
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
def LogCollectHSS(self): def LogCollectHSS(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('rm -f hss.log.zip', '\$', 5) mySSH.command('rm -f hss.log.zip', '\$', 5)
if re.match('OAI', self.EPCType, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('zip hss.log.zip hss*.log', '\$', 60) mySSH.command('zip hss.log.zip hss*.log', '\$', 60)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm hss*.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm hss*.log', '\$', 5)
if re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('zip hss.log.zip logs/hss*.* *.pcap', '\$', 60) mySSH.command('zip hss.log.zip logs/hss*.* *.pcap', '\$', 60)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f logs/hss*.* *.pcap', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm -f logs/hss*.* *.pcap', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cp /opt/hss_sim0609/hss.log .', '\$', 60) mySSH.command('cp /opt/hss_sim0609/hss.log .', '\$', 60)
mySSH.command('zip hss.log.zip hss.log', '\$', 60) mySSH.command('zip hss.log.zip hss.log', '\$', 60)
else: else:
...@@ -373,13 +370,13 @@ class EPCManagement(): ...@@ -373,13 +370,13 @@ class EPCManagement():
def LogCollectMME(self): def LogCollectMME(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('rm -f mme.log.zip', '\$', 5) mySSH.command('rm -f mme.log.zip', '\$', 5)
if re.match('OAI', self.EPCType, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('zip mme.log.zip mme*.log', '\$', 60) mySSH.command('zip mme.log.zip mme*.log', '\$', 60)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm mme*.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm mme*.log', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cp /opt/ltebox/var/log/*Log.0 .', '\$', 5) mySSH.command('cp /opt/ltebox/var/log/*Log.0 .', '\$', 5)
mySSH.command('zip mme.log.zip mmeLog.0 s1apcLog.0 s1apsLog.0 s11cLog.0 libLog.0 s1apCodecLog.0', '\$', 60) mySSH.command('zip mme.log.zip mmeLog.0 s1apcLog.0 s1apsLog.0 s11cLog.0 libLog.0 s1apCodecLog.0', '\$', 60)
else: else:
...@@ -388,13 +385,13 @@ class EPCManagement(): ...@@ -388,13 +385,13 @@ class EPCManagement():
def LogCollectSPGW(self): def LogCollectSPGW(self):
mySSH = SSH.SSHConnection() mySSH = SSH.SSHConnection()
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword) mySSH.open(self.IPAddress, self.UserName, self.Password)
mySSH.command('cd ' + self.EPCSourceCodePath + '/scripts', '\$', 5) mySSH.command('cd ' + self.SourceCodePath + '/scripts', '\$', 5)
mySSH.command('rm -f spgw.log.zip', '\$', 5) mySSH.command('rm -f spgw.log.zip', '\$', 5)
if re.match('OAI', self.EPCType, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.EPCType, re.IGNORECASE): if re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE):
mySSH.command('zip spgw.log.zip spgw*.log', '\$', 60) mySSH.command('zip spgw.log.zip spgw*.log', '\$', 60)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm spgw*.log', '\$', 5) mySSH.command('echo ' + self.Password + ' | sudo -S rm spgw*.log', '\$', 5)
elif re.match('ltebox', self.EPCType, re.IGNORECASE): elif re.match('ltebox', self.Type, re.IGNORECASE):
mySSH.command('cp /opt/ltebox/var/log/xGwLog.0 .', '\$', 5) mySSH.command('cp /opt/ltebox/var/log/xGwLog.0 .', '\$', 5)
mySSH.command('zip spgw.log.zip xGwLog.0', '\$', 60) mySSH.command('zip spgw.log.zip xGwLog.0', '\$', 60)
else: else:
......
...@@ -396,7 +396,6 @@ class HTMLManagement(): ...@@ -396,7 +396,6 @@ class HTMLManagement():
self.htmlFile.close() self.htmlFile.close()
def CreateHtmlTestRow(self, options, status, processesStatus, machine='eNB'): def CreateHtmlTestRow(self, options, status, processesStatus, machine='eNB'):
print ('RD: calling CreateHtmlTestRow')
self.htmlFile = open('test_results.html', 'a') self.htmlFile = open('test_results.html', 'a')
currentTime = int(round(time.time() * 1000)) - self.startTime currentTime = int(round(time.time() * 1000)) - self.startTime
self.htmlFile.write(' <tr>\n') self.htmlFile.write(' <tr>\n')
......
...@@ -3198,6 +3198,8 @@ EPC = epc.EPCManagement() ...@@ -3198,6 +3198,8 @@ EPC = epc.EPCManagement()
RAN = ran.RANManagement() RAN = ran.RANManagement()
HTML = html.HTMLManagement() HTML = html.HTMLManagement()
EPC.SetHtmlObj(HTML)
argvs = sys.argv argvs = sys.argv
argc = len(argvs) argc = len(argvs)
cwd = os.getcwd() cwd = os.getcwd()
......
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