diff options
| author | Kuldeep Kashyap <kashyapk@vmware.com> | 2019-09-25 11:53:00 +0000 | 
|---|---|---|
| committer | Kuldeep Kashyap <kashyapk@vmware.com> | 2019-09-26 10:06:16 +0000 | 
| commit | 8aa6292547e431d3ba8803033d10e5ff38be73d3 (patch) | |
| tree | 59042328705b72dd18074178afd5863f56923b84 /tests | |
| parent | 21a51c4d0f71d2179e9d1280ddf52d6b562d7f3d (diff) | |
tests: Add API to shut/noshut router interface
This API would help to shut/nohut specified router interfaces
Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/topotests/lib/common_config.py | 40 | 
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index c21bdbcd14..ba8a4cb0f4 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -1544,6 +1544,46 @@ def create_bgp_community_lists(tgen, input_dict, build=False):      return result +def shutdown_bringup_interface(tgen, dut, intf_name, ifaceaction=False): +    """ +    Shutdown or bringup router's interface " + +    * `tgen`  : Topogen object +    * `dut`  : Device under test +    * `intf_name`  : Interface name to be shut/no shut +    * `ifaceaction` :  Action, to shut/no shut interface, +                       by default is False + +    Usage +    ----- +    dut = "r3" +    intf = "r3-r1-eth0" +    # Shut down ineterface +    shutdown_bringup_interface(tgen, dut, intf, False) + +    # Bring up ineterface +    shutdown_bringup_interface(tgen, dut, intf, True) + +    Returns +    ------- +    errormsg(str) or True +    """ + +    from topotest import interface_set_status +    router_list = tgen.routers() +    if ifaceaction: +        logger.info("Bringing up interface : {}".format(intf_name)) +    else: +        logger.info("Shutting down interface : {}".format(intf_name)) + +    interface_set_status(router_list[dut], intf_name, +                                  ifaceaction) + +    if ifaceaction: +        # Disabling v6 link local once interfac comes up back +        disable_v6_link_local(tgen, dut, intf_name=intf_name) + +  #############################################  # Verification APIs  #############################################  | 
