cls_oaicitest.py: use new cls_cmd.getConnection() instead of old SSHconnection class
It is clearer in CI logs to use absolute paths, and that is also a "preference" of the new SSH class (cls_cmd.py) in the sense that some functions don't handle "cd" gracefully (because of underlying Python library paramiko). For zip, though, we should change to have nice relative paths in the archives, so use cd <path> && zip ... to achieve that, instead of changing to a directory. This way, the path on which we operate is still visible in the logs in each line.
This commit is contained in:
+19
-32
@@ -43,7 +43,6 @@ import json
|
|||||||
#import our libs
|
#import our libs
|
||||||
import helpreadme as HELP
|
import helpreadme as HELP
|
||||||
import constants as CONST
|
import constants as CONST
|
||||||
import sshconnection
|
|
||||||
|
|
||||||
import cls_module
|
import cls_module
|
||||||
import cls_cmd
|
import cls_cmd
|
||||||
@@ -895,55 +894,43 @@ class OaiCiTest():
|
|||||||
SourceCodePath = self.UESourceCodePath
|
SourceCodePath = self.UESourceCodePath
|
||||||
else:
|
else:
|
||||||
sys.exit('Insufficient Parameter')
|
sys.exit('Insufficient Parameter')
|
||||||
SSH = sshconnection.SSHConnection()
|
with cls_cmd.getConnection(IPAddress) as cmd:
|
||||||
SSH.open(IPAddress, UserName, Password)
|
d = f'{SourceCodePath}/cmake_targets'
|
||||||
SSH.command(f'cd {SourceCodePath}', '\$', 5)
|
cmd.run(f'rm -f {d}/build.log.zip')
|
||||||
SSH.command('cd cmake_targets', '\$', 5)
|
cmd.run(f'cd {d} && zip -r build.log.zip build_log_*/*')
|
||||||
SSH.command('rm -f build.log.zip', '\$', 5)
|
|
||||||
SSH.command('zip -r build.log.zip build_log_*/*', '\$', 60)
|
|
||||||
SSH.close()
|
|
||||||
|
|
||||||
def LogCollectPing(self,EPC):
|
def LogCollectPing(self,EPC):
|
||||||
# Some pipelines are using "none" IP / Credentials
|
# Some pipelines are using "none" IP / Credentials
|
||||||
# In that case, just forget about it
|
# In that case, just forget about it
|
||||||
if EPC.IPAddress == 'none':
|
if EPC.IPAddress == 'none':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
SSH = sshconnection.SSHConnection()
|
with cls_cmd.getConnection(EPC.IPAddress) as cmd:
|
||||||
SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password)
|
d = f"{EPC.SourceCodePath}/scripts"
|
||||||
SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5)
|
cmd.run(f'rm -f {d}/ping.log.zip')
|
||||||
SSH.command('cd scripts', '\$', 5)
|
cmd.run(f'cd {d} && zip ping.log.zip ping*.log')
|
||||||
SSH.command('rm -f ping.log.zip', '\$', 5)
|
cmd.run(f'rm {d}/ping*.log')
|
||||||
SSH.command('zip ping.log.zip ping*.log', '\$', 60)
|
|
||||||
SSH.command('rm ping*.log', '\$', 5)
|
|
||||||
SSH.close()
|
|
||||||
|
|
||||||
def LogCollectIperf(self,EPC):
|
def LogCollectIperf(self,EPC):
|
||||||
# Some pipelines are using "none" IP / Credentials
|
# Some pipelines are using "none" IP / Credentials
|
||||||
# In that case, just forget about it
|
# In that case, just forget about it
|
||||||
if EPC.IPAddress == 'none':
|
if EPC.IPAddress == 'none':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
SSH = sshconnection.SSHConnection()
|
with cls_cmd.getConnection(EPC.IPAddress) as cmd:
|
||||||
SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password)
|
d = f"{EPC.SourceCodePath}/scripts"
|
||||||
SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5)
|
cmd.run(f'rm -f {d}/iperf.log.zip')
|
||||||
SSH.command('cd scripts', '\$', 5)
|
cmd.run(f'cd {d} && zip iperf.log.zip iperf*.log')
|
||||||
SSH.command('rm -f iperf.log.zip', '\$', 5)
|
cmd.run(f'rm {d}/iperf*.log')
|
||||||
SSH.command('zip iperf.log.zip iperf*.log', '\$', 60)
|
|
||||||
SSH.command('rm iperf*.log', '\$', 5)
|
|
||||||
SSH.close()
|
|
||||||
|
|
||||||
def LogCollectOAIUE(self):
|
def LogCollectOAIUE(self):
|
||||||
# Some pipelines are using "none" IP / Credentials
|
# Some pipelines are using "none" IP / Credentials
|
||||||
# In that case, just forget about it
|
# In that case, just forget about it
|
||||||
if self.UEIPAddress == 'none':
|
if self.UEIPAddress == 'none':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
SSH = sshconnection.SSHConnection()
|
with cls_cmd.getConnection(self.UEIPAddress) as cmd:
|
||||||
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
|
d = f'{self.UESourceCodePath}/cmake_targets'
|
||||||
SSH.command(f'cd {self.UESourceCodePath}', '\$', 5)
|
cmd.run(f'echo {self.UEPassword} | sudo -S rm -f {d}/ue.log.zip')
|
||||||
SSH.command(f'cd cmake_targets', '\$', 5)
|
cmd.run(f'cd {d} && echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt')
|
||||||
SSH.command(f'echo {self.UEPassword} | sudo -S rm -f ue.log.zip', '\$', 5)
|
cmd.run(f'echo {self.UEPassword} | sudo -S rm {d}/ue*.log {d}/core* {d}/ue_*record.raw {d}/ue_*.pcap {d}/ue_*txt')
|
||||||
SSH.command(f'echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 60)
|
|
||||||
SSH.command(f'echo {self.UEPassword} | sudo -S rm ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 5)
|
|
||||||
SSH.close()
|
|
||||||
|
|
||||||
def ShowTestID(self):
|
def ShowTestID(self):
|
||||||
logging.info(f'\u001B[1m----------------------------------------\u001B[0m')
|
logging.info(f'\u001B[1m----------------------------------------\u001B[0m')
|
||||||
|
|||||||
Reference in New Issue
Block a user