diff options
author | Peter Mikus <pmikus@cisco.com> | 2019-04-24 11:31:30 +0000 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2019-05-06 10:30:11 +0000 |
commit | e001fdea995835f1ef75a5e21607ba02d78e4068 (patch) | |
tree | 03392169d3d404c55531940aa658fd73db2e54b1 /resources/libraries/python/DUTSetup.py | |
parent | 1c54bfd3bdfafe2764394f6540fd35f708bf2239 (diff) |
CSIT-1493 VPP restart handling code
Change-Id: Ibe52125089f39e0ff17ec607a3ed00c61d52ab8c
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'resources/libraries/python/DUTSetup.py')
-rw-r--r-- | resources/libraries/python/DUTSetup.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index 67edefb930..e2fba066d3 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -61,6 +61,39 @@ class DUTSetup(object): DUTSetup.get_service_logs(node, service) @staticmethod + def restart_service(node, service): + """Restarts the named service on node. + + :param node: Node in the topology. + :param service: Service unit name. + :type node: dict + :type service: str + """ + if DUTSetup.running_in_container(node): + command = 'supervisorctl restart {name}'.format(name=service) + else: + command = 'service {name} restart'.format(name=service) + message = 'Node {host} failed to restart service {name}'.\ + format(host=node['host'], name=service) + + exec_cmd_no_error(node, command, timeout=30, sudo=True, message=message) + + DUTSetup.get_service_logs(node, service) + + @staticmethod + def restart_service_on_all_duts(nodes, service): + """Retarts the named service on all DUTs. + + :param node: Nodes in the topology. + :param service: Service unit name. + :type node: dict + :type service: str + """ + for node in nodes.values(): + if node['type'] == NodeType.DUT: + DUTSetup.restart_service(node, service) + + @staticmethod def start_service(node, service): """Start up the named service on node. @@ -69,6 +102,7 @@ class DUTSetup(object): :type node: dict :type service: str """ + # TODO: change command to start once all parent function updated. if DUTSetup.running_in_container(node): command = 'supervisorctl restart {name}'.format(name=service) else: @@ -609,7 +643,8 @@ class DUTSetup(object): @staticmethod def install_vpp_on_all_duts(nodes, vpp_pkg_dir): - """Install VPP on all DUT nodes. + """Install VPP on all DUT nodes. Start the VPP service in case of + systemd is not available or does not support autostart. :param nodes: Nodes in the topology. :param vpp_pkg_dir: Path to directory where VPP packages are stored. @@ -634,6 +669,8 @@ class DUTSetup(object): format(dir=vpp_pkg_dir), timeout=120, sudo=True, message=message) exec_cmd_no_error(node, 'dpkg -l | grep vpp', sudo=True) + if DUTSetup.running_in_container(node): + DUTSetup.restart_service(node, Constants.VPP_UNIT) else: exec_cmd_no_error(node, 'yum -y remove "*vpp*" || true', timeout=120, sudo=True) @@ -641,6 +678,7 @@ class DUTSetup(object): format(dir=vpp_pkg_dir), timeout=120, sudo=True, message=message) exec_cmd_no_error(node, 'rpm -qai *vpp*', sudo=True) + DUTSetup.restart_service(node, Constants.VPP_UNIT) @staticmethod def running_in_container(node): |