X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVPPUtil.py;h=3a0148a4817e6ac8bfd1517dd4f53e420cb88435;hb=refs%2Fchanges%2F80%2F11580%2F10;hp=da59d1958d998f2ffd093cbd7032eadf94b94061;hpb=cf561a6e3d4c4fbd78ab6c9d0a9aa817bb3300fc;p=csit.git diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index da59d1958d..3a0148a481 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -26,7 +26,7 @@ class VPPUtil(object): :param node: VPP node. :param additional_cmds: Additional commands that the vpp should print - settings for. + settings for. :type node: dict :type additional_cmds: tuple """ @@ -46,3 +46,35 @@ class VPPUtil(object): ssh.connect(node) for _, value in def_setting_tb_displayed.items(): ssh.exec_command_sudo('vppctl sh {}'.format(value)) + + @staticmethod + def stop_vpp_service(node): + """Stop VPP service on the specified node. + + :param node: VPP node. + :type node: dict + :raises RuntimeError: If VPP fails to stop. + """ + + ssh = SSH() + ssh.connect(node) + cmd = "service vpp stop" + ret_code, _, _ = ssh.exec_command_sudo(cmd, timeout=80) + if int(ret_code) != 0: + raise RuntimeError("VPP service did not shut down gracefully.") + + @staticmethod + def start_vpp_service(node): + """start VPP service on the specified node. + + :param node: VPP node. + :type node: dict + :raises RuntimeError: If VPP fails to start. + """ + + ssh = SSH() + ssh.connect(node) + cmd = "service vpp start" + ret_code, _, _ = ssh.exec_command_sudo(cmd) + if int(ret_code) != 0: + raise RuntimeError("VPP service did not start.")