Custom_Command(): no need for class members

This commit is contained in:
Robert Schmidt
2024-09-28 12:45:07 +02:00
parent 61ea76e7af
commit 71807db4ab
3 changed files with 23 additions and 25 deletions
+19
View File
@@ -220,6 +220,25 @@ def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetlos
pal_msg += f' (too high! >{self.iperf_packetloss_threshold}%)'
return (result, f'{req_msg}\n{bir_msg}\n{brl_msg}\n{jit_msg}\n{pal_msg}')
def Custom_Command(HTML, node, command, command_fail):
logging.info(f"Executing custom command on {node}")
cmd = cls_cmd.getConnection(node)
ret = cmd.run(command)
cmd.close()
logging.debug(f"Custom_Command: {command} on node: {node} - {'OK, command succeeded' if ret.returncode == 0 else f'Error, return code: {ret.returncode}'}")
status = 'OK'
message = []
if ret.returncode != 0 and not command_fail:
message = [ret.stdout]
logging.warning(f'Custom_Command output: {message}')
status = 'Warning'
if ret.returncode != 0 and command_fail:
message = [ret.stdout]
logging.error(f'Custom_Command failed: output: {message}')
status = 'KO'
HTML.CreateHtmlTestRowQueue(command, status, message)
return status == 'OK' or status == 'Warning'
#-----------------------------------------------------------
# OaiCiTest Class Definition
#-----------------------------------------------------------