From: Jakub Libosvar Date: Tue, 9 Jun 2015 16:08:50 +0000 (+0000) Subject: Introduce functions using arping executable X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=da42745c466c14e6dbe58cdbc830ae5d1c8bb114;p=openstack-build%2Fneutron-build.git Introduce functions using arping executable The arpinger is gonna be used in the next changeset introducing connection testers. Change-Id: I90ae32c2f52f1debfb11ae2a08b2828ee2be04cc --- diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py index 8884c6696..cce352d0c 100644 --- a/neutron/tests/common/net_helpers.py +++ b/neutron/tests/common/net_helpers.py @@ -81,6 +81,31 @@ def assert_no_ping(src_namespace, dst_ip, timeout=1, count=1): {'ns': src_namespace, 'destination': dst_ip}) +def assert_arping(src_namespace, dst_ip, source=None, timeout=1, count=1): + """Send arp request using arping executable. + + NOTE: ARP protocol is used in IPv4 only. IPv6 uses Neighbour Discovery + Protocol instead. + """ + ns_ip_wrapper = ip_lib.IPWrapper(src_namespace) + arping_cmd = ['arping', '-c', count, '-w', timeout] + if source: + arping_cmd.extend(['-s', source]) + arping_cmd.append(dst_ip) + ns_ip_wrapper.netns.execute(arping_cmd) + + +def assert_no_arping(src_namespace, dst_ip, source=None, timeout=1, count=1): + try: + assert_arping(src_namespace, dst_ip, source, timeout, count) + except RuntimeError: + pass + else: + tools.fail("destination ip %(destination)s is replying to arp from " + "namespace %(ns)s, but it shouldn't" % + {'ns': src_namespace, 'destination': dst_ip}) + + class NamespaceFixture(fixtures.Fixture): """Create a namespace.