blob: 4541f01a1bd4fb80e5a658770cef47f10ef7dc4b [file] [log] [blame]
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001import os
2import fnmatch
3import time
Klement Sekeraf62ae122016-10-11 11:47:09 +02004from hook import Hook
Klement Sekerae4504c62016-12-08 10:16:41 +01005from collections import deque
Klement Sekeraf62ae122016-10-11 11:47:09 +02006
Klement Sekera0e3c0de2016-09-29 14:43:44 +02007# Sphinx creates auto-generated documentation by importing the python source
Klement Sekerada505f62017-01-04 12:58:53 +01008# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows
9# the vpp_papi_provider.py file to be importable without having to build
10# the whole vpp api if the user only wishes to generate the test documentation.
Klement Sekera277b89c2016-10-28 13:20:27 +020011do_import = True
12try:
13 no_vpp_papi = os.getenv("NO_VPP_PAPI")
14 if no_vpp_papi == "1":
15 do_import = False
16except:
17 pass
18
19if do_import:
Ole Troan7e3a8752016-12-05 10:27:09 +010020 from vpp_papi import VPP
Klement Sekera277b89c2016-10-28 13:20:27 +020021
Klement Sekeraf62ae122016-10-11 11:47:09 +020022# from vnet/vnet/mpls/mpls_types.h
23MPLS_IETF_MAX_LABEL = 0xfffff
24MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
25
Klement Sekera0e3c0de2016-09-29 14:43:44 +020026
Neale Ranns177bbdc2016-11-15 09:46:51 +000027class L2_VTR_OP:
28 L2_POP_1 = 3
29
Klement Sekera0e3c0de2016-09-29 14:43:44 +020030
Klement Sekera73884482017-02-23 09:26:30 +010031class UnexpectedApiReturnValueError(Exception):
32 """ exception raised when the API return value is unexpected """
33 pass
34
35
Klement Sekeraf62ae122016-10-11 11:47:09 +020036class VppPapiProvider(object):
37 """VPP-api provider using vpp-papi
38
39 @property hook: hook object providing before and after api/cli hooks
Klement Sekeraf62ae122016-10-11 11:47:09 +020040 """
41
Klement Sekerae0545ef2017-01-25 08:00:40 +010042 _zero, _negative = range(2)
43
Klement Sekera7bb873a2016-11-18 07:38:42 +010044 def __init__(self, name, shm_prefix, test_class):
Klement Sekera277b89c2016-10-28 13:20:27 +020045 self.hook = Hook("vpp-papi-provider")
Klement Sekeraf62ae122016-10-11 11:47:09 +020046 self.name = name
47 self.shm_prefix = shm_prefix
Klement Sekera7bb873a2016-11-18 07:38:42 +010048 self.test_class = test_class
Klement Sekerae0545ef2017-01-25 08:00:40 +010049 self._expect_api_retval = self._zero
50 self._expect_stack = []
Ole Troan7e3a8752016-12-05 10:27:09 +010051 jsonfiles = []
52
Klement Sekera0e3c0de2016-09-29 14:43:44 +020053 install_dir = os.getenv('VPP_TEST_INSTALL_PATH')
Ole Troan7e3a8752016-12-05 10:27:09 +010054 for root, dirnames, filenames in os.walk(install_dir):
55 for filename in fnmatch.filter(filenames, '*.api.json'):
56 jsonfiles.append(os.path.join(root, filename))
57
Ole Troan3cc49712017-03-08 12:02:24 +010058 self.vpp = VPP(jsonfiles, logger=test_class.logger)
Klement Sekerae4504c62016-12-08 10:16:41 +010059 self._events = deque()
Klement Sekeraf62ae122016-10-11 11:47:09 +020060
Klement Sekerae0545ef2017-01-25 08:00:40 +010061 def __enter__(self):
62 return self
63
64 def expect_negative_api_retval(self):
65 """ Expect API failure """
66 self._expect_stack.append(self._expect_api_retval)
67 self._expect_api_retval = self._negative
68 return self
69
70 def expect_zero_api_retval(self):
71 """ Expect API success """
72 self._expect_stack.append(self._expect_api_retval)
73 self._expect_api_retval = self._zero
74 return self
75
76 def __exit__(self, exc_type, exc_value, traceback):
77 self._expect_api_retval = self._expect_stack.pop()
78
Klement Sekeraf62ae122016-10-11 11:47:09 +020079 def register_hook(self, hook):
80 """Replace hook registration with new hook
81
82 :param hook:
83
84 """
85 self.hook = hook
86
Klement Sekera0e3c0de2016-09-29 14:43:44 +020087 def collect_events(self):
Klement Sekerae4504c62016-12-08 10:16:41 +010088 """ Collect all events from the internal queue and clear the queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +020089 e = self._events
Klement Sekerae4504c62016-12-08 10:16:41 +010090 self._events = deque()
Klement Sekera0e3c0de2016-09-29 14:43:44 +020091 return e
92
93 def wait_for_event(self, timeout, name=None):
Klement Sekerae4504c62016-12-08 10:16:41 +010094 """ Wait for and return next event. """
Klement Sekeraacb9b8e2017-02-14 02:55:31 +010095 if name:
96 self.test_class.logger.debug("Expecting event within %ss",
97 timeout)
98 else:
99 self.test_class.logger.debug("Expecting event '%s' within %ss",
100 name, timeout)
Klement Sekerae4504c62016-12-08 10:16:41 +0100101 if self._events:
102 self.test_class.logger.debug("Not waiting, event already queued")
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200103 limit = time.time() + timeout
104 while time.time() < limit:
105 if self._events:
Klement Sekerae4504c62016-12-08 10:16:41 +0100106 e = self._events.popleft()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200107 if name and type(e).__name__ != name:
108 raise Exception(
109 "Unexpected event received: %s, expected: %s" %
110 (type(e).__name__, name))
Klement Sekerae4504c62016-12-08 10:16:41 +0100111 self.test_class.logger.debug("Returning event %s:%s" %
112 (name, e))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200113 return e
114 time.sleep(0) # yield
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200115 raise Exception("Event did not occur within timeout")
116
117 def __call__(self, name, event):
Klement Sekerae4504c62016-12-08 10:16:41 +0100118 """ Enqueue event in the internal event queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200119 # FIXME use the name instead of relying on type(e).__name__ ?
120 # FIXME #2 if this throws, it is eaten silently, Ole?
Klement Sekerae4504c62016-12-08 10:16:41 +0100121 self.test_class.logger.debug("New event: %s: %s" % (name, event))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200122 self._events.append(event)
123
Klement Sekeraf62ae122016-10-11 11:47:09 +0200124 def connect(self):
125 """Connect the API to VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100126 self.vpp.connect(self.name, self.shm_prefix)
127 self.papi = self.vpp.api
128 self.vpp.register_event_callback(self)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200129
130 def disconnect(self):
131 """Disconnect the API from VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100132 self.vpp.disconnect()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200133
134 def api(self, api_fn, api_args, expected_retval=0):
Klement Sekerae4504c62016-12-08 10:16:41 +0100135 """ Call API function and check it's return value.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200136 Call the appropriate hooks before and after the API call
137
138 :param api_fn: API function to call
139 :param api_args: tuple of API function arguments
140 :param expected_retval: Expected return value (Default value = 0)
141 :returns: reply from the API
142
143 """
144 self.hook.before_api(api_fn.__name__, api_args)
Ole Troan7e3a8752016-12-05 10:27:09 +0100145 reply = api_fn(**api_args)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100146 if self._expect_api_retval == self._negative:
147 if hasattr(reply, 'retval') and reply.retval >= 0:
148 msg = "API call passed unexpectedly: expected negative "\
149 "return value instead of %d in %s" % \
150 (reply.retval, repr(reply))
151 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100152 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100153 elif self._expect_api_retval == self._zero:
154 if hasattr(reply, 'retval') and reply.retval != expected_retval:
Neale Ranns88fc83e2017-04-05 08:11:14 -0700155 msg = "API call failed, expected %d return value instead "\
156 "of %d in %s" % (expected_retval, reply.retval,
157 repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100158 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100159 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100160 else:
161 raise Exception("Internal error, unexpected value for "
162 "self._expect_api_retval %s" %
163 self._expect_api_retval)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200164 self.hook.after_api(api_fn.__name__, api_args)
165 return reply
166
167 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100168 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200169
170 :param cli: CLI to execute
171 :returns: CLI output
172
173 """
174 self.hook.before_cli(cli)
175 cli += '\n'
Ole Troan7e3a8752016-12-05 10:27:09 +0100176 r = self.papi.cli_inband(length=len(cli), cmd=cli)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200177 self.hook.after_cli(cli)
Jan49c0fca2016-10-26 15:44:27 +0200178 if hasattr(r, 'reply'):
Ole Troan7e3a8752016-12-05 10:27:09 +0100179 return r.reply.decode().rstrip('\x00')
Klement Sekeraf62ae122016-10-11 11:47:09 +0200180
Jan49c0fca2016-10-26 15:44:27 +0200181 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100182 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200183
184 :param cli: CLI to execute
185 :returns: CLI output
186 """
Ed Warnickeb8ff5d62016-11-28 13:59:22 -0600187 return cli + "\n" + str(self.cli(cli))
Jan49c0fca2016-10-26 15:44:27 +0200188
Jan4af521d2016-11-15 17:05:00 +0100189 def _convert_mac(self, mac):
190 return int(mac.replace(":", ""), 16) << 16
191
Klement Sekeraf62ae122016-10-11 11:47:09 +0200192 def show_version(self):
193 """ """
Klement Sekera7112c542017-03-01 09:53:19 +0100194 return self.api(self.papi.show_version, {})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200195
196 def pg_create_interface(self, pg_index):
197 """
198
199 :param pg_index:
200
201 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100202 return self.api(self.papi.pg_create_interface,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200203 {"interface_id": pg_index})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200204
205 def sw_interface_dump(self, filter=None):
206 """
207
208 :param filter: (Default value = None)
209
210 """
211 if filter is not None:
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200212 args = {"name_filter_valid": 1, "name_filter": filter}
Klement Sekeraf62ae122016-10-11 11:47:09 +0200213 else:
Ole Troan7e3a8752016-12-05 10:27:09 +0100214 args = {}
215 return self.api(self.papi.sw_interface_dump, args)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200216
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000217 def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
Klement Sekerae4504c62016-12-08 10:16:41 +0100218 """ Set the IPvX Table-id for the Interface
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000219
220 :param sw_if_index:
221 :param is_ipv6:
222 :param table_id:
223
224 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100225 return self.api(self.papi.sw_interface_set_table,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200226 {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6,
227 'vrf_id': table_id})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000228
Klement Sekeraf62ae122016-10-11 11:47:09 +0200229 def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
230 is_ipv6=0, is_add=1, del_all=0):
231 """
232
233 :param addr: param is_ipv6: (Default value = 0)
234 :param sw_if_index:
235 :param addr_len:
236 :param is_ipv6: (Default value = 0)
237 :param is_add: (Default value = 1)
238 :param del_all: (Default value = 0)
239
240 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100241 return self.api(self.papi.sw_interface_add_del_address,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200242 {'sw_if_index': sw_if_index,
243 'is_add': is_add,
244 'is_ipv6': is_ipv6,
245 'del_all': del_all,
246 'address_length': addr_len,
247 'address': addr})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200248
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800249 def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index,
250 is_add=1):
251 """ Set the Interface to be unnumbered
252
253 :param is_add: (Default value = 1)
254 :param sw_if_index - interface That will be unnumbered
255 :param ip_sw_if_index - interface with an IP addres
256
257 """
258 return self.api(self.papi.sw_interface_set_unnumbered,
259 {'sw_if_index': ip_sw_if_index,
260 'unnumbered_sw_if_index': sw_if_index,
261 'is_add': is_add})
262
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000263 def sw_interface_enable_disable_mpls(self, sw_if_index,
264 is_enable=1):
265 """
266 Enable/Disable MPLS on the interface
267 :param sw_if_index:
268 :param is_enable: (Default value = 1)
269
270 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100271 return self.api(self.papi.sw_interface_set_mpls_enable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200272 {'sw_if_index': sw_if_index,
273 'enable': is_enable})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000274
Jan Gelety057bb8c2016-12-20 17:32:45 +0100275 def sw_interface_ra_suppress(self, sw_if_index, suppress=1):
Ole Troan7e3a8752016-12-05 10:27:09 +0100276 return self.api(self.papi.sw_interface_ip6nd_ra_config,
Jan Gelety057bb8c2016-12-20 17:32:45 +0100277 {'sw_if_index': sw_if_index,
278 'suppress': suppress})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200279
Neale Ranns3f844d02017-02-18 00:03:54 -0800280 def ip6_nd_proxy(self, address, sw_if_index, is_del=0):
281 return self.api(self.papi.ip6nd_proxy_add_del,
282 {'address': address,
283 'sw_if_index': sw_if_index,
284 'is_del': is_del})
285
Neale Ranns75152282017-01-09 01:00:45 -0800286 def ip6_sw_interface_ra_config(self, sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000287 no,
Neale Ranns75152282017-01-09 01:00:45 -0800288 suppress,
Neale Ranns32e1c012016-11-22 17:07:28 +0000289 send_unicast):
Neale Ranns75152282017-01-09 01:00:45 -0800290 return self.api(self.papi.sw_interface_ip6nd_ra_config,
291 {'sw_if_index': sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000292 'is_no': no,
Klement Sekerada505f62017-01-04 12:58:53 +0100293 'suppress': suppress,
294 'send_unicast': send_unicast})
Neale Ranns75152282017-01-09 01:00:45 -0800295
Neale Ranns87df12d2017-02-18 08:16:41 -0800296 def ip6_sw_interface_ra_prefix(self,
297 sw_if_index,
298 address,
299 address_length,
300 use_default=0,
301 no_advertise=0,
302 off_link=0,
303 no_autoconfig=0,
304 no_onlink=0,
305 is_no=0,
306 val_lifetime=0xffffffff,
307 pref_lifetime=0xffffffff):
308 return self.api(self.papi.sw_interface_ip6nd_ra_prefix,
309 {'sw_if_index': sw_if_index,
310 'address': address,
311 'address_length': address_length,
312 'use_default': use_default,
313 'no_advertise': no_advertise,
314 'off_link': off_link,
315 'no_autoconfig': no_autoconfig,
316 'no_onlink': no_onlink,
317 'is_no': is_no,
318 'val_lifetime': val_lifetime,
319 'pref_lifetime': pref_lifetime})
320
Neale Ranns75152282017-01-09 01:00:45 -0800321 def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
322 """
323 Enable/Disable An interface for IPv6
324 """
325 return self.api(self.papi.sw_interface_ip6_enable_disable,
326 {'sw_if_index': sw_if_index,
327 'enable': enable})
328
Klement Sekeraf62ae122016-10-11 11:47:09 +0200329 def vxlan_add_del_tunnel(
330 self,
331 src_addr,
332 dst_addr,
Eyal Baric5b13602016-11-24 19:42:43 +0200333 mcast_sw_if_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200334 is_add=1,
335 is_ipv6=0,
336 encap_vrf_id=0,
337 decap_next_index=0xFFFFFFFF,
338 vni=0):
339 """
340
341 :param dst_addr:
342 :param src_addr:
343 :param is_add: (Default value = 1)
344 :param is_ipv6: (Default value = 0)
345 :param encap_vrf_id: (Default value = 0)
346 :param decap_next_index: (Default value = 0xFFFFFFFF)
Eyal Baric5b13602016-11-24 19:42:43 +0200347 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200348 :param vni: (Default value = 0)
349
350 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100351 return self.api(self.papi.vxlan_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200352 {'is_add': is_add,
353 'is_ipv6': is_ipv6,
354 'src_address': src_addr,
355 'dst_address': dst_addr,
356 'mcast_sw_if_index': mcast_sw_if_index,
357 'encap_vrf_id': encap_vrf_id,
358 'decap_next_index': decap_next_index,
359 'vni': vni})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200360
Jan4af521d2016-11-15 17:05:00 +0100361 def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
362 learn=1, arp_term=0, is_add=1):
363 """Create/delete bridge domain.
364
365 :param int bd_id: Bridge domain index.
366 :param int flood: Enable/disable bcast/mcast flooding in the BD.
367 (Default value = 1)
368 :param int uu_flood: Enable/disable unknown unicast flood in the BD.
369 (Default value = 1)
370 :param int forward: Enable/disable forwarding on all interfaces in
371 the BD. (Default value = 1)
372 :param int learn: Enable/disable learning on all interfaces in the BD.
373 (Default value = 1)
374 :param int arp_term: Enable/disable arp termination in the BD.
375 (Default value = 1)
376 :param int is_add: Add or delete flag. (Default value = 1)
377 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100378 return self.api(self.papi.bridge_domain_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200379 {'bd_id': bd_id,
380 'flood': flood,
381 'uu_flood': uu_flood,
382 'forward': forward,
383 'learn': learn,
384 'arp_term': arp_term,
385 'is_add': is_add})
Jan4af521d2016-11-15 17:05:00 +0100386
387 def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
388 filter_mac=0, bvi_mac=0):
389 """Create/delete L2 FIB entry.
390
391 :param str mac: MAC address to create FIB entry for.
392 :param int bd_id: Bridge domain index.
393 :param int sw_if_index: Software interface index of the interface.
394 :param int is_add: Add or delete flag. (Default value = 1)
395 :param int static_mac: Set to 1 to create static MAC entry.
396 (Default value = 0)
397 :param int filter_mac: Set to 1 to drop packet that's source or
398 destination MAC address contains defined MAC address.
399 (Default value = 0)
400 :param int bvi_mac: Set to 1 to create entry that points to BVI
401 interface. (Default value = 0)
402 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100403 return self.api(self.papi.l2fib_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200404 {'mac': self._convert_mac(mac),
405 'bd_id': bd_id,
406 'sw_if_index': sw_if_index,
407 'is_add': is_add,
408 'static_mac': static_mac,
409 'filter_mac': filter_mac,
410 'bvi_mac': bvi_mac})
Jan4af521d2016-11-15 17:05:00 +0100411
Klement Sekeraf62ae122016-10-11 11:47:09 +0200412 def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
413 shg=0, bvi=0, enable=1):
Jan4af521d2016-11-15 17:05:00 +0100414 """Add/remove interface to/from bridge domain.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200415
Jan4af521d2016-11-15 17:05:00 +0100416 :param int sw_if_index: Software interface index of the interface.
417 :param int bd_id: Bridge domain index.
418 :param int shg: Split-horizon group index. (Default value = 0)
419 :param int bvi: Set interface as a bridge group virtual interface.
420 (Default value = 0)
421 :param int enable: Add or remove interface. (Default value = 1)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200422 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100423 return self.api(self.papi.sw_interface_set_l2_bridge,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200424 {'rx_sw_if_index': sw_if_index,
425 'bd_id': bd_id,
426 'shg': shg,
427 'bvi': bvi,
428 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200429
Jan00dad122016-11-29 10:04:53 +0100430 def bridge_flags(self, bd_id, is_set, feature_bitmap):
431 """Enable/disable required feature of the bridge domain with defined ID.
432
433 :param int bd_id: Bridge domain ID.
434 :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
435 :param int feature_bitmap: Bitmap value of the feature to be set:
436 - learn (1 << 0),
437 - forward (1 << 1),
438 - flood (1 << 2),
439 - uu-flood (1 << 3) or
440 - arp-term (1 << 4).
441 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100442 return self.api(self.papi.bridge_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200443 {'bd_id': bd_id,
444 'is_set': is_set,
445 'feature_bitmap': feature_bitmap})
Jan00dad122016-11-29 10:04:53 +0100446
447 def bridge_domain_dump(self, bd_id=0):
448 """
449
450 :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
451 existing bridge domains returned)
452 :return: Dictionary of bridge domain(s) data.
453 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100454 return self.api(self.papi.bridge_domain_dump,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200455 {'bd_id': bd_id})
Jan00dad122016-11-29 10:04:53 +0100456
Klement Sekeraf62ae122016-10-11 11:47:09 +0200457 def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
458 enable):
459 """Create or delete unidirectional cross-connect from Tx interface to
460 Rx interface.
461
Jan4af521d2016-11-15 17:05:00 +0100462 :param int rx_sw_if_index: Software interface index of Rx interface.
463 :param int tx_sw_if_index: Software interface index of Tx interface.
464 :param int enable: Create cross-connect if equal to 1, delete
465 cross-connect if equal to 0.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200466
467 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100468 return self.api(self.papi.sw_interface_set_l2_xconnect,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200469 {'rx_sw_if_index': rx_sw_if_index,
470 'tx_sw_if_index': tx_sw_if_index,
471 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200472
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200473 def sw_interface_set_l2_tag_rewrite(
474 self,
475 sw_if_index,
476 vtr_oper,
477 push=0,
478 tag1=0,
479 tag2=0):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000480 """L2 interface vlan tag rewrite configure request
481 :param client_index - opaque cookie to identify the sender
482 :param context - sender context, to match reply w/ request
483 :param sw_if_index - interface the operation is applied to
484 :param vtr_op - Choose from l2_vtr_op_t enum values
485 :param push_dot1q - first pushed flag dot1q id set, else dot1ad
486 :param tag1 - Needed for any push or translate vtr op
487 :param tag2 - Needed for any push 2 or translate x-2 vtr ops
488
489 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100490 return self.api(self.papi.l2_interface_vlan_tag_rewrite,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200491 {'sw_if_index': sw_if_index,
492 'vtr_op': vtr_oper,
493 'push_dot1q': push,
494 'tag1': tag1,
495 'tag2': tag2})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000496
Klement Sekeraf62ae122016-10-11 11:47:09 +0200497 def sw_interface_set_flags(self, sw_if_index, admin_up_down,
498 link_up_down=0, deleted=0):
499 """
500
501 :param admin_up_down:
502 :param sw_if_index:
503 :param link_up_down: (Default value = 0)
504 :param deleted: (Default value = 0)
505
506 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100507 return self.api(self.papi.sw_interface_set_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200508 {'sw_if_index': sw_if_index,
509 'admin_up_down': admin_up_down,
510 'link_up_down': link_up_down,
511 'deleted': deleted})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200512
513 def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
514 no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
515 default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):
516 """Create subinterface
517 from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
518
519 :param sub_id: param inner_vlan:
520 :param sw_if_index:
521 :param outer_vlan:
522 :param inner_vlan:
523 :param no_tags: (Default value = 0)
524 :param one_tag: (Default value = 0)
525 :param two_tags: (Default value = 0)
526 :param dot1ad: (Default value = 0)
527 :param exact_match: (Default value = 0)
528 :param default_sub: (Default value = 0)
529 :param outer_vlan_id_any: (Default value = 0)
530 :param inner_vlan_id_any: (Default value = 0)
531
532 """
533 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100534 self.papi.create_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200535 {'sw_if_index': sw_if_index,
536 'sub_id': sub_id,
537 'no_tags': no_tags,
538 'one_tag': one_tag,
539 'two_tags': two_tags,
540 'dot1ad': dot1ad,
541 'exact_match': exact_match,
542 'default_sub': default_sub,
543 'outer_vlan_id_any': outer_vlan_id_any,
544 'inner_vlan_id_any': inner_vlan_id_any,
545 'outer_vlan_id': outer_vlan,
546 'inner_vlan_id': inner_vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200547
Neale Ranns177bbdc2016-11-15 09:46:51 +0000548 def delete_subif(self, sw_if_index):
549 """Delete subinterface
550
551 :param sw_if_index:
552 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100553 return self.api(self.papi.delete_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200554 {'sw_if_index': sw_if_index})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000555
Klement Sekeraf62ae122016-10-11 11:47:09 +0200556 def create_vlan_subif(self, sw_if_index, vlan):
557 """
558
559 :param vlan:
560 :param sw_if_index:
561
562 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100563 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200564 {'sw_if_index': sw_if_index,
565 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200566
Matej Klotton0178d522016-11-04 11:11:44 +0100567 def create_loopback(self, mac=''):
568 """
569
570 :param mac: (Optional)
571 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100572 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200573 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100574
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100575 def delete_loopback(self, sw_if_index):
576 return self.api(self.papi.delete_loopback,
577 {'sw_if_index': sw_if_index, })
578
Klement Sekeraf62ae122016-10-11 11:47:09 +0200579 def ip_add_del_route(
580 self,
581 dst_address,
582 dst_address_length,
583 next_hop_address,
584 next_hop_sw_if_index=0xFFFFFFFF,
585 table_id=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200586 next_hop_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000587 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200588 next_hop_n_out_labels=0,
589 next_hop_out_label_stack=[],
590 next_hop_via_label=MPLS_LABEL_INVALID,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200591 create_vrf_if_needed=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000592 is_resolve_host=0,
593 is_resolve_attached=0,
594 classify_table_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200595 is_add=1,
596 is_drop=0,
Juraj Sloboda86a2c572016-10-27 10:44:25 +0200597 is_unreach=0,
598 is_prohibit=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200599 is_ipv6=0,
600 is_local=0,
601 is_classify=0,
602 is_multipath=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000603 not_last=0):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200604 """
605
606 :param dst_address_length:
607 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
608 :param dst_address:
609 :param next_hop_address:
610 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
611 :param vrf_id: (Default value = 0)
612 :param lookup_in_vrf: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200613 :param classify_table_index: (Default value = 0xFFFFFFFF)
614 :param create_vrf_if_needed: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200615 :param is_add: (Default value = 1)
616 :param is_drop: (Default value = 0)
617 :param is_ipv6: (Default value = 0)
618 :param is_local: (Default value = 0)
619 :param is_classify: (Default value = 0)
620 :param is_multipath: (Default value = 0)
621 :param is_resolve_host: (Default value = 0)
622 :param is_resolve_attached: (Default value = 0)
623 :param not_last: (Default value = 0)
624 :param next_hop_weight: (Default value = 1)
625
626 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000627
Klement Sekeraf62ae122016-10-11 11:47:09 +0200628 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100629 self.papi.ip_add_del_route,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200630 {'next_hop_sw_if_index': next_hop_sw_if_index,
631 'table_id': table_id,
632 'classify_table_index': classify_table_index,
633 'next_hop_table_id': next_hop_table_id,
634 'create_vrf_if_needed': create_vrf_if_needed,
635 'is_add': is_add,
636 'is_drop': is_drop,
637 'is_unreach': is_unreach,
638 'is_prohibit': is_prohibit,
639 'is_ipv6': is_ipv6,
640 'is_local': is_local,
641 'is_classify': is_classify,
642 'is_multipath': is_multipath,
643 'is_resolve_host': is_resolve_host,
644 'is_resolve_attached': is_resolve_attached,
645 'not_last': not_last,
646 'next_hop_weight': next_hop_weight,
647 'dst_address_length': dst_address_length,
648 'dst_address': dst_address,
649 'next_hop_address': next_hop_address,
650 'next_hop_n_out_labels': next_hop_n_out_labels,
651 'next_hop_via_label': next_hop_via_label,
652 'next_hop_out_label_stack': next_hop_out_label_stack})
Matej Klotton0178d522016-11-04 11:11:44 +0100653
Matej Klotton16a14cd2016-12-07 15:09:13 +0100654 def ip_fib_dump(self):
655 return self.api(self.papi.ip_fib_dump, {})
656
Jan Gelety057bb8c2016-12-20 17:32:45 +0100657 def ip6_fib_dump(self):
658 return self.api(self.papi.ip6_fib_dump, {})
659
Matej Klotton0178d522016-11-04 11:11:44 +0100660 def ip_neighbor_add_del(self,
661 sw_if_index,
662 mac_address,
663 dst_address,
Matej Klotton0178d522016-11-04 11:11:44 +0100664 is_add=1,
665 is_ipv6=0,
666 is_static=0,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800667 is_no_adj_fib=0,
Matej Klotton0178d522016-11-04 11:11:44 +0100668 ):
669 """ Add neighbor MAC to IPv4 or IPv6 address.
670
671 :param sw_if_index:
672 :param mac_address:
673 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100674 :param is_add: (Default value = 1)
675 :param is_ipv6: (Default value = 0)
676 :param is_static: (Default value = 0)
Neale Rannsb3b2de72017-03-08 05:17:22 -0800677 :param is_no_adj_fib: (Default value = 0)
Matej Klotton0178d522016-11-04 11:11:44 +0100678 """
679
680 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100681 self.papi.ip_neighbor_add_del,
Neale Rannsbaf2e902017-02-25 04:20:00 -0800682 {'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200683 'is_add': is_add,
684 'is_ipv6': is_ipv6,
685 'is_static': is_static,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800686 'is_no_adj_fib': is_no_adj_fib,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200687 'mac_address': mac_address,
688 'dst_address': dst_address
Ole Troan7e3a8752016-12-05 10:27:09 +0100689 }
Matej Klotton0178d522016-11-04 11:11:44 +0100690 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100691
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800692 def ip_neighbor_dump(self,
693 sw_if_index,
694 is_ipv6=0):
695 """ Return IP neighbor dump.
696
697 :param sw_if_index:
698 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
699 """
700
701 return self.api(
702 self.papi.ip_neighbor_dump,
703 {'is_ipv6': is_ipv6,
704 'sw_if_index': sw_if_index
705 }
706 )
707
708 def proxy_arp_add_del(self,
709 low_address,
710 hi_address,
711 vrf_id=0,
712 is_add=1):
713 """ Config Proxy Arp Range.
714
715 :param low_address: Start address in the rnage to Proxy for
716 :param hi_address: End address in the rnage to Proxy for
717 :param vrf_id: The VRF/table in which to proxy
718 """
719
720 return self.api(
721 self.papi.proxy_arp_add_del,
722 {'vrf_id': vrf_id,
723 'is_add': is_add,
724 'low_address': low_address,
725 'hi_address': hi_address,
726 }
727 )
728
729 def proxy_arp_intfc_enable_disable(self,
730 sw_if_index,
731 is_enable=1):
732 """ Enable/Disable an interface for proxy ARP requests
733
734 :param sw_if_index: Interface
735 :param enable_disable: Enable/Disable
736 """
737
738 return self.api(
739 self.papi.proxy_arp_intfc_enable_disable,
740 {'sw_if_index': sw_if_index,
741 'enable_disable': is_enable
742 }
743 )
744
Jane546d3b2016-12-08 13:10:03 +0100745 def reset_vrf(self,
746 vrf_id,
747 is_ipv6=0,
748 ):
749 """ Reset VRF (remove all routes etc.) request.
750
751 :param int vrf_id: ID of the FIB table / VRF to reset.
752 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
753 """
754
755 return self.api(
756 self.papi.reset_vrf,
757 {'vrf_id': vrf_id,
758 'is_ipv6': is_ipv6,
759 }
760 )
761
762 def reset_fib(self,
763 vrf_id,
764 is_ipv6=0,
765 ):
766 """ Reset VRF (remove all routes etc.) request.
767
768 :param int vrf_id: ID of the FIB table / VRF to reset.
769 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
770 """
771
772 return self.api(
773 self.papi.reset_fib,
774 {'vrf_id': vrf_id,
775 'is_ipv6': is_ipv6,
776 }
777 )
778
779 def ip_dump(self,
780 is_ipv6=0,
781 ):
782 """ Return IP dump.
783
784 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
785 """
786
787 return self.api(
788 self.papi.ip_dump,
789 {'is_ipv6': is_ipv6,
790 }
791 )
792
Klement Sekera7bb873a2016-11-18 07:38:42 +0100793 def sw_interface_span_enable_disable(
Ole Troan399ca1c2016-12-06 23:00:38 +0100794 self, sw_if_index_from, sw_if_index_to, state=1):
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100795 """
796
797 :param sw_if_index_from:
798 :param sw_if_index_to:
Matej Klottondeb69842016-12-09 15:05:46 +0100799 :param state:
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100800 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100801 return self.api(self.papi.sw_interface_span_enable_disable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200802 {'sw_if_index_from': sw_if_index_from,
803 'sw_if_index_to': sw_if_index_to,
804 'state': state})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000805
806 def gre_tunnel_add_del(self,
807 src_address,
808 dst_address,
809 outer_fib_id=0,
810 is_teb=0,
811 is_add=1,
812 is_ip6=0):
813 """ Add a GRE tunnel
814
815 :param src_address:
816 :param dst_address:
817 :param outer_fib_id: (Default value = 0)
818 :param is_add: (Default value = 1)
819 :param is_ipv6: (Default value = 0)
820 :param is_teb: (Default value = 0)
821 """
822
823 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100824 self.papi.gre_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200825 {'is_add': is_add,
826 'is_ipv6': is_ip6,
827 'teb': is_teb,
828 'src_address': src_address,
829 'dst_address': dst_address,
830 'outer_fib_id': outer_fib_id}
Neale Ranns177bbdc2016-11-15 09:46:51 +0000831 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000832
Neale Ranns5a8123b2017-01-26 01:18:23 -0800833 def mpls_fib_dump(self):
834 return self.api(self.papi.mpls_fib_dump, {})
835
Neale Rannsad422ed2016-11-02 14:20:04 +0000836 def mpls_route_add_del(
837 self,
838 label,
839 eos,
840 next_hop_proto_is_ip4,
841 next_hop_address,
842 next_hop_sw_if_index=0xFFFFFFFF,
843 table_id=0,
844 next_hop_table_id=0,
845 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200846 next_hop_n_out_labels=0,
847 next_hop_out_label_stack=[],
848 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000849 create_vrf_if_needed=0,
850 is_resolve_host=0,
851 is_resolve_attached=0,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800852 is_interface_rx=0,
853 is_rpf_id=0,
854 is_multicast=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000855 is_add=1,
856 is_drop=0,
857 is_multipath=0,
858 classify_table_index=0xFFFFFFFF,
859 is_classify=0,
860 not_last=0):
861 """
862
863 :param dst_address_length:
864 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
865 :param dst_address:
866 :param next_hop_address:
867 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
868 :param vrf_id: (Default value = 0)
869 :param lookup_in_vrf: (Default value = 0)
870 :param classify_table_index: (Default value = 0xFFFFFFFF)
871 :param create_vrf_if_needed: (Default value = 0)
872 :param is_add: (Default value = 1)
873 :param is_drop: (Default value = 0)
874 :param is_ipv6: (Default value = 0)
875 :param is_local: (Default value = 0)
876 :param is_classify: (Default value = 0)
877 :param is_multipath: (Default value = 0)
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800878 :param is_multicast: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +0000879 :param is_resolve_host: (Default value = 0)
880 :param is_resolve_attached: (Default value = 0)
881 :param not_last: (Default value = 0)
882 :param next_hop_weight: (Default value = 1)
883
884 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000885
886 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100887 self.papi.mpls_route_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200888 {'mr_label': label,
889 'mr_eos': eos,
890 'mr_table_id': table_id,
891 'mr_classify_table_index': classify_table_index,
892 'mr_create_table_if_needed': create_vrf_if_needed,
893 'mr_is_add': is_add,
894 'mr_is_classify': is_classify,
895 'mr_is_multipath': is_multipath,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800896 'mr_is_multicast': is_multicast,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200897 'mr_is_resolve_host': is_resolve_host,
898 'mr_is_resolve_attached': is_resolve_attached,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800899 'mr_is_interface_rx': is_interface_rx,
900 'mr_is_rpf_id': is_rpf_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200901 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
902 'mr_next_hop_weight': next_hop_weight,
903 'mr_next_hop': next_hop_address,
904 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
905 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
906 'mr_next_hop_table_id': next_hop_table_id,
907 'mr_next_hop_via_label': next_hop_via_label,
908 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
Neale Rannsad422ed2016-11-02 14:20:04 +0000909
910 def mpls_ip_bind_unbind(
911 self,
912 label,
913 dst_address,
914 dst_address_length,
915 table_id=0,
916 ip_table_id=0,
917 is_ip4=1,
918 create_vrf_if_needed=0,
919 is_bind=1):
920 """
921 """
922 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100923 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200924 {'mb_mpls_table_id': table_id,
925 'mb_label': label,
926 'mb_ip_table_id': ip_table_id,
927 'mb_create_table_if_needed': create_vrf_if_needed,
928 'mb_is_bind': is_bind,
929 'mb_is_ip4': is_ip4,
930 'mb_address_length': dst_address_length,
931 'mb_address': dst_address})
Neale Rannsad422ed2016-11-02 14:20:04 +0000932
933 def mpls_tunnel_add_del(
934 self,
935 tun_sw_if_index,
936 next_hop_proto_is_ip4,
937 next_hop_address,
938 next_hop_sw_if_index=0xFFFFFFFF,
939 next_hop_table_id=0,
940 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200941 next_hop_n_out_labels=0,
942 next_hop_out_label_stack=[],
943 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000944 create_vrf_if_needed=0,
945 is_add=1,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800946 l2_only=0,
947 is_multicast=0):
Neale Rannsad422ed2016-11-02 14:20:04 +0000948 """
949
950 :param dst_address_length:
951 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
952 :param dst_address:
953 :param next_hop_address:
954 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
955 :param vrf_id: (Default value = 0)
956 :param lookup_in_vrf: (Default value = 0)
957 :param classify_table_index: (Default value = 0xFFFFFFFF)
958 :param create_vrf_if_needed: (Default value = 0)
959 :param is_add: (Default value = 1)
960 :param is_drop: (Default value = 0)
961 :param is_ipv6: (Default value = 0)
962 :param is_local: (Default value = 0)
963 :param is_classify: (Default value = 0)
964 :param is_multipath: (Default value = 0)
965 :param is_resolve_host: (Default value = 0)
966 :param is_resolve_attached: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +0000967 :param next_hop_weight: (Default value = 1)
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800968 :param is_multicast: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +0000969
970 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000971 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100972 self.papi.mpls_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200973 {'mt_sw_if_index': tun_sw_if_index,
974 'mt_is_add': is_add,
975 'mt_l2_only': l2_only,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800976 'mt_is_multicast': is_multicast,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200977 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
978 'mt_next_hop_weight': next_hop_weight,
979 'mt_next_hop': next_hop_address,
980 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
981 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
982 'mt_next_hop_table_id': next_hop_table_id,
983 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
Matus Fabiande886752016-12-07 03:38:19 -0800984
985 def snat_interface_add_del_feature(
986 self,
987 sw_if_index,
988 is_inside=1,
989 is_add=1):
990 """Enable/disable S-NAT feature on the interface
991
992 :param sw_if_index: Software index of the interface
993 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
994 :param is_add: 1 if add, 0 if delete (Default value = 1)
995 """
996 return self.api(
997 self.papi.snat_interface_add_del_feature,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200998 {'is_add': is_add,
999 'is_inside': is_inside,
1000 'sw_if_index': sw_if_index})
Matus Fabiande886752016-12-07 03:38:19 -08001001
1002 def snat_add_static_mapping(
1003 self,
1004 local_ip,
Matus Fabian36532bd2017-01-23 23:42:28 -08001005 external_ip=0,
1006 external_sw_if_index=0xFFFFFFFF,
Matus Fabiande886752016-12-07 03:38:19 -08001007 local_port=0,
1008 external_port=0,
1009 addr_only=1,
1010 vrf_id=0,
Matus Fabian09d96f42017-02-02 01:43:00 -08001011 protocol=0,
Matus Fabiande886752016-12-07 03:38:19 -08001012 is_add=1,
1013 is_ip4=1):
1014 """Add/delete S-NAT static mapping
1015
1016 :param local_ip: Local IP address
1017 :param external_ip: External IP address
Matus Fabian36532bd2017-01-23 23:42:28 -08001018 :param external_sw_if_index: External interface instead of IP address
Matus Fabiande886752016-12-07 03:38:19 -08001019 :param local_port: Local port number (Default value = 0)
1020 :param external_port: External port number (Default value = 0)
1021 :param addr_only: 1 if address only mapping, 0 if address and port
1022 :param vrf_id: VRF ID
Matus Fabian09d96f42017-02-02 01:43:00 -08001023 :param protocol: IP protocol (Default value = 0)
Matus Fabiande886752016-12-07 03:38:19 -08001024 :param is_add: 1 if add, 0 if delete (Default value = 1)
1025 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1026 """
1027 return self.api(
1028 self.papi.snat_add_static_mapping,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001029 {'is_add': is_add,
1030 'is_ip4': is_ip4,
1031 'addr_only': addr_only,
1032 'local_ip_address': local_ip,
1033 'external_ip_address': external_ip,
1034 'local_port': local_port,
1035 'external_port': external_port,
Matus Fabian36532bd2017-01-23 23:42:28 -08001036 'external_sw_if_index': external_sw_if_index,
Matus Fabian09d96f42017-02-02 01:43:00 -08001037 'vrf_id': vrf_id,
1038 'protocol': protocol})
Matus Fabiande886752016-12-07 03:38:19 -08001039
1040 def snat_add_address_range(
1041 self,
1042 first_ip_address,
1043 last_ip_address,
1044 is_add=1,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001045 is_ip4=1,
1046 vrf_id=0xFFFFFFFF):
Matus Fabiande886752016-12-07 03:38:19 -08001047 """Add/del S-NAT address range
1048
1049 :param first_ip_address: First IP address
1050 :param last_ip_address: Last IP address
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001051 :param vrf_id: VRF id for the address range
Matus Fabiande886752016-12-07 03:38:19 -08001052 :param is_add: 1 if add, 0 if delete (Default value = 1)
1053 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1054 """
1055 return self.api(
1056 self.papi.snat_add_address_range,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001057 {'is_ip4': is_ip4,
1058 'first_ip_address': first_ip_address,
1059 'last_ip_address': last_ip_address,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001060 'vrf_id': vrf_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001061 'is_add': is_add})
Matus Fabiande886752016-12-07 03:38:19 -08001062
1063 def snat_address_dump(self):
1064 """Dump S-NAT addresses
1065 :return: Dictionary of S-NAT addresses
1066 """
1067 return self.api(self.papi.snat_address_dump, {})
1068
1069 def snat_interface_dump(self):
1070 """Dump interfaces with S-NAT feature
1071 :return: Dictionary of interfaces with S-NAT feature
1072 """
1073 return self.api(self.papi.snat_interface_dump, {})
1074
1075 def snat_static_mapping_dump(self):
1076 """Dump S-NAT static mappings
1077 :return: Dictionary of S-NAT static mappings
1078 """
1079 return self.api(self.papi.snat_static_mapping_dump, {})
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001080
Matus Fabian9902fcd2016-12-21 23:58:46 -08001081 def snat_show_config(self):
1082 """Show S-NAT config
1083 :return: S-NAT config parameters
1084 """
1085 return self.api(self.papi.snat_show_config, {})
1086
Matus Fabian8bf68e82017-01-12 04:24:35 -08001087 def snat_add_interface_addr(
1088 self,
1089 sw_if_index,
1090 is_add=1):
1091 """Add/del S-NAT address from interface
1092
1093 :param sw_if_index: Software index of the interface
1094 :param is_add: 1 if add, 0 if delete (Default value = 1)
1095 """
1096 return self.api(self.papi.snat_add_del_interface_addr,
1097 {'is_add': is_add, 'sw_if_index': sw_if_index})
1098
1099 def snat_interface_addr_dump(self):
1100 """Dump S-NAT addresses interfaces
1101 :return: Dictionary of S-NAT addresses interfaces
1102 """
1103 return self.api(self.papi.snat_interface_addr_dump, {})
1104
Matus Fabianeea28d72017-01-13 04:15:54 -08001105 def snat_ipfix(
1106 self,
1107 domain_id=1,
1108 src_port=4739,
1109 enable=1):
1110 """Enable/disable S-NAT IPFIX logging
1111
1112 :param domain_id: Observation domain ID (Default value = 1)
1113 :param src_port: Source port number (Default value = 4739)
1114 :param enable: 1 if enable, 0 if disable (Default value = 1)
1115 """
1116 return self.api(
1117 self.papi.snat_ipfix_enable_disable,
1118 {'domain_id': domain_id,
1119 'src_port': src_port,
1120 'enable': enable})
1121
magalik23caa882017-02-08 23:25:45 -08001122 def snat_user_session_dump(
1123 self,
1124 ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001125 vrf_id,
1126 is_ip4=1):
magalik23caa882017-02-08 23:25:45 -08001127 """Dump S-NAT user's sessions
1128
1129 :param ip_address: ip adress of the user to be dumped
1130 :param cpu_index: cpu_index on which the user is
1131 :param vrf_id: VRF ID
1132 :return: Dictionary of S-NAT sessions
1133 """
1134 return self.api(
1135 self.papi.snat_user_session_dump,
1136 {'ip_address': ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001137 'vrf_id': vrf_id,
1138 'is_ip4': is_ip4})
magalik23caa882017-02-08 23:25:45 -08001139
1140 def snat_user_dump(self):
1141 """Dump S-NAT users
1142
1143 :return: Dictionary of S-NAT users
1144 """
1145 return self.api(self.papi.snat_user_dump, {})
1146
Matus Fabian066f0342017-02-10 03:48:01 -08001147 def snat_add_det_map(
1148 self,
1149 in_addr,
1150 in_plen,
1151 out_addr,
1152 out_plen,
1153 is_add=1):
1154 """Add/delete S-NAT deterministic mapping
1155
1156 :param is_add - 1 if add, 0 if delete
1157 :param in_addr - inside IP address
1158 :param in_plen - inside IP address prefix length
1159 :param out_addr - outside IP address
1160 :param out_plen - outside IP address prefix length
1161 """
1162 return self.api(
1163 self.papi.snat_add_det_map,
1164 {'is_add': is_add,
1165 'in_addr': in_addr,
1166 'in_plen': in_plen,
1167 'out_addr': out_addr,
1168 'out_plen': out_plen})
1169
1170 def snat_det_forward(
1171 self,
1172 in_addr):
1173 """Get outside address and port range from inside address
1174
1175 :param in_addr - inside IP address
1176 """
1177 return self.api(
1178 self.papi.snat_det_forward,
1179 {'in_addr': in_addr})
1180
1181 def snat_det_reverse(
1182 self,
1183 out_addr,
1184 out_port):
1185 """Get inside address from outside address and port
1186
1187 :param out_addr - outside IP address
1188 :param out_port - outside port
1189 """
1190 return self.api(
1191 self.papi.snat_det_reverse,
1192 {'out_addr': out_addr,
1193 'out_port': out_port})
1194
Martin17a75cb2017-03-08 05:53:20 -08001195 def snat_det_map_dump(self):
1196 """Dump S-NAT deterministic mappings
1197
1198 :return: Dictionary of S-NAT deterministic mappings
1199 """
1200 return self.api(self.papi.snat_det_map_dump, {})
1201
Matus Fabian6a0946f2017-04-12 03:36:13 -07001202 def snat_det_set_timeouts(
1203 self,
1204 udp=300,
1205 tcp_established=7440,
1206 tcp_transitory=240,
1207 icmp=60):
1208 """Set values of timeouts for deterministic NAT (in seconds)
1209
1210 :param udp - UDP timeout (Default value = 300)
1211 :param tcp_established - TCP established timeout (Default value = 7440)
1212 :param tcp_transitory - TCP transitory timeout (Default value = 240)
1213 :param icmp - ICMP timeout (Default value = 60)
1214 """
1215 return self.api(
1216 self.papi.snat_det_set_timeouts,
1217 {'udp': udp,
1218 'tcp_established': tcp_established,
1219 'tcp_transitory': tcp_transitory,
1220 'icmp': icmp})
1221
1222 def snat_det_get_timeouts(self):
1223 """Get values of timeouts for deterministic NAT
1224
1225 :return: Timeouts for deterministic NAT (in seconds)
1226 """
1227 return self.api(self.papi.snat_det_get_timeouts, {})
1228
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001229 def control_ping(self):
1230 self.api(self.papi.control_ping)
1231
1232 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
Klement Sekerab17dd962017-01-09 07:43:48 +01001233 detect_mult, local_addr, peer_addr, is_ipv6=0,
1234 bfd_key_id=None, conf_key_id=None):
1235 if bfd_key_id is None:
1236 return self.api(self.papi.bfd_udp_add,
1237 {
1238 'sw_if_index': sw_if_index,
1239 'desired_min_tx': desired_min_tx,
1240 'required_min_rx': required_min_rx,
1241 'local_addr': local_addr,
1242 'peer_addr': peer_addr,
1243 'is_ipv6': is_ipv6,
1244 'detect_mult': detect_mult,
1245 })
1246 else:
1247 return self.api(self.papi.bfd_udp_add,
1248 {
1249 'sw_if_index': sw_if_index,
1250 'desired_min_tx': desired_min_tx,
1251 'required_min_rx': required_min_rx,
1252 'local_addr': local_addr,
1253 'peer_addr': peer_addr,
1254 'is_ipv6': is_ipv6,
1255 'detect_mult': detect_mult,
1256 'is_authenticated': 1,
1257 'bfd_key_id': bfd_key_id,
1258 'conf_key_id': conf_key_id,
1259 })
1260
Klement Sekeraa57a9702017-02-02 06:58:07 +01001261 def bfd_udp_mod(self, sw_if_index, desired_min_tx, required_min_rx,
1262 detect_mult, local_addr, peer_addr, is_ipv6=0):
1263 return self.api(self.papi.bfd_udp_mod,
1264 {
1265 'sw_if_index': sw_if_index,
1266 'desired_min_tx': desired_min_tx,
1267 'required_min_rx': required_min_rx,
1268 'local_addr': local_addr,
1269 'peer_addr': peer_addr,
1270 'is_ipv6': is_ipv6,
1271 'detect_mult': detect_mult,
1272 })
1273
Klement Sekerab17dd962017-01-09 07:43:48 +01001274 def bfd_udp_auth_activate(self, sw_if_index, local_addr, peer_addr,
1275 is_ipv6=0, bfd_key_id=None, conf_key_id=None,
1276 is_delayed=False):
1277 return self.api(self.papi.bfd_udp_auth_activate,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001278 {
1279 'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001280 'local_addr': local_addr,
1281 'peer_addr': peer_addr,
1282 'is_ipv6': is_ipv6,
Klement Sekerab17dd962017-01-09 07:43:48 +01001283 'is_delayed': 1 if is_delayed else 0,
1284 'bfd_key_id': bfd_key_id,
1285 'conf_key_id': conf_key_id,
1286 })
1287
1288 def bfd_udp_auth_deactivate(self, sw_if_index, local_addr, peer_addr,
1289 is_ipv6=0, is_delayed=False):
1290 return self.api(self.papi.bfd_udp_auth_deactivate,
1291 {
1292 'sw_if_index': sw_if_index,
1293 'local_addr': local_addr,
1294 'peer_addr': peer_addr,
1295 'is_ipv6': is_ipv6,
1296 'is_delayed': 1 if is_delayed else 0,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001297 })
1298
1299 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
1300 return self.api(self.papi.bfd_udp_del,
1301 {
1302 'sw_if_index': sw_if_index,
1303 'local_addr': local_addr,
1304 'peer_addr': peer_addr,
1305 'is_ipv6': is_ipv6,
1306 })
1307
1308 def bfd_udp_session_dump(self):
1309 return self.api(self.papi.bfd_udp_session_dump, {})
1310
Klement Sekerab17dd962017-01-09 07:43:48 +01001311 def bfd_udp_session_set_flags(self, admin_up_down, sw_if_index, local_addr,
1312 peer_addr, is_ipv6=0):
1313 return self.api(self.papi.bfd_udp_session_set_flags, {
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001314 'admin_up_down': admin_up_down,
Klement Sekerab17dd962017-01-09 07:43:48 +01001315 'sw_if_index': sw_if_index,
1316 'local_addr': local_addr,
1317 'peer_addr': peer_addr,
1318 'is_ipv6': is_ipv6,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001319 })
1320
1321 def want_bfd_events(self, enable_disable=1):
1322 return self.api(self.papi.want_bfd_events, {
1323 'enable_disable': enable_disable,
1324 'pid': os.getpid(),
1325 })
Steve Shin7957d6e2016-12-19 09:24:50 -08001326
Klement Sekerab17dd962017-01-09 07:43:48 +01001327 def bfd_auth_set_key(self, conf_key_id, auth_type, key):
1328 return self.api(self.papi.bfd_auth_set_key, {
1329 'conf_key_id': conf_key_id,
1330 'auth_type': auth_type,
1331 'key': key,
1332 'key_len': len(key),
1333 })
1334
1335 def bfd_auth_del_key(self, conf_key_id):
1336 return self.api(self.papi.bfd_auth_del_key, {
1337 'conf_key_id': conf_key_id,
1338 })
1339
1340 def bfd_auth_keys_dump(self):
1341 return self.api(self.papi.bfd_auth_keys_dump, {})
1342
Klement Sekera239790f2017-02-16 10:53:53 +01001343 def bfd_udp_set_echo_source(self, sw_if_index):
1344 return self.api(self.papi.bfd_udp_set_echo_source,
1345 {'sw_if_index': sw_if_index})
1346
Klement Sekera73884482017-02-23 09:26:30 +01001347 def bfd_udp_del_echo_source(self):
1348 return self.api(self.papi.bfd_udp_del_echo_source, {})
1349
Steve Shin7957d6e2016-12-19 09:24:50 -08001350 def classify_add_del_table(
1351 self,
1352 is_add,
1353 mask,
1354 match_n_vectors=1,
1355 table_index=0xFFFFFFFF,
1356 nbuckets=2,
1357 memory_size=2097152,
1358 skip_n_vectors=0,
1359 next_table_index=0xFFFFFFFF,
1360 miss_next_index=0xFFFFFFFF,
1361 current_data_flag=0,
1362 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -08001363 """
1364 :param is_add:
1365 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +01001366 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +01001367 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -08001368 :param nbuckets: (Default value = 2)
1369 :param memory_size: (Default value = 2097152)
1370 :param skip_n_vectors: (Default value = 0)
1371 :param next_table_index: (Default value = 0xFFFFFFFF)
1372 :param miss_next_index: (Default value = 0xFFFFFFFF)
1373 :param current_data_flag: (Default value = 0)
1374 :param current_data_offset: (Default value = 0)
1375 """
1376
1377 return self.api(
1378 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001379 {'is_add': is_add,
1380 'table_index': table_index,
1381 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -08001382 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001383 'skip_n_vectors': skip_n_vectors,
1384 'match_n_vectors': match_n_vectors,
1385 'next_table_index': next_table_index,
1386 'miss_next_index': miss_next_index,
1387 'current_data_flag': current_data_flag,
1388 'current_data_offset': current_data_offset,
1389 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -08001390
1391 def classify_add_del_session(
1392 self,
1393 is_add,
1394 table_index,
1395 match,
1396 opaque_index=0xFFFFFFFF,
1397 hit_next_index=0xFFFFFFFF,
1398 advance=0,
1399 action=0,
1400 metadata=0):
1401 """
1402 :param is_add:
1403 :param table_index:
1404 :param match:
1405 :param opaque_index: (Default value = 0xFFFFFFFF)
1406 :param hit_next_index: (Default value = 0xFFFFFFFF)
1407 :param advance: (Default value = 0)
1408 :param action: (Default value = 0)
1409 :param metadata: (Default value = 0)
1410 """
1411
1412 return self.api(
1413 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001414 {'is_add': is_add,
1415 'table_index': table_index,
1416 'hit_next_index': hit_next_index,
1417 'opaque_index': opaque_index,
1418 'advance': advance,
1419 'action': action,
1420 'metadata': metadata,
1421 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -08001422
1423 def input_acl_set_interface(
1424 self,
1425 is_add,
1426 sw_if_index,
1427 ip4_table_index=0xFFFFFFFF,
1428 ip6_table_index=0xFFFFFFFF,
1429 l2_table_index=0xFFFFFFFF):
1430 """
1431 :param is_add:
1432 :param sw_if_index:
1433 :param ip4_table_index: (Default value = 0xFFFFFFFF)
1434 :param ip6_table_index: (Default value = 0xFFFFFFFF)
1435 :param l2_table_index: (Default value = 0xFFFFFFFF)
1436 """
1437
1438 return self.api(
1439 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001440 {'sw_if_index': sw_if_index,
1441 'ip4_table_index': ip4_table_index,
1442 'ip6_table_index': ip6_table_index,
1443 'l2_table_index': l2_table_index,
1444 'is_add': is_add})
1445
1446 def set_ipfix_exporter(
1447 self,
1448 collector_address,
1449 src_address,
1450 path_mtu,
1451 template_interval,
1452 vrf_id=0,
1453 collector_port=4739,
1454 udp_checksum=0):
1455 return self.api(
1456 self.papi.set_ipfix_exporter,
1457 {
1458 'collector_address': collector_address,
1459 'collector_port': collector_port,
1460 'src_address': src_address,
1461 'vrf_id': vrf_id,
1462 'path_mtu': path_mtu,
1463 'template_interval': template_interval,
1464 'udp_checksum': udp_checksum,
1465 })
Neale Rannsfca0c242017-01-13 07:57:46 -08001466
1467 def dhcp_proxy_config(self,
1468 dhcp_server,
1469 dhcp_src_address,
1470 rx_table_id=0,
1471 server_table_id=0,
1472 is_add=1,
Neale Ranns20a175a2017-02-14 07:28:41 -08001473 is_ipv6=0):
Neale Rannsfca0c242017-01-13 07:57:46 -08001474 return self.api(
Neale Ranns20a175a2017-02-14 07:28:41 -08001475 self.papi.dhcp_proxy_config,
Neale Rannsfca0c242017-01-13 07:57:46 -08001476 {
1477 'rx_vrf_id': rx_table_id,
1478 'server_vrf_id': server_table_id,
1479 'is_ipv6': is_ipv6,
1480 'is_add': is_add,
Neale Rannsfca0c242017-01-13 07:57:46 -08001481 'dhcp_server': dhcp_server,
1482 'dhcp_src_address': dhcp_src_address,
1483 })
1484
1485 def dhcp_proxy_set_vss(self,
1486 table_id,
1487 fib_id,
1488 oui,
1489 is_add=1,
1490 is_ip6=0):
1491 return self.api(
1492 self.papi.dhcp_proxy_set_vss,
1493 {
1494 'tbl_id': table_id,
1495 'fib_id': fib_id,
1496 'is_ipv6': is_ip6,
1497 'is_add': is_add,
1498 'oui': oui,
1499 })
Neale Ranns32e1c012016-11-22 17:07:28 +00001500
1501 def ip_mroute_add_del(self,
1502 src_address,
1503 grp_address,
1504 grp_address_length,
1505 e_flags,
1506 next_hop_sw_if_index,
1507 i_flags,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001508 rpf_id=0,
Neale Ranns32e1c012016-11-22 17:07:28 +00001509 table_id=0,
1510 create_vrf_if_needed=0,
1511 is_add=1,
1512 is_ipv6=0,
1513 is_local=0):
1514 """
1515 """
1516 return self.api(
1517 self.papi.ip_mroute_add_del,
1518 {'next_hop_sw_if_index': next_hop_sw_if_index,
1519 'entry_flags': e_flags,
1520 'itf_flags': i_flags,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001521 'table_id': table_id,
1522 'rpf_id': rpf_id,
Neale Ranns32e1c012016-11-22 17:07:28 +00001523 'create_vrf_if_needed': create_vrf_if_needed,
1524 'is_add': is_add,
1525 'is_ipv6': is_ipv6,
1526 'is_local': is_local,
1527 'grp_address_length': grp_address_length,
1528 'grp_address': grp_address,
1529 'src_address': src_address})
1530
1531 def mfib_signal_dump(self):
1532 return self.api(self.papi.mfib_signal_dump, {})
Neale Ranns5a8123b2017-01-26 01:18:23 -08001533
1534 def ip_mfib_dump(self):
1535 return self.api(self.papi.ip_mfib_dump, {})
Filip Tehlar770e89e2017-01-31 10:39:16 +01001536
1537 def lisp_enable_disable(self, is_enabled):
1538 return self.api(
1539 self.papi.lisp_enable_disable,
1540 {
1541 'is_en': is_enabled,
1542 })
1543
1544 def lisp_locator_set(self,
1545 ls_name,
1546 is_add=1):
1547 return self.api(
1548 self.papi.lisp_add_del_locator_set,
1549 {
1550 'is_add': is_add,
1551 'locator_set_name': ls_name
1552 })
1553
1554 def lisp_locator_set_dump(self):
1555 return self.api(self.papi.lisp_locator_set_dump, {})
1556
1557 def lisp_locator(self,
1558 ls_name,
1559 sw_if_index,
1560 priority=1,
1561 weight=1,
1562 is_add=1):
1563 return self.api(
1564 self.papi.lisp_add_del_locator,
1565 {
1566 'is_add': is_add,
1567 'locator_set_name': ls_name,
1568 'sw_if_index': sw_if_index,
1569 'priority': priority,
1570 'weight': weight
1571 })
1572
1573 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
1574 return self.api(
1575 self.papi.lisp_locator_dump,
1576 {
1577 'is_index_set': is_index_set,
1578 'ls_name': ls_name,
1579 'ls_index': ls_index,
1580 })
1581
1582 def lisp_local_mapping(self,
1583 ls_name,
1584 eid_type,
1585 eid,
1586 prefix_len,
1587 vni=0,
1588 key_id=0,
1589 key="",
1590 is_add=1):
1591 return self.api(
1592 self.papi.lisp_add_del_local_eid,
1593 {
1594 'locator_set_name': ls_name,
1595 'is_add': is_add,
1596 'eid_type': eid_type,
1597 'eid': eid,
1598 'prefix_len': prefix_len,
1599 'vni': vni,
1600 'key_id': key_id,
1601 'key': key
1602 })
1603
1604 def lisp_eid_table_dump(self,
1605 eid_set=0,
1606 prefix_length=0,
1607 vni=0,
1608 eid_type=0,
1609 eid=None,
1610 filter_opt=0):
1611 return self.api(
1612 self.papi.lisp_eid_table_dump,
1613 {
1614 'eid_set': eid_set,
1615 'prefix_length': prefix_length,
1616 'vni': vni,
1617 'eid_type': eid_type,
1618 'eid': eid,
1619 'filter': filter_opt,
1620 })
1621
1622 def lisp_remote_mapping(self,
1623 eid_type,
1624 eid,
1625 eid_prefix_len=0,
1626 vni=0,
1627 rlocs=None,
1628 rlocs_num=0,
1629 is_src_dst=0,
1630 is_add=1):
1631 return self.api(
1632 self.papi.lisp_add_del_remote_mapping,
1633 {
1634 'is_add': is_add,
1635 'eid_type': eid_type,
1636 'eid': eid,
1637 'eid_len': eid_prefix_len,
1638 'rloc_num': rlocs_num,
1639 'rlocs': rlocs,
1640 'vni': vni,
1641 'is_src_dst': is_src_dst,
1642 })
1643
1644 def lisp_adjacency(self,
1645 leid,
1646 reid,
1647 leid_len,
1648 reid_len,
1649 eid_type,
1650 is_add=1,
1651 vni=0):
1652 return self.api(
1653 self.papi.lisp_add_del_adjacency,
1654 {
1655 'is_add': is_add,
1656 'vni': vni,
1657 'eid_type': eid_type,
1658 'leid': leid,
1659 'reid': reid,
1660 'leid_len': leid_len,
1661 'reid_len': reid_len,
1662 })
1663
1664 def lisp_adjacencies_get(self, vni=0):
1665 return self.api(
1666 self.papi.lisp_adjacencies_get,
1667 {
1668 'vni': vni
1669 })
Neale Ranns80823802017-02-20 18:23:41 -08001670
1671 def map_add_domain(self,
1672 ip6_prefix,
1673 ip6_prefix_len,
1674 ip6_src,
1675 ip6_src_prefix_len,
1676 ip4_prefix,
1677 ip4_prefix_len,
1678 ea_bits_len=0,
1679 psid_offset=0,
1680 psid_length=0,
1681 is_translation=0,
1682 mtu=1280):
1683 return self.api(
1684 self.papi.map_add_domain,
1685 {
1686 'ip6_prefix': ip6_prefix,
1687 'ip6_prefix_len': ip6_prefix_len,
1688 'ip4_prefix': ip4_prefix,
1689 'ip4_prefix_len': ip4_prefix_len,
1690 'ip6_src': ip6_src,
1691 'ip6_src_prefix_len': ip6_src_prefix_len,
1692 'ea_bits_len': ea_bits_len,
1693 'psid_offset': psid_offset,
1694 'psid_length': psid_length,
1695 'is_translation': is_translation,
1696 'mtu': mtu
1697 })