Adding v6 support to vrouter
Change-Id: I0abe5fe2debf4a6697a84b5507ea9c453d14bf34
diff --git a/xos/synchronizer/models/vrouter.xproto b/xos/synchronizer/models/vrouter.xproto
index 006ecb9..32be732 100644
--- a/xos/synchronizer/models/vrouter.xproto
+++ b/xos/synchronizer/models/vrouter.xproto
@@ -18,6 +18,6 @@
option verbose_name = "vRouter static route";
required manytoone vrouter->VRouterServiceInstance:static_routes = 1 [help_text = "The static route to be configured in ONOS", db_index = False, null = False, blank = False];
- required string prefix = 2 [help_text = "The destination prefix and netmask (xxx.yyy.www.zzz/nm)", max_length = 20, null = False, tosca_key = True, db_index = False, unique = True, blank = False];
- required string next_hop = 5 [help_text = "The next-hop for the route", max_length = 17, null = False, db_index = False, blank = False];
+ required string prefix = 2 [help_text = "The destination prefix and netmask (IP/NM)", max_length = 52, null = False, tosca_key = True, db_index = False, unique = True, blank = False];
+ required string next_hop = 5 [help_text = "The next-hop for the route", max_length = 52, null = False, db_index = False, blank = False];
}
diff --git a/xos/synchronizer/steps/test_sync_routes.py b/xos/synchronizer/steps/test_sync_routes.py
index 1e227a2..d64272f 100644
--- a/xos/synchronizer/steps/test_sync_routes.py
+++ b/xos/synchronizer/steps/test_sync_routes.py
@@ -75,11 +75,9 @@
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
-
self.sync_step = SyncRoutes
self.sync_step.log = Mock()
-
# mock onos-fabric
onos_fabric = Mock()
onos_fabric.name = "onos-fabric"
@@ -105,18 +103,15 @@
self.o.vrouter.owner = self.vrouter
self.o.tologdict.return_value = {}
-
-
-
def tearDown(self):
self.o = None
sys.path = self.sys_path_save
@requests_mock.Mocker()
- def test_sync_route(self, m):
+ def test_sync_route_ipv4(self, m):
- self.o.next_hop = "192.168.0.254"
self.o.prefix = "0.0.0.0/0"
+ self.o.next_hop = "192.168.0.254"
expected_conf = {
"prefix": self.o.prefix,
@@ -132,10 +127,29 @@
self.assertTrue(m.called)
@requests_mock.Mocker()
- def test_delete_route(self, m):
+ def test_sync_route_ipv6(self, m):
- self.o.next_hop = "192.168.0.254"
+ self.o.prefix = "::/0"
+ self.o.next_hop = "2001:db8:abcd:0012::0/64"
+
+ expected_conf = {
+ "prefix": self.o.prefix,
+ "nextHop": self.o.next_hop
+ }
+
+ m.post("http://onos-fabric:8181/onos/routeservice/routes",
+ status_code=204,
+ additional_matcher=functools.partial(match_json, expected_conf))
+
+ self.sync_step().sync_record(self.o)
+
+ self.assertTrue(m.called)
+
+ @requests_mock.Mocker()
+ def test_delete_route_ipv4(self, m):
+
self.o.prefix = "0.0.0.0/0"
+ self.o.next_hop = "192.168.0.254"
expected_conf = {
"prefix": self.o.prefix,
@@ -148,4 +162,23 @@
self.sync_step().delete_record(self.o)
- self.assertTrue(m.called)
\ No newline at end of file
+ self.assertTrue(m.called)
+
+ @requests_mock.Mocker()
+ def test_delete_route_ipv6(self, m):
+
+ self.o.prefix = "::/0"
+ self.o.next_hop = "2001:db8:abcd:0012::0/64"
+
+ expected_conf = {
+ "prefix": self.o.prefix,
+ "nextHop": self.o.next_hop
+ }
+
+ m.delete("http://onos-fabric:8181/onos/routeservice/routes",
+ status_code=204,
+ additional_matcher=functools.partial(match_json, expected_conf))
+
+ self.sync_step().delete_record(self.o)
+
+ self.assertTrue(m.called)