stats: stat_validate_counter_vector3 non-static
[vpp.git] / test / vpp_srv6.py
index 28ff4b8..d6efedc 100644 (file)
@@ -4,7 +4,7 @@
   object abstractions for representing SRv6 localSIDs in VPP
 """
 
-from vpp_object import *
+from vpp_object import VppObject
 from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
 
 
@@ -19,7 +19,9 @@ class SRv6LocalSIDBehaviors():
     SR_BEHAVIOR_DX4 = 7
     SR_BEHAVIOR_DT6 = 8
     SR_BEHAVIOR_DT4 = 9
-    SR_BEHAVIOR_LAST = 10      # Must always be the last one
+    SR_BEHAVIOR_END_UN_PERF = 10
+    SR_BEHAVIOR_END_UN = 11
+    SR_BEHAVIOR_LAST = 12      # Must always be the last one
 
 
 class SRv6PolicyType():
@@ -40,24 +42,12 @@ class VppSRv6LocalSID(VppObject):
     SRv6 LocalSID
     """
 
-    def __init__(self, test, localsid_addr, behavior, nh_addr, end_psp,
-                 sw_if_index, vlan_index, fib_table):
+    def __init__(self, test, localsid, behavior, nh_addr,
+                 end_psp, sw_if_index, vlan_index, fib_table):
         self._test = test
-        self.localsid_addr = localsid_addr
-        # keep binary format in _localsid_addr
-        self._localsid_addr = inet_pton(AF_INET6, self.localsid_addr)
+        self.localsid = localsid
         self.behavior = behavior
         self.nh_addr = nh_addr
-        # keep binary format in _nh_addr
-        if ':' in nh_addr:
-            # IPv6
-            self._nh_addr = inet_pton(AF_INET6, nh_addr)
-        else:
-            # IPv4
-            # API expects 16 octets (128 bits)
-            # last 4 octets are used for IPv4
-            # --> prepend 12 octets
-            self._nh_addr = ('\x00' * 12) + inet_pton(AF_INET, nh_addr)
         self.end_psp = end_psp
         self.sw_if_index = sw_if_index
         self.vlan_index = vlan_index
@@ -66,9 +56,9 @@ class VppSRv6LocalSID(VppObject):
 
     def add_vpp_config(self):
         self._test.vapi.sr_localsid_add_del(
-            self._localsid_addr,
-            self.behavior,
-            self._nh_addr,
+            localsid=self.localsid,
+            behavior=self.behavior,
+            nh_addr=self.nh_addr,
             is_del=0,
             end_psp=self.end_psp,
             sw_if_index=self.sw_if_index,
@@ -78,9 +68,9 @@ class VppSRv6LocalSID(VppObject):
 
     def remove_vpp_config(self):
         self._test.vapi.sr_localsid_add_del(
-            self._localsid_addr,
-            self.behavior,
-            self._nh_addr,
+            localsid=self.localsid,
+            behavior=self.behavior,
+            nh_addr=self.nh_addr,
             is_del=1,
             end_psp=self.end_psp,
             sw_if_index=self.sw_if_index,
@@ -93,13 +83,10 @@ class VppSRv6LocalSID(VppObject):
         # use _configured flag for now
         return self._configured
 
-    def __str__(self):
-        return self.object_id()
-
     def object_id(self):
         return ("%d;%s,%d"
                 % (self.fib_table,
-                   self.localsid_addr,
+                   self.localsid,
                    self.behavior))
 
 
@@ -113,17 +100,11 @@ class VppSRv6Policy(VppObject):
                  segments, source):
         self._test = test
         self.bsid = bsid
-        # keep binary format in _bsid
-        self._bsid = inet_pton(AF_INET6, bsid)
         self.is_encap = is_encap
         self.sr_type = sr_type
         self.weight = weight
         self.fib_table = fib_table
         self.segments = segments
-        # keep binary format in _segments
-        self._segments = []
-        for seg in segments:
-            self._segments.extend(inet_pton(AF_INET6, seg))
         self.n_segments = len(segments)
         # source not passed to API
         # self.source = inet_pton(AF_INET6, source)
@@ -132,18 +113,17 @@ class VppSRv6Policy(VppObject):
 
     def add_vpp_config(self):
         self._test.vapi.sr_policy_add(
-                     self._bsid,
-                     self.weight,
-                     self.is_encap,
-                     self.sr_type,
-                     self.fib_table,
-                     self.n_segments,
-                     self._segments)
+                     bsid=self.bsid,
+                     weight=self.weight,
+                     is_encap=self.is_encap,
+                     is_spray=self.sr_type,
+                     fib_table=self.fib_table,
+                     sids={'num_sids': self.n_segments, 'sids': self.segments})
         self._configured = True
 
     def remove_vpp_config(self):
         self._test.vapi.sr_policy_del(
-                     self._bsid)
+                     self.bsid)
         self._configured = False
 
     def query_vpp_config(self):
@@ -151,9 +131,6 @@ class VppSRv6Policy(VppObject):
         # use _configured flag for now
         return self._configured
 
-    def __str__(self):
-        return self.object_id()
-
     def object_id(self):
         return ("%d;%s-><%s>;%d"
                 % (self.sr_type,
@@ -177,19 +154,7 @@ class VppSRv6Steering(VppObject):
                  sw_if_index):
         self._test = test
         self.bsid = bsid
-        # keep binary format in _bsid
-        self._bsid = inet_pton(AF_INET6, bsid)
         self.prefix = prefix
-        # keep binary format in _prefix
-        if ':' in prefix:
-            # IPv6
-            self._prefix = inet_pton(AF_INET6, prefix)
-        else:
-            # IPv4
-            # API expects 16 octets (128 bits)
-            # last 4 octets are used for IPv4
-            # --> prepend 12 octets
-            self._prefix = ('\x00' * 12) + inet_pton(AF_INET, prefix)
         self.mask_width = mask_width
         self.traffic_type = traffic_type
         self.sr_policy_index = sr_policy_index
@@ -199,26 +164,24 @@ class VppSRv6Steering(VppObject):
 
     def add_vpp_config(self):
         self._test.vapi.sr_steering_add_del(
-                     0,
-                     self._bsid,
-                     self.sr_policy_index,
-                     self.table_id,
-                     self._prefix,
-                     self.mask_width,
-                     self.sw_if_index,
-                     self.traffic_type)
+                     is_del=0,
+                     bsid=self.bsid,
+                     sr_policy_index=self.sr_policy_index,
+                     table_id=self.table_id,
+                     prefix={'address': self.prefix, 'len':  self.mask_width},
+                     sw_if_index=self.sw_if_index,
+                     traffic_type=self.traffic_type)
         self._configured = True
 
     def remove_vpp_config(self):
         self._test.vapi.sr_steering_add_del(
-                     1,
-                     self._bsid,
-                     self.sr_policy_index,
-                     self.table_id,
-                     self._prefix,
-                     self.mask_width,
-                     self.sw_if_index,
-                     self.traffic_type)
+                     is_del=1,
+                     bsid=self.bsid,
+                     sr_policy_index=self.sr_policy_index,
+                     table_id=self.table_id,
+                     prefix={'address': self.prefix, 'len':  self.mask_width},
+                     sw_if_index=self.sw_if_index,
+                     traffic_type=self.traffic_type)
         self._configured = False
 
     def query_vpp_config(self):
@@ -226,9 +189,6 @@ class VppSRv6Steering(VppObject):
         # use _configured flag for now
         return self._configured
 
-    def __str__(self):
-        return self.object_id()
-
     def object_id(self):
         return ("%d;%d;%s/%d->%s"
                 % (self.table_id,