tests: refactor ForeignAddressFactory 88/30288/3
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Fri, 4 Dec 2020 22:50:26 +0000 (17:50 -0500)
committerFlorin Coras <florin.coras@gmail.com>
Sun, 6 Dec 2020 18:54:07 +0000 (18:54 +0000)
Move ForeignAddressFactory back to test_lisp.
It is the only test that uses the code and has
embedded addresses specific to the test.

Type: test

Change-Id: If1a39f9b167e36dd7aff7481350ddb8fe17155d2
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
src/plugins/lisp/test/test_lisp.py
test/util.py

index 0bb4211..0a6e752 100644 (file)
@@ -11,7 +11,7 @@ from scapy.layers.inet6 import IPv6
 from framework import VppTestCase, VppTestRunner
 from lisp import VppLocalMapping, VppLispAdjacency, VppLispLocator, \
     VppLispLocatorSet, VppRemoteMapping, LispRemoteLocator
-from util import ppp, ForeignAddressFactory
+from util import ppp
 
 # From py_lispnetworking.lisp.py:  # GNU General Public License v2.0
 
@@ -31,6 +31,19 @@ bind_layers(LISP_GPE_Header, IPv6, next_proto=2)
 bind_layers(LISP_GPE_Header, Ether, next_proto=3)
 
 
+class ForeignAddressFactory(object):
+    count = 0
+    prefix_len = 24
+    net_template = '10.10.10.{}'
+    net = net_template.format(0) + '/' + str(prefix_len)
+
+    def get_ip4(self):
+        if self.count > 255:
+            raise Exception("Network host address exhaustion")
+        self.count += 1
+        return self.net_template.format(self.count)
+
+
 class Driver(metaclass=abc.ABCMeta):
 
     config_order = ['locator-sets',
index fc1eae0..b691deb 100644 (file)
@@ -203,19 +203,6 @@ class Host(object):
         self._ip6_ll = ip6_ll
 
 
-class ForeignAddressFactory(object):
-    count = 0
-    prefix_len = 24
-    net_template = '10.10.10.{}'
-    net = net_template.format(0) + '/' + str(prefix_len)
-
-    def get_ip4(self):
-        if self.count > 255:
-            raise Exception("Network host address exhaustion")
-        self.count += 1
-        return self.net_template.format(self.count)
-
-
 class L4_Conn():
     """ L4 'connection' tied to two VPP interfaces """