blob: 7f9e2ae1293cb4bcec3517d31ef56d09941957a8 [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:
155 msg = "API call failed, expected zero return value instead "\
156 "of %d in %s" % (expected_retval, repr(reply))
157 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100158 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100159 else:
160 raise Exception("Internal error, unexpected value for "
161 "self._expect_api_retval %s" %
162 self._expect_api_retval)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200163 self.hook.after_api(api_fn.__name__, api_args)
164 return reply
165
166 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100167 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200168
169 :param cli: CLI to execute
170 :returns: CLI output
171
172 """
173 self.hook.before_cli(cli)
174 cli += '\n'
Ole Troan7e3a8752016-12-05 10:27:09 +0100175 r = self.papi.cli_inband(length=len(cli), cmd=cli)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200176 self.hook.after_cli(cli)
Jan49c0fca2016-10-26 15:44:27 +0200177 if hasattr(r, 'reply'):
Ole Troan7e3a8752016-12-05 10:27:09 +0100178 return r.reply.decode().rstrip('\x00')
Klement Sekeraf62ae122016-10-11 11:47:09 +0200179
Jan49c0fca2016-10-26 15:44:27 +0200180 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100181 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200182
183 :param cli: CLI to execute
184 :returns: CLI output
185 """
Ed Warnickeb8ff5d62016-11-28 13:59:22 -0600186 return cli + "\n" + str(self.cli(cli))
Jan49c0fca2016-10-26 15:44:27 +0200187
Jan4af521d2016-11-15 17:05:00 +0100188 def _convert_mac(self, mac):
189 return int(mac.replace(":", ""), 16) << 16
190
Klement Sekeraf62ae122016-10-11 11:47:09 +0200191 def show_version(self):
192 """ """
Klement Sekera7112c542017-03-01 09:53:19 +0100193 return self.api(self.papi.show_version, {})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200194
195 def pg_create_interface(self, pg_index):
196 """
197
198 :param pg_index:
199
200 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100201 return self.api(self.papi.pg_create_interface,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200202 {"interface_id": pg_index})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200203
204 def sw_interface_dump(self, filter=None):
205 """
206
207 :param filter: (Default value = None)
208
209 """
210 if filter is not None:
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200211 args = {"name_filter_valid": 1, "name_filter": filter}
Klement Sekeraf62ae122016-10-11 11:47:09 +0200212 else:
Ole Troan7e3a8752016-12-05 10:27:09 +0100213 args = {}
214 return self.api(self.papi.sw_interface_dump, args)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200215
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000216 def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
Klement Sekerae4504c62016-12-08 10:16:41 +0100217 """ Set the IPvX Table-id for the Interface
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000218
219 :param sw_if_index:
220 :param is_ipv6:
221 :param table_id:
222
223 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100224 return self.api(self.papi.sw_interface_set_table,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200225 {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6,
226 'vrf_id': table_id})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000227
Klement Sekeraf62ae122016-10-11 11:47:09 +0200228 def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
229 is_ipv6=0, is_add=1, del_all=0):
230 """
231
232 :param addr: param is_ipv6: (Default value = 0)
233 :param sw_if_index:
234 :param addr_len:
235 :param is_ipv6: (Default value = 0)
236 :param is_add: (Default value = 1)
237 :param del_all: (Default value = 0)
238
239 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100240 return self.api(self.papi.sw_interface_add_del_address,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200241 {'sw_if_index': sw_if_index,
242 'is_add': is_add,
243 'is_ipv6': is_ipv6,
244 'del_all': del_all,
245 'address_length': addr_len,
246 'address': addr})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200247
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800248 def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index,
249 is_add=1):
250 """ Set the Interface to be unnumbered
251
252 :param is_add: (Default value = 1)
253 :param sw_if_index - interface That will be unnumbered
254 :param ip_sw_if_index - interface with an IP addres
255
256 """
257 return self.api(self.papi.sw_interface_set_unnumbered,
258 {'sw_if_index': ip_sw_if_index,
259 'unnumbered_sw_if_index': sw_if_index,
260 'is_add': is_add})
261
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000262 def sw_interface_enable_disable_mpls(self, sw_if_index,
263 is_enable=1):
264 """
265 Enable/Disable MPLS on the interface
266 :param sw_if_index:
267 :param is_enable: (Default value = 1)
268
269 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100270 return self.api(self.papi.sw_interface_set_mpls_enable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200271 {'sw_if_index': sw_if_index,
272 'enable': is_enable})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000273
Jan Gelety057bb8c2016-12-20 17:32:45 +0100274 def sw_interface_ra_suppress(self, sw_if_index, suppress=1):
Ole Troan7e3a8752016-12-05 10:27:09 +0100275 return self.api(self.papi.sw_interface_ip6nd_ra_config,
Jan Gelety057bb8c2016-12-20 17:32:45 +0100276 {'sw_if_index': sw_if_index,
277 'suppress': suppress})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200278
Neale Ranns3f844d02017-02-18 00:03:54 -0800279 def ip6_nd_proxy(self, address, sw_if_index, is_del=0):
280 return self.api(self.papi.ip6nd_proxy_add_del,
281 {'address': address,
282 'sw_if_index': sw_if_index,
283 'is_del': is_del})
284
Neale Ranns75152282017-01-09 01:00:45 -0800285 def ip6_sw_interface_ra_config(self, sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000286 no,
Neale Ranns75152282017-01-09 01:00:45 -0800287 suppress,
Neale Ranns32e1c012016-11-22 17:07:28 +0000288 send_unicast):
Neale Ranns75152282017-01-09 01:00:45 -0800289 return self.api(self.papi.sw_interface_ip6nd_ra_config,
290 {'sw_if_index': sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000291 'is_no': no,
Klement Sekerada505f62017-01-04 12:58:53 +0100292 'suppress': suppress,
293 'send_unicast': send_unicast})
Neale Ranns75152282017-01-09 01:00:45 -0800294
Neale Ranns87df12d2017-02-18 08:16:41 -0800295 def ip6_sw_interface_ra_prefix(self,
296 sw_if_index,
297 address,
298 address_length,
299 use_default=0,
300 no_advertise=0,
301 off_link=0,
302 no_autoconfig=0,
303 no_onlink=0,
304 is_no=0,
305 val_lifetime=0xffffffff,
306 pref_lifetime=0xffffffff):
307 return self.api(self.papi.sw_interface_ip6nd_ra_prefix,
308 {'sw_if_index': sw_if_index,
309 'address': address,
310 'address_length': address_length,
311 'use_default': use_default,
312 'no_advertise': no_advertise,
313 'off_link': off_link,
314 'no_autoconfig': no_autoconfig,
315 'no_onlink': no_onlink,
316 'is_no': is_no,
317 'val_lifetime': val_lifetime,
318 'pref_lifetime': pref_lifetime})
319
Neale Ranns75152282017-01-09 01:00:45 -0800320 def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
321 """
322 Enable/Disable An interface for IPv6
323 """
324 return self.api(self.papi.sw_interface_ip6_enable_disable,
325 {'sw_if_index': sw_if_index,
326 'enable': enable})
327
Klement Sekeraf62ae122016-10-11 11:47:09 +0200328 def vxlan_add_del_tunnel(
329 self,
330 src_addr,
331 dst_addr,
Eyal Baric5b13602016-11-24 19:42:43 +0200332 mcast_sw_if_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200333 is_add=1,
334 is_ipv6=0,
335 encap_vrf_id=0,
336 decap_next_index=0xFFFFFFFF,
337 vni=0):
338 """
339
340 :param dst_addr:
341 :param src_addr:
342 :param is_add: (Default value = 1)
343 :param is_ipv6: (Default value = 0)
344 :param encap_vrf_id: (Default value = 0)
345 :param decap_next_index: (Default value = 0xFFFFFFFF)
Eyal Baric5b13602016-11-24 19:42:43 +0200346 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200347 :param vni: (Default value = 0)
348
349 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100350 return self.api(self.papi.vxlan_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200351 {'is_add': is_add,
352 'is_ipv6': is_ipv6,
353 'src_address': src_addr,
354 'dst_address': dst_addr,
355 'mcast_sw_if_index': mcast_sw_if_index,
356 'encap_vrf_id': encap_vrf_id,
357 'decap_next_index': decap_next_index,
358 'vni': vni})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200359
Jan4af521d2016-11-15 17:05:00 +0100360 def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
361 learn=1, arp_term=0, is_add=1):
362 """Create/delete bridge domain.
363
364 :param int bd_id: Bridge domain index.
365 :param int flood: Enable/disable bcast/mcast flooding in the BD.
366 (Default value = 1)
367 :param int uu_flood: Enable/disable unknown unicast flood in the BD.
368 (Default value = 1)
369 :param int forward: Enable/disable forwarding on all interfaces in
370 the BD. (Default value = 1)
371 :param int learn: Enable/disable learning on all interfaces in the BD.
372 (Default value = 1)
373 :param int arp_term: Enable/disable arp termination in the BD.
374 (Default value = 1)
375 :param int is_add: Add or delete flag. (Default value = 1)
376 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100377 return self.api(self.papi.bridge_domain_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200378 {'bd_id': bd_id,
379 'flood': flood,
380 'uu_flood': uu_flood,
381 'forward': forward,
382 'learn': learn,
383 'arp_term': arp_term,
384 'is_add': is_add})
Jan4af521d2016-11-15 17:05:00 +0100385
386 def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
387 filter_mac=0, bvi_mac=0):
388 """Create/delete L2 FIB entry.
389
390 :param str mac: MAC address to create FIB entry for.
391 :param int bd_id: Bridge domain index.
392 :param int sw_if_index: Software interface index of the interface.
393 :param int is_add: Add or delete flag. (Default value = 1)
394 :param int static_mac: Set to 1 to create static MAC entry.
395 (Default value = 0)
396 :param int filter_mac: Set to 1 to drop packet that's source or
397 destination MAC address contains defined MAC address.
398 (Default value = 0)
399 :param int bvi_mac: Set to 1 to create entry that points to BVI
400 interface. (Default value = 0)
401 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100402 return self.api(self.papi.l2fib_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200403 {'mac': self._convert_mac(mac),
404 'bd_id': bd_id,
405 'sw_if_index': sw_if_index,
406 'is_add': is_add,
407 'static_mac': static_mac,
408 'filter_mac': filter_mac,
409 'bvi_mac': bvi_mac})
Jan4af521d2016-11-15 17:05:00 +0100410
Klement Sekeraf62ae122016-10-11 11:47:09 +0200411 def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
412 shg=0, bvi=0, enable=1):
Jan4af521d2016-11-15 17:05:00 +0100413 """Add/remove interface to/from bridge domain.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200414
Jan4af521d2016-11-15 17:05:00 +0100415 :param int sw_if_index: Software interface index of the interface.
416 :param int bd_id: Bridge domain index.
417 :param int shg: Split-horizon group index. (Default value = 0)
418 :param int bvi: Set interface as a bridge group virtual interface.
419 (Default value = 0)
420 :param int enable: Add or remove interface. (Default value = 1)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200421 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100422 return self.api(self.papi.sw_interface_set_l2_bridge,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200423 {'rx_sw_if_index': sw_if_index,
424 'bd_id': bd_id,
425 'shg': shg,
426 'bvi': bvi,
427 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200428
Jan00dad122016-11-29 10:04:53 +0100429 def bridge_flags(self, bd_id, is_set, feature_bitmap):
430 """Enable/disable required feature of the bridge domain with defined ID.
431
432 :param int bd_id: Bridge domain ID.
433 :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
434 :param int feature_bitmap: Bitmap value of the feature to be set:
435 - learn (1 << 0),
436 - forward (1 << 1),
437 - flood (1 << 2),
438 - uu-flood (1 << 3) or
439 - arp-term (1 << 4).
440 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100441 return self.api(self.papi.bridge_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200442 {'bd_id': bd_id,
443 'is_set': is_set,
444 'feature_bitmap': feature_bitmap})
Jan00dad122016-11-29 10:04:53 +0100445
446 def bridge_domain_dump(self, bd_id=0):
447 """
448
449 :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
450 existing bridge domains returned)
451 :return: Dictionary of bridge domain(s) data.
452 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100453 return self.api(self.papi.bridge_domain_dump,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200454 {'bd_id': bd_id})
Jan00dad122016-11-29 10:04:53 +0100455
Klement Sekeraf62ae122016-10-11 11:47:09 +0200456 def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
457 enable):
458 """Create or delete unidirectional cross-connect from Tx interface to
459 Rx interface.
460
Jan4af521d2016-11-15 17:05:00 +0100461 :param int rx_sw_if_index: Software interface index of Rx interface.
462 :param int tx_sw_if_index: Software interface index of Tx interface.
463 :param int enable: Create cross-connect if equal to 1, delete
464 cross-connect if equal to 0.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200465
466 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100467 return self.api(self.papi.sw_interface_set_l2_xconnect,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200468 {'rx_sw_if_index': rx_sw_if_index,
469 'tx_sw_if_index': tx_sw_if_index,
470 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200471
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200472 def sw_interface_set_l2_tag_rewrite(
473 self,
474 sw_if_index,
475 vtr_oper,
476 push=0,
477 tag1=0,
478 tag2=0):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000479 """L2 interface vlan tag rewrite configure request
480 :param client_index - opaque cookie to identify the sender
481 :param context - sender context, to match reply w/ request
482 :param sw_if_index - interface the operation is applied to
483 :param vtr_op - Choose from l2_vtr_op_t enum values
484 :param push_dot1q - first pushed flag dot1q id set, else dot1ad
485 :param tag1 - Needed for any push or translate vtr op
486 :param tag2 - Needed for any push 2 or translate x-2 vtr ops
487
488 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100489 return self.api(self.papi.l2_interface_vlan_tag_rewrite,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200490 {'sw_if_index': sw_if_index,
491 'vtr_op': vtr_oper,
492 'push_dot1q': push,
493 'tag1': tag1,
494 'tag2': tag2})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000495
Klement Sekeraf62ae122016-10-11 11:47:09 +0200496 def sw_interface_set_flags(self, sw_if_index, admin_up_down,
497 link_up_down=0, deleted=0):
498 """
499
500 :param admin_up_down:
501 :param sw_if_index:
502 :param link_up_down: (Default value = 0)
503 :param deleted: (Default value = 0)
504
505 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100506 return self.api(self.papi.sw_interface_set_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200507 {'sw_if_index': sw_if_index,
508 'admin_up_down': admin_up_down,
509 'link_up_down': link_up_down,
510 'deleted': deleted})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200511
512 def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
513 no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
514 default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):
515 """Create subinterface
516 from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
517
518 :param sub_id: param inner_vlan:
519 :param sw_if_index:
520 :param outer_vlan:
521 :param inner_vlan:
522 :param no_tags: (Default value = 0)
523 :param one_tag: (Default value = 0)
524 :param two_tags: (Default value = 0)
525 :param dot1ad: (Default value = 0)
526 :param exact_match: (Default value = 0)
527 :param default_sub: (Default value = 0)
528 :param outer_vlan_id_any: (Default value = 0)
529 :param inner_vlan_id_any: (Default value = 0)
530
531 """
532 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100533 self.papi.create_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200534 {'sw_if_index': sw_if_index,
535 'sub_id': sub_id,
536 'no_tags': no_tags,
537 'one_tag': one_tag,
538 'two_tags': two_tags,
539 'dot1ad': dot1ad,
540 'exact_match': exact_match,
541 'default_sub': default_sub,
542 'outer_vlan_id_any': outer_vlan_id_any,
543 'inner_vlan_id_any': inner_vlan_id_any,
544 'outer_vlan_id': outer_vlan,
545 'inner_vlan_id': inner_vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200546
Neale Ranns177bbdc2016-11-15 09:46:51 +0000547 def delete_subif(self, sw_if_index):
548 """Delete subinterface
549
550 :param sw_if_index:
551 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100552 return self.api(self.papi.delete_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200553 {'sw_if_index': sw_if_index})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000554
Klement Sekeraf62ae122016-10-11 11:47:09 +0200555 def create_vlan_subif(self, sw_if_index, vlan):
556 """
557
558 :param vlan:
559 :param sw_if_index:
560
561 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100562 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200563 {'sw_if_index': sw_if_index,
564 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200565
Matej Klotton0178d522016-11-04 11:11:44 +0100566 def create_loopback(self, mac=''):
567 """
568
569 :param mac: (Optional)
570 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100571 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200572 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100573
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100574 def delete_loopback(self, sw_if_index):
575 return self.api(self.papi.delete_loopback,
576 {'sw_if_index': sw_if_index, })
577
Klement Sekeraf62ae122016-10-11 11:47:09 +0200578 def ip_add_del_route(
579 self,
580 dst_address,
581 dst_address_length,
582 next_hop_address,
583 next_hop_sw_if_index=0xFFFFFFFF,
584 table_id=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200585 next_hop_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000586 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200587 next_hop_n_out_labels=0,
588 next_hop_out_label_stack=[],
589 next_hop_via_label=MPLS_LABEL_INVALID,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200590 create_vrf_if_needed=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000591 is_resolve_host=0,
592 is_resolve_attached=0,
593 classify_table_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200594 is_add=1,
595 is_drop=0,
Juraj Sloboda86a2c572016-10-27 10:44:25 +0200596 is_unreach=0,
597 is_prohibit=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200598 is_ipv6=0,
599 is_local=0,
600 is_classify=0,
601 is_multipath=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000602 not_last=0):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200603 """
604
605 :param dst_address_length:
606 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
607 :param dst_address:
608 :param next_hop_address:
609 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
610 :param vrf_id: (Default value = 0)
611 :param lookup_in_vrf: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200612 :param classify_table_index: (Default value = 0xFFFFFFFF)
613 :param create_vrf_if_needed: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200614 :param is_add: (Default value = 1)
615 :param is_drop: (Default value = 0)
616 :param is_ipv6: (Default value = 0)
617 :param is_local: (Default value = 0)
618 :param is_classify: (Default value = 0)
619 :param is_multipath: (Default value = 0)
620 :param is_resolve_host: (Default value = 0)
621 :param is_resolve_attached: (Default value = 0)
622 :param not_last: (Default value = 0)
623 :param next_hop_weight: (Default value = 1)
624
625 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000626
Klement Sekeraf62ae122016-10-11 11:47:09 +0200627 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100628 self.papi.ip_add_del_route,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200629 {'next_hop_sw_if_index': next_hop_sw_if_index,
630 'table_id': table_id,
631 'classify_table_index': classify_table_index,
632 'next_hop_table_id': next_hop_table_id,
633 'create_vrf_if_needed': create_vrf_if_needed,
634 'is_add': is_add,
635 'is_drop': is_drop,
636 'is_unreach': is_unreach,
637 'is_prohibit': is_prohibit,
638 'is_ipv6': is_ipv6,
639 'is_local': is_local,
640 'is_classify': is_classify,
641 'is_multipath': is_multipath,
642 'is_resolve_host': is_resolve_host,
643 'is_resolve_attached': is_resolve_attached,
644 'not_last': not_last,
645 'next_hop_weight': next_hop_weight,
646 'dst_address_length': dst_address_length,
647 'dst_address': dst_address,
648 'next_hop_address': next_hop_address,
649 'next_hop_n_out_labels': next_hop_n_out_labels,
650 'next_hop_via_label': next_hop_via_label,
651 'next_hop_out_label_stack': next_hop_out_label_stack})
Matej Klotton0178d522016-11-04 11:11:44 +0100652
Matej Klotton16a14cd2016-12-07 15:09:13 +0100653 def ip_fib_dump(self):
654 return self.api(self.papi.ip_fib_dump, {})
655
Jan Gelety057bb8c2016-12-20 17:32:45 +0100656 def ip6_fib_dump(self):
657 return self.api(self.papi.ip6_fib_dump, {})
658
Matej Klotton0178d522016-11-04 11:11:44 +0100659 def ip_neighbor_add_del(self,
660 sw_if_index,
661 mac_address,
662 dst_address,
Matej Klotton0178d522016-11-04 11:11:44 +0100663 is_add=1,
664 is_ipv6=0,
665 is_static=0,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800666 is_no_adj_fib=0,
Matej Klotton0178d522016-11-04 11:11:44 +0100667 ):
668 """ Add neighbor MAC to IPv4 or IPv6 address.
669
670 :param sw_if_index:
671 :param mac_address:
672 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100673 :param is_add: (Default value = 1)
674 :param is_ipv6: (Default value = 0)
675 :param is_static: (Default value = 0)
Neale Rannsb3b2de72017-03-08 05:17:22 -0800676 :param is_no_adj_fib: (Default value = 0)
Matej Klotton0178d522016-11-04 11:11:44 +0100677 """
678
679 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100680 self.papi.ip_neighbor_add_del,
Neale Rannsbaf2e902017-02-25 04:20:00 -0800681 {'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200682 'is_add': is_add,
683 'is_ipv6': is_ipv6,
684 'is_static': is_static,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800685 'is_no_adj_fib': is_no_adj_fib,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200686 'mac_address': mac_address,
687 'dst_address': dst_address
Ole Troan7e3a8752016-12-05 10:27:09 +0100688 }
Matej Klotton0178d522016-11-04 11:11:44 +0100689 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100690
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800691 def ip_neighbor_dump(self,
692 sw_if_index,
693 is_ipv6=0):
694 """ Return IP neighbor dump.
695
696 :param sw_if_index:
697 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
698 """
699
700 return self.api(
701 self.papi.ip_neighbor_dump,
702 {'is_ipv6': is_ipv6,
703 'sw_if_index': sw_if_index
704 }
705 )
706
707 def proxy_arp_add_del(self,
708 low_address,
709 hi_address,
710 vrf_id=0,
711 is_add=1):
712 """ Config Proxy Arp Range.
713
714 :param low_address: Start address in the rnage to Proxy for
715 :param hi_address: End address in the rnage to Proxy for
716 :param vrf_id: The VRF/table in which to proxy
717 """
718
719 return self.api(
720 self.papi.proxy_arp_add_del,
721 {'vrf_id': vrf_id,
722 'is_add': is_add,
723 'low_address': low_address,
724 'hi_address': hi_address,
725 }
726 )
727
728 def proxy_arp_intfc_enable_disable(self,
729 sw_if_index,
730 is_enable=1):
731 """ Enable/Disable an interface for proxy ARP requests
732
733 :param sw_if_index: Interface
734 :param enable_disable: Enable/Disable
735 """
736
737 return self.api(
738 self.papi.proxy_arp_intfc_enable_disable,
739 {'sw_if_index': sw_if_index,
740 'enable_disable': is_enable
741 }
742 )
743
Jane546d3b2016-12-08 13:10:03 +0100744 def reset_vrf(self,
745 vrf_id,
746 is_ipv6=0,
747 ):
748 """ Reset VRF (remove all routes etc.) request.
749
750 :param int vrf_id: ID of the FIB table / VRF to reset.
751 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
752 """
753
754 return self.api(
755 self.papi.reset_vrf,
756 {'vrf_id': vrf_id,
757 'is_ipv6': is_ipv6,
758 }
759 )
760
761 def reset_fib(self,
762 vrf_id,
763 is_ipv6=0,
764 ):
765 """ Reset VRF (remove all routes etc.) request.
766
767 :param int vrf_id: ID of the FIB table / VRF to reset.
768 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
769 """
770
771 return self.api(
772 self.papi.reset_fib,
773 {'vrf_id': vrf_id,
774 'is_ipv6': is_ipv6,
775 }
776 )
777
778 def ip_dump(self,
779 is_ipv6=0,
780 ):
781 """ Return IP dump.
782
783 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
784 """
785
786 return self.api(
787 self.papi.ip_dump,
788 {'is_ipv6': is_ipv6,
789 }
790 )
791
Klement Sekera7bb873a2016-11-18 07:38:42 +0100792 def sw_interface_span_enable_disable(
Ole Troan399ca1c2016-12-06 23:00:38 +0100793 self, sw_if_index_from, sw_if_index_to, state=1):
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100794 """
795
796 :param sw_if_index_from:
797 :param sw_if_index_to:
Matej Klottondeb69842016-12-09 15:05:46 +0100798 :param state:
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100799 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100800 return self.api(self.papi.sw_interface_span_enable_disable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200801 {'sw_if_index_from': sw_if_index_from,
802 'sw_if_index_to': sw_if_index_to,
803 'state': state})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000804
805 def gre_tunnel_add_del(self,
806 src_address,
807 dst_address,
808 outer_fib_id=0,
809 is_teb=0,
810 is_add=1,
811 is_ip6=0):
812 """ Add a GRE tunnel
813
814 :param src_address:
815 :param dst_address:
816 :param outer_fib_id: (Default value = 0)
817 :param is_add: (Default value = 1)
818 :param is_ipv6: (Default value = 0)
819 :param is_teb: (Default value = 0)
820 """
821
822 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100823 self.papi.gre_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200824 {'is_add': is_add,
825 'is_ipv6': is_ip6,
826 'teb': is_teb,
827 'src_address': src_address,
828 'dst_address': dst_address,
829 'outer_fib_id': outer_fib_id}
Neale Ranns177bbdc2016-11-15 09:46:51 +0000830 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000831
Neale Ranns5a8123b2017-01-26 01:18:23 -0800832 def mpls_fib_dump(self):
833 return self.api(self.papi.mpls_fib_dump, {})
834
Neale Rannsad422ed2016-11-02 14:20:04 +0000835 def mpls_route_add_del(
836 self,
837 label,
838 eos,
839 next_hop_proto_is_ip4,
840 next_hop_address,
841 next_hop_sw_if_index=0xFFFFFFFF,
842 table_id=0,
843 next_hop_table_id=0,
844 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200845 next_hop_n_out_labels=0,
846 next_hop_out_label_stack=[],
847 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000848 create_vrf_if_needed=0,
849 is_resolve_host=0,
850 is_resolve_attached=0,
851 is_add=1,
852 is_drop=0,
853 is_multipath=0,
854 classify_table_index=0xFFFFFFFF,
855 is_classify=0,
856 not_last=0):
857 """
858
859 :param dst_address_length:
860 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
861 :param dst_address:
862 :param next_hop_address:
863 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
864 :param vrf_id: (Default value = 0)
865 :param lookup_in_vrf: (Default value = 0)
866 :param classify_table_index: (Default value = 0xFFFFFFFF)
867 :param create_vrf_if_needed: (Default value = 0)
868 :param is_add: (Default value = 1)
869 :param is_drop: (Default value = 0)
870 :param is_ipv6: (Default value = 0)
871 :param is_local: (Default value = 0)
872 :param is_classify: (Default value = 0)
873 :param is_multipath: (Default value = 0)
874 :param is_resolve_host: (Default value = 0)
875 :param is_resolve_attached: (Default value = 0)
876 :param not_last: (Default value = 0)
877 :param next_hop_weight: (Default value = 1)
878
879 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000880
881 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100882 self.papi.mpls_route_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200883 {'mr_label': label,
884 'mr_eos': eos,
885 'mr_table_id': table_id,
886 'mr_classify_table_index': classify_table_index,
887 'mr_create_table_if_needed': create_vrf_if_needed,
888 'mr_is_add': is_add,
889 'mr_is_classify': is_classify,
890 'mr_is_multipath': is_multipath,
891 'mr_is_resolve_host': is_resolve_host,
892 'mr_is_resolve_attached': is_resolve_attached,
893 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
894 'mr_next_hop_weight': next_hop_weight,
895 'mr_next_hop': next_hop_address,
896 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
897 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
898 'mr_next_hop_table_id': next_hop_table_id,
899 'mr_next_hop_via_label': next_hop_via_label,
900 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
Neale Rannsad422ed2016-11-02 14:20:04 +0000901
902 def mpls_ip_bind_unbind(
903 self,
904 label,
905 dst_address,
906 dst_address_length,
907 table_id=0,
908 ip_table_id=0,
909 is_ip4=1,
910 create_vrf_if_needed=0,
911 is_bind=1):
912 """
913 """
914 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100915 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200916 {'mb_mpls_table_id': table_id,
917 'mb_label': label,
918 'mb_ip_table_id': ip_table_id,
919 'mb_create_table_if_needed': create_vrf_if_needed,
920 'mb_is_bind': is_bind,
921 'mb_is_ip4': is_ip4,
922 'mb_address_length': dst_address_length,
923 'mb_address': dst_address})
Neale Rannsad422ed2016-11-02 14:20:04 +0000924
925 def mpls_tunnel_add_del(
926 self,
927 tun_sw_if_index,
928 next_hop_proto_is_ip4,
929 next_hop_address,
930 next_hop_sw_if_index=0xFFFFFFFF,
931 next_hop_table_id=0,
932 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200933 next_hop_n_out_labels=0,
934 next_hop_out_label_stack=[],
935 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000936 create_vrf_if_needed=0,
937 is_add=1,
938 l2_only=0):
939 """
940
941 :param dst_address_length:
942 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
943 :param dst_address:
944 :param next_hop_address:
945 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
946 :param vrf_id: (Default value = 0)
947 :param lookup_in_vrf: (Default value = 0)
948 :param classify_table_index: (Default value = 0xFFFFFFFF)
949 :param create_vrf_if_needed: (Default value = 0)
950 :param is_add: (Default value = 1)
951 :param is_drop: (Default value = 0)
952 :param is_ipv6: (Default value = 0)
953 :param is_local: (Default value = 0)
954 :param is_classify: (Default value = 0)
955 :param is_multipath: (Default value = 0)
956 :param is_resolve_host: (Default value = 0)
957 :param is_resolve_attached: (Default value = 0)
958 :param not_last: (Default value = 0)
959 :param next_hop_weight: (Default value = 1)
960
961 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000962 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100963 self.papi.mpls_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200964 {'mt_sw_if_index': tun_sw_if_index,
965 'mt_is_add': is_add,
966 'mt_l2_only': l2_only,
967 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
968 'mt_next_hop_weight': next_hop_weight,
969 'mt_next_hop': next_hop_address,
970 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
971 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
972 'mt_next_hop_table_id': next_hop_table_id,
973 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
Matus Fabiande886752016-12-07 03:38:19 -0800974
975 def snat_interface_add_del_feature(
976 self,
977 sw_if_index,
978 is_inside=1,
979 is_add=1):
980 """Enable/disable S-NAT feature on the interface
981
982 :param sw_if_index: Software index of the interface
983 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
984 :param is_add: 1 if add, 0 if delete (Default value = 1)
985 """
986 return self.api(
987 self.papi.snat_interface_add_del_feature,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200988 {'is_add': is_add,
989 'is_inside': is_inside,
990 'sw_if_index': sw_if_index})
Matus Fabiande886752016-12-07 03:38:19 -0800991
992 def snat_add_static_mapping(
993 self,
994 local_ip,
Matus Fabian36532bd2017-01-23 23:42:28 -0800995 external_ip=0,
996 external_sw_if_index=0xFFFFFFFF,
Matus Fabiande886752016-12-07 03:38:19 -0800997 local_port=0,
998 external_port=0,
999 addr_only=1,
1000 vrf_id=0,
Matus Fabian09d96f42017-02-02 01:43:00 -08001001 protocol=0,
Matus Fabiande886752016-12-07 03:38:19 -08001002 is_add=1,
1003 is_ip4=1):
1004 """Add/delete S-NAT static mapping
1005
1006 :param local_ip: Local IP address
1007 :param external_ip: External IP address
Matus Fabian36532bd2017-01-23 23:42:28 -08001008 :param external_sw_if_index: External interface instead of IP address
Matus Fabiande886752016-12-07 03:38:19 -08001009 :param local_port: Local port number (Default value = 0)
1010 :param external_port: External port number (Default value = 0)
1011 :param addr_only: 1 if address only mapping, 0 if address and port
1012 :param vrf_id: VRF ID
Matus Fabian09d96f42017-02-02 01:43:00 -08001013 :param protocol: IP protocol (Default value = 0)
Matus Fabiande886752016-12-07 03:38:19 -08001014 :param is_add: 1 if add, 0 if delete (Default value = 1)
1015 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1016 """
1017 return self.api(
1018 self.papi.snat_add_static_mapping,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001019 {'is_add': is_add,
1020 'is_ip4': is_ip4,
1021 'addr_only': addr_only,
1022 'local_ip_address': local_ip,
1023 'external_ip_address': external_ip,
1024 'local_port': local_port,
1025 'external_port': external_port,
Matus Fabian36532bd2017-01-23 23:42:28 -08001026 'external_sw_if_index': external_sw_if_index,
Matus Fabian09d96f42017-02-02 01:43:00 -08001027 'vrf_id': vrf_id,
1028 'protocol': protocol})
Matus Fabiande886752016-12-07 03:38:19 -08001029
1030 def snat_add_address_range(
1031 self,
1032 first_ip_address,
1033 last_ip_address,
1034 is_add=1,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001035 is_ip4=1,
1036 vrf_id=0xFFFFFFFF):
Matus Fabiande886752016-12-07 03:38:19 -08001037 """Add/del S-NAT address range
1038
1039 :param first_ip_address: First IP address
1040 :param last_ip_address: Last IP address
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001041 :param vrf_id: VRF id for the address range
Matus Fabiande886752016-12-07 03:38:19 -08001042 :param is_add: 1 if add, 0 if delete (Default value = 1)
1043 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1044 """
1045 return self.api(
1046 self.papi.snat_add_address_range,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001047 {'is_ip4': is_ip4,
1048 'first_ip_address': first_ip_address,
1049 'last_ip_address': last_ip_address,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001050 'vrf_id': vrf_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001051 'is_add': is_add})
Matus Fabiande886752016-12-07 03:38:19 -08001052
1053 def snat_address_dump(self):
1054 """Dump S-NAT addresses
1055 :return: Dictionary of S-NAT addresses
1056 """
1057 return self.api(self.papi.snat_address_dump, {})
1058
1059 def snat_interface_dump(self):
1060 """Dump interfaces with S-NAT feature
1061 :return: Dictionary of interfaces with S-NAT feature
1062 """
1063 return self.api(self.papi.snat_interface_dump, {})
1064
1065 def snat_static_mapping_dump(self):
1066 """Dump S-NAT static mappings
1067 :return: Dictionary of S-NAT static mappings
1068 """
1069 return self.api(self.papi.snat_static_mapping_dump, {})
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001070
Matus Fabian9902fcd2016-12-21 23:58:46 -08001071 def snat_show_config(self):
1072 """Show S-NAT config
1073 :return: S-NAT config parameters
1074 """
1075 return self.api(self.papi.snat_show_config, {})
1076
Matus Fabian8bf68e82017-01-12 04:24:35 -08001077 def snat_add_interface_addr(
1078 self,
1079 sw_if_index,
1080 is_add=1):
1081 """Add/del S-NAT address from interface
1082
1083 :param sw_if_index: Software index of the interface
1084 :param is_add: 1 if add, 0 if delete (Default value = 1)
1085 """
1086 return self.api(self.papi.snat_add_del_interface_addr,
1087 {'is_add': is_add, 'sw_if_index': sw_if_index})
1088
1089 def snat_interface_addr_dump(self):
1090 """Dump S-NAT addresses interfaces
1091 :return: Dictionary of S-NAT addresses interfaces
1092 """
1093 return self.api(self.papi.snat_interface_addr_dump, {})
1094
Matus Fabianeea28d72017-01-13 04:15:54 -08001095 def snat_ipfix(
1096 self,
1097 domain_id=1,
1098 src_port=4739,
1099 enable=1):
1100 """Enable/disable S-NAT IPFIX logging
1101
1102 :param domain_id: Observation domain ID (Default value = 1)
1103 :param src_port: Source port number (Default value = 4739)
1104 :param enable: 1 if enable, 0 if disable (Default value = 1)
1105 """
1106 return self.api(
1107 self.papi.snat_ipfix_enable_disable,
1108 {'domain_id': domain_id,
1109 'src_port': src_port,
1110 'enable': enable})
1111
magalik23caa882017-02-08 23:25:45 -08001112 def snat_user_session_dump(
1113 self,
1114 ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001115 vrf_id,
1116 is_ip4=1):
magalik23caa882017-02-08 23:25:45 -08001117 """Dump S-NAT user's sessions
1118
1119 :param ip_address: ip adress of the user to be dumped
1120 :param cpu_index: cpu_index on which the user is
1121 :param vrf_id: VRF ID
1122 :return: Dictionary of S-NAT sessions
1123 """
1124 return self.api(
1125 self.papi.snat_user_session_dump,
1126 {'ip_address': ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001127 'vrf_id': vrf_id,
1128 'is_ip4': is_ip4})
magalik23caa882017-02-08 23:25:45 -08001129
1130 def snat_user_dump(self):
1131 """Dump S-NAT users
1132
1133 :return: Dictionary of S-NAT users
1134 """
1135 return self.api(self.papi.snat_user_dump, {})
1136
Matus Fabian066f0342017-02-10 03:48:01 -08001137 def snat_add_det_map(
1138 self,
1139 in_addr,
1140 in_plen,
1141 out_addr,
1142 out_plen,
1143 is_add=1):
1144 """Add/delete S-NAT deterministic mapping
1145
1146 :param is_add - 1 if add, 0 if delete
1147 :param in_addr - inside IP address
1148 :param in_plen - inside IP address prefix length
1149 :param out_addr - outside IP address
1150 :param out_plen - outside IP address prefix length
1151 """
1152 return self.api(
1153 self.papi.snat_add_det_map,
1154 {'is_add': is_add,
1155 'in_addr': in_addr,
1156 'in_plen': in_plen,
1157 'out_addr': out_addr,
1158 'out_plen': out_plen})
1159
1160 def snat_det_forward(
1161 self,
1162 in_addr):
1163 """Get outside address and port range from inside address
1164
1165 :param in_addr - inside IP address
1166 """
1167 return self.api(
1168 self.papi.snat_det_forward,
1169 {'in_addr': in_addr})
1170
1171 def snat_det_reverse(
1172 self,
1173 out_addr,
1174 out_port):
1175 """Get inside address from outside address and port
1176
1177 :param out_addr - outside IP address
1178 :param out_port - outside port
1179 """
1180 return self.api(
1181 self.papi.snat_det_reverse,
1182 {'out_addr': out_addr,
1183 'out_port': out_port})
1184
Martin17a75cb2017-03-08 05:53:20 -08001185 def snat_det_map_dump(self):
1186 """Dump S-NAT deterministic mappings
1187
1188 :return: Dictionary of S-NAT deterministic mappings
1189 """
1190 return self.api(self.papi.snat_det_map_dump, {})
1191
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001192 def control_ping(self):
1193 self.api(self.papi.control_ping)
1194
1195 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
Klement Sekerab17dd962017-01-09 07:43:48 +01001196 detect_mult, local_addr, peer_addr, is_ipv6=0,
1197 bfd_key_id=None, conf_key_id=None):
1198 if bfd_key_id is None:
1199 return self.api(self.papi.bfd_udp_add,
1200 {
1201 'sw_if_index': sw_if_index,
1202 'desired_min_tx': desired_min_tx,
1203 'required_min_rx': required_min_rx,
1204 'local_addr': local_addr,
1205 'peer_addr': peer_addr,
1206 'is_ipv6': is_ipv6,
1207 'detect_mult': detect_mult,
1208 })
1209 else:
1210 return self.api(self.papi.bfd_udp_add,
1211 {
1212 'sw_if_index': sw_if_index,
1213 'desired_min_tx': desired_min_tx,
1214 'required_min_rx': required_min_rx,
1215 'local_addr': local_addr,
1216 'peer_addr': peer_addr,
1217 'is_ipv6': is_ipv6,
1218 'detect_mult': detect_mult,
1219 'is_authenticated': 1,
1220 'bfd_key_id': bfd_key_id,
1221 'conf_key_id': conf_key_id,
1222 })
1223
Klement Sekeraa57a9702017-02-02 06:58:07 +01001224 def bfd_udp_mod(self, sw_if_index, desired_min_tx, required_min_rx,
1225 detect_mult, local_addr, peer_addr, is_ipv6=0):
1226 return self.api(self.papi.bfd_udp_mod,
1227 {
1228 'sw_if_index': sw_if_index,
1229 'desired_min_tx': desired_min_tx,
1230 'required_min_rx': required_min_rx,
1231 'local_addr': local_addr,
1232 'peer_addr': peer_addr,
1233 'is_ipv6': is_ipv6,
1234 'detect_mult': detect_mult,
1235 })
1236
Klement Sekerab17dd962017-01-09 07:43:48 +01001237 def bfd_udp_auth_activate(self, sw_if_index, local_addr, peer_addr,
1238 is_ipv6=0, bfd_key_id=None, conf_key_id=None,
1239 is_delayed=False):
1240 return self.api(self.papi.bfd_udp_auth_activate,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001241 {
1242 'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001243 'local_addr': local_addr,
1244 'peer_addr': peer_addr,
1245 'is_ipv6': is_ipv6,
Klement Sekerab17dd962017-01-09 07:43:48 +01001246 'is_delayed': 1 if is_delayed else 0,
1247 'bfd_key_id': bfd_key_id,
1248 'conf_key_id': conf_key_id,
1249 })
1250
1251 def bfd_udp_auth_deactivate(self, sw_if_index, local_addr, peer_addr,
1252 is_ipv6=0, is_delayed=False):
1253 return self.api(self.papi.bfd_udp_auth_deactivate,
1254 {
1255 'sw_if_index': sw_if_index,
1256 'local_addr': local_addr,
1257 'peer_addr': peer_addr,
1258 'is_ipv6': is_ipv6,
1259 'is_delayed': 1 if is_delayed else 0,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001260 })
1261
1262 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
1263 return self.api(self.papi.bfd_udp_del,
1264 {
1265 'sw_if_index': sw_if_index,
1266 'local_addr': local_addr,
1267 'peer_addr': peer_addr,
1268 'is_ipv6': is_ipv6,
1269 })
1270
1271 def bfd_udp_session_dump(self):
1272 return self.api(self.papi.bfd_udp_session_dump, {})
1273
Klement Sekerab17dd962017-01-09 07:43:48 +01001274 def bfd_udp_session_set_flags(self, admin_up_down, sw_if_index, local_addr,
1275 peer_addr, is_ipv6=0):
1276 return self.api(self.papi.bfd_udp_session_set_flags, {
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001277 'admin_up_down': admin_up_down,
Klement Sekerab17dd962017-01-09 07:43:48 +01001278 'sw_if_index': sw_if_index,
1279 'local_addr': local_addr,
1280 'peer_addr': peer_addr,
1281 'is_ipv6': is_ipv6,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001282 })
1283
1284 def want_bfd_events(self, enable_disable=1):
1285 return self.api(self.papi.want_bfd_events, {
1286 'enable_disable': enable_disable,
1287 'pid': os.getpid(),
1288 })
Steve Shin7957d6e2016-12-19 09:24:50 -08001289
Klement Sekerab17dd962017-01-09 07:43:48 +01001290 def bfd_auth_set_key(self, conf_key_id, auth_type, key):
1291 return self.api(self.papi.bfd_auth_set_key, {
1292 'conf_key_id': conf_key_id,
1293 'auth_type': auth_type,
1294 'key': key,
1295 'key_len': len(key),
1296 })
1297
1298 def bfd_auth_del_key(self, conf_key_id):
1299 return self.api(self.papi.bfd_auth_del_key, {
1300 'conf_key_id': conf_key_id,
1301 })
1302
1303 def bfd_auth_keys_dump(self):
1304 return self.api(self.papi.bfd_auth_keys_dump, {})
1305
Klement Sekera239790f2017-02-16 10:53:53 +01001306 def bfd_udp_set_echo_source(self, sw_if_index):
1307 return self.api(self.papi.bfd_udp_set_echo_source,
1308 {'sw_if_index': sw_if_index})
1309
Klement Sekera73884482017-02-23 09:26:30 +01001310 def bfd_udp_del_echo_source(self):
1311 return self.api(self.papi.bfd_udp_del_echo_source, {})
1312
Steve Shin7957d6e2016-12-19 09:24:50 -08001313 def classify_add_del_table(
1314 self,
1315 is_add,
1316 mask,
1317 match_n_vectors=1,
1318 table_index=0xFFFFFFFF,
1319 nbuckets=2,
1320 memory_size=2097152,
1321 skip_n_vectors=0,
1322 next_table_index=0xFFFFFFFF,
1323 miss_next_index=0xFFFFFFFF,
1324 current_data_flag=0,
1325 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -08001326 """
1327 :param is_add:
1328 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +01001329 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +01001330 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -08001331 :param nbuckets: (Default value = 2)
1332 :param memory_size: (Default value = 2097152)
1333 :param skip_n_vectors: (Default value = 0)
1334 :param next_table_index: (Default value = 0xFFFFFFFF)
1335 :param miss_next_index: (Default value = 0xFFFFFFFF)
1336 :param current_data_flag: (Default value = 0)
1337 :param current_data_offset: (Default value = 0)
1338 """
1339
1340 return self.api(
1341 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001342 {'is_add': is_add,
1343 'table_index': table_index,
1344 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -08001345 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001346 'skip_n_vectors': skip_n_vectors,
1347 'match_n_vectors': match_n_vectors,
1348 'next_table_index': next_table_index,
1349 'miss_next_index': miss_next_index,
1350 'current_data_flag': current_data_flag,
1351 'current_data_offset': current_data_offset,
1352 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -08001353
1354 def classify_add_del_session(
1355 self,
1356 is_add,
1357 table_index,
1358 match,
1359 opaque_index=0xFFFFFFFF,
1360 hit_next_index=0xFFFFFFFF,
1361 advance=0,
1362 action=0,
1363 metadata=0):
1364 """
1365 :param is_add:
1366 :param table_index:
1367 :param match:
1368 :param opaque_index: (Default value = 0xFFFFFFFF)
1369 :param hit_next_index: (Default value = 0xFFFFFFFF)
1370 :param advance: (Default value = 0)
1371 :param action: (Default value = 0)
1372 :param metadata: (Default value = 0)
1373 """
1374
1375 return self.api(
1376 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001377 {'is_add': is_add,
1378 'table_index': table_index,
1379 'hit_next_index': hit_next_index,
1380 'opaque_index': opaque_index,
1381 'advance': advance,
1382 'action': action,
1383 'metadata': metadata,
1384 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -08001385
1386 def input_acl_set_interface(
1387 self,
1388 is_add,
1389 sw_if_index,
1390 ip4_table_index=0xFFFFFFFF,
1391 ip6_table_index=0xFFFFFFFF,
1392 l2_table_index=0xFFFFFFFF):
1393 """
1394 :param is_add:
1395 :param sw_if_index:
1396 :param ip4_table_index: (Default value = 0xFFFFFFFF)
1397 :param ip6_table_index: (Default value = 0xFFFFFFFF)
1398 :param l2_table_index: (Default value = 0xFFFFFFFF)
1399 """
1400
1401 return self.api(
1402 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001403 {'sw_if_index': sw_if_index,
1404 'ip4_table_index': ip4_table_index,
1405 'ip6_table_index': ip6_table_index,
1406 'l2_table_index': l2_table_index,
1407 'is_add': is_add})
1408
1409 def set_ipfix_exporter(
1410 self,
1411 collector_address,
1412 src_address,
1413 path_mtu,
1414 template_interval,
1415 vrf_id=0,
1416 collector_port=4739,
1417 udp_checksum=0):
1418 return self.api(
1419 self.papi.set_ipfix_exporter,
1420 {
1421 'collector_address': collector_address,
1422 'collector_port': collector_port,
1423 'src_address': src_address,
1424 'vrf_id': vrf_id,
1425 'path_mtu': path_mtu,
1426 'template_interval': template_interval,
1427 'udp_checksum': udp_checksum,
1428 })
Neale Rannsfca0c242017-01-13 07:57:46 -08001429
1430 def dhcp_proxy_config(self,
1431 dhcp_server,
1432 dhcp_src_address,
1433 rx_table_id=0,
1434 server_table_id=0,
1435 is_add=1,
Neale Ranns20a175a2017-02-14 07:28:41 -08001436 is_ipv6=0):
Neale Rannsfca0c242017-01-13 07:57:46 -08001437 return self.api(
Neale Ranns20a175a2017-02-14 07:28:41 -08001438 self.papi.dhcp_proxy_config,
Neale Rannsfca0c242017-01-13 07:57:46 -08001439 {
1440 'rx_vrf_id': rx_table_id,
1441 'server_vrf_id': server_table_id,
1442 'is_ipv6': is_ipv6,
1443 'is_add': is_add,
Neale Rannsfca0c242017-01-13 07:57:46 -08001444 'dhcp_server': dhcp_server,
1445 'dhcp_src_address': dhcp_src_address,
1446 })
1447
1448 def dhcp_proxy_set_vss(self,
1449 table_id,
1450 fib_id,
1451 oui,
1452 is_add=1,
1453 is_ip6=0):
1454 return self.api(
1455 self.papi.dhcp_proxy_set_vss,
1456 {
1457 'tbl_id': table_id,
1458 'fib_id': fib_id,
1459 'is_ipv6': is_ip6,
1460 'is_add': is_add,
1461 'oui': oui,
1462 })
Neale Ranns32e1c012016-11-22 17:07:28 +00001463
1464 def ip_mroute_add_del(self,
1465 src_address,
1466 grp_address,
1467 grp_address_length,
1468 e_flags,
1469 next_hop_sw_if_index,
1470 i_flags,
1471 table_id=0,
1472 create_vrf_if_needed=0,
1473 is_add=1,
1474 is_ipv6=0,
1475 is_local=0):
1476 """
1477 """
1478 return self.api(
1479 self.papi.ip_mroute_add_del,
1480 {'next_hop_sw_if_index': next_hop_sw_if_index,
1481 'entry_flags': e_flags,
1482 'itf_flags': i_flags,
1483 'create_vrf_if_needed': create_vrf_if_needed,
1484 'is_add': is_add,
1485 'is_ipv6': is_ipv6,
1486 'is_local': is_local,
1487 'grp_address_length': grp_address_length,
1488 'grp_address': grp_address,
1489 'src_address': src_address})
1490
1491 def mfib_signal_dump(self):
1492 return self.api(self.papi.mfib_signal_dump, {})
Neale Ranns5a8123b2017-01-26 01:18:23 -08001493
1494 def ip_mfib_dump(self):
1495 return self.api(self.papi.ip_mfib_dump, {})
Filip Tehlar770e89e2017-01-31 10:39:16 +01001496
1497 def lisp_enable_disable(self, is_enabled):
1498 return self.api(
1499 self.papi.lisp_enable_disable,
1500 {
1501 'is_en': is_enabled,
1502 })
1503
1504 def lisp_locator_set(self,
1505 ls_name,
1506 is_add=1):
1507 return self.api(
1508 self.papi.lisp_add_del_locator_set,
1509 {
1510 'is_add': is_add,
1511 'locator_set_name': ls_name
1512 })
1513
1514 def lisp_locator_set_dump(self):
1515 return self.api(self.papi.lisp_locator_set_dump, {})
1516
1517 def lisp_locator(self,
1518 ls_name,
1519 sw_if_index,
1520 priority=1,
1521 weight=1,
1522 is_add=1):
1523 return self.api(
1524 self.papi.lisp_add_del_locator,
1525 {
1526 'is_add': is_add,
1527 'locator_set_name': ls_name,
1528 'sw_if_index': sw_if_index,
1529 'priority': priority,
1530 'weight': weight
1531 })
1532
1533 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
1534 return self.api(
1535 self.papi.lisp_locator_dump,
1536 {
1537 'is_index_set': is_index_set,
1538 'ls_name': ls_name,
1539 'ls_index': ls_index,
1540 })
1541
1542 def lisp_local_mapping(self,
1543 ls_name,
1544 eid_type,
1545 eid,
1546 prefix_len,
1547 vni=0,
1548 key_id=0,
1549 key="",
1550 is_add=1):
1551 return self.api(
1552 self.papi.lisp_add_del_local_eid,
1553 {
1554 'locator_set_name': ls_name,
1555 'is_add': is_add,
1556 'eid_type': eid_type,
1557 'eid': eid,
1558 'prefix_len': prefix_len,
1559 'vni': vni,
1560 'key_id': key_id,
1561 'key': key
1562 })
1563
1564 def lisp_eid_table_dump(self,
1565 eid_set=0,
1566 prefix_length=0,
1567 vni=0,
1568 eid_type=0,
1569 eid=None,
1570 filter_opt=0):
1571 return self.api(
1572 self.papi.lisp_eid_table_dump,
1573 {
1574 'eid_set': eid_set,
1575 'prefix_length': prefix_length,
1576 'vni': vni,
1577 'eid_type': eid_type,
1578 'eid': eid,
1579 'filter': filter_opt,
1580 })
1581
1582 def lisp_remote_mapping(self,
1583 eid_type,
1584 eid,
1585 eid_prefix_len=0,
1586 vni=0,
1587 rlocs=None,
1588 rlocs_num=0,
1589 is_src_dst=0,
1590 is_add=1):
1591 return self.api(
1592 self.papi.lisp_add_del_remote_mapping,
1593 {
1594 'is_add': is_add,
1595 'eid_type': eid_type,
1596 'eid': eid,
1597 'eid_len': eid_prefix_len,
1598 'rloc_num': rlocs_num,
1599 'rlocs': rlocs,
1600 'vni': vni,
1601 'is_src_dst': is_src_dst,
1602 })
1603
1604 def lisp_adjacency(self,
1605 leid,
1606 reid,
1607 leid_len,
1608 reid_len,
1609 eid_type,
1610 is_add=1,
1611 vni=0):
1612 return self.api(
1613 self.papi.lisp_add_del_adjacency,
1614 {
1615 'is_add': is_add,
1616 'vni': vni,
1617 'eid_type': eid_type,
1618 'leid': leid,
1619 'reid': reid,
1620 'leid_len': leid_len,
1621 'reid_len': reid_len,
1622 })
1623
1624 def lisp_adjacencies_get(self, vni=0):
1625 return self.api(
1626 self.papi.lisp_adjacencies_get,
1627 {
1628 'vni': vni
1629 })
Neale Ranns80823802017-02-20 18:23:41 -08001630
1631 def map_add_domain(self,
1632 ip6_prefix,
1633 ip6_prefix_len,
1634 ip6_src,
1635 ip6_src_prefix_len,
1636 ip4_prefix,
1637 ip4_prefix_len,
1638 ea_bits_len=0,
1639 psid_offset=0,
1640 psid_length=0,
1641 is_translation=0,
1642 mtu=1280):
1643 return self.api(
1644 self.papi.map_add_domain,
1645 {
1646 'ip6_prefix': ip6_prefix,
1647 'ip6_prefix_len': ip6_prefix_len,
1648 'ip4_prefix': ip4_prefix,
1649 'ip4_prefix_len': ip4_prefix_len,
1650 'ip6_src': ip6_src,
1651 'ip6_src_prefix_len': ip6_src_prefix_len,
1652 'ea_bits_len': ea_bits_len,
1653 'psid_offset': psid_offset,
1654 'psid_length': psid_length,
1655 'is_translation': is_translation,
1656 'mtu': mtu
1657 })