blob: db530d981133593b19d47538d9484379224c7caa [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
8# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows the
9# vpp_papi_provider.py file to be importable without having to build the whole
10# 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 Sekeraf62ae122016-10-11 11:47:09 +020031class VppPapiProvider(object):
32 """VPP-api provider using vpp-papi
33
34 @property hook: hook object providing before and after api/cli hooks
35
36
37 """
38
Klement Sekera7bb873a2016-11-18 07:38:42 +010039 def __init__(self, name, shm_prefix, test_class):
Klement Sekera277b89c2016-10-28 13:20:27 +020040 self.hook = Hook("vpp-papi-provider")
Klement Sekeraf62ae122016-10-11 11:47:09 +020041 self.name = name
42 self.shm_prefix = shm_prefix
Klement Sekera7bb873a2016-11-18 07:38:42 +010043 self.test_class = test_class
Ole Troan7e3a8752016-12-05 10:27:09 +010044 jsonfiles = []
45
Klement Sekera0e3c0de2016-09-29 14:43:44 +020046 install_dir = os.getenv('VPP_TEST_INSTALL_PATH')
Ole Troan7e3a8752016-12-05 10:27:09 +010047 for root, dirnames, filenames in os.walk(install_dir):
48 for filename in fnmatch.filter(filenames, '*.api.json'):
49 jsonfiles.append(os.path.join(root, filename))
50
51 self.papi = VPP(jsonfiles)
Klement Sekerae4504c62016-12-08 10:16:41 +010052 self._events = deque()
Klement Sekeraf62ae122016-10-11 11:47:09 +020053
54 def register_hook(self, hook):
55 """Replace hook registration with new hook
56
57 :param hook:
58
59 """
60 self.hook = hook
61
Klement Sekera0e3c0de2016-09-29 14:43:44 +020062 def collect_events(self):
Klement Sekerae4504c62016-12-08 10:16:41 +010063 """ Collect all events from the internal queue and clear the queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +020064 e = self._events
Klement Sekerae4504c62016-12-08 10:16:41 +010065 self._events = deque()
Klement Sekera0e3c0de2016-09-29 14:43:44 +020066 return e
67
68 def wait_for_event(self, timeout, name=None):
Klement Sekerae4504c62016-12-08 10:16:41 +010069 """ Wait for and return next event. """
70 if self._events:
71 self.test_class.logger.debug("Not waiting, event already queued")
Klement Sekera0e3c0de2016-09-29 14:43:44 +020072 limit = time.time() + timeout
73 while time.time() < limit:
74 if self._events:
Klement Sekerae4504c62016-12-08 10:16:41 +010075 e = self._events.popleft()
Klement Sekera0e3c0de2016-09-29 14:43:44 +020076 if name and type(e).__name__ != name:
77 raise Exception(
78 "Unexpected event received: %s, expected: %s" %
79 (type(e).__name__, name))
Klement Sekerae4504c62016-12-08 10:16:41 +010080 self.test_class.logger.debug("Returning event %s:%s" %
81 (name, e))
Klement Sekera0e3c0de2016-09-29 14:43:44 +020082 return e
83 time.sleep(0) # yield
84 if name is not None:
85 raise Exception("Event %s did not occur within timeout" % name)
86 raise Exception("Event did not occur within timeout")
87
88 def __call__(self, name, event):
Klement Sekerae4504c62016-12-08 10:16:41 +010089 """ Enqueue event in the internal event queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +020090 # FIXME use the name instead of relying on type(e).__name__ ?
91 # FIXME #2 if this throws, it is eaten silently, Ole?
Klement Sekerae4504c62016-12-08 10:16:41 +010092 self.test_class.logger.debug("New event: %s: %s" % (name, event))
Klement Sekera0e3c0de2016-09-29 14:43:44 +020093 self._events.append(event)
94
Klement Sekeraf62ae122016-10-11 11:47:09 +020095 def connect(self):
96 """Connect the API to VPP"""
Ole Troan7e3a8752016-12-05 10:27:09 +010097 self.papi.connect(self.name, self.shm_prefix)
Klement Sekera0e3c0de2016-09-29 14:43:44 +020098 self.papi.register_event_callback(self)
Klement Sekeraf62ae122016-10-11 11:47:09 +020099
100 def disconnect(self):
101 """Disconnect the API from VPP"""
Ole Troan7e3a8752016-12-05 10:27:09 +0100102 self.papi.disconnect()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200103
104 def api(self, api_fn, api_args, expected_retval=0):
Klement Sekerae4504c62016-12-08 10:16:41 +0100105 """ Call API function and check it's return value.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200106 Call the appropriate hooks before and after the API call
107
108 :param api_fn: API function to call
109 :param api_args: tuple of API function arguments
110 :param expected_retval: Expected return value (Default value = 0)
111 :returns: reply from the API
112
113 """
114 self.hook.before_api(api_fn.__name__, api_args)
Ole Troan7e3a8752016-12-05 10:27:09 +0100115 reply = api_fn(**api_args)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200116 if hasattr(reply, 'retval') and reply.retval != expected_retval:
117 msg = "API call failed, expected retval == %d, got %s" % (
118 expected_retval, repr(reply))
Klement Sekerae4504c62016-12-08 10:16:41 +0100119 self.test_class.logger.info(msg)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200120 raise Exception(msg)
121 self.hook.after_api(api_fn.__name__, api_args)
122 return reply
123
124 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100125 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200126
127 :param cli: CLI to execute
128 :returns: CLI output
129
130 """
131 self.hook.before_cli(cli)
132 cli += '\n'
Ole Troan7e3a8752016-12-05 10:27:09 +0100133 r = self.papi.cli_inband(length=len(cli), cmd=cli)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200134 self.hook.after_cli(cli)
Jan49c0fca2016-10-26 15:44:27 +0200135 if hasattr(r, 'reply'):
Ole Troan7e3a8752016-12-05 10:27:09 +0100136 return r.reply.decode().rstrip('\x00')
Klement Sekeraf62ae122016-10-11 11:47:09 +0200137
Jan49c0fca2016-10-26 15:44:27 +0200138 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100139 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200140
141 :param cli: CLI to execute
142 :returns: CLI output
143 """
Ed Warnickeb8ff5d62016-11-28 13:59:22 -0600144 return cli + "\n" + str(self.cli(cli))
Jan49c0fca2016-10-26 15:44:27 +0200145
Jan4af521d2016-11-15 17:05:00 +0100146 def _convert_mac(self, mac):
147 return int(mac.replace(":", ""), 16) << 16
148
Klement Sekeraf62ae122016-10-11 11:47:09 +0200149 def show_version(self):
150 """ """
Ole Troan7e3a8752016-12-05 10:27:09 +0100151 return self.papi.show_version()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200152
153 def pg_create_interface(self, pg_index):
154 """
155
156 :param pg_index:
157
158 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100159 return self.api(self.papi.pg_create_interface,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200160 {"interface_id": pg_index})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200161
162 def sw_interface_dump(self, filter=None):
163 """
164
165 :param filter: (Default value = None)
166
167 """
168 if filter is not None:
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200169 args = {"name_filter_valid": 1, "name_filter": filter}
Klement Sekeraf62ae122016-10-11 11:47:09 +0200170 else:
Ole Troan7e3a8752016-12-05 10:27:09 +0100171 args = {}
172 return self.api(self.papi.sw_interface_dump, args)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200173
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000174 def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
Klement Sekerae4504c62016-12-08 10:16:41 +0100175 """ Set the IPvX Table-id for the Interface
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000176
177 :param sw_if_index:
178 :param is_ipv6:
179 :param table_id:
180
181 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100182 return self.api(self.papi.sw_interface_set_table,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200183 {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6,
184 'vrf_id': table_id})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000185
Klement Sekeraf62ae122016-10-11 11:47:09 +0200186 def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
187 is_ipv6=0, is_add=1, del_all=0):
188 """
189
190 :param addr: param is_ipv6: (Default value = 0)
191 :param sw_if_index:
192 :param addr_len:
193 :param is_ipv6: (Default value = 0)
194 :param is_add: (Default value = 1)
195 :param del_all: (Default value = 0)
196
197 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100198 return self.api(self.papi.sw_interface_add_del_address,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200199 {'sw_if_index': sw_if_index,
200 'is_add': is_add,
201 'is_ipv6': is_ipv6,
202 'del_all': del_all,
203 'address_length': addr_len,
204 'address': addr})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200205
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000206 def sw_interface_enable_disable_mpls(self, sw_if_index,
207 is_enable=1):
208 """
209 Enable/Disable MPLS on the interface
210 :param sw_if_index:
211 :param is_enable: (Default value = 1)
212
213 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100214 return self.api(self.papi.sw_interface_set_mpls_enable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200215 {'sw_if_index': sw_if_index,
216 'enable': is_enable})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000217
Klement Sekeraf62ae122016-10-11 11:47:09 +0200218 def sw_interface_ra_suppress(self, sw_if_index):
Ole Troan7e3a8752016-12-05 10:27:09 +0100219 return self.api(self.papi.sw_interface_ip6nd_ra_config,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200220 {'sw_if_index': sw_if_index})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200221
Klement Sekeraf62ae122016-10-11 11:47:09 +0200222 def vxlan_add_del_tunnel(
223 self,
224 src_addr,
225 dst_addr,
Eyal Baric5b13602016-11-24 19:42:43 +0200226 mcast_sw_if_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200227 is_add=1,
228 is_ipv6=0,
229 encap_vrf_id=0,
230 decap_next_index=0xFFFFFFFF,
231 vni=0):
232 """
233
234 :param dst_addr:
235 :param src_addr:
236 :param is_add: (Default value = 1)
237 :param is_ipv6: (Default value = 0)
238 :param encap_vrf_id: (Default value = 0)
239 :param decap_next_index: (Default value = 0xFFFFFFFF)
Eyal Baric5b13602016-11-24 19:42:43 +0200240 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200241 :param vni: (Default value = 0)
242
243 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100244 return self.api(self.papi.vxlan_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200245 {'is_add': is_add,
246 'is_ipv6': is_ipv6,
247 'src_address': src_addr,
248 'dst_address': dst_addr,
249 'mcast_sw_if_index': mcast_sw_if_index,
250 'encap_vrf_id': encap_vrf_id,
251 'decap_next_index': decap_next_index,
252 'vni': vni})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200253
Jan4af521d2016-11-15 17:05:00 +0100254 def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
255 learn=1, arp_term=0, is_add=1):
256 """Create/delete bridge domain.
257
258 :param int bd_id: Bridge domain index.
259 :param int flood: Enable/disable bcast/mcast flooding in the BD.
260 (Default value = 1)
261 :param int uu_flood: Enable/disable unknown unicast flood in the BD.
262 (Default value = 1)
263 :param int forward: Enable/disable forwarding on all interfaces in
264 the BD. (Default value = 1)
265 :param int learn: Enable/disable learning on all interfaces in the BD.
266 (Default value = 1)
267 :param int arp_term: Enable/disable arp termination in the BD.
268 (Default value = 1)
269 :param int is_add: Add or delete flag. (Default value = 1)
270 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100271 return self.api(self.papi.bridge_domain_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200272 {'bd_id': bd_id,
273 'flood': flood,
274 'uu_flood': uu_flood,
275 'forward': forward,
276 'learn': learn,
277 'arp_term': arp_term,
278 'is_add': is_add})
Jan4af521d2016-11-15 17:05:00 +0100279
280 def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
281 filter_mac=0, bvi_mac=0):
282 """Create/delete L2 FIB entry.
283
284 :param str mac: MAC address to create FIB entry for.
285 :param int bd_id: Bridge domain index.
286 :param int sw_if_index: Software interface index of the interface.
287 :param int is_add: Add or delete flag. (Default value = 1)
288 :param int static_mac: Set to 1 to create static MAC entry.
289 (Default value = 0)
290 :param int filter_mac: Set to 1 to drop packet that's source or
291 destination MAC address contains defined MAC address.
292 (Default value = 0)
293 :param int bvi_mac: Set to 1 to create entry that points to BVI
294 interface. (Default value = 0)
295 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100296 return self.api(self.papi.l2fib_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200297 {'mac': self._convert_mac(mac),
298 'bd_id': bd_id,
299 'sw_if_index': sw_if_index,
300 'is_add': is_add,
301 'static_mac': static_mac,
302 'filter_mac': filter_mac,
303 'bvi_mac': bvi_mac})
Jan4af521d2016-11-15 17:05:00 +0100304
Klement Sekeraf62ae122016-10-11 11:47:09 +0200305 def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
306 shg=0, bvi=0, enable=1):
Jan4af521d2016-11-15 17:05:00 +0100307 """Add/remove interface to/from bridge domain.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200308
Jan4af521d2016-11-15 17:05:00 +0100309 :param int sw_if_index: Software interface index of the interface.
310 :param int bd_id: Bridge domain index.
311 :param int shg: Split-horizon group index. (Default value = 0)
312 :param int bvi: Set interface as a bridge group virtual interface.
313 (Default value = 0)
314 :param int enable: Add or remove interface. (Default value = 1)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200315 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100316 return self.api(self.papi.sw_interface_set_l2_bridge,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200317 {'rx_sw_if_index': sw_if_index,
318 'bd_id': bd_id,
319 'shg': shg,
320 'bvi': bvi,
321 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200322
Jan00dad122016-11-29 10:04:53 +0100323 def bridge_flags(self, bd_id, is_set, feature_bitmap):
324 """Enable/disable required feature of the bridge domain with defined ID.
325
326 :param int bd_id: Bridge domain ID.
327 :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
328 :param int feature_bitmap: Bitmap value of the feature to be set:
329 - learn (1 << 0),
330 - forward (1 << 1),
331 - flood (1 << 2),
332 - uu-flood (1 << 3) or
333 - arp-term (1 << 4).
334 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100335 return self.api(self.papi.bridge_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200336 {'bd_id': bd_id,
337 'is_set': is_set,
338 'feature_bitmap': feature_bitmap})
Jan00dad122016-11-29 10:04:53 +0100339
340 def bridge_domain_dump(self, bd_id=0):
341 """
342
343 :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
344 existing bridge domains returned)
345 :return: Dictionary of bridge domain(s) data.
346 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100347 return self.api(self.papi.bridge_domain_dump,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200348 {'bd_id': bd_id})
Jan00dad122016-11-29 10:04:53 +0100349
Klement Sekeraf62ae122016-10-11 11:47:09 +0200350 def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
351 enable):
352 """Create or delete unidirectional cross-connect from Tx interface to
353 Rx interface.
354
Jan4af521d2016-11-15 17:05:00 +0100355 :param int rx_sw_if_index: Software interface index of Rx interface.
356 :param int tx_sw_if_index: Software interface index of Tx interface.
357 :param int enable: Create cross-connect if equal to 1, delete
358 cross-connect if equal to 0.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200359
360 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100361 return self.api(self.papi.sw_interface_set_l2_xconnect,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200362 {'rx_sw_if_index': rx_sw_if_index,
363 'tx_sw_if_index': tx_sw_if_index,
364 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200365
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200366 def sw_interface_set_l2_tag_rewrite(
367 self,
368 sw_if_index,
369 vtr_oper,
370 push=0,
371 tag1=0,
372 tag2=0):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000373 """L2 interface vlan tag rewrite configure request
374 :param client_index - opaque cookie to identify the sender
375 :param context - sender context, to match reply w/ request
376 :param sw_if_index - interface the operation is applied to
377 :param vtr_op - Choose from l2_vtr_op_t enum values
378 :param push_dot1q - first pushed flag dot1q id set, else dot1ad
379 :param tag1 - Needed for any push or translate vtr op
380 :param tag2 - Needed for any push 2 or translate x-2 vtr ops
381
382 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100383 return self.api(self.papi.l2_interface_vlan_tag_rewrite,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200384 {'sw_if_index': sw_if_index,
385 'vtr_op': vtr_oper,
386 'push_dot1q': push,
387 'tag1': tag1,
388 'tag2': tag2})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000389
Klement Sekeraf62ae122016-10-11 11:47:09 +0200390 def sw_interface_set_flags(self, sw_if_index, admin_up_down,
391 link_up_down=0, deleted=0):
392 """
393
394 :param admin_up_down:
395 :param sw_if_index:
396 :param link_up_down: (Default value = 0)
397 :param deleted: (Default value = 0)
398
399 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100400 return self.api(self.papi.sw_interface_set_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200401 {'sw_if_index': sw_if_index,
402 'admin_up_down': admin_up_down,
403 'link_up_down': link_up_down,
404 'deleted': deleted})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200405
406 def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
407 no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
408 default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):
409 """Create subinterface
410 from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
411
412 :param sub_id: param inner_vlan:
413 :param sw_if_index:
414 :param outer_vlan:
415 :param inner_vlan:
416 :param no_tags: (Default value = 0)
417 :param one_tag: (Default value = 0)
418 :param two_tags: (Default value = 0)
419 :param dot1ad: (Default value = 0)
420 :param exact_match: (Default value = 0)
421 :param default_sub: (Default value = 0)
422 :param outer_vlan_id_any: (Default value = 0)
423 :param inner_vlan_id_any: (Default value = 0)
424
425 """
426 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100427 self.papi.create_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200428 {'sw_if_index': sw_if_index,
429 'sub_id': sub_id,
430 'no_tags': no_tags,
431 'one_tag': one_tag,
432 'two_tags': two_tags,
433 'dot1ad': dot1ad,
434 'exact_match': exact_match,
435 'default_sub': default_sub,
436 'outer_vlan_id_any': outer_vlan_id_any,
437 'inner_vlan_id_any': inner_vlan_id_any,
438 'outer_vlan_id': outer_vlan,
439 'inner_vlan_id': inner_vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200440
Neale Ranns177bbdc2016-11-15 09:46:51 +0000441 def delete_subif(self, sw_if_index):
442 """Delete subinterface
443
444 :param sw_if_index:
445 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100446 return self.api(self.papi.delete_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200447 {'sw_if_index': sw_if_index})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000448
Klement Sekeraf62ae122016-10-11 11:47:09 +0200449 def create_vlan_subif(self, sw_if_index, vlan):
450 """
451
452 :param vlan:
453 :param sw_if_index:
454
455 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100456 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200457 {'sw_if_index': sw_if_index,
458 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200459
Matej Klotton0178d522016-11-04 11:11:44 +0100460 def create_loopback(self, mac=''):
461 """
462
463 :param mac: (Optional)
464 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100465 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200466 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100467
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100468 def delete_loopback(self, sw_if_index):
469 return self.api(self.papi.delete_loopback,
470 {'sw_if_index': sw_if_index, })
471
Klement Sekeraf62ae122016-10-11 11:47:09 +0200472 def ip_add_del_route(
473 self,
474 dst_address,
475 dst_address_length,
476 next_hop_address,
477 next_hop_sw_if_index=0xFFFFFFFF,
478 table_id=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200479 next_hop_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000480 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200481 next_hop_n_out_labels=0,
482 next_hop_out_label_stack=[],
483 next_hop_via_label=MPLS_LABEL_INVALID,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200484 create_vrf_if_needed=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000485 is_resolve_host=0,
486 is_resolve_attached=0,
487 classify_table_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200488 is_add=1,
489 is_drop=0,
Juraj Sloboda86a2c572016-10-27 10:44:25 +0200490 is_unreach=0,
491 is_prohibit=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200492 is_ipv6=0,
493 is_local=0,
494 is_classify=0,
495 is_multipath=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000496 not_last=0):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200497 """
498
499 :param dst_address_length:
500 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
501 :param dst_address:
502 :param next_hop_address:
503 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
504 :param vrf_id: (Default value = 0)
505 :param lookup_in_vrf: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200506 :param classify_table_index: (Default value = 0xFFFFFFFF)
507 :param create_vrf_if_needed: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200508 :param is_add: (Default value = 1)
509 :param is_drop: (Default value = 0)
510 :param is_ipv6: (Default value = 0)
511 :param is_local: (Default value = 0)
512 :param is_classify: (Default value = 0)
513 :param is_multipath: (Default value = 0)
514 :param is_resolve_host: (Default value = 0)
515 :param is_resolve_attached: (Default value = 0)
516 :param not_last: (Default value = 0)
517 :param next_hop_weight: (Default value = 1)
518
519 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000520
Klement Sekeraf62ae122016-10-11 11:47:09 +0200521 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100522 self.papi.ip_add_del_route,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200523 {'next_hop_sw_if_index': next_hop_sw_if_index,
524 'table_id': table_id,
525 'classify_table_index': classify_table_index,
526 'next_hop_table_id': next_hop_table_id,
527 'create_vrf_if_needed': create_vrf_if_needed,
528 'is_add': is_add,
529 'is_drop': is_drop,
530 'is_unreach': is_unreach,
531 'is_prohibit': is_prohibit,
532 'is_ipv6': is_ipv6,
533 'is_local': is_local,
534 'is_classify': is_classify,
535 'is_multipath': is_multipath,
536 'is_resolve_host': is_resolve_host,
537 'is_resolve_attached': is_resolve_attached,
538 'not_last': not_last,
539 'next_hop_weight': next_hop_weight,
540 'dst_address_length': dst_address_length,
541 'dst_address': dst_address,
542 'next_hop_address': next_hop_address,
543 'next_hop_n_out_labels': next_hop_n_out_labels,
544 'next_hop_via_label': next_hop_via_label,
545 'next_hop_out_label_stack': next_hop_out_label_stack})
Matej Klotton0178d522016-11-04 11:11:44 +0100546
Matej Klotton16a14cd2016-12-07 15:09:13 +0100547 def ip_fib_dump(self):
548 return self.api(self.papi.ip_fib_dump, {})
549
Matej Klotton0178d522016-11-04 11:11:44 +0100550 def ip_neighbor_add_del(self,
551 sw_if_index,
552 mac_address,
553 dst_address,
554 vrf_id=0,
555 is_add=1,
556 is_ipv6=0,
557 is_static=0,
558 ):
559 """ Add neighbor MAC to IPv4 or IPv6 address.
560
561 :param sw_if_index:
562 :param mac_address:
563 :param dst_address:
564 :param vrf_id: (Default value = 0)
565 :param is_add: (Default value = 1)
566 :param is_ipv6: (Default value = 0)
567 :param is_static: (Default value = 0)
568 """
569
570 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100571 self.papi.ip_neighbor_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200572 {'vrf_id': vrf_id,
573 'sw_if_index': sw_if_index,
574 'is_add': is_add,
575 'is_ipv6': is_ipv6,
576 'is_static': is_static,
577 'mac_address': mac_address,
578 'dst_address': dst_address
Ole Troan7e3a8752016-12-05 10:27:09 +0100579 }
Matej Klotton0178d522016-11-04 11:11:44 +0100580 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100581
Klement Sekera7bb873a2016-11-18 07:38:42 +0100582 def sw_interface_span_enable_disable(
Ole Troan399ca1c2016-12-06 23:00:38 +0100583 self, sw_if_index_from, sw_if_index_to, state=1):
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100584 """
585
586 :param sw_if_index_from:
587 :param sw_if_index_to:
Matej Klottondeb69842016-12-09 15:05:46 +0100588 :param state:
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100589 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100590 return self.api(self.papi.sw_interface_span_enable_disable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200591 {'sw_if_index_from': sw_if_index_from,
592 'sw_if_index_to': sw_if_index_to,
593 'state': state})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000594
595 def gre_tunnel_add_del(self,
596 src_address,
597 dst_address,
598 outer_fib_id=0,
599 is_teb=0,
600 is_add=1,
601 is_ip6=0):
602 """ Add a GRE tunnel
603
604 :param src_address:
605 :param dst_address:
606 :param outer_fib_id: (Default value = 0)
607 :param is_add: (Default value = 1)
608 :param is_ipv6: (Default value = 0)
609 :param is_teb: (Default value = 0)
610 """
611
612 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100613 self.papi.gre_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200614 {'is_add': is_add,
615 'is_ipv6': is_ip6,
616 'teb': is_teb,
617 'src_address': src_address,
618 'dst_address': dst_address,
619 'outer_fib_id': outer_fib_id}
Neale Ranns177bbdc2016-11-15 09:46:51 +0000620 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000621
622 def mpls_route_add_del(
623 self,
624 label,
625 eos,
626 next_hop_proto_is_ip4,
627 next_hop_address,
628 next_hop_sw_if_index=0xFFFFFFFF,
629 table_id=0,
630 next_hop_table_id=0,
631 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200632 next_hop_n_out_labels=0,
633 next_hop_out_label_stack=[],
634 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000635 create_vrf_if_needed=0,
636 is_resolve_host=0,
637 is_resolve_attached=0,
638 is_add=1,
639 is_drop=0,
640 is_multipath=0,
641 classify_table_index=0xFFFFFFFF,
642 is_classify=0,
643 not_last=0):
644 """
645
646 :param dst_address_length:
647 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
648 :param dst_address:
649 :param next_hop_address:
650 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
651 :param vrf_id: (Default value = 0)
652 :param lookup_in_vrf: (Default value = 0)
653 :param classify_table_index: (Default value = 0xFFFFFFFF)
654 :param create_vrf_if_needed: (Default value = 0)
655 :param is_add: (Default value = 1)
656 :param is_drop: (Default value = 0)
657 :param is_ipv6: (Default value = 0)
658 :param is_local: (Default value = 0)
659 :param is_classify: (Default value = 0)
660 :param is_multipath: (Default value = 0)
661 :param is_resolve_host: (Default value = 0)
662 :param is_resolve_attached: (Default value = 0)
663 :param not_last: (Default value = 0)
664 :param next_hop_weight: (Default value = 1)
665
666 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000667
668 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100669 self.papi.mpls_route_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200670 {'mr_label': label,
671 'mr_eos': eos,
672 'mr_table_id': table_id,
673 'mr_classify_table_index': classify_table_index,
674 'mr_create_table_if_needed': create_vrf_if_needed,
675 'mr_is_add': is_add,
676 'mr_is_classify': is_classify,
677 'mr_is_multipath': is_multipath,
678 'mr_is_resolve_host': is_resolve_host,
679 'mr_is_resolve_attached': is_resolve_attached,
680 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
681 'mr_next_hop_weight': next_hop_weight,
682 'mr_next_hop': next_hop_address,
683 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
684 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
685 'mr_next_hop_table_id': next_hop_table_id,
686 'mr_next_hop_via_label': next_hop_via_label,
687 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
Neale Rannsad422ed2016-11-02 14:20:04 +0000688
689 def mpls_ip_bind_unbind(
690 self,
691 label,
692 dst_address,
693 dst_address_length,
694 table_id=0,
695 ip_table_id=0,
696 is_ip4=1,
697 create_vrf_if_needed=0,
698 is_bind=1):
699 """
700 """
701 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100702 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200703 {'mb_mpls_table_id': table_id,
704 'mb_label': label,
705 'mb_ip_table_id': ip_table_id,
706 'mb_create_table_if_needed': create_vrf_if_needed,
707 'mb_is_bind': is_bind,
708 'mb_is_ip4': is_ip4,
709 'mb_address_length': dst_address_length,
710 'mb_address': dst_address})
Neale Rannsad422ed2016-11-02 14:20:04 +0000711
712 def mpls_tunnel_add_del(
713 self,
714 tun_sw_if_index,
715 next_hop_proto_is_ip4,
716 next_hop_address,
717 next_hop_sw_if_index=0xFFFFFFFF,
718 next_hop_table_id=0,
719 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200720 next_hop_n_out_labels=0,
721 next_hop_out_label_stack=[],
722 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +0000723 create_vrf_if_needed=0,
724 is_add=1,
725 l2_only=0):
726 """
727
728 :param dst_address_length:
729 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
730 :param dst_address:
731 :param next_hop_address:
732 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
733 :param vrf_id: (Default value = 0)
734 :param lookup_in_vrf: (Default value = 0)
735 :param classify_table_index: (Default value = 0xFFFFFFFF)
736 :param create_vrf_if_needed: (Default value = 0)
737 :param is_add: (Default value = 1)
738 :param is_drop: (Default value = 0)
739 :param is_ipv6: (Default value = 0)
740 :param is_local: (Default value = 0)
741 :param is_classify: (Default value = 0)
742 :param is_multipath: (Default value = 0)
743 :param is_resolve_host: (Default value = 0)
744 :param is_resolve_attached: (Default value = 0)
745 :param not_last: (Default value = 0)
746 :param next_hop_weight: (Default value = 1)
747
748 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000749 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100750 self.papi.mpls_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200751 {'mt_sw_if_index': tun_sw_if_index,
752 'mt_is_add': is_add,
753 'mt_l2_only': l2_only,
754 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
755 'mt_next_hop_weight': next_hop_weight,
756 'mt_next_hop': next_hop_address,
757 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
758 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
759 'mt_next_hop_table_id': next_hop_table_id,
760 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
Matus Fabiande886752016-12-07 03:38:19 -0800761
762 def snat_interface_add_del_feature(
763 self,
764 sw_if_index,
765 is_inside=1,
766 is_add=1):
767 """Enable/disable S-NAT feature on the interface
768
769 :param sw_if_index: Software index of the interface
770 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
771 :param is_add: 1 if add, 0 if delete (Default value = 1)
772 """
773 return self.api(
774 self.papi.snat_interface_add_del_feature,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200775 {'is_add': is_add,
776 'is_inside': is_inside,
777 'sw_if_index': sw_if_index})
Matus Fabiande886752016-12-07 03:38:19 -0800778
779 def snat_add_static_mapping(
780 self,
781 local_ip,
782 external_ip,
783 local_port=0,
784 external_port=0,
785 addr_only=1,
786 vrf_id=0,
787 is_add=1,
788 is_ip4=1):
789 """Add/delete S-NAT static mapping
790
791 :param local_ip: Local IP address
792 :param external_ip: External IP address
793 :param local_port: Local port number (Default value = 0)
794 :param external_port: External port number (Default value = 0)
795 :param addr_only: 1 if address only mapping, 0 if address and port
796 :param vrf_id: VRF ID
797 :param is_add: 1 if add, 0 if delete (Default value = 1)
798 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
799 """
800 return self.api(
801 self.papi.snat_add_static_mapping,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200802 {'is_add': is_add,
803 'is_ip4': is_ip4,
804 'addr_only': addr_only,
805 'local_ip_address': local_ip,
806 'external_ip_address': external_ip,
807 'local_port': local_port,
808 'external_port': external_port,
809 'vrf_id': vrf_id})
Matus Fabiande886752016-12-07 03:38:19 -0800810
811 def snat_add_address_range(
812 self,
813 first_ip_address,
814 last_ip_address,
815 is_add=1,
816 is_ip4=1):
817 """Add/del S-NAT address range
818
819 :param first_ip_address: First IP address
820 :param last_ip_address: Last IP address
821 :param is_add: 1 if add, 0 if delete (Default value = 1)
822 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
823 """
824 return self.api(
825 self.papi.snat_add_address_range,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200826 {'is_ip4': is_ip4,
827 'first_ip_address': first_ip_address,
828 'last_ip_address': last_ip_address,
829 'is_add': is_add})
Matus Fabiande886752016-12-07 03:38:19 -0800830
831 def snat_address_dump(self):
832 """Dump S-NAT addresses
833 :return: Dictionary of S-NAT addresses
834 """
835 return self.api(self.papi.snat_address_dump, {})
836
837 def snat_interface_dump(self):
838 """Dump interfaces with S-NAT feature
839 :return: Dictionary of interfaces with S-NAT feature
840 """
841 return self.api(self.papi.snat_interface_dump, {})
842
843 def snat_static_mapping_dump(self):
844 """Dump S-NAT static mappings
845 :return: Dictionary of S-NAT static mappings
846 """
847 return self.api(self.papi.snat_static_mapping_dump, {})
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200848
Matus Fabian9902fcd2016-12-21 23:58:46 -0800849 def snat_show_config(self):
850 """Show S-NAT config
851 :return: S-NAT config parameters
852 """
853 return self.api(self.papi.snat_show_config, {})
854
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200855 def control_ping(self):
856 self.api(self.papi.control_ping)
857
858 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
859 detect_mult, local_addr, peer_addr, is_ipv6=0):
860 return self.api(self.papi.bfd_udp_add,
861 {
862 'sw_if_index': sw_if_index,
863 'desired_min_tx': desired_min_tx,
864 'required_min_rx': required_min_rx,
865 'local_addr': local_addr,
866 'peer_addr': peer_addr,
867 'is_ipv6': is_ipv6,
868 'detect_mult': detect_mult,
869 })
870
871 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
872 return self.api(self.papi.bfd_udp_del,
873 {
874 'sw_if_index': sw_if_index,
875 'local_addr': local_addr,
876 'peer_addr': peer_addr,
877 'is_ipv6': is_ipv6,
878 })
879
880 def bfd_udp_session_dump(self):
881 return self.api(self.papi.bfd_udp_session_dump, {})
882
883 def bfd_session_set_flags(self, bs_idx, admin_up_down):
884 return self.api(self.papi.bfd_session_set_flags, {
885 'bs_index': bs_idx,
886 'admin_up_down': admin_up_down,
887 })
888
889 def want_bfd_events(self, enable_disable=1):
890 return self.api(self.papi.want_bfd_events, {
891 'enable_disable': enable_disable,
892 'pid': os.getpid(),
893 })
Steve Shin7957d6e2016-12-19 09:24:50 -0800894
895 def classify_add_del_table(
896 self,
897 is_add,
898 mask,
899 match_n_vectors=1,
900 table_index=0xFFFFFFFF,
901 nbuckets=2,
902 memory_size=2097152,
903 skip_n_vectors=0,
904 next_table_index=0xFFFFFFFF,
905 miss_next_index=0xFFFFFFFF,
906 current_data_flag=0,
907 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -0800908 """
909 :param is_add:
910 :param mask:
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100911 :param match_n_vectors: (Default value = 1):
912 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -0800913 :param nbuckets: (Default value = 2)
914 :param memory_size: (Default value = 2097152)
915 :param skip_n_vectors: (Default value = 0)
916 :param next_table_index: (Default value = 0xFFFFFFFF)
917 :param miss_next_index: (Default value = 0xFFFFFFFF)
918 :param current_data_flag: (Default value = 0)
919 :param current_data_offset: (Default value = 0)
920 """
921
922 return self.api(
923 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100924 {'is_add': is_add,
925 'table_index': table_index,
926 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -0800927 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100928 'skip_n_vectors': skip_n_vectors,
929 'match_n_vectors': match_n_vectors,
930 'next_table_index': next_table_index,
931 'miss_next_index': miss_next_index,
932 'current_data_flag': current_data_flag,
933 'current_data_offset': current_data_offset,
934 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -0800935
936 def classify_add_del_session(
937 self,
938 is_add,
939 table_index,
940 match,
941 opaque_index=0xFFFFFFFF,
942 hit_next_index=0xFFFFFFFF,
943 advance=0,
944 action=0,
945 metadata=0):
946 """
947 :param is_add:
948 :param table_index:
949 :param match:
950 :param opaque_index: (Default value = 0xFFFFFFFF)
951 :param hit_next_index: (Default value = 0xFFFFFFFF)
952 :param advance: (Default value = 0)
953 :param action: (Default value = 0)
954 :param metadata: (Default value = 0)
955 """
956
957 return self.api(
958 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100959 {'is_add': is_add,
960 'table_index': table_index,
961 'hit_next_index': hit_next_index,
962 'opaque_index': opaque_index,
963 'advance': advance,
964 'action': action,
965 'metadata': metadata,
966 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -0800967
968 def input_acl_set_interface(
969 self,
970 is_add,
971 sw_if_index,
972 ip4_table_index=0xFFFFFFFF,
973 ip6_table_index=0xFFFFFFFF,
974 l2_table_index=0xFFFFFFFF):
975 """
976 :param is_add:
977 :param sw_if_index:
978 :param ip4_table_index: (Default value = 0xFFFFFFFF)
979 :param ip6_table_index: (Default value = 0xFFFFFFFF)
980 :param l2_table_index: (Default value = 0xFFFFFFFF)
981 """
982
983 return self.api(
984 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100985 {'sw_if_index': sw_if_index,
986 'ip4_table_index': ip4_table_index,
987 'ip6_table_index': ip6_table_index,
988 'l2_table_index': l2_table_index,
989 'is_add': is_add})
990
991 def set_ipfix_exporter(
992 self,
993 collector_address,
994 src_address,
995 path_mtu,
996 template_interval,
997 vrf_id=0,
998 collector_port=4739,
999 udp_checksum=0):
1000 return self.api(
1001 self.papi.set_ipfix_exporter,
1002 {
1003 'collector_address': collector_address,
1004 'collector_port': collector_port,
1005 'src_address': src_address,
1006 'vrf_id': vrf_id,
1007 'path_mtu': path_mtu,
1008 'template_interval': template_interval,
1009 'udp_checksum': udp_checksum,
1010 })