X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDUTSetup.py;h=6ebd9eab1ad717d42f9d5db5eb71f7a6f1640132;hb=e97369a7ee71b014b6d495f142321391c2f8c8ef;hp=419a4e291fa171b68aaec71b828fa7c0cf29d5aa;hpb=9a0d6a86aadb5dfcc9fb55af2a8efc4881540579;p=csit.git diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index 419a4e291f..6ebd9eab1a 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -17,7 +17,7 @@ from time import sleep from robot.api import logger from resources.libraries.python.Constants import Constants -from resources.libraries.python.ssh import SSH, exec_cmd, exec_cmd_no_error +from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error from resources.libraries.python.topology import NodeType, Topology @@ -33,11 +33,13 @@ class DUTSetup: :type node: dict :type service: str """ - command = u"cat /tmp/*supervisor*.log"\ - if DUTSetup.running_in_container(node) \ - else f"journalctl --no-pager _SYSTEMD_INVOCATION_ID=$(systemctl " \ - f"show -p InvocationID --value {service})" - + if DUTSetup.running_in_container(node): + command = u"cat /var/log/vpp/vpp.log" + else: + command = ( + f"journalctl --no-pager _SYSTEMD_INVOCATION_ID=$(systemctl " + f"show -p InvocationID --value {service})" + ) message = f"Node {node[u'host']} failed to get logs from unit {service}" exec_cmd_no_error( @@ -66,9 +68,10 @@ class DUTSetup: :type node: dict :type service: str """ - command = f"supervisorctl restart {service}" \ - if DUTSetup.running_in_container(node) \ - else f"service {service} restart" + if DUTSetup.running_in_container(node): + command = f"supervisorctl restart {service}" + else: + command = f"systemctl restart {service}" message = f"Node {node[u'host']} failed to restart service {service}" exec_cmd_no_error( @@ -99,10 +102,10 @@ class DUTSetup: :type node: dict :type service: str """ - # TODO: change command to start once all parent function updated. - command = f"supervisorctl restart {service}" \ - if DUTSetup.running_in_container(node) \ - else f"service {service} restart" + if DUTSetup.running_in_container(node): + command = f"supervisorctl restart {service}" + else: + command = f"systemctl restart {service}" message = f"Node {node[u'host']} failed to start service {service}" exec_cmd_no_error( @@ -135,9 +138,10 @@ class DUTSetup: """ DUTSetup.get_service_logs(node, service) - command = f"supervisorctl stop {service}" \ - if DUTSetup.running_in_container(node) \ - else f"service {service} stop" + if DUTSetup.running_in_container(node): + command = f"supervisorctl stop {service}" + else: + command = f"systemctl stop {service}" message = f"Node {node[u'host']} failed to stop service {service}" exec_cmd_no_error( @@ -442,8 +446,10 @@ class DUTSetup: :type pci_addrs: list """ for pci_addr in pci_addrs: - if not driver or \ - DUTSetup.get_pci_dev_driver(node, pci_addr) != driver: + cur_driver = DUTSetup.get_pci_dev_driver(node, pci_addr) + if not cur_driver: + return + if not driver or cur_driver != driver: DUTSetup.pci_driver_unbind(node, pci_addr) @staticmethod