5 from collections import deque
7 # Sphinx creates auto-generated documentation by importing the python source
8 # 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.
13 no_vpp_papi = os.getenv("NO_VPP_PAPI")
14 if no_vpp_papi == "1":
20 from vpp_papi import VPP
22 # from vnet/vnet/mpls/mpls_types.h
23 MPLS_IETF_MAX_LABEL = 0xfffff
24 MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
31 class VppPapiProvider(object):
32 """VPP-api provider using vpp-papi
34 @property hook: hook object providing before and after api/cli hooks
39 def __init__(self, name, shm_prefix, test_class):
40 self.hook = Hook("vpp-papi-provider")
42 self.shm_prefix = shm_prefix
43 self.test_class = test_class
46 install_dir = os.getenv('VPP_TEST_INSTALL_PATH')
47 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))
51 self.papi = VPP(jsonfiles)
52 self._events = deque()
54 def register_hook(self, hook):
55 """Replace hook registration with new hook
62 def collect_events(self):
63 """ Collect all events from the internal queue and clear the queue. """
65 self._events = deque()
68 def wait_for_event(self, timeout, name=None):
69 """ Wait for and return next event. """
71 self.test_class.logger.debug("Not waiting, event already queued")
72 limit = time.time() + timeout
73 while time.time() < limit:
75 e = self._events.popleft()
76 if name and type(e).__name__ != name:
78 "Unexpected event received: %s, expected: %s" %
79 (type(e).__name__, name))
80 self.test_class.logger.debug("Returning event %s:%s" %
85 raise Exception("Event %s did not occur within timeout" % name)
86 raise Exception("Event did not occur within timeout")
88 def __call__(self, name, event):
89 """ Enqueue event in the internal event queue. """
90 # FIXME use the name instead of relying on type(e).__name__ ?
91 # FIXME #2 if this throws, it is eaten silently, Ole?
92 self.test_class.logger.debug("New event: %s: %s" % (name, event))
93 self._events.append(event)
96 """Connect the API to VPP"""
97 self.papi.connect(self.name, self.shm_prefix)
98 self.papi.register_event_callback(self)
100 def disconnect(self):
101 """Disconnect the API from VPP"""
102 self.papi.disconnect()
104 def api(self, api_fn, api_args, expected_retval=0):
105 """ Call API function and check it's return value.
106 Call the appropriate hooks before and after the API call
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
114 self.hook.before_api(api_fn.__name__, api_args)
115 reply = api_fn(**api_args)
116 if hasattr(reply, 'retval') and reply.retval != expected_retval:
117 msg = "API call failed, expected retval == %d, got %s" % (
118 expected_retval, repr(reply))
119 self.test_class.logger.info(msg)
121 self.hook.after_api(api_fn.__name__, api_args)
125 """ Execute a CLI, calling the before/after hooks appropriately.
127 :param cli: CLI to execute
131 self.hook.before_cli(cli)
133 r = self.papi.cli_inband(length=len(cli), cmd=cli)
134 self.hook.after_cli(cli)
135 if hasattr(r, 'reply'):
136 return r.reply.decode().rstrip('\x00')
138 def ppcli(self, cli):
139 """ Helper method to print CLI command in case of info logging level.
141 :param cli: CLI to execute
144 return cli + "\n" + str(self.cli(cli))
146 def _convert_mac(self, mac):
147 return int(mac.replace(":", ""), 16) << 16
149 def show_version(self):
151 return self.papi.show_version()
153 def pg_create_interface(self, pg_index):
159 return self.api(self.papi.pg_create_interface,
160 {"interface_id": pg_index})
162 def sw_interface_dump(self, filter=None):
165 :param filter: (Default value = None)
168 if filter is not None:
169 args = {"name_filter_valid": 1, "name_filter": filter}
172 return self.api(self.papi.sw_interface_dump, args)
174 def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
175 """ Set the IPvX Table-id for the Interface
182 return self.api(self.papi.sw_interface_set_table,
183 {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6,
186 def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
187 is_ipv6=0, is_add=1, del_all=0):
190 :param addr: param is_ipv6: (Default value = 0)
193 :param is_ipv6: (Default value = 0)
194 :param is_add: (Default value = 1)
195 :param del_all: (Default value = 0)
198 return self.api(self.papi.sw_interface_add_del_address,
199 {'sw_if_index': sw_if_index,
203 'address_length': addr_len,
206 def sw_interface_enable_disable_mpls(self, sw_if_index,
209 Enable/Disable MPLS on the interface
211 :param is_enable: (Default value = 1)
214 return self.api(self.papi.sw_interface_set_mpls_enable,
215 {'sw_if_index': sw_if_index,
216 'enable': is_enable})
218 def sw_interface_ra_suppress(self, sw_if_index):
219 return self.api(self.papi.sw_interface_ip6nd_ra_config,
220 {'sw_if_index': sw_if_index})
222 def ip6_sw_interface_ra_config(self, sw_if_index,
225 return self.api(self.papi.sw_interface_ip6nd_ra_config,
226 {'sw_if_index': sw_if_index,
227 'suppress': suppress,
228 'send_unicast': send_unicast})
230 def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
232 Enable/Disable An interface for IPv6
234 return self.api(self.papi.sw_interface_ip6_enable_disable,
235 {'sw_if_index': sw_if_index,
238 def vxlan_add_del_tunnel(
242 mcast_sw_if_index=0xFFFFFFFF,
246 decap_next_index=0xFFFFFFFF,
252 :param is_add: (Default value = 1)
253 :param is_ipv6: (Default value = 0)
254 :param encap_vrf_id: (Default value = 0)
255 :param decap_next_index: (Default value = 0xFFFFFFFF)
256 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
257 :param vni: (Default value = 0)
260 return self.api(self.papi.vxlan_add_del_tunnel,
263 'src_address': src_addr,
264 'dst_address': dst_addr,
265 'mcast_sw_if_index': mcast_sw_if_index,
266 'encap_vrf_id': encap_vrf_id,
267 'decap_next_index': decap_next_index,
270 def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
271 learn=1, arp_term=0, is_add=1):
272 """Create/delete bridge domain.
274 :param int bd_id: Bridge domain index.
275 :param int flood: Enable/disable bcast/mcast flooding in the BD.
277 :param int uu_flood: Enable/disable unknown unicast flood in the BD.
279 :param int forward: Enable/disable forwarding on all interfaces in
280 the BD. (Default value = 1)
281 :param int learn: Enable/disable learning on all interfaces in the BD.
283 :param int arp_term: Enable/disable arp termination in the BD.
285 :param int is_add: Add or delete flag. (Default value = 1)
287 return self.api(self.papi.bridge_domain_add_del,
290 'uu_flood': uu_flood,
293 'arp_term': arp_term,
296 def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
297 filter_mac=0, bvi_mac=0):
298 """Create/delete L2 FIB entry.
300 :param str mac: MAC address to create FIB entry for.
301 :param int bd_id: Bridge domain index.
302 :param int sw_if_index: Software interface index of the interface.
303 :param int is_add: Add or delete flag. (Default value = 1)
304 :param int static_mac: Set to 1 to create static MAC entry.
306 :param int filter_mac: Set to 1 to drop packet that's source or
307 destination MAC address contains defined MAC address.
309 :param int bvi_mac: Set to 1 to create entry that points to BVI
310 interface. (Default value = 0)
312 return self.api(self.papi.l2fib_add_del,
313 {'mac': self._convert_mac(mac),
315 'sw_if_index': sw_if_index,
317 'static_mac': static_mac,
318 'filter_mac': filter_mac,
321 def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
322 shg=0, bvi=0, enable=1):
323 """Add/remove interface to/from bridge domain.
325 :param int sw_if_index: Software interface index of the interface.
326 :param int bd_id: Bridge domain index.
327 :param int shg: Split-horizon group index. (Default value = 0)
328 :param int bvi: Set interface as a bridge group virtual interface.
330 :param int enable: Add or remove interface. (Default value = 1)
332 return self.api(self.papi.sw_interface_set_l2_bridge,
333 {'rx_sw_if_index': sw_if_index,
339 def bridge_flags(self, bd_id, is_set, feature_bitmap):
340 """Enable/disable required feature of the bridge domain with defined ID.
342 :param int bd_id: Bridge domain ID.
343 :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
344 :param int feature_bitmap: Bitmap value of the feature to be set:
348 - uu-flood (1 << 3) or
351 return self.api(self.papi.bridge_flags,
354 'feature_bitmap': feature_bitmap})
356 def bridge_domain_dump(self, bd_id=0):
359 :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
360 existing bridge domains returned)
361 :return: Dictionary of bridge domain(s) data.
363 return self.api(self.papi.bridge_domain_dump,
366 def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
368 """Create or delete unidirectional cross-connect from Tx interface to
371 :param int rx_sw_if_index: Software interface index of Rx interface.
372 :param int tx_sw_if_index: Software interface index of Tx interface.
373 :param int enable: Create cross-connect if equal to 1, delete
374 cross-connect if equal to 0.
377 return self.api(self.papi.sw_interface_set_l2_xconnect,
378 {'rx_sw_if_index': rx_sw_if_index,
379 'tx_sw_if_index': tx_sw_if_index,
382 def sw_interface_set_l2_tag_rewrite(
389 """L2 interface vlan tag rewrite configure request
390 :param client_index - opaque cookie to identify the sender
391 :param context - sender context, to match reply w/ request
392 :param sw_if_index - interface the operation is applied to
393 :param vtr_op - Choose from l2_vtr_op_t enum values
394 :param push_dot1q - first pushed flag dot1q id set, else dot1ad
395 :param tag1 - Needed for any push or translate vtr op
396 :param tag2 - Needed for any push 2 or translate x-2 vtr ops
399 return self.api(self.papi.l2_interface_vlan_tag_rewrite,
400 {'sw_if_index': sw_if_index,
406 def sw_interface_set_flags(self, sw_if_index, admin_up_down,
407 link_up_down=0, deleted=0):
410 :param admin_up_down:
412 :param link_up_down: (Default value = 0)
413 :param deleted: (Default value = 0)
416 return self.api(self.papi.sw_interface_set_flags,
417 {'sw_if_index': sw_if_index,
418 'admin_up_down': admin_up_down,
419 'link_up_down': link_up_down,
422 def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
423 no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
424 default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):
425 """Create subinterface
426 from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
428 :param sub_id: param inner_vlan:
432 :param no_tags: (Default value = 0)
433 :param one_tag: (Default value = 0)
434 :param two_tags: (Default value = 0)
435 :param dot1ad: (Default value = 0)
436 :param exact_match: (Default value = 0)
437 :param default_sub: (Default value = 0)
438 :param outer_vlan_id_any: (Default value = 0)
439 :param inner_vlan_id_any: (Default value = 0)
443 self.papi.create_subif,
444 {'sw_if_index': sw_if_index,
448 'two_tags': two_tags,
450 'exact_match': exact_match,
451 'default_sub': default_sub,
452 'outer_vlan_id_any': outer_vlan_id_any,
453 'inner_vlan_id_any': inner_vlan_id_any,
454 'outer_vlan_id': outer_vlan,
455 'inner_vlan_id': inner_vlan})
457 def delete_subif(self, sw_if_index):
458 """Delete subinterface
462 return self.api(self.papi.delete_subif,
463 {'sw_if_index': sw_if_index})
465 def create_vlan_subif(self, sw_if_index, vlan):
472 return self.api(self.papi.create_vlan_subif,
473 {'sw_if_index': sw_if_index,
476 def create_loopback(self, mac=''):
479 :param mac: (Optional)
481 return self.api(self.papi.create_loopback,
482 {'mac_address': mac})
484 def delete_loopback(self, sw_if_index):
485 return self.api(self.papi.delete_loopback,
486 {'sw_if_index': sw_if_index, })
488 def ip_add_del_route(
493 next_hop_sw_if_index=0xFFFFFFFF,
497 next_hop_n_out_labels=0,
498 next_hop_out_label_stack=[],
499 next_hop_via_label=MPLS_LABEL_INVALID,
500 create_vrf_if_needed=0,
502 is_resolve_attached=0,
503 classify_table_index=0xFFFFFFFF,
515 :param dst_address_length:
516 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
518 :param next_hop_address:
519 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
520 :param vrf_id: (Default value = 0)
521 :param lookup_in_vrf: (Default value = 0)
522 :param classify_table_index: (Default value = 0xFFFFFFFF)
523 :param create_vrf_if_needed: (Default value = 0)
524 :param is_add: (Default value = 1)
525 :param is_drop: (Default value = 0)
526 :param is_ipv6: (Default value = 0)
527 :param is_local: (Default value = 0)
528 :param is_classify: (Default value = 0)
529 :param is_multipath: (Default value = 0)
530 :param is_resolve_host: (Default value = 0)
531 :param is_resolve_attached: (Default value = 0)
532 :param not_last: (Default value = 0)
533 :param next_hop_weight: (Default value = 1)
538 self.papi.ip_add_del_route,
539 {'next_hop_sw_if_index': next_hop_sw_if_index,
540 'table_id': table_id,
541 'classify_table_index': classify_table_index,
542 'next_hop_table_id': next_hop_table_id,
543 'create_vrf_if_needed': create_vrf_if_needed,
546 'is_unreach': is_unreach,
547 'is_prohibit': is_prohibit,
549 'is_local': is_local,
550 'is_classify': is_classify,
551 'is_multipath': is_multipath,
552 'is_resolve_host': is_resolve_host,
553 'is_resolve_attached': is_resolve_attached,
554 'not_last': not_last,
555 'next_hop_weight': next_hop_weight,
556 'dst_address_length': dst_address_length,
557 'dst_address': dst_address,
558 'next_hop_address': next_hop_address,
559 'next_hop_n_out_labels': next_hop_n_out_labels,
560 'next_hop_via_label': next_hop_via_label,
561 'next_hop_out_label_stack': next_hop_out_label_stack})
563 def ip_fib_dump(self):
564 return self.api(self.papi.ip_fib_dump, {})
566 def ip_neighbor_add_del(self,
575 """ Add neighbor MAC to IPv4 or IPv6 address.
580 :param vrf_id: (Default value = 0)
581 :param is_add: (Default value = 1)
582 :param is_ipv6: (Default value = 0)
583 :param is_static: (Default value = 0)
587 self.papi.ip_neighbor_add_del,
589 'sw_if_index': sw_if_index,
592 'is_static': is_static,
593 'mac_address': mac_address,
594 'dst_address': dst_address
602 """ Reset VRF (remove all routes etc.) request.
604 :param int vrf_id: ID of the FIB table / VRF to reset.
605 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
619 """ Reset VRF (remove all routes etc.) request.
621 :param int vrf_id: ID of the FIB table / VRF to reset.
622 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
637 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
646 def sw_interface_span_enable_disable(
647 self, sw_if_index_from, sw_if_index_to, state=1):
650 :param sw_if_index_from:
651 :param sw_if_index_to:
654 return self.api(self.papi.sw_interface_span_enable_disable,
655 {'sw_if_index_from': sw_if_index_from,
656 'sw_if_index_to': sw_if_index_to,
659 def gre_tunnel_add_del(self,
670 :param outer_fib_id: (Default value = 0)
671 :param is_add: (Default value = 1)
672 :param is_ipv6: (Default value = 0)
673 :param is_teb: (Default value = 0)
677 self.papi.gre_add_del_tunnel,
681 'src_address': src_address,
682 'dst_address': dst_address,
683 'outer_fib_id': outer_fib_id}
686 def mpls_route_add_del(
690 next_hop_proto_is_ip4,
692 next_hop_sw_if_index=0xFFFFFFFF,
696 next_hop_n_out_labels=0,
697 next_hop_out_label_stack=[],
698 next_hop_via_label=MPLS_LABEL_INVALID,
699 create_vrf_if_needed=0,
701 is_resolve_attached=0,
705 classify_table_index=0xFFFFFFFF,
710 :param dst_address_length:
711 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
713 :param next_hop_address:
714 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
715 :param vrf_id: (Default value = 0)
716 :param lookup_in_vrf: (Default value = 0)
717 :param classify_table_index: (Default value = 0xFFFFFFFF)
718 :param create_vrf_if_needed: (Default value = 0)
719 :param is_add: (Default value = 1)
720 :param is_drop: (Default value = 0)
721 :param is_ipv6: (Default value = 0)
722 :param is_local: (Default value = 0)
723 :param is_classify: (Default value = 0)
724 :param is_multipath: (Default value = 0)
725 :param is_resolve_host: (Default value = 0)
726 :param is_resolve_attached: (Default value = 0)
727 :param not_last: (Default value = 0)
728 :param next_hop_weight: (Default value = 1)
733 self.papi.mpls_route_add_del,
736 'mr_table_id': table_id,
737 'mr_classify_table_index': classify_table_index,
738 'mr_create_table_if_needed': create_vrf_if_needed,
740 'mr_is_classify': is_classify,
741 'mr_is_multipath': is_multipath,
742 'mr_is_resolve_host': is_resolve_host,
743 'mr_is_resolve_attached': is_resolve_attached,
744 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
745 'mr_next_hop_weight': next_hop_weight,
746 'mr_next_hop': next_hop_address,
747 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
748 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
749 'mr_next_hop_table_id': next_hop_table_id,
750 'mr_next_hop_via_label': next_hop_via_label,
751 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
753 def mpls_ip_bind_unbind(
761 create_vrf_if_needed=0,
766 self.papi.mpls_ip_bind_unbind,
767 {'mb_mpls_table_id': table_id,
769 'mb_ip_table_id': ip_table_id,
770 'mb_create_table_if_needed': create_vrf_if_needed,
771 'mb_is_bind': is_bind,
773 'mb_address_length': dst_address_length,
774 'mb_address': dst_address})
776 def mpls_tunnel_add_del(
779 next_hop_proto_is_ip4,
781 next_hop_sw_if_index=0xFFFFFFFF,
784 next_hop_n_out_labels=0,
785 next_hop_out_label_stack=[],
786 next_hop_via_label=MPLS_LABEL_INVALID,
787 create_vrf_if_needed=0,
792 :param dst_address_length:
793 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
795 :param next_hop_address:
796 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
797 :param vrf_id: (Default value = 0)
798 :param lookup_in_vrf: (Default value = 0)
799 :param classify_table_index: (Default value = 0xFFFFFFFF)
800 :param create_vrf_if_needed: (Default value = 0)
801 :param is_add: (Default value = 1)
802 :param is_drop: (Default value = 0)
803 :param is_ipv6: (Default value = 0)
804 :param is_local: (Default value = 0)
805 :param is_classify: (Default value = 0)
806 :param is_multipath: (Default value = 0)
807 :param is_resolve_host: (Default value = 0)
808 :param is_resolve_attached: (Default value = 0)
809 :param not_last: (Default value = 0)
810 :param next_hop_weight: (Default value = 1)
814 self.papi.mpls_tunnel_add_del,
815 {'mt_sw_if_index': tun_sw_if_index,
817 'mt_l2_only': l2_only,
818 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
819 'mt_next_hop_weight': next_hop_weight,
820 'mt_next_hop': next_hop_address,
821 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
822 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
823 'mt_next_hop_table_id': next_hop_table_id,
824 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
826 def snat_interface_add_del_feature(
831 """Enable/disable S-NAT feature on the interface
833 :param sw_if_index: Software index of the interface
834 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
835 :param is_add: 1 if add, 0 if delete (Default value = 1)
838 self.papi.snat_interface_add_del_feature,
840 'is_inside': is_inside,
841 'sw_if_index': sw_if_index})
843 def snat_add_static_mapping(
847 external_sw_if_index=0xFFFFFFFF,
854 """Add/delete S-NAT static mapping
856 :param local_ip: Local IP address
857 :param external_ip: External IP address
858 :param external_sw_if_index: External interface instead of IP address
859 :param local_port: Local port number (Default value = 0)
860 :param external_port: External port number (Default value = 0)
861 :param addr_only: 1 if address only mapping, 0 if address and port
862 :param vrf_id: VRF ID
863 :param is_add: 1 if add, 0 if delete (Default value = 1)
864 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
867 self.papi.snat_add_static_mapping,
870 'addr_only': addr_only,
871 'local_ip_address': local_ip,
872 'external_ip_address': external_ip,
873 'local_port': local_port,
874 'external_port': external_port,
875 'external_sw_if_index': external_sw_if_index,
878 def snat_add_address_range(
884 """Add/del S-NAT address range
886 :param first_ip_address: First IP address
887 :param last_ip_address: Last IP address
888 :param is_add: 1 if add, 0 if delete (Default value = 1)
889 :param is_ip4: 1 if address type is IPv4 (Default value = 1)
892 self.papi.snat_add_address_range,
894 'first_ip_address': first_ip_address,
895 'last_ip_address': last_ip_address,
898 def snat_address_dump(self):
899 """Dump S-NAT addresses
900 :return: Dictionary of S-NAT addresses
902 return self.api(self.papi.snat_address_dump, {})
904 def snat_interface_dump(self):
905 """Dump interfaces with S-NAT feature
906 :return: Dictionary of interfaces with S-NAT feature
908 return self.api(self.papi.snat_interface_dump, {})
910 def snat_static_mapping_dump(self):
911 """Dump S-NAT static mappings
912 :return: Dictionary of S-NAT static mappings
914 return self.api(self.papi.snat_static_mapping_dump, {})
916 def snat_show_config(self):
918 :return: S-NAT config parameters
920 return self.api(self.papi.snat_show_config, {})
922 def snat_add_interface_addr(
926 """Add/del S-NAT address from interface
928 :param sw_if_index: Software index of the interface
929 :param is_add: 1 if add, 0 if delete (Default value = 1)
931 return self.api(self.papi.snat_add_del_interface_addr,
932 {'is_add': is_add, 'sw_if_index': sw_if_index})
934 def snat_interface_addr_dump(self):
935 """Dump S-NAT addresses interfaces
936 :return: Dictionary of S-NAT addresses interfaces
938 return self.api(self.papi.snat_interface_addr_dump, {})
945 """Enable/disable S-NAT IPFIX logging
947 :param domain_id: Observation domain ID (Default value = 1)
948 :param src_port: Source port number (Default value = 4739)
949 :param enable: 1 if enable, 0 if disable (Default value = 1)
952 self.papi.snat_ipfix_enable_disable,
953 {'domain_id': domain_id,
954 'src_port': src_port,
957 def control_ping(self):
958 self.api(self.papi.control_ping)
960 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
961 detect_mult, local_addr, peer_addr, is_ipv6=0):
962 return self.api(self.papi.bfd_udp_add,
964 'sw_if_index': sw_if_index,
965 'desired_min_tx': desired_min_tx,
966 'required_min_rx': required_min_rx,
967 'local_addr': local_addr,
968 'peer_addr': peer_addr,
970 'detect_mult': detect_mult,
973 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
974 return self.api(self.papi.bfd_udp_del,
976 'sw_if_index': sw_if_index,
977 'local_addr': local_addr,
978 'peer_addr': peer_addr,
982 def bfd_udp_session_dump(self):
983 return self.api(self.papi.bfd_udp_session_dump, {})
985 def bfd_session_set_flags(self, bs_idx, admin_up_down):
986 return self.api(self.papi.bfd_session_set_flags, {
988 'admin_up_down': admin_up_down,
991 def want_bfd_events(self, enable_disable=1):
992 return self.api(self.papi.want_bfd_events, {
993 'enable_disable': enable_disable,
997 def classify_add_del_table(
1002 table_index=0xFFFFFFFF,
1004 memory_size=2097152,
1006 next_table_index=0xFFFFFFFF,
1007 miss_next_index=0xFFFFFFFF,
1008 current_data_flag=0,
1009 current_data_offset=0):
1013 :param match_n_vectors: (Default value = 1)
1014 :param table_index: (Default value = 0xFFFFFFFF)
1015 :param nbuckets: (Default value = 2)
1016 :param memory_size: (Default value = 2097152)
1017 :param skip_n_vectors: (Default value = 0)
1018 :param next_table_index: (Default value = 0xFFFFFFFF)
1019 :param miss_next_index: (Default value = 0xFFFFFFFF)
1020 :param current_data_flag: (Default value = 0)
1021 :param current_data_offset: (Default value = 0)
1025 self.papi.classify_add_del_table,
1027 'table_index': table_index,
1028 'nbuckets': nbuckets,
1029 'memory_size': memory_size,
1030 'skip_n_vectors': skip_n_vectors,
1031 'match_n_vectors': match_n_vectors,
1032 'next_table_index': next_table_index,
1033 'miss_next_index': miss_next_index,
1034 'current_data_flag': current_data_flag,
1035 'current_data_offset': current_data_offset,
1038 def classify_add_del_session(
1043 opaque_index=0xFFFFFFFF,
1044 hit_next_index=0xFFFFFFFF,
1052 :param opaque_index: (Default value = 0xFFFFFFFF)
1053 :param hit_next_index: (Default value = 0xFFFFFFFF)
1054 :param advance: (Default value = 0)
1055 :param action: (Default value = 0)
1056 :param metadata: (Default value = 0)
1060 self.papi.classify_add_del_session,
1062 'table_index': table_index,
1063 'hit_next_index': hit_next_index,
1064 'opaque_index': opaque_index,
1067 'metadata': metadata,
1070 def input_acl_set_interface(
1074 ip4_table_index=0xFFFFFFFF,
1075 ip6_table_index=0xFFFFFFFF,
1076 l2_table_index=0xFFFFFFFF):
1080 :param ip4_table_index: (Default value = 0xFFFFFFFF)
1081 :param ip6_table_index: (Default value = 0xFFFFFFFF)
1082 :param l2_table_index: (Default value = 0xFFFFFFFF)
1086 self.papi.input_acl_set_interface,
1087 {'sw_if_index': sw_if_index,
1088 'ip4_table_index': ip4_table_index,
1089 'ip6_table_index': ip6_table_index,
1090 'l2_table_index': l2_table_index,
1093 def set_ipfix_exporter(
1100 collector_port=4739,
1103 self.papi.set_ipfix_exporter,
1105 'collector_address': collector_address,
1106 'collector_port': collector_port,
1107 'src_address': src_address,
1109 'path_mtu': path_mtu,
1110 'template_interval': template_interval,
1111 'udp_checksum': udp_checksum,