diff --git a/ci-scripts/main.py b/ci-scripts/main.py index 322b6a5c72ed28e09e7897b3187678e76963a5d2..1566b2d47df32ca1ed9a36df1ce0757f4ea57453 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -498,6 +498,9 @@ def GetParametersFromXML(action): string_field = test.findtext('test_svr_id') if (string_field is not None): CONTAINERS.testSvrId = string_field + elif action == 'Custom_Command': + RAN.node = test.findtext('node') + RAN.command = test.findtext('command') else: logging.warning(f"unknown action {action} from option-parsing point-of-view") @@ -879,6 +882,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re RAN.BuildeNB(HTML) elif action == 'WaitEndBuild_eNB': RAN.WaitBuildeNBisFinished(HTML) + elif action == 'Custom_Command': + logging.info(f"Executing custom command") + RAN.CustomCommand(HTML) elif action == 'Initialize_eNB': check_eNB = False check_OAI_UE = False diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index fd6a073f21f9c8bc4d3dbd5c0aeea0db48cd3575..8ec72bf40f0f49bb943be066674fd56d45c7a4f2 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -38,6 +38,7 @@ import os import time from multiprocessing import Process, Lock, SimpleQueue import yaml +import cls_cmd #----------------------------------------------------------- @@ -96,6 +97,8 @@ class RANManagement(): #checkers from xml self.ran_checkers={} self.cmd_prefix = '' # prefix before {lte,nr}-softmodem + self.node = '' + self.command = '' #----------------------------------------------------------- @@ -259,6 +262,21 @@ class RANManagement(): mySSH.close() self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.backgroundBuildTestId[int(self.eNB_instance)], HTML) + def CustomCommand(self, HTML): + if self.node == '' or self.node == "localhost": + cmd = cls_cmd.LocalCmd() + else: + cmd = cls_cmd.RemoteCmd(self.node) + ret = cmd.run(self.command) + cmd.close() + logging.debug(f'CustomCommand: {self.command} returnCode: {ret.returncode} output: {ret.stdout}') + html_queue = SimpleQueue() + status = 'OK' + if ret.returncode != 0: + html_queue.put(ret.stdout) + status = 'Warning' + HTML.CreateHtmlTestRow(self.command, status, 1, html_queue) + def checkBuildeNB(self, lIpAddr, lUserName, lPassWord, lSourcePath, testcaseId, HTML): HTML.testCase_id=testcaseId diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index b4dabb1654fe2f4ad5e3e54b84d5f2832bc080d5..93e3bc9fb03f1e80eb5604aaf06d0402e070e4d0 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -51,3 +51,4 @@ - Push_Local_Registry - Pull_Local_Registry - Clean_Test_Server_Images + - Custom_Command