blob: 92070424be9ba03cf8de28619e1485a44a174711 [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
Klement Sekera7112c542017-03-01 09:53:19 +010058 self.vpp = VPP(jsonfiles)
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,
666 ):
667 """ Add neighbor MAC to IPv4 or IPv6 address.
668
669 :param sw_if_index:
670 :param mac_address:
671 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100672 :param is_add: (Default value = 1)
673 :param is_ipv6: (Default value = 0)
674 :param is_static: (Default value = 0)
675 """
676
677 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100678 self.papi.ip_neighbor_add_del,
Neale Rannsbaf2e902017-02-25 04:20:00 -0800679 {'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200680 'is_add': is_add,
681 'is_ipv6': is_ipv6,
682 'is_static': is_static,
683 'mac_address': mac_address,
684 'dst_address': dst_address
Ole Troan7e3a8752016-12-05 10:27:09 +0100685 }
Matej Klotton0178d522016-11-04 11:11:44 +0100686 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100687
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800688 def ip_neighbor_dump(self,
689 sw_if_index,
690 is_ipv6=0):
691 """ Return IP neighbor dump.
692
693 :param sw_if_index:
694 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
695 """
696
697 return self.api(
698 self.papi.ip_neighbor_dump,
699 {'is_ipv6': is_ipv6,
700 'sw_if_index': sw_if_index
701 }
702 )
703
704 def proxy_arp_add_del(self,
705 low_address,
706 hi_address,
707 vrf_id=0,
708 is_add=1):
709 """ Config Proxy Arp Range.
710
711 :param low_address: Start address in the rnage to Proxy for
712 :param hi_address: End address in the rnage to Proxy for
713 :param vrf_id: The VRF/table in which to proxy
714 """
715
716 return self.api(
717 self.papi.proxy_arp_add_del,
718 {'vrf_id': vrf_id,
719 'is_add': is_add,
720 'low_address': low_address,
721 'hi_address': hi_address,
722 }
723 )
724
725 def proxy_arp_intfc_enable_disable(self,
726 sw_if_index,
727 is_enable=1):
728 """ Enable/Disable an interface for proxy ARP requests
729
730 :param sw_if_index: Interface
731 :param enable_disable: Enable/Disable
732 """
733
734 return self.api(
735 self.papi.proxy_arp_intfc_enable_disable,
736 {'sw_if_index': sw_if_index,
737 'enable_disable': is_enable
738 }
739 )
740
Jane546d3b2016-12-08 13:10:03 +0100741 def reset_vrf(self,
742 vrf_id,
743 is_ipv6=0,
744 ):
745 """ Reset VRF (remove all routes etc.) request.
746
747 :param int vrf_id: ID of the FIB table / VRF to reset.
748 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
749 """
750
751 return self.api(
752 self.papi.reset_vrf,
753 {'vrf_id': vrf_id,
754 'is_ipv6': is_ipv6,
755 }
756 )
757
758 def reset_fib(self,
759 vrf_id,
760 is_ipv6=0,
761 ):
762 """ Reset VRF (remove all routes etc.) request.
763
764 :param int vrf_id: ID of the FIB table / VRF to reset.
765 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
766 """
767
768 return self.api(
769 self.papi.reset_fib,
770 {'vrf_id': vrf_id,
771 'is_ipv6': is_ipv6,
772 }
773 )
774
775 def ip_dump(self,
776 is_ipv6=0,
777 ):
778 """ Return IP dump.
779
780 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
781 """
782
783 return self.api(
784 self.papi.ip_dump,
785 {'is_ipv6': is_ipv6,
786 }
787 )
788
Klement Sekera7bb873a2016-11-18 07:38:42 +0100789 def sw_interface_span_enable_disable(
Ole Troan399ca1c2016-12-06 23:00:38 +0100790 self, sw_if_index_from, sw_if_index_to, state=1):
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100791 """
792
793 :param sw_if_index_from:
794 :param sw_if_index_to:
Matej Klottondeb69842016-12-09 15:05:46 +0100795 :param state:
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100796 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100797 return self.api(self.papi.sw_interface_span_enable_disable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200798 {'sw_if_index_from': sw_if_index_from,
799 'sw_if_index_to': sw_if_index_to,
800 'state': state})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000801
802 def gre_tunnel_add_del(self,
803 src_address,
804 dst_address,
805 outer_fib_id=0,
806 is_teb=0,
807 is_add=1,
808 is_ip6=0):
809 """ Add a GRE tunnel
810
811 :param src_address:
812 :param dst_address:
813 :param outer_fib_id: (Default value = 0)
814 :param is_add: (Default value = 1)
815 :param is_ipv6: (Default value = 0)
816 :param is_teb: (Default value = 0)
817 """
818
819 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100820 self.papi.gre_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200821 {'is_add': is_add,
822 'is_ipv6': is_ip6,
823 'teb': is_teb,
824 'src_address': src_address,
825 'dst_address': dst_address,
826 'outer_fib_id': outer_fib_id}
Neale Ranns177bbdc2016-11-15 09:46:51 +0000827 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000828
Neale Ranns5a8123b2017-01-26 01:18:23 -0800829 def mpls_fib_dump(self):
830 return self.api(self.papi.mpls_fib_dump, {})
831
Neale Rannsad422ed2016-11-02 14:20:04 +0000832 def mpls_route_add_del(
833 self,
834 label,
835 eos,
836 next_hop_proto_is_ip4,
837 next_hop_address,
838 next_hop_sw_if_index=0xFFFFFFFF,
839 table_id=0,
840 next_hop_table_id=0,
841 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200842 next_hop_n_out_labels=0,
843 next_hop_out_label_stack=[],
844 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000845 create_vrf_if_needed=0,
846 is_resolve_host=0,
847 is_resolve_attached=0,
848 is_add=1,
849 is_drop=0,
850 is_multipath=0,
851 classify_table_index=0xFFFFFFFF,
852 is_classify=0,
853 not_last=0):
854 """
855
856 :param dst_address_length:
857 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
858 :param dst_address:
859 :param next_hop_address:
860 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
861 :param vrf_id: (Default value = 0)
862 :param lookup_in_vrf: (Default value = 0)
863 :param classify_table_index: (Default value = 0xFFFFFFFF)
864 :param create_vrf_if_needed: (Default value = 0)
865 :param is_add: (Default value = 1)
866 :param is_drop: (Default value = 0)
867 :param is_ipv6: (Default value = 0)
868 :param is_local: (Default value = 0)
869 :param is_classify: (Default value = 0)
870 :param is_multipath: (Default value = 0)
871 :param is_resolve_host: (Default value = 0)
872 :param is_resolve_attached: (Default value = 0)
873 :param not_last: (Default value = 0)
874 :param next_hop_weight: (Default value = 1)
875
876 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000877
878 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100879 self.papi.mpls_route_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200880 {'mr_label': label,
881 'mr_eos': eos,
882 'mr_table_id': table_id,
883 'mr_classify_table_index': classify_table_index,
884 'mr_create_table_if_needed': create_vrf_if_needed,
885 'mr_is_add': is_add,
886 'mr_is_classify': is_classify,
887 'mr_is_multipath': is_multipath,
888 'mr_is_resolve_host': is_resolve_host,
889 'mr_is_resolve_attached': is_resolve_attached,
890 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
891 'mr_next_hop_weight': next_hop_weight,
892 'mr_next_hop': next_hop_address,
893 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
894 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
895 'mr_next_hop_table_id': next_hop_table_id,
896 'mr_next_hop_via_label': next_hop_via_label,
897 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
Neale Rannsad422ed2016-11-02 14:20:04 +0000898
899 def mpls_ip_bind_unbind(
900 self,
901 label,
902 dst_address,
903 dst_address_length,
904 table_id=0,
905 ip_table_id=0,
906 is_ip4=1,
907 create_vrf_if_needed=0,
908 is_bind=1):
909 """
910 """
911 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100912 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200913 {'mb_mpls_table_id': table_id,
914 'mb_label': label,
915 'mb_ip_table_id': ip_table_id,
916 'mb_create_table_if_needed': create_vrf_if_needed,
917 'mb_is_bind': is_bind,
918 'mb_is_ip4': is_ip4,
919 'mb_address_length': dst_address_length,
920 'mb_address': dst_address})
Neale Rannsad422ed2016-11-02 14:20:04 +0000921
922 def mpls_tunnel_add_del(
923 self,
924 tun_sw_if_index,
925 next_hop_proto_is_ip4,
926 next_hop_address,
927 next_hop_sw_if_index=0xFFFFFFFF,
928 next_hop_table_id=0,
929 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200930 next_hop_n_out_labels=0,
931 next_hop_out_label_stack=[],
932 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000933 create_vrf_if_needed=0,
934 is_add=1,
935 l2_only=0):
936 """
937
938 :param dst_address_length:
939 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
940 :param dst_address:
941 :param next_hop_address:
942 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
943 :param vrf_id: (Default value = 0)
944 :param lookup_in_vrf: (Default value = 0)
945 :param classify_table_index: (Default value = 0xFFFFFFFF)
946 :param create_vrf_if_needed: (Default value = 0)
947 :param is_add: (Default value = 1)
948 :param is_drop: (Default value = 0)
949 :param is_ipv6: (Default value = 0)
950 :param is_local: (Default value = 0)
951 :param is_classify: (Default value = 0)
952 :param is_multipath: (Default value = 0)
953 :param is_resolve_host: (Default value = 0)
954 :param is_resolve_attached: (Default value = 0)
955 :param not_last: (Default value = 0)
956 :param next_hop_weight: (Default value = 1)
957
958 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000959 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100960 self.papi.mpls_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200961 {'mt_sw_if_index': tun_sw_if_index,
962 'mt_is_add': is_add,
963 'mt_l2_only': l2_only,
964 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
965 'mt_next_hop_weight': next_hop_weight,
966 'mt_next_hop': next_hop_address,
967 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
968 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
969 'mt_next_hop_table_id': next_hop_table_id,
970 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
Matus Fabiande886752016-12-07 03:38:19 -0800971
972 def snat_interface_add_del_feature(
973 self,
974 sw_if_index,
975 is_inside=1,
976 is_add=1):
977 """Enable/disable S-NAT feature on the interface
978
979 :param sw_if_index: Software index of the interface
980 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
981 :param is_add: 1 if add, 0 if delete (Default value = 1)
982 """
983 return self.api(
984 self.papi.snat_interface_add_del_feature,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200985 {'is_add': is_add,
986 'is_inside': is_inside,
987 'sw_if_index': sw_if_index})
Matus Fabiande886752016-12-07 03:38:19 -0800988
989 def snat_add_static_mapping(
990 self,
991 local_ip,
Matus Fabian36532bd2017-01-23 23:42:28 -0800992 external_ip=0,
993 external_sw_if_index=0xFFFFFFFF,
Matus Fabiande886752016-12-07 03:38:19 -0800994 local_port=0,
995 external_port=0,
996 addr_only=1,
997 vrf_id=0,
Matus Fabian09d96f42017-02-02 01:43:00 -0800998 protocol=0,
Matus Fabiande886752016-12-07 03:38:19 -0800999 is_add=1,
1000 is_ip4=1):
1001 """Add/delete S-NAT static mapping
1002
1003 :param local_ip: Local IP address
1004 :param external_ip: External IP address
Matus Fabian36532bd2017-01-23 23:42:28 -08001005 :param external_sw_if_index: External interface instead of IP address
Matus Fabiande886752016-12-07 03:38:19 -08001006 :param local_port: Local port number (Default value = 0)
1007 :param external_port: External port number (Default value = 0)
1008 :param addr_only: 1 if address only mapping, 0 if address and port
1009 :param vrf_id: VRF ID
Matus Fabian09d96f42017-02-02 01:43:00 -08001010 :param protocol: IP protocol (Default value = 0)
Matus Fabiande886752016-12-07 03:38:19 -08001011 :param is_add: 1 if add, 0 if delete (Default value = 1)
1012 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1013 """
1014 return self.api(
1015 self.papi.snat_add_static_mapping,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001016 {'is_add': is_add,
1017 'is_ip4': is_ip4,
1018 'addr_only': addr_only,
1019 'local_ip_address': local_ip,
1020 'external_ip_address': external_ip,
1021 'local_port': local_port,
1022 'external_port': external_port,
Matus Fabian36532bd2017-01-23 23:42:28 -08001023 'external_sw_if_index': external_sw_if_index,
Matus Fabian09d96f42017-02-02 01:43:00 -08001024 'vrf_id': vrf_id,
1025 'protocol': protocol})
Matus Fabiande886752016-12-07 03:38:19 -08001026
1027 def snat_add_address_range(
1028 self,
1029 first_ip_address,
1030 last_ip_address,
1031 is_add=1,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001032 is_ip4=1,
1033 vrf_id=0xFFFFFFFF):
Matus Fabiande886752016-12-07 03:38:19 -08001034 """Add/del S-NAT address range
1035
1036 :param first_ip_address: First IP address
1037 :param last_ip_address: Last IP address
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001038 :param vrf_id: VRF id for the address range
Matus Fabiande886752016-12-07 03:38:19 -08001039 :param is_add: 1 if add, 0 if delete (Default value = 1)
1040 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
1041 """
1042 return self.api(
1043 self.papi.snat_add_address_range,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001044 {'is_ip4': is_ip4,
1045 'first_ip_address': first_ip_address,
1046 'last_ip_address': last_ip_address,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001047 'vrf_id': vrf_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001048 'is_add': is_add})
Matus Fabiande886752016-12-07 03:38:19 -08001049
1050 def snat_address_dump(self):
1051 """Dump S-NAT addresses
1052 :return: Dictionary of S-NAT addresses
1053 """
1054 return self.api(self.papi.snat_address_dump, {})
1055
1056 def snat_interface_dump(self):
1057 """Dump interfaces with S-NAT feature
1058 :return: Dictionary of interfaces with S-NAT feature
1059 """
1060 return self.api(self.papi.snat_interface_dump, {})
1061
1062 def snat_static_mapping_dump(self):
1063 """Dump S-NAT static mappings
1064 :return: Dictionary of S-NAT static mappings
1065 """
1066 return self.api(self.papi.snat_static_mapping_dump, {})
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001067
Matus Fabian9902fcd2016-12-21 23:58:46 -08001068 def snat_show_config(self):
1069 """Show S-NAT config
1070 :return: S-NAT config parameters
1071 """
1072 return self.api(self.papi.snat_show_config, {})
1073
Matus Fabian8bf68e82017-01-12 04:24:35 -08001074 def snat_add_interface_addr(
1075 self,
1076 sw_if_index,
1077 is_add=1):
1078 """Add/del S-NAT address from interface
1079
1080 :param sw_if_index: Software index of the interface
1081 :param is_add: 1 if add, 0 if delete (Default value = 1)
1082 """
1083 return self.api(self.papi.snat_add_del_interface_addr,
1084 {'is_add': is_add, 'sw_if_index': sw_if_index})
1085
1086 def snat_interface_addr_dump(self):
1087 """Dump S-NAT addresses interfaces
1088 :return: Dictionary of S-NAT addresses interfaces
1089 """
1090 return self.api(self.papi.snat_interface_addr_dump, {})
1091
Matus Fabianeea28d72017-01-13 04:15:54 -08001092 def snat_ipfix(
1093 self,
1094 domain_id=1,
1095 src_port=4739,
1096 enable=1):
1097 """Enable/disable S-NAT IPFIX logging
1098
1099 :param domain_id: Observation domain ID (Default value = 1)
1100 :param src_port: Source port number (Default value = 4739)
1101 :param enable: 1 if enable, 0 if disable (Default value = 1)
1102 """
1103 return self.api(
1104 self.papi.snat_ipfix_enable_disable,
1105 {'domain_id': domain_id,
1106 'src_port': src_port,
1107 'enable': enable})
1108
magalik23caa882017-02-08 23:25:45 -08001109 def snat_user_session_dump(
1110 self,
1111 ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001112 vrf_id,
1113 is_ip4=1):
magalik23caa882017-02-08 23:25:45 -08001114 """Dump S-NAT user's sessions
1115
1116 :param ip_address: ip adress of the user to be dumped
1117 :param cpu_index: cpu_index on which the user is
1118 :param vrf_id: VRF ID
1119 :return: Dictionary of S-NAT sessions
1120 """
1121 return self.api(
1122 self.papi.snat_user_session_dump,
1123 {'ip_address': ip_address,
Martin6b7fcda2017-03-08 03:31:02 -08001124 'vrf_id': vrf_id,
1125 'is_ip4': is_ip4})
magalik23caa882017-02-08 23:25:45 -08001126
1127 def snat_user_dump(self):
1128 """Dump S-NAT users
1129
1130 :return: Dictionary of S-NAT users
1131 """
1132 return self.api(self.papi.snat_user_dump, {})
1133
Matus Fabian066f0342017-02-10 03:48:01 -08001134 def snat_add_det_map(
1135 self,
1136 in_addr,
1137 in_plen,
1138 out_addr,
1139 out_plen,
1140 is_add=1):
1141 """Add/delete S-NAT deterministic mapping
1142
1143 :param is_add - 1 if add, 0 if delete
1144 :param in_addr - inside IP address
1145 :param in_plen - inside IP address prefix length
1146 :param out_addr - outside IP address
1147 :param out_plen - outside IP address prefix length
1148 """
1149 return self.api(
1150 self.papi.snat_add_det_map,
1151 {'is_add': is_add,
1152 'in_addr': in_addr,
1153 'in_plen': in_plen,
1154 'out_addr': out_addr,
1155 'out_plen': out_plen})
1156
1157 def snat_det_forward(
1158 self,
1159 in_addr):
1160 """Get outside address and port range from inside address
1161
1162 :param in_addr - inside IP address
1163 """
1164 return self.api(
1165 self.papi.snat_det_forward,
1166 {'in_addr': in_addr})
1167
1168 def snat_det_reverse(
1169 self,
1170 out_addr,
1171 out_port):
1172 """Get inside address from outside address and port
1173
1174 :param out_addr - outside IP address
1175 :param out_port - outside port
1176 """
1177 return self.api(
1178 self.papi.snat_det_reverse,
1179 {'out_addr': out_addr,
1180 'out_port': out_port})
1181
Martin17a75cb2017-03-08 05:53:20 -08001182 def snat_det_map_dump(self):
1183 """Dump S-NAT deterministic mappings
1184
1185 :return: Dictionary of S-NAT deterministic mappings
1186 """
1187 return self.api(self.papi.snat_det_map_dump, {})
1188
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001189 def control_ping(self):
1190 self.api(self.papi.control_ping)
1191
1192 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
Klement Sekerab17dd962017-01-09 07:43:48 +01001193 detect_mult, local_addr, peer_addr, is_ipv6=0,
1194 bfd_key_id=None, conf_key_id=None):
1195 if bfd_key_id is None:
1196 return self.api(self.papi.bfd_udp_add,
1197 {
1198 'sw_if_index': sw_if_index,
1199 'desired_min_tx': desired_min_tx,
1200 'required_min_rx': required_min_rx,
1201 'local_addr': local_addr,
1202 'peer_addr': peer_addr,
1203 'is_ipv6': is_ipv6,
1204 'detect_mult': detect_mult,
1205 })
1206 else:
1207 return self.api(self.papi.bfd_udp_add,
1208 {
1209 'sw_if_index': sw_if_index,
1210 'desired_min_tx': desired_min_tx,
1211 'required_min_rx': required_min_rx,
1212 'local_addr': local_addr,
1213 'peer_addr': peer_addr,
1214 'is_ipv6': is_ipv6,
1215 'detect_mult': detect_mult,
1216 'is_authenticated': 1,
1217 'bfd_key_id': bfd_key_id,
1218 'conf_key_id': conf_key_id,
1219 })
1220
Klement Sekeraa57a9702017-02-02 06:58:07 +01001221 def bfd_udp_mod(self, sw_if_index, desired_min_tx, required_min_rx,
1222 detect_mult, local_addr, peer_addr, is_ipv6=0):
1223 return self.api(self.papi.bfd_udp_mod,
1224 {
1225 'sw_if_index': sw_if_index,
1226 'desired_min_tx': desired_min_tx,
1227 'required_min_rx': required_min_rx,
1228 'local_addr': local_addr,
1229 'peer_addr': peer_addr,
1230 'is_ipv6': is_ipv6,
1231 'detect_mult': detect_mult,
1232 })
1233
Klement Sekerab17dd962017-01-09 07:43:48 +01001234 def bfd_udp_auth_activate(self, sw_if_index, local_addr, peer_addr,
1235 is_ipv6=0, bfd_key_id=None, conf_key_id=None,
1236 is_delayed=False):
1237 return self.api(self.papi.bfd_udp_auth_activate,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001238 {
1239 'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001240 'local_addr': local_addr,
1241 'peer_addr': peer_addr,
1242 'is_ipv6': is_ipv6,
Klement Sekerab17dd962017-01-09 07:43:48 +01001243 'is_delayed': 1 if is_delayed else 0,
1244 'bfd_key_id': bfd_key_id,
1245 'conf_key_id': conf_key_id,
1246 })
1247
1248 def bfd_udp_auth_deactivate(self, sw_if_index, local_addr, peer_addr,
1249 is_ipv6=0, is_delayed=False):
1250 return self.api(self.papi.bfd_udp_auth_deactivate,
1251 {
1252 'sw_if_index': sw_if_index,
1253 'local_addr': local_addr,
1254 'peer_addr': peer_addr,
1255 'is_ipv6': is_ipv6,
1256 'is_delayed': 1 if is_delayed else 0,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001257 })
1258
1259 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
1260 return self.api(self.papi.bfd_udp_del,
1261 {
1262 'sw_if_index': sw_if_index,
1263 'local_addr': local_addr,
1264 'peer_addr': peer_addr,
1265 'is_ipv6': is_ipv6,
1266 })
1267
1268 def bfd_udp_session_dump(self):
1269 return self.api(self.papi.bfd_udp_session_dump, {})
1270
Klement Sekerab17dd962017-01-09 07:43:48 +01001271 def bfd_udp_session_set_flags(self, admin_up_down, sw_if_index, local_addr,
1272 peer_addr, is_ipv6=0):
1273 return self.api(self.papi.bfd_udp_session_set_flags, {
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001274 'admin_up_down': admin_up_down,
Klement Sekerab17dd962017-01-09 07:43:48 +01001275 'sw_if_index': sw_if_index,
1276 'local_addr': local_addr,
1277 'peer_addr': peer_addr,
1278 'is_ipv6': is_ipv6,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001279 })
1280
1281 def want_bfd_events(self, enable_disable=1):
1282 return self.api(self.papi.want_bfd_events, {
1283 'enable_disable': enable_disable,
1284 'pid': os.getpid(),
1285 })
Steve Shin7957d6e2016-12-19 09:24:50 -08001286
Klement Sekerab17dd962017-01-09 07:43:48 +01001287 def bfd_auth_set_key(self, conf_key_id, auth_type, key):
1288 return self.api(self.papi.bfd_auth_set_key, {
1289 'conf_key_id': conf_key_id,
1290 'auth_type': auth_type,
1291 'key': key,
1292 'key_len': len(key),
1293 })
1294
1295 def bfd_auth_del_key(self, conf_key_id):
1296 return self.api(self.papi.bfd_auth_del_key, {
1297 'conf_key_id': conf_key_id,
1298 })
1299
1300 def bfd_auth_keys_dump(self):
1301 return self.api(self.papi.bfd_auth_keys_dump, {})
1302
Klement Sekera239790f2017-02-16 10:53:53 +01001303 def bfd_udp_set_echo_source(self, sw_if_index):
1304 return self.api(self.papi.bfd_udp_set_echo_source,
1305 {'sw_if_index': sw_if_index})
1306
Klement Sekera73884482017-02-23 09:26:30 +01001307 def bfd_udp_del_echo_source(self):
1308 return self.api(self.papi.bfd_udp_del_echo_source, {})
1309
Steve Shin7957d6e2016-12-19 09:24:50 -08001310 def classify_add_del_table(
1311 self,
1312 is_add,
1313 mask,
1314 match_n_vectors=1,
1315 table_index=0xFFFFFFFF,
1316 nbuckets=2,
1317 memory_size=2097152,
1318 skip_n_vectors=0,
1319 next_table_index=0xFFFFFFFF,
1320 miss_next_index=0xFFFFFFFF,
1321 current_data_flag=0,
1322 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -08001323 """
1324 :param is_add:
1325 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +01001326 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +01001327 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -08001328 :param nbuckets: (Default value = 2)
1329 :param memory_size: (Default value = 2097152)
1330 :param skip_n_vectors: (Default value = 0)
1331 :param next_table_index: (Default value = 0xFFFFFFFF)
1332 :param miss_next_index: (Default value = 0xFFFFFFFF)
1333 :param current_data_flag: (Default value = 0)
1334 :param current_data_offset: (Default value = 0)
1335 """
1336
1337 return self.api(
1338 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001339 {'is_add': is_add,
1340 'table_index': table_index,
1341 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -08001342 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001343 'skip_n_vectors': skip_n_vectors,
1344 'match_n_vectors': match_n_vectors,
1345 'next_table_index': next_table_index,
1346 'miss_next_index': miss_next_index,
1347 'current_data_flag': current_data_flag,
1348 'current_data_offset': current_data_offset,
1349 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -08001350
1351 def classify_add_del_session(
1352 self,
1353 is_add,
1354 table_index,
1355 match,
1356 opaque_index=0xFFFFFFFF,
1357 hit_next_index=0xFFFFFFFF,
1358 advance=0,
1359 action=0,
1360 metadata=0):
1361 """
1362 :param is_add:
1363 :param table_index:
1364 :param match:
1365 :param opaque_index: (Default value = 0xFFFFFFFF)
1366 :param hit_next_index: (Default value = 0xFFFFFFFF)
1367 :param advance: (Default value = 0)
1368 :param action: (Default value = 0)
1369 :param metadata: (Default value = 0)
1370 """
1371
1372 return self.api(
1373 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001374 {'is_add': is_add,
1375 'table_index': table_index,
1376 'hit_next_index': hit_next_index,
1377 'opaque_index': opaque_index,
1378 'advance': advance,
1379 'action': action,
1380 'metadata': metadata,
1381 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -08001382
1383 def input_acl_set_interface(
1384 self,
1385 is_add,
1386 sw_if_index,
1387 ip4_table_index=0xFFFFFFFF,
1388 ip6_table_index=0xFFFFFFFF,
1389 l2_table_index=0xFFFFFFFF):
1390 """
1391 :param is_add:
1392 :param sw_if_index:
1393 :param ip4_table_index: (Default value = 0xFFFFFFFF)
1394 :param ip6_table_index: (Default value = 0xFFFFFFFF)
1395 :param l2_table_index: (Default value = 0xFFFFFFFF)
1396 """
1397
1398 return self.api(
1399 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +01001400 {'sw_if_index': sw_if_index,
1401 'ip4_table_index': ip4_table_index,
1402 'ip6_table_index': ip6_table_index,
1403 'l2_table_index': l2_table_index,
1404 'is_add': is_add})
1405
1406 def set_ipfix_exporter(
1407 self,
1408 collector_address,
1409 src_address,
1410 path_mtu,
1411 template_interval,
1412 vrf_id=0,
1413 collector_port=4739,
1414 udp_checksum=0):
1415 return self.api(
1416 self.papi.set_ipfix_exporter,
1417 {
1418 'collector_address': collector_address,
1419 'collector_port': collector_port,
1420 'src_address': src_address,
1421 'vrf_id': vrf_id,
1422 'path_mtu': path_mtu,
1423 'template_interval': template_interval,
1424 'udp_checksum': udp_checksum,
1425 })
Neale Rannsfca0c242017-01-13 07:57:46 -08001426
1427 def dhcp_proxy_config(self,
1428 dhcp_server,
1429 dhcp_src_address,
1430 rx_table_id=0,
1431 server_table_id=0,
1432 is_add=1,
Neale Ranns20a175a2017-02-14 07:28:41 -08001433 is_ipv6=0):
Neale Rannsfca0c242017-01-13 07:57:46 -08001434 return self.api(
Neale Ranns20a175a2017-02-14 07:28:41 -08001435 self.papi.dhcp_proxy_config,
Neale Rannsfca0c242017-01-13 07:57:46 -08001436 {
1437 'rx_vrf_id': rx_table_id,
1438 'server_vrf_id': server_table_id,
1439 'is_ipv6': is_ipv6,
1440 'is_add': is_add,
Neale Rannsfca0c242017-01-13 07:57:46 -08001441 'dhcp_server': dhcp_server,
1442 'dhcp_src_address': dhcp_src_address,
1443 })
1444
1445 def dhcp_proxy_set_vss(self,
1446 table_id,
1447 fib_id,
1448 oui,
1449 is_add=1,
1450 is_ip6=0):
1451 return self.api(
1452 self.papi.dhcp_proxy_set_vss,
1453 {
1454 'tbl_id': table_id,
1455 'fib_id': fib_id,
1456 'is_ipv6': is_ip6,
1457 'is_add': is_add,
1458 'oui': oui,
1459 })
Neale Ranns32e1c012016-11-22 17:07:28 +00001460
1461 def ip_mroute_add_del(self,
1462 src_address,
1463 grp_address,
1464 grp_address_length,
1465 e_flags,
1466 next_hop_sw_if_index,
1467 i_flags,
1468 table_id=0,
1469 create_vrf_if_needed=0,
1470 is_add=1,
1471 is_ipv6=0,
1472 is_local=0):
1473 """
1474 """
1475 return self.api(
1476 self.papi.ip_mroute_add_del,
1477 {'next_hop_sw_if_index': next_hop_sw_if_index,
1478 'entry_flags': e_flags,
1479 'itf_flags': i_flags,
1480 'create_vrf_if_needed': create_vrf_if_needed,
1481 'is_add': is_add,
1482 'is_ipv6': is_ipv6,
1483 'is_local': is_local,
1484 'grp_address_length': grp_address_length,
1485 'grp_address': grp_address,
1486 'src_address': src_address})
1487
1488 def mfib_signal_dump(self):
1489 return self.api(self.papi.mfib_signal_dump, {})
Neale Ranns5a8123b2017-01-26 01:18:23 -08001490
1491 def ip_mfib_dump(self):
1492 return self.api(self.papi.ip_mfib_dump, {})
Filip Tehlar770e89e2017-01-31 10:39:16 +01001493
1494 def lisp_enable_disable(self, is_enabled):
1495 return self.api(
1496 self.papi.lisp_enable_disable,
1497 {
1498 'is_en': is_enabled,
1499 })
1500
1501 def lisp_locator_set(self,
1502 ls_name,
1503 is_add=1):
1504 return self.api(
1505 self.papi.lisp_add_del_locator_set,
1506 {
1507 'is_add': is_add,
1508 'locator_set_name': ls_name
1509 })
1510
1511 def lisp_locator_set_dump(self):
1512 return self.api(self.papi.lisp_locator_set_dump, {})
1513
1514 def lisp_locator(self,
1515 ls_name,
1516 sw_if_index,
1517 priority=1,
1518 weight=1,
1519 is_add=1):
1520 return self.api(
1521 self.papi.lisp_add_del_locator,
1522 {
1523 'is_add': is_add,
1524 'locator_set_name': ls_name,
1525 'sw_if_index': sw_if_index,
1526 'priority': priority,
1527 'weight': weight
1528 })
1529
1530 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
1531 return self.api(
1532 self.papi.lisp_locator_dump,
1533 {
1534 'is_index_set': is_index_set,
1535 'ls_name': ls_name,
1536 'ls_index': ls_index,
1537 })
1538
1539 def lisp_local_mapping(self,
1540 ls_name,
1541 eid_type,
1542 eid,
1543 prefix_len,
1544 vni=0,
1545 key_id=0,
1546 key="",
1547 is_add=1):
1548 return self.api(
1549 self.papi.lisp_add_del_local_eid,
1550 {
1551 'locator_set_name': ls_name,
1552 'is_add': is_add,
1553 'eid_type': eid_type,
1554 'eid': eid,
1555 'prefix_len': prefix_len,
1556 'vni': vni,
1557 'key_id': key_id,
1558 'key': key
1559 })
1560
1561 def lisp_eid_table_dump(self,
1562 eid_set=0,
1563 prefix_length=0,
1564 vni=0,
1565 eid_type=0,
1566 eid=None,
1567 filter_opt=0):
1568 return self.api(
1569 self.papi.lisp_eid_table_dump,
1570 {
1571 'eid_set': eid_set,
1572 'prefix_length': prefix_length,
1573 'vni': vni,
1574 'eid_type': eid_type,
1575 'eid': eid,
1576 'filter': filter_opt,
1577 })
1578
1579 def lisp_remote_mapping(self,
1580 eid_type,
1581 eid,
1582 eid_prefix_len=0,
1583 vni=0,
1584 rlocs=None,
1585 rlocs_num=0,
1586 is_src_dst=0,
1587 is_add=1):
1588 return self.api(
1589 self.papi.lisp_add_del_remote_mapping,
1590 {
1591 'is_add': is_add,
1592 'eid_type': eid_type,
1593 'eid': eid,
1594 'eid_len': eid_prefix_len,
1595 'rloc_num': rlocs_num,
1596 'rlocs': rlocs,
1597 'vni': vni,
1598 'is_src_dst': is_src_dst,
1599 })
1600
1601 def lisp_adjacency(self,
1602 leid,
1603 reid,
1604 leid_len,
1605 reid_len,
1606 eid_type,
1607 is_add=1,
1608 vni=0):
1609 return self.api(
1610 self.papi.lisp_add_del_adjacency,
1611 {
1612 'is_add': is_add,
1613 'vni': vni,
1614 'eid_type': eid_type,
1615 'leid': leid,
1616 'reid': reid,
1617 'leid_len': leid_len,
1618 'reid_len': reid_len,
1619 })
1620
1621 def lisp_adjacencies_get(self, vni=0):
1622 return self.api(
1623 self.papi.lisp_adjacencies_get,
1624 {
1625 'vni': vni
1626 })
Neale Ranns80823802017-02-20 18:23:41 -08001627
1628 def map_add_domain(self,
1629 ip6_prefix,
1630 ip6_prefix_len,
1631 ip6_src,
1632 ip6_src_prefix_len,
1633 ip4_prefix,
1634 ip4_prefix_len,
1635 ea_bits_len=0,
1636 psid_offset=0,
1637 psid_length=0,
1638 is_translation=0,
1639 mtu=1280):
1640 return self.api(
1641 self.papi.map_add_domain,
1642 {
1643 'ip6_prefix': ip6_prefix,
1644 'ip6_prefix_len': ip6_prefix_len,
1645 'ip4_prefix': ip4_prefix,
1646 'ip4_prefix_len': ip4_prefix_len,
1647 'ip6_src': ip6_src,
1648 'ip6_src_prefix_len': ip6_src_prefix_len,
1649 'ea_bits_len': ea_bits_len,
1650 'psid_offset': psid_offset,
1651 'psid_length': psid_length,
1652 'is_translation': is_translation,
1653 'mtu': mtu
1654 })