blob: 8da0811d7705e0515b8cf316139684206201596e [file] [log] [blame]
Ole Troan9a475372019-03-05 16:58:24 +01001# NB NB NB NB NB NB NB NB NB NB NB
2#
3# NOTE: The API binary wrappers in this file are in the process of being
4# deprecated. DO NOT ADD NEW WRAPPERS HERE. Call the functions using
5# named arguments directly instead.
6#
7
Paul Vinciguerra00671cf2018-11-25 12:47:04 -08008import os
Klement Sekera0e3c0de2016-09-29 14:43:44 +02009import time
Klement Sekerae4504c62016-12-08 10:16:41 +010010from collections import deque
Klement Sekeraf62ae122016-10-11 11:47:09 +020011
Ole Troanf159f582019-02-28 20:20:47 +010012from six import moves, iteritems
Paul Vinciguerra19542292019-03-17 17:34:46 -070013from vpp_papi import VPPApiClient, mac_pton
Paul Vinciguerra00671cf2018-11-25 12:47:04 -080014from hook import Hook
Paul Vinciguerrab5f15bd2019-03-17 08:42:58 -070015from vpp_ip_route import MPLS_IETF_MAX_LABEL, MPLS_LABEL_INVALID
Klement Sekeraf62ae122016-10-11 11:47:09 +020016
Klement Sekera0e3c0de2016-09-29 14:43:44 +020017
Ole Troanf159f582019-02-28 20:20:47 +010018#
19# Dictionary keyed on message name to override default values for
20# named parameters
21#
Ole Troan9a475372019-03-05 16:58:24 +010022defaultmapping = {
23 'map_add_domain': {'mtu': 1280},
24 'syslog_set_sender': {'collector_port': 514,
25 'max_msg_size': 480},
26 'acl_interface_add_del': {'is_add': 1, 'is_input': 1},
27 'acl_interface_list_dump': {'sw_if_index': 4294967295, },
28 'app_namespace_add_del': {'sw_if_index': 4294967295, },
29 'bd_ip_mac_add_del': {'is_add': 1, },
Jakub Grajciar4682feb2019-09-02 13:28:52 +020030 'bfd_udp_add': {'is_authenticated': False, 'bfd_key_id': None,
31 'conf_key_id': None},
32 'bfd_udp_auth_activate': {'bfd_key_id': None, 'conf_key_id': None,
33 'is_delayed': False},
Ole Troan9a475372019-03-05 16:58:24 +010034 'bier_disp_entry_add_del': {'next_hop_rpf_id': -1, 'next_hop_is_ip4': 1,
35 'is_add': 1, },
36 'bier_disp_table_add_del': {'is_add': 1, },
37 'bier_imp_add': {'is_add': 1, },
38 'bier_route_add_del': {'is_add': 1, },
39 'bier_table_add_del': {'is_add': 1, },
Jakub Grajciar3d1ef872019-08-26 12:55:15 +020040 'bond_create': {'mac_address': '', 'id': 0xFFFFFFFF},
Ole Troan9a475372019-03-05 16:58:24 +010041 'bridge_domain_add_del': {'flood': 1, 'uu_flood': 1, 'forward': 1,
42 'learn': 1, 'is_add': 1, },
Paul Vinciguerra9a29f792019-04-30 20:44:25 -070043 'bvi_create': {'user_instance': 4294967295, },
44 'bvi_delete': {},
Ole Troan9a475372019-03-05 16:58:24 +010045 'classify_add_del_table': {'match_n_vectors': 1, 'table_index': 4294967295,
46 'nbuckets': 2, 'memory_size': 2097152,
47 'next_table_index': 4294967295,
48 'miss_next_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010049 'gbp_subnet_add_del': {'sw_if_index': 4294967295, 'epg_id': 65535, },
50 'geneve_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
51 'decap_next_index': 4294967295, },
Neale Ranns5a8844b2019-04-16 07:15:35 +000052 'gre_tunnel_add_del': {'instance': 4294967295, 'is_add': 1, },
Ole Troan9a475372019-03-05 16:58:24 +010053 'gtpu_add_del_tunnel': {'is_add': 1, 'mcast_sw_if_index': 4294967295,
54 'decap_next_index': 4294967295, },
55 'input_acl_set_interface': {'ip4_table_index': 4294967295,
56 'ip6_table_index': 4294967295,
57 'l2_table_index': 4294967295, },
58 'ip6_add_del_address_using_prefix': {'is_add': 1, },
59 'ip6nd_send_router_solicitation': {'irt': 1, 'mrt': 120, },
60 'ip_add_del_route': {'next_hop_sw_if_index': 4294967295,
61 'next_hop_weight': 1, 'next_hop_via_label': 1048576,
Ole Troan9a475372019-03-05 16:58:24 +010062 'classify_table_index': 4294967295, 'is_add': 1, },
63 'ip_mroute_add_del': {'is_add': 1, },
64 'ip_neighbor_add_del': {'is_add': 1, },
65 'ip_punt_police': {'is_add': 1, },
66 'ip_punt_redirect': {'is_add': 1, },
Neale Ranns097fa662018-05-01 05:17:55 -070067 'ip_route_add_del': {'is_add': 1, },
Ole Troan9a475372019-03-05 16:58:24 +010068 'ip_table_add_del': {'is_add': 1, },
69 'ip_unnumbered_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010070 'ipsec_interface_add_del_spd': {'is_add': 1, },
71 'ipsec_sad_entry_add_del': {'is_add': 1, },
72 'ipsec_spd_add_del': {'is_add': 1, },
73 'ipsec_spd_dump': {'sa_id': 4294967295, },
74 'ipsec_spd_entry_add_del': {'local_port_stop': 65535,
75 'remote_port_stop': 65535, 'priority': 100,
76 'is_outbound': 1,
77 'is_add': 1, },
78 'ipsec_tunnel_if_add_del': {'is_add': 1, 'anti_replay': 1, },
79 'l2_emulation': {'enable': 1, },
80 'l2fib_add_del': {'is_add': 1, },
Paul Vinciguerraf7f13342019-03-19 11:54:39 -070081 'lb_conf': {'sticky_buckets_per_core': 4294967295,
82 'flow_timeout': 4294967295},
Ole Troan9a475372019-03-05 16:58:24 +010083 'lisp_add_del_adjacency': {'is_add': 1, },
84 'lisp_add_del_local_eid': {'is_add': 1, },
85 'lisp_add_del_locator': {'priority': 1, 'weight': 1, 'is_add': 1, },
86 'lisp_add_del_locator_set': {'is_add': 1, },
87 'lisp_add_del_remote_mapping': {'is_add': 1, },
88 'macip_acl_add_replace': {'acl_index': 4294967295, },
89 'macip_acl_dump': {'acl_index': 4294967295, },
90 'macip_acl_interface_add_del': {'is_add': 1, },
91 'mpls_ip_bind_unbind': {'is_ip4': 1, 'is_bind': 1, },
Ole Troana5b2eec2019-03-11 19:23:25 +010092 'mpls_route_add_del': {'mr_next_hop_sw_if_index': 4294967295,
93 'mr_next_hop_weight': 1,
94 'mr_next_hop_via_label': 1048576,
95 'mr_is_add': 1,
96 'mr_classify_table_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010097 'mpls_table_add_del': {'is_add': 1, },
98 'mpls_tunnel_add_del': {'next_hop_sw_if_index': 4294967295,
99 'next_hop_weight': 1,
100 'next_hop_via_label': 1048576,
101 'is_add': 1, },
102 'mpls_tunnel_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100103 'output_acl_set_interface': {'ip4_table_index': 4294967295,
104 'ip6_table_index': 4294967295,
105 'l2_table_index': 4294967295, },
106 'pppoe_add_del_session': {'is_add': 1, },
107 'policer_add_del': {'is_add': 1, 'conform_action_type': 1, },
108 'proxy_arp_add_del': {'is_add': 1, },
109 'proxy_arp_intfc_enable_disable': {'is_enable': 1, },
Ole Troan9a475372019-03-05 16:58:24 +0100110 'set_ip_flow_hash': {'src': 1, 'dst': 1, 'sport': 1, 'dport': 1,
111 'proto': 1, },
112 'set_ipfix_exporter': {'collector_port': 4739, },
113 'sr_localsid_add_del': {'sw_if_index': 4294967295, },
114 'sr_policy_add': {'weight': 1, 'is_encap': 1, },
115 'svs_enable_disable': {'is_enable': 1, },
116 'svs_route_add_del': {'is_add': 1, },
117 'svs_table_add_del': {'is_add': 1, },
118 'sw_interface_add_del_address': {'is_add': 1, },
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700119 'sw_interface_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100120 'sw_interface_ip6nd_ra_prefix': {'val_lifetime': 4294967295,
121 'pref_lifetime': 4294967295, },
122 'sw_interface_set_ip_directed_broadcast': {'enable': 1, },
123 'sw_interface_set_l2_bridge': {'enable': 1, },
124 'sw_interface_set_mpls_enable': {'enable': 1, },
125 'sw_interface_set_mtu': {'mtu': [0, 0, 0, 0], },
126 'sw_interface_set_unnumbered': {'is_add': 1, },
127 'sw_interface_span_enable_disable': {'state': 1, },
128 'vxlan_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
129 'decap_next_index': 4294967295,
130 'instance': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100131 'vxlan_gbp_tunnel_dump': {'sw_if_index': 4294967295, },
132 'vxlan_gpe_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
133 'protocol': 3, },
134 'want_bfd_events': {'enable_disable': 1, },
Ole Troan9a475372019-03-05 16:58:24 +0100135 'want_igmp_events': {'enable': 1, },
136 'want_interface_events': {'enable_disable': 1, },
137 'want_ip4_arp_events': {'enable_disable': 1, 'ip': '0.0.0.0', },
138 'want_ip6_nd_events': {'enable_disable': 1, 'ip': '::', },
139 'want_ip6_ra_events': {'enable_disable': 1, },
140 'want_l2_macs_events': {'enable_disable': 1, },
141}
Ole Troanf159f582019-02-28 20:20:47 +0100142
Matus Fabianb4515b42018-11-19 04:25:32 -0800143
Paul Vinciguerra9673e3e2019-05-10 20:41:08 -0400144class CliFailedCommandError(Exception):
145 """ cli command failed."""
146
147
148class CliSyntaxError(Exception):
149 """ cli command had a syntax error."""
150
151
Klement Sekera73884482017-02-23 09:26:30 +0100152class UnexpectedApiReturnValueError(Exception):
153 """ exception raised when the API return value is unexpected """
154 pass
155
156
Klement Sekeraf62ae122016-10-11 11:47:09 +0200157class VppPapiProvider(object):
158 """VPP-api provider using vpp-papi
159
160 @property hook: hook object providing before and after api/cli hooks
Klement Sekeraf62ae122016-10-11 11:47:09 +0200161 """
162
Klement Sekerae0545ef2017-01-25 08:00:40 +0100163 _zero, _negative = range(2)
164
Klement Sekera611864f2018-09-26 11:19:00 +0200165 def __init__(self, name, shm_prefix, test_class, read_timeout):
Paul Vinciguerra895e2f82019-01-08 20:37:40 -0800166 self.hook = Hook(test_class)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200167 self.name = name
168 self.shm_prefix = shm_prefix
Klement Sekera7bb873a2016-11-18 07:38:42 +0100169 self.test_class = test_class
Klement Sekerae0545ef2017-01-25 08:00:40 +0100170 self._expect_api_retval = self._zero
171 self._expect_stack = []
Ole Troan7e3a8752016-12-05 10:27:09 +0100172
Paul Vinciguerra19542292019-03-17 17:34:46 -0700173 # install_dir is a class attribute. We need to set it before
174 # calling the constructor.
175 VPPApiClient.apidir = os.getenv('VPP_INSTALL_PATH')
Paul Vinciguerra04575c52019-01-13 10:26:05 -0800176
Ole Troan4ff09ae2019-04-15 11:27:22 +0200177 use_socket = False
178 try:
179 if os.environ['SOCKET'] == '1':
180 use_socket = True
Paul Vinciguerrabff9f2f2019-05-09 16:12:35 -0400181 except KeyError:
Ole Troan4ff09ae2019-04-15 11:27:22 +0200182 pass
Paul Vinciguerra19542292019-03-17 17:34:46 -0700183
184 self.vpp = VPPApiClient(logger=test_class.logger,
185 read_timeout=read_timeout,
186 use_socket=use_socket,
187 server_address=test_class.api_sock)
Klement Sekerae4504c62016-12-08 10:16:41 +0100188 self._events = deque()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200189
Klement Sekerae0545ef2017-01-25 08:00:40 +0100190 def __enter__(self):
191 return self
192
Klement Sekera7d6afb32018-11-08 11:52:04 +0100193 def assert_negative_api_retval(self):
194 """ Expect API failure - used with with, e.g.:
195 with self.vapi.assert_negative_api_retval():
196 self.vapi.<api call expected to fail>
197 """
Klement Sekerae0545ef2017-01-25 08:00:40 +0100198 self._expect_stack.append(self._expect_api_retval)
199 self._expect_api_retval = self._negative
200 return self
201
Klement Sekera7d6afb32018-11-08 11:52:04 +0100202 def assert_zero_api_retval(self):
203 """ Expect API success - used with with, e.g.:
204 with self.vapi.assert_negative_api_retval():
205 self.vapi.<api call expected to succeed>
206
207 note: this is useful only inside another with block
208 as success is the default expected value
209 """
Klement Sekerae0545ef2017-01-25 08:00:40 +0100210 self._expect_stack.append(self._expect_api_retval)
211 self._expect_api_retval = self._zero
212 return self
213
214 def __exit__(self, exc_type, exc_value, traceback):
215 self._expect_api_retval = self._expect_stack.pop()
216
Klement Sekeraf62ae122016-10-11 11:47:09 +0200217 def register_hook(self, hook):
218 """Replace hook registration with new hook
219
220 :param hook:
221
222 """
223 self.hook = hook
224
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200225 def collect_events(self):
Klement Sekerae4504c62016-12-08 10:16:41 +0100226 """ Collect all events from the internal queue and clear the queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200227 e = self._events
Klement Sekerae4504c62016-12-08 10:16:41 +0100228 self._events = deque()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200229 return e
230
231 def wait_for_event(self, timeout, name=None):
Klement Sekerae4504c62016-12-08 10:16:41 +0100232 """ Wait for and return next event. """
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100233 if name:
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100234 self.test_class.logger.debug("Expecting event '%s' within %ss",
235 name, timeout)
Eyal Bari20197482017-09-13 12:29:08 +0300236 else:
237 self.test_class.logger.debug("Expecting event within %ss",
238 timeout)
Klement Sekerae4504c62016-12-08 10:16:41 +0100239 if self._events:
240 self.test_class.logger.debug("Not waiting, event already queued")
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200241 limit = time.time() + timeout
242 while time.time() < limit:
243 if self._events:
Klement Sekerae4504c62016-12-08 10:16:41 +0100244 e = self._events.popleft()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200245 if name and type(e).__name__ != name:
246 raise Exception(
247 "Unexpected event received: %s, expected: %s" %
248 (type(e).__name__, name))
Klement Sekerae4504c62016-12-08 10:16:41 +0100249 self.test_class.logger.debug("Returning event %s:%s" %
250 (name, e))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200251 return e
Paul Vinciguerra0f6602c2019-03-10 09:10:54 -0700252 self.test_class.sleep(0) # yield
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200253 raise Exception("Event did not occur within timeout")
254
255 def __call__(self, name, event):
Klement Sekerae4504c62016-12-08 10:16:41 +0100256 """ Enqueue event in the internal event queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200257 # FIXME use the name instead of relying on type(e).__name__ ?
258 # FIXME #2 if this throws, it is eaten silently, Ole?
Klement Sekerae4504c62016-12-08 10:16:41 +0100259 self.test_class.logger.debug("New event: %s: %s" % (name, event))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200260 self._events.append(event)
261
Ole Troanf159f582019-02-28 20:20:47 +0100262 def factory(self, name, apifn):
263 def f(*a, **ka):
264 fields = apifn._func.msg.fields
265
266 # add positional and kw arguments
267 d = ka
268 for i, o in enumerate(fields[3:]):
269 try:
270 d[o] = a[i]
Jakub Grajciar4682feb2019-09-02 13:28:52 +0200271 except BaseException:
Ole Troanf159f582019-02-28 20:20:47 +0100272 break
273
274 # Default override
275 if name in defaultmapping:
276 for k, v in iteritems(defaultmapping[name]):
277 if k in d:
278 continue
279 d[k] = v
280 return self.api(apifn, d)
Ole Troan9a475372019-03-05 16:58:24 +0100281
Ole Troanf159f582019-02-28 20:20:47 +0100282 return f
283
Paul Vinciguerra7ab99702019-03-05 04:30:04 -0800284 def __getattribute__(self, name):
Ole Troanf159f582019-02-28 20:20:47 +0100285 try:
Paul Vinciguerra7ab99702019-03-05 04:30:04 -0800286 method = super(VppPapiProvider, self).__getattribute__(name)
287 except AttributeError:
288 method = self.factory(name, getattr(self.papi, name))
289 # lazily load the method so we don't need to call factory
290 # again for this name.
291 setattr(self, name, method)
292 return method
Ole Troanf159f582019-02-28 20:20:47 +0100293
Klement Sekeraf62ae122016-10-11 11:47:09 +0200294 def connect(self):
295 """Connect the API to VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100296 self.vpp.connect(self.name, self.shm_prefix)
297 self.papi = self.vpp.api
298 self.vpp.register_event_callback(self)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200299
300 def disconnect(self):
301 """Disconnect the API from VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100302 self.vpp.disconnect()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200303
304 def api(self, api_fn, api_args, expected_retval=0):
Klement Sekerae4504c62016-12-08 10:16:41 +0100305 """ Call API function and check it's return value.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200306 Call the appropriate hooks before and after the API call
307
308 :param api_fn: API function to call
309 :param api_args: tuple of API function arguments
310 :param expected_retval: Expected return value (Default value = 0)
311 :returns: reply from the API
312
313 """
314 self.hook.before_api(api_fn.__name__, api_args)
Ole Troan7e3a8752016-12-05 10:27:09 +0100315 reply = api_fn(**api_args)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100316 if self._expect_api_retval == self._negative:
317 if hasattr(reply, 'retval') and reply.retval >= 0:
Ole Troan9a475372019-03-05 16:58:24 +0100318 msg = "API call passed unexpectedly: expected negative " \
319 "return value instead of %d in %s" % \
320 (reply.retval, moves.reprlib.repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100321 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100322 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100323 elif self._expect_api_retval == self._zero:
324 if hasattr(reply, 'retval') and reply.retval != expected_retval:
Ole Troan9a475372019-03-05 16:58:24 +0100325 msg = "API call failed, expected %d return value instead " \
326 "of %d in %s" % (expected_retval, reply.retval,
Paul Vinciguerra1b534f52019-06-15 20:31:31 -0400327 repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100328 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100329 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100330 else:
331 raise Exception("Internal error, unexpected value for "
332 "self._expect_api_retval %s" %
333 self._expect_api_retval)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200334 self.hook.after_api(api_fn.__name__, api_args)
335 return reply
336
Dave Barach5932ce12019-10-09 17:28:04 -0400337 def cli_return_response(self, cli):
338 """ Execute a CLI, calling the before/after hooks appropriately.
339 Return the reply without examining it
340
341 :param cli: CLI to execute
342 :returns: response object
343
344 """
345 self.hook.before_cli(cli)
346 cli += '\n'
347 r = self.papi.cli_inband(cmd=cli)
348 self.hook.after_cli(cli)
349 return r
350
Klement Sekeraf62ae122016-10-11 11:47:09 +0200351 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100352 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200353
354 :param cli: CLI to execute
355 :returns: CLI output
356
357 """
Dave Barach5932ce12019-10-09 17:28:04 -0400358 r = self.cli_return_response(cli)
Paul Vinciguerra9673e3e2019-05-10 20:41:08 -0400359 if r.retval == -156:
360 raise CliSyntaxError(r.reply)
361 if r.retval != 0:
362 raise CliFailedCommandError(r.reply)
Jan49c0fca2016-10-26 15:44:27 +0200363 if hasattr(r, 'reply'):
Ole Troan413f4a52018-11-28 11:36:05 +0100364 return r.reply
Klement Sekeraf62ae122016-10-11 11:47:09 +0200365
Jan49c0fca2016-10-26 15:44:27 +0200366 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100367 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200368
369 :param cli: CLI to execute
370 :returns: CLI output
371 """
Ole Troan6ed154f2019-10-15 19:31:55 +0200372 return cli + "\n" + self.cli(cli)
Jan49c0fca2016-10-26 15:44:27 +0200373
Neale Ranns37029302018-08-10 05:30:06 -0700374 def want_ip4_arp_events(self, enable_disable=1, ip="0.0.0.0"):
Eyal Bari20197482017-09-13 12:29:08 +0300375 return self.api(self.papi.want_ip4_arp_events,
376 {'enable_disable': enable_disable,
Neale Ranns37029302018-08-10 05:30:06 -0700377 'ip': ip,
Eyal Bari20197482017-09-13 12:29:08 +0300378 'pid': os.getpid(), })
379
Neale Ranns37029302018-08-10 05:30:06 -0700380 def want_ip6_nd_events(self, enable_disable=1, ip="::"):
Eyal Baric125ecc2017-09-20 11:29:17 +0300381 return self.api(self.papi.want_ip6_nd_events,
382 {'enable_disable': enable_disable,
Neale Ranns37029302018-08-10 05:30:06 -0700383 'ip': ip,
Eyal Baric125ecc2017-09-20 11:29:17 +0300384 'pid': os.getpid(), })
385
Juraj Sloboda4b9669d2018-01-15 10:39:21 +0100386 def want_ip6_ra_events(self, enable_disable=1):
387 return self.api(self.papi.want_ip6_ra_events,
388 {'enable_disable': enable_disable,
389 'pid': os.getpid(), })
390
391 def ip6nd_send_router_solicitation(self, sw_if_index, irt=1, mrt=120,
392 mrc=0, mrd=0):
393 return self.api(self.papi.ip6nd_send_router_solicitation,
394 {'irt': irt,
395 'mrt': mrt,
396 'mrc': mrc,
397 'mrd': mrd,
398 'sw_if_index': sw_if_index})
399
Juraj Slobodab3f90502018-10-04 15:15:16 +0200400 def want_interface_events(self, enable_disable=1):
401 return self.api(self.papi.want_interface_events,
402 {'enable_disable': enable_disable,
403 'pid': os.getpid(), })
404
Ole Troane1ade682019-03-04 23:55:43 +0100405 def want_l2_macs_events(self, enable_disable=1, scan_delay=0,
406 max_macs_in_event=0, learn_limit=0):
Eyal Bari24db0ec2017-09-27 21:43:51 +0300407 return self.api(self.papi.want_l2_macs_events,
408 {'enable_disable': enable_disable,
409 'scan_delay': scan_delay,
410 'max_macs_in_event': max_macs_in_event,
411 'learn_limit': learn_limit,
412 'pid': os.getpid(), })
413
Neale Rannsc819fc62018-02-16 02:44:05 -0800414 def sw_interface_set_mac_address(self, sw_if_index, mac):
415 return self.api(self.papi.sw_interface_set_mac_address,
416 {'sw_if_index': sw_if_index,
417 'mac_address': mac})
418
Ole Troane1ade682019-03-04 23:55:43 +0100419 def p2p_ethernet_add(self, sw_if_index, remote_mac, subif_id):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200420 """Create p2p ethernet subinterface
421
422 :param sw_if_index: main (parent) interface
423 :param remote_mac: client (remote) mac address
424
425 """
426 return self.api(
427 self.papi.p2p_ethernet_add,
428 {'parent_if_index': sw_if_index,
429 'remote_mac': remote_mac,
430 'subif_id': subif_id})
431
Ole Troane1ade682019-03-04 23:55:43 +0100432 def p2p_ethernet_del(self, sw_if_index, remote_mac):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200433 """Delete p2p ethernet subinterface
434
435 :param sw_if_index: main (parent) interface
436 :param remote_mac: client (remote) mac address
437
438 """
439 return self.api(
440 self.papi.p2p_ethernet_del,
441 {'parent_if_index': sw_if_index,
442 'remote_mac': remote_mac})
443
Klement Sekeraf62ae122016-10-11 11:47:09 +0200444 def create_vlan_subif(self, sw_if_index, vlan):
445 """
446
447 :param vlan:
448 :param sw_if_index:
449
450 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100451 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200452 {'sw_if_index': sw_if_index,
453 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200454
Matej Klotton0178d522016-11-04 11:11:44 +0100455 def create_loopback(self, mac=''):
456 """
457
458 :param mac: (Optional)
459 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100460 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200461 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100462
Neale Ranns097fa662018-05-01 05:17:55 -0700463 def ip_table_add_del(self,
464 table_id,
465 is_add=1,
466 is_ipv6=0):
467 """
468
469 :param table_id
470 :param is_add: (Default value = 1)
471 :param is_ipv6: (Default value = 0)
472
473 """
474
475 return self.api(
476 self.papi.ip_table_add_del,
477 {'table':
478 {
479 'table_id': table_id,
480 'is_ip6': is_ipv6
481 },
482 'is_add': is_add})
483
484 def ip_table_dump(self):
485 return self.api(self.papi.ip_table_dump, {})
486
487 def ip_route_dump(self, table_id, is_ip6=False):
488 return self.api(self.papi.ip_route_dump,
489 {'table': {
490 'table_id': table_id,
491 'is_ip6': is_ip6
492 }})
493
Matej Klotton0178d522016-11-04 11:11:44 +0100494 def ip_neighbor_add_del(self,
495 sw_if_index,
496 mac_address,
Neale Ranns37029302018-08-10 05:30:06 -0700497 ip_address,
Matej Klotton0178d522016-11-04 11:11:44 +0100498 is_add=1,
Neale Ranns37029302018-08-10 05:30:06 -0700499 flags=0):
Matej Klotton0178d522016-11-04 11:11:44 +0100500 """ Add neighbor MAC to IPv4 or IPv6 address.
501
502 :param sw_if_index:
503 :param mac_address:
504 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100505 :param is_add: (Default value = 1)
Neale Ranns37029302018-08-10 05:30:06 -0700506 :param flags: (Default value = 0/NONE)
Matej Klotton0178d522016-11-04 11:11:44 +0100507 """
Matej Klotton0178d522016-11-04 11:11:44 +0100508 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100509 self.papi.ip_neighbor_add_del,
Neale Ranns37029302018-08-10 05:30:06 -0700510 {
511 'is_add': is_add,
512 'neighbor': {
513 'sw_if_index': sw_if_index,
514 'flags': flags,
515 'mac_address': mac_address,
516 'ip_address': ip_address
517 }
518 }
Matej Klotton0178d522016-11-04 11:11:44 +0100519 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100520
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800521 def proxy_arp_add_del(self,
Neale Ranns37029302018-08-10 05:30:06 -0700522 low,
523 hi,
524 table_id=0,
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800525 is_add=1):
526 """ Config Proxy Arp Range.
527
528 :param low_address: Start address in the rnage to Proxy for
529 :param hi_address: End address in the rnage to Proxy for
530 :param vrf_id: The VRF/table in which to proxy
531 """
532
533 return self.api(
534 self.papi.proxy_arp_add_del,
Neale Ranns0053de62018-05-22 08:40:52 -0700535 {'proxy':
Ole Troan9a475372019-03-05 16:58:24 +0100536 {
537 'table_id': table_id,
538 'low': low,
539 'hi': hi,
540 },
541 'is_add': is_add})
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800542
543 def proxy_arp_intfc_enable_disable(self,
544 sw_if_index,
545 is_enable=1):
546 """ Enable/Disable an interface for proxy ARP requests
547
548 :param sw_if_index: Interface
549 :param enable_disable: Enable/Disable
550 """
551
552 return self.api(
553 self.papi.proxy_arp_intfc_enable_disable,
554 {'sw_if_index': sw_if_index,
555 'enable_disable': is_enable
556 }
557 )
558
Neale Ranns5a8844b2019-04-16 07:15:35 +0000559 def gre_tunnel_add_del(self,
560 src,
561 dst,
Neale Ranns177bbdc2016-11-15 09:46:51 +0000562 outer_fib_id=0,
John Loa43ccae2018-02-13 17:15:23 -0500563 tunnel_type=0,
564 instance=0xFFFFFFFF,
565 session_id=0,
Neale Ranns5a8844b2019-04-16 07:15:35 +0000566 is_add=1):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000567 """ Add a GRE tunnel
568
569 :param src_address:
570 :param dst_address:
571 :param outer_fib_id: (Default value = 0)
John Loa43ccae2018-02-13 17:15:23 -0500572 :param tunnel_type: (Default value = 0)
573 :param instance: (Default value = 0xFFFFFFFF)
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700574 :param session_id: (Default value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000575 :param is_add: (Default value = 1)
576 :param is_ipv6: (Default value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000577 """
578
579 return self.api(
Neale Ranns5a8844b2019-04-16 07:15:35 +0000580 self.papi.gre_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200581 {'is_add': is_add,
Neale Ranns5a8844b2019-04-16 07:15:35 +0000582 'tunnel':
583 {
584 'type': tunnel_type,
585 'instance': instance,
586 'src': src,
587 'dst': dst,
588 'outer_fib_id': outer_fib_id,
589 'session_id': session_id}
590 }
Neale Ranns177bbdc2016-11-15 09:46:51 +0000591 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000592
Neale Rannsd0df49f2018-08-08 01:06:40 -0700593 def udp_encap_add(self,
Neale Rannsd0df49f2018-08-08 01:06:40 -0700594 src_ip,
595 dst_ip,
596 src_port,
597 dst_port,
598 table_id=0):
Neale Ranns810086d2017-11-05 16:26:46 -0800599 """ Add a GRE tunnel
Neale Ranns810086d2017-11-05 16:26:46 -0800600 :param src_ip:
601 :param dst_ip:
602 :param src_port:
603 :param dst_port:
604 :param outer_fib_id: (Default value = 0)
Neale Ranns810086d2017-11-05 16:26:46 -0800605 """
606
607 return self.api(
Neale Rannsd0df49f2018-08-08 01:06:40 -0700608 self.papi.udp_encap_add,
609 {
610 'udp_encap': {
Neale Rannsd0df49f2018-08-08 01:06:40 -0700611 'src_ip': src_ip,
612 'dst_ip': dst_ip,
613 'src_port': src_port,
614 'dst_port': dst_port,
615 'table_id': table_id
616 }
617 })
618
Neale Ranns097fa662018-05-01 05:17:55 -0700619 def udp_encap_del(self, id):
620 return self.api(self.papi.udp_encap_del, {'id': id})
621
622 def udp_encap_dump(self):
623 return self.api(self.papi.udp_encap_dump, {})
624
625 def want_udp_encap_stats(self, enable=1):
626 return self.api(self.papi.want_udp_encap_stats,
627 {'enable': enable,
628 'pid': os.getpid()})
629
630 def mpls_route_dump(self, table_id):
631 return self.api(self.papi.mpls_route_dump,
632 {'table': {
633 'mt_table_id': table_id
634 }})
635
636 def mpls_table_dump(self):
637 return self.api(self.papi.mpls_table_dump, {})
638
Neale Ranns15002542017-09-10 04:39:11 -0700639 def mpls_table_add_del(
640 self,
641 table_id,
642 is_add=1):
643 """
644
645 :param table_id
646 :param is_add: (Default value = 1)
647
648 """
649
650 return self.api(
651 self.papi.mpls_table_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700652 {'mt_table':
653 {
654 'mt_table_id': table_id,
655 },
Neale Ranns15002542017-09-10 04:39:11 -0700656 'mt_is_add': is_add})
657
Neale Ranns097fa662018-05-01 05:17:55 -0700658 def mpls_route_add_del(self,
659 table_id,
660 label,
661 eos,
662 eos_proto,
663 is_multicast,
664 paths,
665 is_add,
666 is_multipath):
667 """ MPLS Route add/del """
668 return self.api(
669 self.papi.mpls_route_add_del,
670 {'mr_route':
671 {
672 'mr_table_id': table_id,
673 'mr_label': label,
674 'mr_eos': eos,
675 'mr_eos_proto': eos_proto,
676 'mr_is_multicast': is_multicast,
677 'mr_n_paths': len(paths),
678 'mr_paths': paths,
679 },
680 'mr_is_add': is_add,
681 'mr_is_multipath': is_multipath})
682
Neale Rannsad422ed2016-11-02 14:20:04 +0000683 def mpls_ip_bind_unbind(
684 self,
685 label,
Neale Ranns097fa662018-05-01 05:17:55 -0700686 prefix,
Neale Rannsad422ed2016-11-02 14:20:04 +0000687 table_id=0,
688 ip_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000689 is_bind=1):
690 """
691 """
692 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100693 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200694 {'mb_mpls_table_id': table_id,
695 'mb_label': label,
696 'mb_ip_table_id': ip_table_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200697 'mb_is_bind': is_bind,
Neale Ranns097fa662018-05-01 05:17:55 -0700698 'mb_prefix': prefix})
Neale Rannsad422ed2016-11-02 14:20:04 +0000699
700 def mpls_tunnel_add_del(
701 self,
702 tun_sw_if_index,
Neale Ranns097fa662018-05-01 05:17:55 -0700703 paths,
Neale Rannsad422ed2016-11-02 14:20:04 +0000704 is_add=1,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800705 l2_only=0,
706 is_multicast=0):
Neale Rannsad422ed2016-11-02 14:20:04 +0000707 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000708 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000709 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100710 self.papi.mpls_tunnel_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700711 {'mt_is_add': is_add,
712 'mt_tunnel':
713 {
714 'mt_sw_if_index': tun_sw_if_index,
715 'mt_l2_only': l2_only,
716 'mt_is_multicast': is_multicast,
717 'mt_n_paths': len(paths),
718 'mt_paths': paths,
719 }})
Matus Fabiande886752016-12-07 03:38:19 -0800720
Steve Shin7957d6e2016-12-19 09:24:50 -0800721 def classify_add_del_table(
722 self,
723 is_add,
724 mask,
725 match_n_vectors=1,
726 table_index=0xFFFFFFFF,
727 nbuckets=2,
728 memory_size=2097152,
729 skip_n_vectors=0,
730 next_table_index=0xFFFFFFFF,
731 miss_next_index=0xFFFFFFFF,
732 current_data_flag=0,
733 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -0800734 """
735 :param is_add:
736 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +0100737 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100738 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -0800739 :param nbuckets: (Default value = 2)
740 :param memory_size: (Default value = 2097152)
741 :param skip_n_vectors: (Default value = 0)
742 :param next_table_index: (Default value = 0xFFFFFFFF)
743 :param miss_next_index: (Default value = 0xFFFFFFFF)
744 :param current_data_flag: (Default value = 0)
745 :param current_data_offset: (Default value = 0)
746 """
Ole Troan19cb04d2019-10-17 20:44:25 +0200747 mask_len = ((len(mask) - 1) // 16 + 1) * 16
748 mask = mask + b'\0' * (mask_len - len(mask))
Steve Shin7957d6e2016-12-19 09:24:50 -0800749 return self.api(
750 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100751 {'is_add': is_add,
752 'table_index': table_index,
753 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -0800754 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100755 'skip_n_vectors': skip_n_vectors,
756 'match_n_vectors': match_n_vectors,
757 'next_table_index': next_table_index,
758 'miss_next_index': miss_next_index,
759 'current_data_flag': current_data_flag,
760 'current_data_offset': current_data_offset,
Juraj Sloboda75282452018-06-12 14:20:49 +0200761 'mask_len': mask_len,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100762 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -0800763
764 def classify_add_del_session(
765 self,
766 is_add,
767 table_index,
768 match,
769 opaque_index=0xFFFFFFFF,
770 hit_next_index=0xFFFFFFFF,
771 advance=0,
772 action=0,
773 metadata=0):
774 """
775 :param is_add:
776 :param table_index:
777 :param match:
778 :param opaque_index: (Default value = 0xFFFFFFFF)
779 :param hit_next_index: (Default value = 0xFFFFFFFF)
780 :param advance: (Default value = 0)
781 :param action: (Default value = 0)
782 :param metadata: (Default value = 0)
783 """
784
Ole Troan19cb04d2019-10-17 20:44:25 +0200785 match_len = ((len(match) - 1) // 16 + 1) * 16
786 match = match + b'\0' * (match_len - len(match))
Steve Shin7957d6e2016-12-19 09:24:50 -0800787 return self.api(
788 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100789 {'is_add': is_add,
790 'table_index': table_index,
791 'hit_next_index': hit_next_index,
792 'opaque_index': opaque_index,
793 'advance': advance,
794 'action': action,
795 'metadata': metadata,
Juraj Sloboda75282452018-06-12 14:20:49 +0200796 'match_len': match_len,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100797 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -0800798
799 def input_acl_set_interface(
800 self,
801 is_add,
802 sw_if_index,
803 ip4_table_index=0xFFFFFFFF,
804 ip6_table_index=0xFFFFFFFF,
805 l2_table_index=0xFFFFFFFF):
806 """
807 :param is_add:
808 :param sw_if_index:
809 :param ip4_table_index: (Default value = 0xFFFFFFFF)
810 :param ip6_table_index: (Default value = 0xFFFFFFFF)
811 :param l2_table_index: (Default value = 0xFFFFFFFF)
812 """
813
814 return self.api(
815 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100816 {'sw_if_index': sw_if_index,
817 'ip4_table_index': ip4_table_index,
818 'ip6_table_index': ip6_table_index,
819 'l2_table_index': l2_table_index,
820 'is_add': is_add})
821
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100822 def output_acl_set_interface(
823 self,
824 is_add,
825 sw_if_index,
826 ip4_table_index=0xFFFFFFFF,
827 ip6_table_index=0xFFFFFFFF,
828 l2_table_index=0xFFFFFFFF):
829 """
830 :param is_add:
831 :param sw_if_index:
832 :param ip4_table_index: (Default value = 0xFFFFFFFF)
833 :param ip6_table_index: (Default value = 0xFFFFFFFF)
834 :param l2_table_index: (Default value = 0xFFFFFFFF)
835 """
836
837 return self.api(
838 self.papi.output_acl_set_interface,
839 {'sw_if_index': sw_if_index,
840 'ip4_table_index': ip4_table_index,
841 'ip6_table_index': ip6_table_index,
842 'l2_table_index': l2_table_index,
843 'is_add': is_add})
844
Klement Sekera77fabdb2017-01-02 07:46:14 +0100845 def set_ipfix_exporter(
846 self,
847 collector_address,
848 src_address,
849 path_mtu,
850 template_interval,
851 vrf_id=0,
852 collector_port=4739,
853 udp_checksum=0):
854 return self.api(
855 self.papi.set_ipfix_exporter,
856 {
857 'collector_address': collector_address,
858 'collector_port': collector_port,
859 'src_address': src_address,
860 'vrf_id': vrf_id,
861 'path_mtu': path_mtu,
862 'template_interval': template_interval,
863 'udp_checksum': udp_checksum,
864 })
Neale Rannsfca0c242017-01-13 07:57:46 -0800865
Neale Ranns32e1c012016-11-22 17:07:28 +0000866 def ip_mroute_add_del(self,
Neale Ranns097fa662018-05-01 05:17:55 -0700867 table_id,
868 prefix,
Neale Ranns32e1c012016-11-22 17:07:28 +0000869 e_flags,
Neale Ranns097fa662018-05-01 05:17:55 -0700870 rpf_id,
871 paths,
Neale Ranns32e1c012016-11-22 17:07:28 +0000872 is_add=1,
Neale Ranns097fa662018-05-01 05:17:55 -0700873 is_multipath=1):
Neale Ranns32e1c012016-11-22 17:07:28 +0000874 """
Neale Rannsd792d9c2017-10-21 10:53:20 -0700875 IP Multicast Route add/del
Neale Ranns32e1c012016-11-22 17:07:28 +0000876 """
877 return self.api(
878 self.papi.ip_mroute_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700879 {
880 'is_add': is_add,
881 'is_multipath': is_multipath,
882 'route': {
883 'table_id': table_id,
884 'entry_flags': e_flags,
885 'rpf_id': rpf_id,
886 'prefix': prefix,
887 'n_paths': len(paths),
888 'paths': paths,
889 }
890 })
891
892 def mfib_signal_dump(self):
893 return self.api(self.papi.mfib_signal_dump, {})
894
895 def ip_mroute_dump(self, table_id, is_ip6=False):
896 return self.api(self.papi.ip_mroute_dump,
897 {'table': {
898 'table_id': table_id,
899 'is_ip6': is_ip6
900 }})
Neale Ranns32e1c012016-11-22 17:07:28 +0000901
Filip Tehlar770e89e2017-01-31 10:39:16 +0100902 def lisp_enable_disable(self, is_enabled):
903 return self.api(
904 self.papi.lisp_enable_disable,
905 {
906 'is_en': is_enabled,
907 })
908
Ole Troane1ade682019-03-04 23:55:43 +0100909 def lisp_add_del_locator_set(self,
910 ls_name,
911 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100912 return self.api(
913 self.papi.lisp_add_del_locator_set,
914 {
915 'is_add': is_add,
916 'locator_set_name': ls_name
917 })
918
Ole Troane1ade682019-03-04 23:55:43 +0100919 def lisp_add_del_locator(self,
920 ls_name,
921 sw_if_index,
922 priority=1,
923 weight=1,
924 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100925 return self.api(
926 self.papi.lisp_add_del_locator,
927 {
928 'is_add': is_add,
929 'locator_set_name': ls_name,
930 'sw_if_index': sw_if_index,
931 'priority': priority,
932 'weight': weight
933 })
934
935 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
936 return self.api(
937 self.papi.lisp_locator_dump,
938 {
939 'is_index_set': is_index_set,
940 'ls_name': ls_name,
941 'ls_index': ls_index,
942 })
943
Ole Troane1ade682019-03-04 23:55:43 +0100944 def lisp_add_del_local_eid(self,
945 ls_name,
946 eid_type,
947 eid,
948 prefix_len,
949 vni=0,
950 key_id=0,
951 key="",
952 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100953 return self.api(
954 self.papi.lisp_add_del_local_eid,
955 {
956 'locator_set_name': ls_name,
957 'is_add': is_add,
958 'eid_type': eid_type,
959 'eid': eid,
960 'prefix_len': prefix_len,
961 'vni': vni,
962 'key_id': key_id,
963 'key': key
964 })
965
966 def lisp_eid_table_dump(self,
967 eid_set=0,
968 prefix_length=0,
969 vni=0,
970 eid_type=0,
971 eid=None,
972 filter_opt=0):
973 return self.api(
974 self.papi.lisp_eid_table_dump,
975 {
976 'eid_set': eid_set,
977 'prefix_length': prefix_length,
978 'vni': vni,
979 'eid_type': eid_type,
980 'eid': eid,
981 'filter': filter_opt,
982 })
983
Ole Troane1ade682019-03-04 23:55:43 +0100984 def lisp_add_del_remote_mapping(self,
985 eid_type,
986 eid,
987 eid_prefix_len=0,
988 vni=0,
989 rlocs=[],
990 rlocs_num=0,
991 is_src_dst=0,
992 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100993 return self.api(
994 self.papi.lisp_add_del_remote_mapping,
995 {
996 'is_add': is_add,
997 'eid_type': eid_type,
998 'eid': eid,
999 'eid_len': eid_prefix_len,
1000 'rloc_num': rlocs_num,
1001 'rlocs': rlocs,
1002 'vni': vni,
1003 'is_src_dst': is_src_dst,
1004 })
1005
Ole Troane1ade682019-03-04 23:55:43 +01001006 def lisp_add_del_adjacency(self,
1007 leid,
1008 reid,
1009 leid_len,
1010 reid_len,
1011 eid_type,
1012 is_add=1,
1013 vni=0):
Filip Tehlar770e89e2017-01-31 10:39:16 +01001014 return self.api(
1015 self.papi.lisp_add_del_adjacency,
1016 {
1017 'is_add': is_add,
1018 'vni': vni,
1019 'eid_type': eid_type,
1020 'leid': leid,
1021 'reid': reid,
1022 'leid_len': leid_len,
1023 'reid_len': reid_len,
1024 })
1025
Hongjun Nief486b12017-04-12 19:21:16 +08001026 def gtpu_add_del_tunnel(
1027 self,
1028 src_addr,
1029 dst_addr,
1030 is_add=1,
1031 is_ipv6=0,
1032 mcast_sw_if_index=0xFFFFFFFF,
1033 encap_vrf_id=0,
1034 decap_next_index=0xFFFFFFFF,
1035 teid=0):
1036 """
1037
1038 :param is_add: (Default value = 1)
1039 :param is_ipv6: (Default value = 0)
1040 :param src_addr:
1041 :param dst_addr:
1042 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
1043 :param encap_vrf_id: (Default value = 0)
1044 :param decap_next_index: (Default value = 0xFFFFFFFF)
1045 :param teid: (Default value = 0)
1046
1047 """
1048 return self.api(self.papi.gtpu_add_del_tunnel,
1049 {'is_add': is_add,
1050 'is_ipv6': is_ipv6,
1051 'src_address': src_addr,
1052 'dst_address': dst_addr,
1053 'mcast_sw_if_index': mcast_sw_if_index,
1054 'encap_vrf_id': encap_vrf_id,
1055 'decap_next_index': decap_next_index,
1056 'teid': teid})
Hongjun Ni8a0a0ae2017-05-27 20:23:09 +08001057
1058 def vxlan_gpe_add_del_tunnel(
1059 self,
1060 src_addr,
1061 dst_addr,
1062 mcast_sw_if_index=0xFFFFFFFF,
1063 is_add=1,
1064 is_ipv6=0,
1065 encap_vrf_id=0,
1066 decap_vrf_id=0,
1067 protocol=3,
1068 vni=0):
1069 """
1070
1071 :param local:
1072 :param remote:
1073 :param is_add: (Default value = 1)
1074 :param is_ipv6: (Default value = 0)
1075 :param encap_vrf_id: (Default value = 0)
1076 :param decap_vrf_id: (Default value = 0)
1077 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
1078 :param protocol: (Default value = 3)
1079 :param vni: (Default value = 0)
1080
1081 """
1082 return self.api(self.papi.vxlan_gpe_add_del_tunnel,
1083 {'is_add': is_add,
1084 'is_ipv6': is_ipv6,
1085 'local': src_addr,
1086 'remote': dst_addr,
1087 'mcast_sw_if_index': mcast_sw_if_index,
1088 'encap_vrf_id': encap_vrf_id,
1089 'decap_vrf_id': decap_vrf_id,
1090 'protocol': protocol,
1091 'vni': vni})
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001092
Neale Ranns79a05f52018-09-11 07:39:43 -07001093 def vxlan_gbp_tunnel_dump(self, sw_if_index=0xffffffff):
1094 return self.api(self.papi.vxlan_gbp_tunnel_dump,
Ole Troan0bcad322018-12-11 13:04:01 +01001095 {'sw_if_index': sw_if_index,
1096 '_no_type_conversion': True})
Mohsin Kazmi61b94c62018-08-20 18:32:39 +02001097
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001098 def pppoe_add_del_session(
1099 self,
1100 client_ip,
1101 client_mac,
1102 session_id=0,
1103 is_add=1,
1104 is_ipv6=0,
1105 decap_vrf_id=0):
1106 """
1107
1108 :param is_add: (Default value = 1)
1109 :param is_ipv6: (Default value = 0)
1110 :param client_ip:
1111 :param session_id: (Default value = 0)
1112 :param client_mac:
1113 :param decap_vrf_id: (Default value = 0)
1114
1115 """
1116 return self.api(self.papi.pppoe_add_del_session,
1117 {'is_add': is_add,
1118 'is_ipv6': is_ipv6,
1119 'session_id': session_id,
1120 'client_ip': client_ip,
1121 'decap_vrf_id': decap_vrf_id,
1122 'client_mac': client_mac})
Kris Michielsen91074432017-06-22 13:00:20 +02001123
Neale Ranns7c922dc2018-08-30 06:12:27 -07001124 def sr_mpls_policy_add(self, bsid, weight, type, segments):
1125 return self.api(self.papi.sr_mpls_policy_add,
1126 {'bsid': bsid,
1127 'weight': weight,
1128 'type': type,
1129 'n_segments': len(segments),
1130 'segments': segments})
1131
1132 def sr_mpls_policy_del(self, bsid):
1133 return self.api(self.papi.sr_mpls_policy_del,
1134 {'bsid': bsid})
1135
Kris Michielsen91074432017-06-22 13:00:20 +02001136 def sr_localsid_add_del(self,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001137 localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02001138 behavior,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001139 nh_addr4,
1140 nh_addr6,
Kris Michielsen91074432017-06-22 13:00:20 +02001141 is_del=0,
1142 end_psp=0,
1143 sw_if_index=0xFFFFFFFF,
1144 vlan_index=0,
1145 fib_table=0,
1146 ):
1147 """ Add/del IPv6 SR local-SID.
1148
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001149 :param localsid:
Kris Michielsen91074432017-06-22 13:00:20 +02001150 :param behavior: END=1; END.X=2; END.DX2=4; END.DX6=5;
1151 :param behavior: END.DX4=6; END.DT6=7; END.DT4=8
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001152 :param nh_addr4:
1153 :param nh_addr6:
Kris Michielsen91074432017-06-22 13:00:20 +02001154 :param is_del: (Default value = 0)
1155 :param end_psp: (Default value = 0)
1156 :param sw_if_index: (Default value = 0xFFFFFFFF)
1157 :param vlan_index: (Default value = 0)
1158 :param fib_table: (Default value = 0)
1159 """
1160 return self.api(
1161 self.papi.sr_localsid_add_del,
1162 {'is_del': is_del,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001163 'localsid': localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02001164 'end_psp': end_psp,
1165 'behavior': behavior,
1166 'sw_if_index': sw_if_index,
1167 'vlan_index': vlan_index,
1168 'fib_table': fib_table,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001169 'nh_addr4': nh_addr4,
1170 'nh_addr6': nh_addr6
Kris Michielsen91074432017-06-22 13:00:20 +02001171 }
1172 )
1173
1174 def sr_policy_add(
1175 self,
1176 bsid_addr,
1177 weight=1,
1178 is_encap=1,
1179 type=0,
1180 fib_table=0,
1181 n_segments=0,
1182 segments=[]):
1183 """
1184 :param bsid_addr: bindingSID of the SR Policy
1185 :param weight: weight of the sid list. optional. (default: 1)
1186 :param is_encap: (bool) whether SR policy should Encap or SRH insert \
1187 (default: Encap)
1188 :param type: type/behavior of the SR policy. (default or spray) \
1189 (default: default)
1190 :param fib_table: VRF where to install the FIB entry for the BSID \
1191 (default: 0)
1192 :param n_segments: number of segments \
1193 (default: 0)
1194 :param segments: a vector of IPv6 address composing the segment list \
1195 (default: [])
1196 """
1197 return self.api(
1198 self.papi.sr_policy_add,
1199 {'bsid_addr': bsid_addr,
1200 'weight': weight,
1201 'is_encap': is_encap,
1202 'type': type,
1203 'fib_table': fib_table,
1204 'n_segments': n_segments,
1205 'segments': segments
1206 }
1207 )
1208
1209 def sr_policy_del(
1210 self,
1211 bsid_addr,
1212 sr_policy_index=0):
1213 """
1214 :param bsid: bindingSID of the SR Policy
1215 :param sr_policy_index: index of the sr policy (default: 0)
1216 """
1217 return self.api(
1218 self.papi.sr_policy_del,
1219 {'bsid_addr': bsid_addr,
1220 'sr_policy_index': sr_policy_index
1221 })
1222
1223 def sr_steering_add_del(
1224 self,
1225 is_del,
1226 bsid_addr,
1227 sr_policy_index,
1228 table_id,
1229 prefix_addr,
1230 mask_width,
1231 sw_if_index,
1232 traffic_type):
1233 """
1234 Steer traffic L2 and L3 traffic through a given SR policy
1235
1236 :param is_del: delete or add
1237 :param bsid_addr: bindingSID of the SR Policy (alt to sr_policy_index)
1238 :param sr_policy: is the index of the SR Policy (alt to bsid)
1239 :param table_id: is the VRF where to install the FIB entry for the BSID
1240 :param prefix_addr: is the IPv4/v6 address for L3 traffic type
1241 :param mask_width: is the mask for L3 traffic type
1242 :param sw_if_index: is the incoming interface for L2 traffic
1243 :param traffic_type: type of traffic (IPv4: 4, IPv6: 6, L2: 2)
1244 """
1245 return self.api(
1246 self.papi.sr_steering_add_del,
1247 {'is_del': is_del,
1248 'bsid_addr': bsid_addr,
1249 'sr_policy_index': sr_policy_index,
1250 'table_id': table_id,
1251 'prefix_addr': prefix_addr,
1252 'mask_width': mask_width,
1253 'sw_if_index': sw_if_index,
1254 'traffic_type': traffic_type
1255 })
Pavel Kotucek932f7412017-09-07 14:44:52 +02001256
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001257 def acl_add_replace(self, acl_index, r, tag='',
1258 expected_retval=0):
1259 """Add/replace an ACL
1260 :param int acl_index: ACL index to replace, 2^32-1 to create new ACL.
1261 :param acl_rule r: ACL rules array.
1262 :param str tag: symbolic tag (description) for this ACL.
1263 :param int count: number of rules.
1264 """
1265 return self.api(self.papi.acl_add_replace,
1266 {'acl_index': acl_index,
1267 'r': r,
1268 'count': len(r),
1269 'tag': tag},
1270 expected_retval=expected_retval)
1271
Andrew Yourtchenko987abe92017-09-27 13:50:31 +02001272 def acl_del(self, acl_index, expected_retval=0):
1273 """
1274
1275 :param acl_index:
1276 :return:
1277 """
1278 return self.api(self.papi.acl_del,
1279 {'acl_index': acl_index},
1280 expected_retval=expected_retval)
1281
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001282 def acl_interface_set_acl_list(self, sw_if_index, n_input, acls,
1283 expected_retval=0):
1284 return self.api(self.papi.acl_interface_set_acl_list,
1285 {'sw_if_index': sw_if_index,
1286 'count': len(acls),
1287 'n_input': n_input,
1288 'acls': acls},
1289 expected_retval=expected_retval)
1290
Andrew Yourtchenkoc43b3f92018-02-06 17:42:32 +01001291 def acl_interface_set_etype_whitelist(self, sw_if_index,
1292 n_input, whitelist,
1293 expected_retval=0):
1294 return self.api(self.papi.acl_interface_set_etype_whitelist,
1295 {'sw_if_index': sw_if_index,
1296 'count': len(whitelist),
1297 'n_input': n_input,
1298 'whitelist': whitelist},
1299 expected_retval=expected_retval)
1300
Pavel Kotucek8daa80a2017-09-25 09:44:05 +02001301 def acl_interface_add_del(self,
1302 sw_if_index,
1303 acl_index,
1304 is_add=1):
1305 """ Add/Delete ACL to/from interface
1306
1307 :param sw_if_index:
1308 :param acl_index:
1309 :param is_add: (Default value = 1)
1310 """
1311
1312 return self.api(self.papi.acl_interface_add_del,
1313 {'is_add': is_add,
1314 'is_input': 1,
1315 'sw_if_index': sw_if_index,
1316 'acl_index': acl_index})
1317
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001318 def acl_dump(self, acl_index, expected_retval=0):
1319 return self.api(self.papi.acl_dump,
1320 {'acl_index': acl_index},
1321 expected_retval=expected_retval)
1322
Andrew Yourtchenko0e89dfc2018-03-23 09:34:29 +01001323 def acl_interface_list_dump(self, sw_if_index=0xFFFFFFFF,
1324 expected_retval=0):
1325 return self.api(self.papi.acl_interface_list_dump,
1326 {'sw_if_index': sw_if_index},
1327 expected_retval=expected_retval)
1328
Pavel Kotucekc29940c2017-09-07 08:17:31 +02001329 def macip_acl_add(self, rules, tag=""):
1330 """ Add MACIP acl
1331
1332 :param rules: list of rules for given acl
1333 :param tag: acl tag
1334 """
1335
1336 return self.api(self.papi.macip_acl_add,
1337 {'r': rules,
1338 'count': len(rules),
1339 'tag': tag})
1340
Pavel Kotucek932f7412017-09-07 14:44:52 +02001341 def macip_acl_add_replace(self, rules, acl_index=0xFFFFFFFF, tag=""):
1342 """ Add MACIP acl
1343
1344 :param rules: list of rules for given acl
1345 :param tag: acl tag
1346 """
1347
Pavel Kotucekc29940c2017-09-07 08:17:31 +02001348 return self.api(self.papi.macip_acl_add_replace,
1349 {'acl_index': acl_index,
1350 'r': rules,
Pavel Kotucek932f7412017-09-07 14:44:52 +02001351 'count': len(rules),
1352 'tag': tag})
1353
Pavel Kotucek932f7412017-09-07 14:44:52 +02001354 def macip_acl_interface_add_del(self,
1355 sw_if_index,
1356 acl_index,
1357 is_add=1):
1358 """ Add MACIP acl to interface
1359
1360 :param sw_if_index:
1361 :param acl_index:
1362 :param is_add: (Default value = 1)
1363 """
1364
1365 return self.api(self.papi.macip_acl_interface_add_del,
1366 {'is_add': is_add,
1367 'sw_if_index': sw_if_index,
1368 'acl_index': acl_index})
1369
Pavel Kotucek932f7412017-09-07 14:44:52 +02001370 def macip_acl_dump(self, acl_index=4294967295):
1371 """ Return MACIP acl dump
1372 """
1373
1374 return self.api(
1375 self.papi.macip_acl_dump, {'acl_index': acl_index})
Neale Rannsd91c1db2017-07-31 02:30:50 -07001376
1377 def policer_add_del(self,
1378 name,
1379 cir,
1380 eir,
1381 cb,
1382 eb,
1383 is_add=1,
1384 rate_type=0,
1385 round_type=0,
1386 ptype=0,
1387 color_aware=0,
1388 conform_action_type=1,
1389 conform_dscp=0,
1390 exceed_action_type=0,
1391 exceed_dscp=0,
1392 violate_action_type=0,
1393 violate_dscp=0):
1394 return self.api(self.papi.policer_add_del,
1395 {'name': name,
1396 'cir': cir,
1397 'eir': eir,
1398 'cb': cb,
1399 'eb': eb,
1400 'is_add': is_add,
1401 'rate_type': rate_type,
1402 'round_type': round_type,
1403 'type': ptype,
1404 'color_aware': color_aware,
1405 'conform_action_type': conform_action_type,
1406 'conform_dscp': conform_dscp,
1407 'exceed_action_type': exceed_action_type,
1408 'exceed_dscp': exceed_dscp,
1409 'violate_action_type': violate_action_type,
1410 'violate_dscp': violate_dscp})
1411
1412 def ip_punt_police(self,
1413 policer_index,
1414 is_ip6=0,
1415 is_add=1):
1416 return self.api(self.papi.ip_punt_police,
1417 {'policer_index': policer_index,
1418 'is_add': is_add,
1419 'is_ip6': is_ip6})
1420
1421 def ip_punt_redirect(self,
1422 rx_sw_if_index,
1423 tx_sw_if_index,
Pavel Kotucek609e1212018-11-27 09:59:44 +01001424 address,
Neale Rannsd91c1db2017-07-31 02:30:50 -07001425 is_add=1):
1426 return self.api(self.papi.ip_punt_redirect,
Pavel Kotucek609e1212018-11-27 09:59:44 +01001427 {'punt': {'rx_sw_if_index': rx_sw_if_index,
1428 'tx_sw_if_index': tx_sw_if_index,
1429 'nh': address},
1430 'is_add': is_add})
1431
1432 def ip_punt_redirect_dump(self, sw_if_index, is_ipv6=0):
1433 return self.api(self.papi.ip_punt_redirect_dump,
1434 {'sw_if_index': sw_if_index,
1435 'is_ipv6': is_ipv6})
Neale Rannsd792d9c2017-10-21 10:53:20 -07001436
1437 def bier_table_add_del(self,
1438 bti,
1439 mpls_label,
1440 is_add=1):
1441 """ BIER Table add/del """
1442 return self.api(
1443 self.papi.bier_table_add_del,
1444 {'bt_tbl_id': {"bt_set": bti.set_id,
1445 "bt_sub_domain": bti.sub_domain_id,
1446 "bt_hdr_len_id": bti.hdr_len_id},
1447 'bt_label': mpls_label,
1448 'bt_is_add': is_add})
1449
1450 def bier_table_dump(self):
1451 return self.api(self.papi.bier_table_dump, {})
1452
1453 def bier_route_add_del(self,
1454 bti,
1455 bp,
Neale Ranns91286372017-12-05 13:24:04 -08001456 paths,
Neale Rannsef90ed02018-09-13 08:45:12 -07001457 is_add=1,
1458 is_replace=0):
Neale Rannsd792d9c2017-10-21 10:53:20 -07001459 """ BIER Route add/del """
1460 return self.api(
1461 self.papi.bier_route_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -07001462 {
1463 'br_route': {
1464 'br_tbl_id': {"bt_set": bti.set_id,
1465 "bt_sub_domain": bti.sub_domain_id,
1466 "bt_hdr_len_id": bti.hdr_len_id},
1467 'br_bp': bp,
1468 'br_n_paths': len(paths),
1469 'br_paths': paths,
1470 },
1471 'br_is_add': is_add,
1472 'br_is_replace': is_replace
1473 })
Neale Rannsd792d9c2017-10-21 10:53:20 -07001474
1475 def bier_route_dump(self, bti):
1476 return self.api(
1477 self.papi.bier_route_dump,
1478 {'br_tbl_id': {"bt_set": bti.set_id,
1479 "bt_sub_domain": bti.sub_domain_id,
1480 "bt_hdr_len_id": bti.hdr_len_id}})
1481
1482 def bier_imp_add(self,
1483 bti,
1484 src,
1485 ibytes,
1486 is_add=1):
1487 """ BIER Imposition Add """
1488 return self.api(
1489 self.papi.bier_imp_add,
1490 {'bi_tbl_id': {"bt_set": bti.set_id,
1491 "bt_sub_domain": bti.sub_domain_id,
1492 "bt_hdr_len_id": bti.hdr_len_id},
1493 'bi_src': src,
1494 'bi_n_bytes': len(ibytes),
1495 'bi_bytes': ibytes})
1496
1497 def bier_imp_del(self, bi_index):
1498 """ BIER Imposition del """
1499 return self.api(
1500 self.papi.bier_imp_del,
1501 {'bi_index': bi_index})
1502
1503 def bier_imp_dump(self):
1504 return self.api(self.papi.bier_imp_dump, {})
1505
1506 def bier_disp_table_add_del(self,
1507 bdti,
1508 is_add=1):
1509 """ BIER Disposition Table add/del """
1510 return self.api(
1511 self.papi.bier_disp_table_add_del,
1512 {'bdt_tbl_id': bdti,
1513 'bdt_is_add': is_add})
1514
1515 def bier_disp_table_dump(self):
1516 return self.api(self.papi.bier_disp_table_dump, {})
1517
1518 def bier_disp_entry_add_del(self,
1519 bdti,
1520 bp,
1521 payload_proto,
Neale Rannsf0510722018-01-31 11:35:41 -08001522 next_hop_afi,
Neale Rannsd792d9c2017-10-21 10:53:20 -07001523 next_hop,
1524 next_hop_tbl_id=0,
1525 next_hop_rpf_id=~0,
1526 next_hop_is_ip4=1,
1527 is_add=1):
1528 """ BIER Route add/del """
Neale Ranns31ed7442018-02-23 05:29:09 -08001529 lstack = []
1530 while (len(lstack) < 16):
1531 lstack.append({})
Neale Rannsd792d9c2017-10-21 10:53:20 -07001532 return self.api(
1533 self.papi.bier_disp_entry_add_del,
1534 {'bde_tbl_id': bdti,
1535 'bde_bp': bp,
1536 'bde_payload_proto': payload_proto,
1537 'bde_n_paths': 1,
Paul Vinciguerra79a32a42019-07-11 19:09:30 -04001538 'bde_paths': [{'table_id': next_hop_tbl_id,
Neale Rannsd792d9c2017-10-21 10:53:20 -07001539 'rpf_id': next_hop_rpf_id,
1540 'n_labels': 0,
Neale Ranns31ed7442018-02-23 05:29:09 -08001541 'label_stack': lstack}],
Neale Rannsd792d9c2017-10-21 10:53:20 -07001542 'bde_is_add': is_add})
1543
1544 def bier_disp_entry_dump(self, bdti):
1545 return self.api(
1546 self.papi.bier_disp_entry_dump,
1547 {'bde_tbl_id': bdti})
Gabriel Ganne8527f122017-10-02 11:41:24 +02001548
Florin Coras3ea6ce22017-12-11 09:09:05 -08001549 def session_enable_disable(self, is_enabled):
1550 return self.api(
1551 self.papi.session_enable_disable,
1552 {'is_enable': is_enabled})
“mystarrocks”23f0c452017-12-11 07:11:51 -08001553
1554 def ipsec_spd_add_del(self, spd_id, is_add=1):
1555 """ SPD add/del - Wrapper to add or del ipsec SPD
1556 Sample CLI : 'ipsec spd add 1'
1557
1558 :param spd_id - SPD ID to be created in the vpp . mandatory
1559 :param is_add - create (1) or delete(0) SPD (Default 1 - add) .
1560 optional
1561 :returns: reply from the API
1562 """
1563 return self.api(
1564 self.papi.ipsec_spd_add_del, {
1565 'spd_id': spd_id, 'is_add': is_add})
1566
Neale Ranns311124e2019-01-24 04:52:25 -08001567 def ipsec_spds_dump(self):
1568 return self.api(self.papi.ipsec_spds_dump, {})
1569
“mystarrocks”23f0c452017-12-11 07:11:51 -08001570 def ipsec_interface_add_del_spd(self, spd_id, sw_if_index, is_add=1):
1571 """ IPSEC interface SPD add/del - \
1572 Wrapper to associate/disassociate SPD to interface in VPP
1573 Sample CLI : 'set interface ipsec spd GigabitEthernet0/6/0 1'
1574
1575 :param spd_id - SPD ID to associate with the interface . mandatory
1576 :param sw_if_index - Interface Index which needs to ipsec \
1577 association mandatory
1578 :param is_add - add(1) or del(0) association with interface \
1579 (Default 1 - add) . optional
1580 :returns: reply from the API
1581 """
1582 return self.api(
Klement Sekera4b089f22018-04-17 18:04:57 +02001583 self.papi.ipsec_interface_add_del_spd,
1584 {'spd_id': spd_id, 'sw_if_index': sw_if_index, 'is_add': is_add})
“mystarrocks”23f0c452017-12-11 07:11:51 -08001585
Neale Ranns311124e2019-01-24 04:52:25 -08001586 def ipsec_spd_interface_dump(self, spd_index=None):
1587 return self.api(self.papi.ipsec_spd_interface_dump,
1588 {'spd_index': spd_index if spd_index else 0,
1589 'spd_index_valid': 1 if spd_index else 0})
1590
Neale Ranns17dcec02019-01-09 21:22:20 -08001591 def ipsec_sad_entry_add_del(self,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001592 sad_id,
1593 spi,
Klement Sekera31da2e32018-06-24 22:49:55 +02001594 integrity_algorithm,
1595 integrity_key,
1596 crypto_algorithm,
1597 crypto_key,
1598 protocol,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001599 tunnel_src_address='',
1600 tunnel_dst_address='',
Neale Ranns17dcec02019-01-09 21:22:20 -08001601 flags=0,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001602 salt=0,
Neale Ranns17dcec02019-01-09 21:22:20 -08001603 is_add=1):
“mystarrocks”23f0c452017-12-11 07:11:51 -08001604 """ IPSEC SA add/del
Klement Sekera31da2e32018-06-24 22:49:55 +02001605 :param sad_id: security association ID
1606 :param spi: security param index of the SA in decimal
1607 :param integrity_algorithm:
1608 :param integrity_key:
1609 :param crypto_algorithm:
1610 :param crypto_key:
1611 :param protocol: AH(0) or ESP(1) protocol
1612 :param tunnel_src_address: tunnel mode outer src address
1613 :param tunnel_dst_address: tunnel mode outer dst address
1614 :param is_add:
1615 :param is_tunnel:
“mystarrocks”23f0c452017-12-11 07:11:51 -08001616 :** reference /vpp/src/vnet/ipsec/ipsec.h file for enum values of
1617 crypto and ipsec algorithms
1618 """
1619 return self.api(
Neale Ranns17dcec02019-01-09 21:22:20 -08001620 self.papi.ipsec_sad_entry_add_del,
1621 {
1622 'is_add': is_add,
1623 'entry':
Ole Troan9a475372019-03-05 16:58:24 +01001624 {
1625 'sad_id': sad_id,
1626 'spi': spi,
1627 'tunnel_src': tunnel_src_address,
1628 'tunnel_dst': tunnel_dst_address,
1629 'protocol': protocol,
1630 'integrity_algorithm': integrity_algorithm,
1631 'integrity_key': {
1632 'length': len(integrity_key),
1633 'data': integrity_key,
1634 },
1635 'crypto_algorithm': crypto_algorithm,
1636 'crypto_key': {
1637 'length': len(crypto_key),
1638 'data': crypto_key,
1639 },
1640 'flags': flags,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001641 'salt': salt,
Ole Troan9a475372019-03-05 16:58:24 +01001642 }
Neale Ranns17dcec02019-01-09 21:22:20 -08001643 })
“mystarrocks”23f0c452017-12-11 07:11:51 -08001644
Neale Ranns311124e2019-01-24 04:52:25 -08001645 def ipsec_sa_dump(self, sa_id=None):
1646 return self.api(self.papi.ipsec_sa_dump,
1647 {'sa_id': sa_id if sa_id else 0xffffffff})
1648
Neale Ranns17dcec02019-01-09 21:22:20 -08001649 def ipsec_spd_entry_add_del(self,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001650 spd_id,
Klement Sekera31da2e32018-06-24 22:49:55 +02001651 sa_id,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001652 local_address_start,
1653 local_address_stop,
1654 remote_address_start,
1655 remote_address_stop,
1656 local_port_start=0,
1657 local_port_stop=65535,
1658 remote_port_start=0,
1659 remote_port_stop=65535,
1660 protocol=0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001661 policy=0,
1662 priority=100,
1663 is_outbound=1,
1664 is_add=1,
Klement Sekera611864f2018-09-26 11:19:00 +02001665 is_ipv6=0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001666 is_ip_any=0):
1667 """ IPSEC policy SPD add/del -
1668 Wrapper to configure ipsec SPD policy entries in VPP
Klement Sekera31da2e32018-06-24 22:49:55 +02001669 :param spd_id: SPD ID for the policy
1670 :param local_address_start: local-ip-range start address
1671 :param local_address_stop : local-ip-range stop address
1672 :param remote_address_start: remote-ip-range start address
1673 :param remote_address_stop : remote-ip-range stop address
1674 :param local_port_start: (Default value = 0)
1675 :param local_port_stop: (Default value = 65535)
1676 :param remote_port_start: (Default value = 0)
1677 :param remote_port_stop: (Default value = 65535)
1678 :param protocol: Any(0), AH(51) & ESP(50) protocol (Default value = 0)
1679 :param sa_id: Security Association ID for mapping it to SPD
1680 :param policy: bypass(0), discard(1), resolve(2) or protect(3) action
1681 (Default value = 0)
1682 :param priority: value for the spd action (Default value = 100)
1683 :param is_outbound: flag for inbound(0) or outbound(1)
1684 (Default value = 1)
1685 :param is_add: (Default value = 1)
“mystarrocks”23f0c452017-12-11 07:11:51 -08001686 """
1687 return self.api(
Neale Ranns17dcec02019-01-09 21:22:20 -08001688 self.papi.ipsec_spd_entry_add_del,
1689 {
1690 'is_add': is_add,
1691 'entry':
Ole Troan9a475372019-03-05 16:58:24 +01001692 {
1693 'spd_id': spd_id,
1694 'sa_id': sa_id,
1695 'local_address_start': local_address_start,
1696 'local_address_stop': local_address_stop,
1697 'remote_address_start': remote_address_start,
1698 'remote_address_stop': remote_address_stop,
1699 'local_port_start': local_port_start,
1700 'local_port_stop': local_port_stop,
1701 'remote_port_start': remote_port_start,
1702 'remote_port_stop': remote_port_stop,
1703 'protocol': protocol,
1704 'policy': policy,
1705 'priority': priority,
1706 'is_outbound': is_outbound,
Ole Troan9a475372019-03-05 16:58:24 +01001707 }
Neale Ranns17dcec02019-01-09 21:22:20 -08001708 })
Florin Corasb795bd02017-12-14 11:30:48 -08001709
Neale Ranns311124e2019-01-24 04:52:25 -08001710 def ipsec_spd_dump(self, spd_id, sa_id=0xffffffff):
1711 return self.api(self.papi.ipsec_spd_dump,
1712 {'spd_id': spd_id,
1713 'sa_id': sa_id})
1714
Klement Sekera31da2e32018-06-24 22:49:55 +02001715 def ipsec_tunnel_if_add_del(self, local_ip, remote_ip, local_spi,
1716 remote_spi, crypto_alg, local_crypto_key,
1717 remote_crypto_key, integ_alg, local_integ_key,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001718 remote_integ_key, is_add=1, esn=0, salt=0,
Neale Rannsa6bee0a2019-06-14 01:13:25 -07001719 anti_replay=1, renumber=0,
1720 udp_encap=0, show_instance=0):
Klement Sekera31da2e32018-06-24 22:49:55 +02001721 return self.api(
1722 self.papi.ipsec_tunnel_if_add_del,
Kingwel Xie1ba5bc82019-03-20 07:21:58 -04001723 {
1724 'local_ip': local_ip,
1725 'remote_ip': remote_ip,
1726 'local_spi': local_spi,
1727 'remote_spi': remote_spi,
1728 'crypto_alg': crypto_alg,
1729 'local_crypto_key_len': len(local_crypto_key),
1730 'local_crypto_key': local_crypto_key,
1731 'remote_crypto_key_len': len(remote_crypto_key),
1732 'remote_crypto_key': remote_crypto_key,
1733 'integ_alg': integ_alg,
1734 'local_integ_key_len': len(local_integ_key),
1735 'local_integ_key': local_integ_key,
1736 'remote_integ_key_len': len(remote_integ_key),
1737 'remote_integ_key': remote_integ_key,
1738 'is_add': is_add,
1739 'esn': esn,
1740 'anti_replay': anti_replay,
1741 'renumber': renumber,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001742 'show_instance': show_instance,
Neale Rannsa6bee0a2019-06-14 01:13:25 -07001743 'udp_encap': udp_encap,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001744 'salt': salt
Kingwel Xie1ba5bc82019-03-20 07:21:58 -04001745 })
Klement Sekera31da2e32018-06-24 22:49:55 +02001746
Klement Sekerab4d30532018-11-08 13:00:02 +01001747 def ipsec_select_backend(self, protocol, index):
1748 return self.api(self.papi.ipsec_select_backend,
1749 {'protocol': protocol, 'index': index})
1750
1751 def ipsec_backend_dump(self):
1752 return self.api(self.papi.ipsec_backend_dump, {})
1753
Ole Troane1ade682019-03-04 23:55:43 +01001754 def app_namespace_add_del(self,
1755 namespace_id,
1756 ip4_fib_id=0,
1757 ip6_fib_id=0,
1758 sw_if_index=0xFFFFFFFF,
1759 secret=0):
Florin Corasb795bd02017-12-14 11:30:48 -08001760 return self.api(
1761 self.papi.app_namespace_add_del,
1762 {'secret': secret,
1763 'sw_if_index': sw_if_index,
1764 'ip4_fib_id': ip4_fib_id,
1765 'ip6_fib_id': ip6_fib_id,
1766 'namespace_id': namespace_id,
1767 'namespace_id_len': len(namespace_id)})
Klement Sekera75e7d132017-09-20 08:26:30 +02001768
Neale Ranns50f0ac02019-05-15 02:13:37 -07001769 def punt_socket_register(self, reg, pathname,
1770 header_version=1):
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001771 """ Register punt socket """
Klement Sekera75e7d132017-09-20 08:26:30 +02001772 return self.api(self.papi.punt_socket_register,
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001773 {'header_version': header_version,
Neale Ranns50f0ac02019-05-15 02:13:37 -07001774 'punt': reg,
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001775 'pathname': pathname})
1776
Neale Ranns50f0ac02019-05-15 02:13:37 -07001777 def punt_socket_deregister(self, reg):
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001778 """ Unregister punt socket """
1779 return self.api(self.papi.punt_socket_deregister,
Neale Ranns50f0ac02019-05-15 02:13:37 -07001780 {'punt': reg})
Klement Sekera75e7d132017-09-20 08:26:30 +02001781
Neale Ranns4ba67722019-02-28 11:11:39 +00001782 def gbp_endpoint_add(self, sw_if_index, ips, mac, sclass, flags,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001783 tun_src, tun_dst):
Neale Rannsc0a93142018-09-05 15:42:26 -07001784 """ GBP endpoint Add """
1785 return self.api(self.papi.gbp_endpoint_add,
1786 {'endpoint': {
1787 'sw_if_index': sw_if_index,
1788 'ips': ips,
1789 'n_ips': len(ips),
1790 'mac': mac,
Neale Ranns4ba67722019-02-28 11:11:39 +00001791 'sclass': sclass,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001792 'flags': flags,
1793 'tun': {
1794 'src': tun_src,
1795 'dst': tun_dst,
1796 }}})
Neale Rannsc0a93142018-09-05 15:42:26 -07001797
1798 def gbp_endpoint_del(self, handle):
1799 """ GBP endpoint Del """
1800 return self.api(self.papi.gbp_endpoint_del,
1801 {'handle': handle})
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001802
1803 def gbp_endpoint_dump(self):
1804 """ GBP endpoint Dump """
Ole Troan0bcad322018-12-11 13:04:01 +01001805 return self.api(self.papi.gbp_endpoint_dump,
1806 {'_no_type_conversion': True})
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001807
Neale Ranns4ba67722019-02-28 11:11:39 +00001808 def gbp_endpoint_group_add(self, vnid, sclass, bd,
Neale Ranns32f6d8e2019-03-05 04:22:08 -08001809 rd, uplink_sw_if_index,
1810 retention):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001811 """ GBP endpoint group Add """
1812 return self.api(self.papi.gbp_endpoint_group_add,
1813 {'epg':
Ole Troan9a475372019-03-05 16:58:24 +01001814 {
1815 'uplink_sw_if_index': uplink_sw_if_index,
1816 'bd_id': bd,
1817 'rd_id': rd,
1818 'vnid': vnid,
1819 'sclass': sclass,
1820 'retention': retention
1821 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001822
Neale Ranns4ba67722019-02-28 11:11:39 +00001823 def gbp_endpoint_group_del(self, sclass):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001824 """ GBP endpoint group Del """
1825 return self.api(self.papi.gbp_endpoint_group_del,
Neale Ranns4ba67722019-02-28 11:11:39 +00001826 {'sclass': sclass})
Neale Ranns25b04942018-04-04 09:34:50 -07001827
Neale Ranns160c9232019-06-19 06:25:56 -07001828 def gbp_bridge_domain_add(self, bd_id, rd_id, flags,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001829 bvi_sw_if_index,
Neale Ranns879d11c2019-01-21 23:34:18 -08001830 uu_fwd_sw_if_index,
1831 bm_flood_sw_if_index):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001832 """ GBP bridge-domain Add """
1833 return self.api(self.papi.gbp_bridge_domain_add,
1834 {'bd':
Ole Troan9a475372019-03-05 16:58:24 +01001835 {
1836 'flags': flags,
1837 'bvi_sw_if_index': bvi_sw_if_index,
1838 'uu_fwd_sw_if_index': uu_fwd_sw_if_index,
1839 'bm_flood_sw_if_index': bm_flood_sw_if_index,
Neale Ranns160c9232019-06-19 06:25:56 -07001840 'bd_id': bd_id,
1841 'rd_id': rd_id
Ole Troan9a475372019-03-05 16:58:24 +01001842 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001843
1844 def gbp_bridge_domain_del(self, bd_id):
1845 """ GBP bridge-domain Del """
1846 return self.api(self.papi.gbp_bridge_domain_del,
1847 {'bd_id': bd_id})
1848
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001849 def gbp_route_domain_add(self, rd_id,
Neale Ranns160c9232019-06-19 06:25:56 -07001850 scope,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001851 ip4_table_id,
1852 ip6_table_id,
1853 ip4_uu_sw_if_index,
1854 ip6_uu_sw_if_index):
1855 """ GBP route-domain Add """
1856 return self.api(self.papi.gbp_route_domain_add,
1857 {'rd':
Ole Troan9a475372019-03-05 16:58:24 +01001858 {
Neale Ranns160c9232019-06-19 06:25:56 -07001859 'scope': scope,
Ole Troan9a475372019-03-05 16:58:24 +01001860 'ip4_table_id': ip4_table_id,
1861 'ip6_table_id': ip6_table_id,
1862 'ip4_uu_sw_if_index': ip4_uu_sw_if_index,
1863 'ip6_uu_sw_if_index': ip6_uu_sw_if_index,
1864 'rd_id': rd_id
1865 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001866
1867 def gbp_route_domain_del(self, rd_id):
1868 """ GBP route-domain Del """
1869 return self.api(self.papi.gbp_route_domain_del,
1870 {'rd_id': rd_id})
1871
Neale Ranns4ba67722019-02-28 11:11:39 +00001872 def gbp_recirc_add_del(self, is_add, sw_if_index, sclass, is_ext):
Neale Ranns25b04942018-04-04 09:34:50 -07001873 """ GBP recirc Add/Del """
1874 return self.api(self.papi.gbp_recirc_add_del,
1875 {'is_add': is_add,
1876 'recirc': {
1877 'is_ext': is_ext,
1878 'sw_if_index': sw_if_index,
Neale Ranns4ba67722019-02-28 11:11:39 +00001879 'sclass': sclass}})
Neale Ranns25b04942018-04-04 09:34:50 -07001880
1881 def gbp_recirc_dump(self):
1882 """ GBP recirc Dump """
1883 return self.api(self.papi.gbp_recirc_dump, {})
1884
Benoît Ganneba6abfa2019-07-01 17:10:41 +02001885 def gbp_ext_itf_add_del(self, is_add, sw_if_index, bd_id, rd_id, flags):
Neale Rannsb6a47952018-11-21 05:44:35 -08001886 """ GBP recirc Add/Del """
1887 return self.api(self.papi.gbp_ext_itf_add_del,
1888 {'is_add': is_add,
1889 'ext_itf': {
1890 'sw_if_index': sw_if_index,
1891 'bd_id': bd_id,
Benoît Ganneba6abfa2019-07-01 17:10:41 +02001892 'rd_id': rd_id,
1893 'flags': flags}})
Neale Rannsb6a47952018-11-21 05:44:35 -08001894
1895 def gbp_ext_itf_dump(self):
1896 """ GBP recirc Dump """
1897 return self.api(self.papi.gbp_ext_itf_dump, {})
1898
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001899 def gbp_subnet_add_del(self, is_add, rd_id,
1900 prefix, type,
Neale Ranns25b04942018-04-04 09:34:50 -07001901 sw_if_index=0xffffffff,
Neale Ranns4ba67722019-02-28 11:11:39 +00001902 sclass=0xffff):
Neale Ranns25b04942018-04-04 09:34:50 -07001903 """ GBP Subnet Add/Del """
1904 return self.api(self.papi.gbp_subnet_add_del,
1905 {'is_add': is_add,
1906 'subnet': {
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001907 'type': type,
Neale Ranns25b04942018-04-04 09:34:50 -07001908 'sw_if_index': sw_if_index,
Neale Ranns4ba67722019-02-28 11:11:39 +00001909 'sclass': sclass,
Neale Rannsc0a93142018-09-05 15:42:26 -07001910 'prefix': prefix,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001911 'rd_id': rd_id}})
Neale Ranns25b04942018-04-04 09:34:50 -07001912
1913 def gbp_subnet_dump(self):
1914 """ GBP Subnet Dump """
Ole Troan0bcad322018-12-11 13:04:01 +01001915 return self.api(self.papi.gbp_subnet_dump,
1916 {'_no_type_conversion': True})
Neale Ranns25b04942018-04-04 09:34:50 -07001917
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001918 def gbp_contract_dump(self):
1919 """ GBP contract Dump """
1920 return self.api(self.papi.gbp_contract_dump, {})
Ole Troan6ee40512018-02-12 18:14:39 +01001921
Neale Ranns8da9fc62019-03-04 14:08:11 -08001922 def gbp_vxlan_tunnel_add(self, vni, bd_rd_id, mode, src):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001923 """ GBP VXLAN tunnel add """
1924 return self.api(self.papi.gbp_vxlan_tunnel_add,
1925 {
1926 'tunnel': {
1927 'vni': vni,
1928 'mode': mode,
Neale Ranns8da9fc62019-03-04 14:08:11 -08001929 'bd_rd_id': bd_rd_id,
1930 'src': src
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001931 }
1932 })
1933
1934 def gbp_vxlan_tunnel_del(self, vni):
1935 """ GBP VXLAN tunnel del """
1936 return self.api(self.papi.gbp_vxlan_tunnel_del,
1937 {
1938 'vni': vni,
1939 })
1940
1941 def gbp_vxlan_tunnel_dump(self):
1942 """ GBP VXLAN tunnel add/del """
1943 return self.api(self.papi.gbp_vxlan_tunnel_dump, {})
1944
Neale Ranns947ea622018-06-07 23:48:20 -07001945 def igmp_enable_disable(self, sw_if_index, enable, host):
1946 """ Enable/disable IGMP on a given interface """
1947 return self.api(self.papi.igmp_enable_disable,
1948 {'enable': enable,
1949 'mode': host,
1950 'sw_if_index': sw_if_index})
1951
Jakub Grajciar97748ca2018-10-04 11:05:35 +02001952 def igmp_proxy_device_add_del(self, vrf_id, sw_if_index, add):
1953 """ Add/del IGMP proxy device """
1954 return self.api(self.papi.igmp_proxy_device_add_del,
1955 {'vrf_id': vrf_id, 'sw_if_index': sw_if_index,
1956 'add': add})
1957
1958 def igmp_proxy_device_add_del_interface(self, vrf_id, sw_if_index, add):
1959 """ Add/del interface to/from IGMP proxy device """
1960 return self.api(self.papi.igmp_proxy_device_add_del_interface,
1961 {'vrf_id': vrf_id, 'sw_if_index': sw_if_index,
1962 'add': add})
1963
Neale Ranns947ea622018-06-07 23:48:20 -07001964 def igmp_listen(self, filter, sw_if_index, saddrs, gaddr):
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001965 """ Listen for new (S,G) on specified interface
1966
1967 :param enable: add/del
1968 :param sw_if_index: interface sw index
1969 :param saddr: source ip4 addr
1970 :param gaddr: group ip4 addr
1971 """
1972 return self.api(self.papi.igmp_listen,
Neale Ranns947ea622018-06-07 23:48:20 -07001973 {
1974 'group':
Ole Troan9a475372019-03-05 16:58:24 +01001975 {
1976 'filter': filter,
1977 'sw_if_index': sw_if_index,
1978 'n_srcs': len(saddrs),
1979 'saddrs': saddrs,
1980 'gaddr': gaddr
1981 }
Neale Ranns947ea622018-06-07 23:48:20 -07001982 })
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001983
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001984 def igmp_clear_interface(self, sw_if_index):
1985 """ Remove all (S,G)s from specified interface
1986 doesn't send IGMP report!
1987 """
1988 return self.api(
1989 self.papi.igmp_clear_interface, {
1990 'sw_if_index': sw_if_index})
1991
1992 def want_igmp_events(self, enable=1):
1993 return self.api(self.papi.want_igmp_events, {'enable': enable,
1994 'pid': os.getpid()})
Steven9cd2d7a2017-12-20 12:43:01 -08001995
1996 def bond_create(
1997 self,
1998 mode,
1999 lb,
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002000 numa_only,
Steven9cd2d7a2017-12-20 12:43:01 -08002001 use_custom_mac,
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002002 mac_address='',
2003 interface_id=0xFFFFFFFF):
Steven9cd2d7a2017-12-20 12:43:01 -08002004 """
2005 :param mode: mode
2006 :param lb: load balance
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002007 :param numa_only: tx on local numa node for lacp mode
Steven9cd2d7a2017-12-20 12:43:01 -08002008 :param use_custom_mac: use custom mac
2009 :param mac_address: mac address
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002010 :param interface_id: custom interface ID
Steven9cd2d7a2017-12-20 12:43:01 -08002011 """
2012 return self.api(
2013 self.papi.bond_create,
2014 {'mode': mode,
2015 'lb': lb,
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002016 'numa_only': numa_only,
Steven9cd2d7a2017-12-20 12:43:01 -08002017 'use_custom_mac': use_custom_mac,
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002018 'mac_address': mac_address,
2019 'id': interface_id
Steven9cd2d7a2017-12-20 12:43:01 -08002020 })
2021
Neale Ranns17ff3c12018-07-04 10:24:24 -07002022 def pipe_delete(self, parent_sw_if_index):
2023 return self.api(self.papi.pipe_delete,
2024 {'parent_sw_if_index': parent_sw_if_index})
2025
Neale Rannsd1e68ab2018-10-01 01:42:13 -07002026 def svs_table_add_del(self, af, table_id, is_add=1):
2027 return self.api(self.papi.svs_table_add_del,
2028 {
2029 'table_id': table_id,
2030 'is_add': is_add,
2031 'af': af,
2032 })
2033
2034 def svs_route_add_del(self, table_id, prefix, src_table_id, is_add=1):
2035 return self.api(self.papi.svs_route_add_del,
2036 {
2037 'table_id': table_id,
2038 'source_table_id': src_table_id,
2039 'prefix': prefix,
2040 'is_add': is_add,
2041 })
2042
2043 def svs_enable_disable(self, af, table_id, sw_if_index, is_enable=1):
2044 return self.api(self.papi.svs_enable_disable,
2045 {
2046 'af': af,
2047 'table_id': table_id,
2048 'sw_if_index': sw_if_index,
2049 'is_enable': is_enable,
2050 })
Mohsin Kazmi29467b52019-10-08 19:42:38 +02002051
2052 def feature_gso_enable_disable(self, sw_if_index, enable_disable=1):
2053 return self.api(self.papi.feature_gso_enable_disable,
2054 {
2055 'sw_if_index': sw_if_index,
2056 'enable_disable': enable_disable,
2057 })