X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FIPv6Util.py;h=883304487dd570957501a235166d3bfe694a8c49;hb=533ce0def99dc776f5a2b9075aaabea000c2dc89;hp=28e5f7d2fbe9f60ce43290d067d8ca6a1f9225ea;hpb=0e28406b43bf4ce145f1530f15dbb00957edf945;p=csit.git diff --git a/resources/libraries/python/IPv6Util.py b/resources/libraries/python/IPv6Util.py index 28e5f7d2fb..883304487d 100644 --- a/resources/libraries/python/IPv6Util.py +++ b/resources/libraries/python/IPv6Util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2020 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: @@ -15,32 +15,33 @@ from resources.libraries.python.InterfaceUtil import InterfaceUtil from resources.libraries.python.IPUtil import IPUtil -from resources.libraries.python.PapiExecutor import PapiExecutor +from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.topology import NodeType -class IPv6Util(object): +class IPv6Util: """IPv6 utilities""" @staticmethod - def vpp_ra_suppress_link_layer(node, interface): - """Suppress ICMPv6 router advertisement message for link scope address. + def vpp_interface_ra_suppress(node, interface): + """Disable sending ICMPv6 router-advertisement messages on + an interface on a VPP node. :param node: VPP node. :param interface: Interface name. :type node: dict :type interface: str """ - cmd = 'sw_interface_ip6nd_ra_config' + cmd = u"sw_interface_ip6nd_ra_config" args = dict( sw_if_index=InterfaceUtil.get_interface_index(node, interface), - suppress=1) - err_msg = 'Failed to suppress ICMPv6 router advertisement message on ' \ - 'interface {ifc}'.format(ifc=interface) + suppress=1 + ) + err_msg = f"Failed to disable sending ICMPv6 router-advertisement " \ + f"messages on interface {interface}" - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg). \ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod def vpp_ra_send_after_interval(node, interface, interval=2): @@ -54,30 +55,31 @@ class IPv6Util(object): :type interface: str :type interval: int """ - cmd = 'sw_interface_ip6nd_ra_config' + cmd = u"sw_interface_ip6nd_ra_config" args = dict( sw_if_index=InterfaceUtil.get_interface_index(node, interface), - initial_interval=int(interval)) - err_msg = 'Failed to set router advertisement interval on ' \ - 'interface {ifc}'.format(ifc=interface) + initial_interval=int(interval) + ) + err_msg = f"Failed to set router advertisement interval " \ + f"on interface {interface}" - with PapiExecutor(node) as papi_exec: - papi_exec.add(cmd, **args).get_replies(err_msg). \ - verify_reply(err_msg=err_msg) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod - def vpp_all_ra_suppress_link_layer(nodes): - """Suppress ICMPv6 router advertisement message for link scope address - on all VPP nodes in the topology. + def vpp_interfaces_ra_suppress_on_all_nodes(nodes): + """Disable sending ICMPv6 router-advertisement messages on all + IPv6 enabled interfaces on all VPP nodes in the topology. :param nodes: Nodes of the test topology. :type nodes: dict """ for node in nodes.values(): - if node['type'] == NodeType.TG: + if node[u"type"] == NodeType.TG: continue - for port_k in node['interfaces'].keys(): + for port_k in node[u"interfaces"].keys(): ip6_addr_list = IPUtil.vpp_get_interface_ip_addresses( - node, port_k, 'ipv6') + node, port_k, u"ipv6" + ) if ip6_addr_list: - IPv6Util.vpp_ra_suppress_link_layer(node, port_k) + IPv6Util.vpp_interface_ra_suppress(node, port_k)