blob: d80f2ed440019326e4520438680fc90478898243 [file] [log] [blame]
Ole Troan9a475372019-03-05 16:58:24 +01001# NB NB NB NB NB NB NB NB NB NB NB
2#
3# NOTE: The API binary wrappers in this file are in the process of being
4# deprecated. DO NOT ADD NEW WRAPPERS HERE. Call the functions using
5# named arguments directly instead.
6#
7
Paul Vinciguerra00671cf2018-11-25 12:47:04 -08008import os
Klement Sekera0e3c0de2016-09-29 14:43:44 +02009import time
Klement Sekerae4504c62016-12-08 10:16:41 +010010from collections import deque
Klement Sekeraf62ae122016-10-11 11:47:09 +020011
Ole Troanf159f582019-02-28 20:20:47 +010012from six import moves, iteritems
Paul Vinciguerra19542292019-03-17 17:34:46 -070013from vpp_papi import VPPApiClient, mac_pton
Paul Vinciguerra00671cf2018-11-25 12:47:04 -080014from hook import Hook
Paul Vinciguerrab5f15bd2019-03-17 08:42:58 -070015from vpp_ip_route import MPLS_IETF_MAX_LABEL, MPLS_LABEL_INVALID
Klement Sekeraf62ae122016-10-11 11:47:09 +020016
Klement Sekera0e3c0de2016-09-29 14:43:44 +020017
Ole Troanf159f582019-02-28 20:20:47 +010018#
19# Dictionary keyed on message name to override default values for
20# named parameters
21#
Ole Troan9a475372019-03-05 16:58:24 +010022defaultmapping = {
23 'map_add_domain': {'mtu': 1280},
24 'syslog_set_sender': {'collector_port': 514,
25 'max_msg_size': 480},
26 'acl_interface_add_del': {'is_add': 1, 'is_input': 1},
27 'acl_interface_list_dump': {'sw_if_index': 4294967295, },
28 'app_namespace_add_del': {'sw_if_index': 4294967295, },
29 'bd_ip_mac_add_del': {'is_add': 1, },
Jakub Grajciar4682feb2019-09-02 13:28:52 +020030 'bfd_udp_add': {'is_authenticated': False, 'bfd_key_id': None,
31 'conf_key_id': None},
32 'bfd_udp_auth_activate': {'bfd_key_id': None, 'conf_key_id': None,
33 'is_delayed': False},
Ole Troan9a475372019-03-05 16:58:24 +010034 'bier_disp_entry_add_del': {'next_hop_rpf_id': -1, 'next_hop_is_ip4': 1,
35 'is_add': 1, },
36 'bier_disp_table_add_del': {'is_add': 1, },
37 'bier_imp_add': {'is_add': 1, },
38 'bier_route_add_del': {'is_add': 1, },
39 'bier_table_add_del': {'is_add': 1, },
Jakub Grajciar3d1ef872019-08-26 12:55:15 +020040 'bond_create': {'mac_address': '', 'id': 0xFFFFFFFF},
Ole Troan9a475372019-03-05 16:58:24 +010041 'bridge_domain_add_del': {'flood': 1, 'uu_flood': 1, 'forward': 1,
42 'learn': 1, 'is_add': 1, },
Paul Vinciguerra9a29f792019-04-30 20:44:25 -070043 'bvi_create': {'user_instance': 4294967295, },
44 'bvi_delete': {},
Ole Troan9a475372019-03-05 16:58:24 +010045 'classify_add_del_table': {'match_n_vectors': 1, 'table_index': 4294967295,
46 'nbuckets': 2, 'memory_size': 2097152,
47 'next_table_index': 4294967295,
48 'miss_next_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010049 'gbp_subnet_add_del': {'sw_if_index': 4294967295, 'epg_id': 65535, },
50 'geneve_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
51 'decap_next_index': 4294967295, },
Neale Ranns5a8844b2019-04-16 07:15:35 +000052 'gre_tunnel_add_del': {'instance': 4294967295, 'is_add': 1, },
Ole Troan9a475372019-03-05 16:58:24 +010053 'gtpu_add_del_tunnel': {'is_add': 1, 'mcast_sw_if_index': 4294967295,
54 'decap_next_index': 4294967295, },
55 'input_acl_set_interface': {'ip4_table_index': 4294967295,
56 'ip6_table_index': 4294967295,
57 'l2_table_index': 4294967295, },
58 'ip6_add_del_address_using_prefix': {'is_add': 1, },
59 'ip6nd_send_router_solicitation': {'irt': 1, 'mrt': 120, },
60 'ip_add_del_route': {'next_hop_sw_if_index': 4294967295,
61 'next_hop_weight': 1, 'next_hop_via_label': 1048576,
Ole Troan9a475372019-03-05 16:58:24 +010062 'classify_table_index': 4294967295, 'is_add': 1, },
63 'ip_mroute_add_del': {'is_add': 1, },
64 'ip_neighbor_add_del': {'is_add': 1, },
65 'ip_punt_police': {'is_add': 1, },
66 'ip_punt_redirect': {'is_add': 1, },
Neale Ranns097fa662018-05-01 05:17:55 -070067 'ip_route_add_del': {'is_add': 1, },
Ole Troan9a475372019-03-05 16:58:24 +010068 'ip_table_add_del': {'is_add': 1, },
69 'ip_unnumbered_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010070 'ipsec_interface_add_del_spd': {'is_add': 1, },
71 'ipsec_sad_entry_add_del': {'is_add': 1, },
72 'ipsec_spd_add_del': {'is_add': 1, },
73 'ipsec_spd_dump': {'sa_id': 4294967295, },
74 'ipsec_spd_entry_add_del': {'local_port_stop': 65535,
75 'remote_port_stop': 65535, 'priority': 100,
76 'is_outbound': 1,
77 'is_add': 1, },
78 'ipsec_tunnel_if_add_del': {'is_add': 1, 'anti_replay': 1, },
79 'l2_emulation': {'enable': 1, },
80 'l2fib_add_del': {'is_add': 1, },
Paul Vinciguerraf7f13342019-03-19 11:54:39 -070081 'lb_conf': {'sticky_buckets_per_core': 4294967295,
82 'flow_timeout': 4294967295},
Ole Troan9a475372019-03-05 16:58:24 +010083 'lisp_add_del_adjacency': {'is_add': 1, },
84 'lisp_add_del_local_eid': {'is_add': 1, },
85 'lisp_add_del_locator': {'priority': 1, 'weight': 1, 'is_add': 1, },
86 'lisp_add_del_locator_set': {'is_add': 1, },
87 'lisp_add_del_remote_mapping': {'is_add': 1, },
88 'macip_acl_add_replace': {'acl_index': 4294967295, },
89 'macip_acl_dump': {'acl_index': 4294967295, },
90 'macip_acl_interface_add_del': {'is_add': 1, },
91 'mpls_ip_bind_unbind': {'is_ip4': 1, 'is_bind': 1, },
Ole Troana5b2eec2019-03-11 19:23:25 +010092 'mpls_route_add_del': {'mr_next_hop_sw_if_index': 4294967295,
93 'mr_next_hop_weight': 1,
94 'mr_next_hop_via_label': 1048576,
95 'mr_is_add': 1,
96 'mr_classify_table_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +010097 'mpls_table_add_del': {'is_add': 1, },
98 'mpls_tunnel_add_del': {'next_hop_sw_if_index': 4294967295,
99 'next_hop_weight': 1,
100 'next_hop_via_label': 1048576,
101 'is_add': 1, },
102 'mpls_tunnel_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100103 'output_acl_set_interface': {'ip4_table_index': 4294967295,
104 'ip6_table_index': 4294967295,
105 'l2_table_index': 4294967295, },
106 'pppoe_add_del_session': {'is_add': 1, },
107 'policer_add_del': {'is_add': 1, 'conform_action_type': 1, },
108 'proxy_arp_add_del': {'is_add': 1, },
109 'proxy_arp_intfc_enable_disable': {'is_enable': 1, },
Ole Troan9a475372019-03-05 16:58:24 +0100110 'set_ip_flow_hash': {'src': 1, 'dst': 1, 'sport': 1, 'dport': 1,
111 'proto': 1, },
112 'set_ipfix_exporter': {'collector_port': 4739, },
113 'sr_localsid_add_del': {'sw_if_index': 4294967295, },
114 'sr_policy_add': {'weight': 1, 'is_encap': 1, },
115 'svs_enable_disable': {'is_enable': 1, },
116 'svs_route_add_del': {'is_add': 1, },
117 'svs_table_add_del': {'is_add': 1, },
118 'sw_interface_add_del_address': {'is_add': 1, },
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700119 'sw_interface_dump': {'sw_if_index': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100120 'sw_interface_ip6nd_ra_prefix': {'val_lifetime': 4294967295,
121 'pref_lifetime': 4294967295, },
122 'sw_interface_set_ip_directed_broadcast': {'enable': 1, },
123 'sw_interface_set_l2_bridge': {'enable': 1, },
124 'sw_interface_set_mpls_enable': {'enable': 1, },
125 'sw_interface_set_mtu': {'mtu': [0, 0, 0, 0], },
126 'sw_interface_set_unnumbered': {'is_add': 1, },
127 'sw_interface_span_enable_disable': {'state': 1, },
128 'vxlan_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
129 'decap_next_index': 4294967295,
130 'instance': 4294967295, },
Ole Troan9a475372019-03-05 16:58:24 +0100131 'vxlan_gbp_tunnel_dump': {'sw_if_index': 4294967295, },
132 'vxlan_gpe_add_del_tunnel': {'mcast_sw_if_index': 4294967295, 'is_add': 1,
133 'protocol': 3, },
134 'want_bfd_events': {'enable_disable': 1, },
Ole Troan9a475372019-03-05 16:58:24 +0100135 'want_igmp_events': {'enable': 1, },
136 'want_interface_events': {'enable_disable': 1, },
137 'want_ip4_arp_events': {'enable_disable': 1, 'ip': '0.0.0.0', },
138 'want_ip6_nd_events': {'enable_disable': 1, 'ip': '::', },
139 'want_ip6_ra_events': {'enable_disable': 1, },
140 'want_l2_macs_events': {'enable_disable': 1, },
141}
Ole Troanf159f582019-02-28 20:20:47 +0100142
Matus Fabianb4515b42018-11-19 04:25:32 -0800143
Paul Vinciguerra9673e3e2019-05-10 20:41:08 -0400144class CliFailedCommandError(Exception):
145 """ cli command failed."""
146
147
148class CliSyntaxError(Exception):
149 """ cli command had a syntax error."""
150
151
Klement Sekera73884482017-02-23 09:26:30 +0100152class UnexpectedApiReturnValueError(Exception):
153 """ exception raised when the API return value is unexpected """
154 pass
155
156
Klement Sekeraf62ae122016-10-11 11:47:09 +0200157class VppPapiProvider(object):
158 """VPP-api provider using vpp-papi
159
160 @property hook: hook object providing before and after api/cli hooks
Klement Sekeraf62ae122016-10-11 11:47:09 +0200161 """
162
Klement Sekerae0545ef2017-01-25 08:00:40 +0100163 _zero, _negative = range(2)
164
Klement Sekera611864f2018-09-26 11:19:00 +0200165 def __init__(self, name, shm_prefix, test_class, read_timeout):
Paul Vinciguerra895e2f82019-01-08 20:37:40 -0800166 self.hook = Hook(test_class)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200167 self.name = name
168 self.shm_prefix = shm_prefix
Klement Sekera7bb873a2016-11-18 07:38:42 +0100169 self.test_class = test_class
Klement Sekerae0545ef2017-01-25 08:00:40 +0100170 self._expect_api_retval = self._zero
171 self._expect_stack = []
Ole Troan7e3a8752016-12-05 10:27:09 +0100172
Paul Vinciguerra19542292019-03-17 17:34:46 -0700173 # install_dir is a class attribute. We need to set it before
174 # calling the constructor.
175 VPPApiClient.apidir = os.getenv('VPP_INSTALL_PATH')
Paul Vinciguerra04575c52019-01-13 10:26:05 -0800176
Ole Troan4ff09ae2019-04-15 11:27:22 +0200177 use_socket = False
178 try:
179 if os.environ['SOCKET'] == '1':
180 use_socket = True
Paul Vinciguerrabff9f2f2019-05-09 16:12:35 -0400181 except KeyError:
Ole Troan4ff09ae2019-04-15 11:27:22 +0200182 pass
Paul Vinciguerra19542292019-03-17 17:34:46 -0700183
184 self.vpp = VPPApiClient(logger=test_class.logger,
185 read_timeout=read_timeout,
186 use_socket=use_socket,
187 server_address=test_class.api_sock)
Klement Sekerae4504c62016-12-08 10:16:41 +0100188 self._events = deque()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200189
Klement Sekerae0545ef2017-01-25 08:00:40 +0100190 def __enter__(self):
191 return self
192
Klement Sekera7d6afb32018-11-08 11:52:04 +0100193 def assert_negative_api_retval(self):
194 """ Expect API failure - used with with, e.g.:
195 with self.vapi.assert_negative_api_retval():
196 self.vapi.<api call expected to fail>
197 """
Klement Sekerae0545ef2017-01-25 08:00:40 +0100198 self._expect_stack.append(self._expect_api_retval)
199 self._expect_api_retval = self._negative
200 return self
201
Klement Sekera7d6afb32018-11-08 11:52:04 +0100202 def assert_zero_api_retval(self):
203 """ Expect API success - used with with, e.g.:
204 with self.vapi.assert_negative_api_retval():
205 self.vapi.<api call expected to succeed>
206
207 note: this is useful only inside another with block
208 as success is the default expected value
209 """
Klement Sekerae0545ef2017-01-25 08:00:40 +0100210 self._expect_stack.append(self._expect_api_retval)
211 self._expect_api_retval = self._zero
212 return self
213
214 def __exit__(self, exc_type, exc_value, traceback):
215 self._expect_api_retval = self._expect_stack.pop()
216
Klement Sekeraf62ae122016-10-11 11:47:09 +0200217 def register_hook(self, hook):
218 """Replace hook registration with new hook
219
220 :param hook:
221
222 """
223 self.hook = hook
224
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200225 def collect_events(self):
Klement Sekerae4504c62016-12-08 10:16:41 +0100226 """ Collect all events from the internal queue and clear the queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200227 e = self._events
Klement Sekerae4504c62016-12-08 10:16:41 +0100228 self._events = deque()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200229 return e
230
231 def wait_for_event(self, timeout, name=None):
Klement Sekerae4504c62016-12-08 10:16:41 +0100232 """ Wait for and return next event. """
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100233 if name:
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100234 self.test_class.logger.debug("Expecting event '%s' within %ss",
235 name, timeout)
Eyal Bari20197482017-09-13 12:29:08 +0300236 else:
237 self.test_class.logger.debug("Expecting event within %ss",
238 timeout)
Klement Sekerae4504c62016-12-08 10:16:41 +0100239 if self._events:
240 self.test_class.logger.debug("Not waiting, event already queued")
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200241 limit = time.time() + timeout
242 while time.time() < limit:
243 if self._events:
Klement Sekerae4504c62016-12-08 10:16:41 +0100244 e = self._events.popleft()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200245 if name and type(e).__name__ != name:
246 raise Exception(
247 "Unexpected event received: %s, expected: %s" %
248 (type(e).__name__, name))
Klement Sekerae4504c62016-12-08 10:16:41 +0100249 self.test_class.logger.debug("Returning event %s:%s" %
250 (name, e))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200251 return e
Paul Vinciguerra0f6602c2019-03-10 09:10:54 -0700252 self.test_class.sleep(0) # yield
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200253 raise Exception("Event did not occur within timeout")
254
255 def __call__(self, name, event):
Klement Sekerae4504c62016-12-08 10:16:41 +0100256 """ Enqueue event in the internal event queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200257 # FIXME use the name instead of relying on type(e).__name__ ?
258 # FIXME #2 if this throws, it is eaten silently, Ole?
Klement Sekerae4504c62016-12-08 10:16:41 +0100259 self.test_class.logger.debug("New event: %s: %s" % (name, event))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200260 self._events.append(event)
261
Ole Troanf159f582019-02-28 20:20:47 +0100262 def factory(self, name, apifn):
263 def f(*a, **ka):
264 fields = apifn._func.msg.fields
265
266 # add positional and kw arguments
267 d = ka
268 for i, o in enumerate(fields[3:]):
269 try:
270 d[o] = a[i]
Jakub Grajciar4682feb2019-09-02 13:28:52 +0200271 except BaseException:
Ole Troanf159f582019-02-28 20:20:47 +0100272 break
273
274 # Default override
275 if name in defaultmapping:
276 for k, v in iteritems(defaultmapping[name]):
277 if k in d:
278 continue
279 d[k] = v
280 return self.api(apifn, d)
Ole Troan9a475372019-03-05 16:58:24 +0100281
Ole Troanf159f582019-02-28 20:20:47 +0100282 return f
283
Paul Vinciguerra7ab99702019-03-05 04:30:04 -0800284 def __getattribute__(self, name):
Ole Troanf159f582019-02-28 20:20:47 +0100285 try:
Paul Vinciguerra7ab99702019-03-05 04:30:04 -0800286 method = super(VppPapiProvider, self).__getattribute__(name)
287 except AttributeError:
288 method = self.factory(name, getattr(self.papi, name))
289 # lazily load the method so we don't need to call factory
290 # again for this name.
291 setattr(self, name, method)
292 return method
Ole Troanf159f582019-02-28 20:20:47 +0100293
Klement Sekeraf62ae122016-10-11 11:47:09 +0200294 def connect(self):
295 """Connect the API to VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100296 self.vpp.connect(self.name, self.shm_prefix)
297 self.papi = self.vpp.api
298 self.vpp.register_event_callback(self)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200299
300 def disconnect(self):
301 """Disconnect the API from VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100302 self.vpp.disconnect()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200303
304 def api(self, api_fn, api_args, expected_retval=0):
Klement Sekerae4504c62016-12-08 10:16:41 +0100305 """ Call API function and check it's return value.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200306 Call the appropriate hooks before and after the API call
307
308 :param api_fn: API function to call
309 :param api_args: tuple of API function arguments
310 :param expected_retval: Expected return value (Default value = 0)
311 :returns: reply from the API
312
313 """
314 self.hook.before_api(api_fn.__name__, api_args)
Ole Troan7e3a8752016-12-05 10:27:09 +0100315 reply = api_fn(**api_args)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100316 if self._expect_api_retval == self._negative:
317 if hasattr(reply, 'retval') and reply.retval >= 0:
Ole Troan9a475372019-03-05 16:58:24 +0100318 msg = "API call passed unexpectedly: expected negative " \
319 "return value instead of %d in %s" % \
320 (reply.retval, moves.reprlib.repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100321 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100322 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100323 elif self._expect_api_retval == self._zero:
324 if hasattr(reply, 'retval') and reply.retval != expected_retval:
Ole Troan9a475372019-03-05 16:58:24 +0100325 msg = "API call failed, expected %d return value instead " \
326 "of %d in %s" % (expected_retval, reply.retval,
Paul Vinciguerra1b534f52019-06-15 20:31:31 -0400327 repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100328 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100329 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100330 else:
331 raise Exception("Internal error, unexpected value for "
332 "self._expect_api_retval %s" %
333 self._expect_api_retval)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200334 self.hook.after_api(api_fn.__name__, api_args)
335 return reply
336
Dave Barach5932ce12019-10-09 17:28:04 -0400337 def cli_return_response(self, cli):
338 """ Execute a CLI, calling the before/after hooks appropriately.
339 Return the reply without examining it
340
341 :param cli: CLI to execute
342 :returns: response object
343
344 """
345 self.hook.before_cli(cli)
346 cli += '\n'
347 r = self.papi.cli_inband(cmd=cli)
348 self.hook.after_cli(cli)
349 return r
350
Klement Sekeraf62ae122016-10-11 11:47:09 +0200351 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100352 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200353
354 :param cli: CLI to execute
355 :returns: CLI output
356
357 """
Dave Barach5932ce12019-10-09 17:28:04 -0400358 r = self.cli_return_response(cli)
Paul Vinciguerra9673e3e2019-05-10 20:41:08 -0400359 if r.retval == -156:
360 raise CliSyntaxError(r.reply)
361 if r.retval != 0:
362 raise CliFailedCommandError(r.reply)
Jan49c0fca2016-10-26 15:44:27 +0200363 if hasattr(r, 'reply'):
Ole Troan413f4a52018-11-28 11:36:05 +0100364 return r.reply
Klement Sekeraf62ae122016-10-11 11:47:09 +0200365
Jan49c0fca2016-10-26 15:44:27 +0200366 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100367 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200368
369 :param cli: CLI to execute
370 :returns: CLI output
371 """
Klement Sekera6be55642019-10-01 19:14:34 +0000372 return cli + "\n" + self.cli(cli).encode('ascii',
373 errors='backslashreplace')
Jan49c0fca2016-10-26 15:44:27 +0200374
Neale Ranns37029302018-08-10 05:30:06 -0700375 def want_ip4_arp_events(self, enable_disable=1, ip="0.0.0.0"):
Eyal Bari20197482017-09-13 12:29:08 +0300376 return self.api(self.papi.want_ip4_arp_events,
377 {'enable_disable': enable_disable,
Neale Ranns37029302018-08-10 05:30:06 -0700378 'ip': ip,
Eyal Bari20197482017-09-13 12:29:08 +0300379 'pid': os.getpid(), })
380
Neale Ranns37029302018-08-10 05:30:06 -0700381 def want_ip6_nd_events(self, enable_disable=1, ip="::"):
Eyal Baric125ecc2017-09-20 11:29:17 +0300382 return self.api(self.papi.want_ip6_nd_events,
383 {'enable_disable': enable_disable,
Neale Ranns37029302018-08-10 05:30:06 -0700384 'ip': ip,
Eyal Baric125ecc2017-09-20 11:29:17 +0300385 'pid': os.getpid(), })
386
Juraj Sloboda4b9669d2018-01-15 10:39:21 +0100387 def want_ip6_ra_events(self, enable_disable=1):
388 return self.api(self.papi.want_ip6_ra_events,
389 {'enable_disable': enable_disable,
390 'pid': os.getpid(), })
391
392 def ip6nd_send_router_solicitation(self, sw_if_index, irt=1, mrt=120,
393 mrc=0, mrd=0):
394 return self.api(self.papi.ip6nd_send_router_solicitation,
395 {'irt': irt,
396 'mrt': mrt,
397 'mrc': mrc,
398 'mrd': mrd,
399 'sw_if_index': sw_if_index})
400
Juraj Slobodab3f90502018-10-04 15:15:16 +0200401 def want_interface_events(self, enable_disable=1):
402 return self.api(self.papi.want_interface_events,
403 {'enable_disable': enable_disable,
404 'pid': os.getpid(), })
405
Ole Troane1ade682019-03-04 23:55:43 +0100406 def want_l2_macs_events(self, enable_disable=1, scan_delay=0,
407 max_macs_in_event=0, learn_limit=0):
Eyal Bari24db0ec2017-09-27 21:43:51 +0300408 return self.api(self.papi.want_l2_macs_events,
409 {'enable_disable': enable_disable,
410 'scan_delay': scan_delay,
411 'max_macs_in_event': max_macs_in_event,
412 'learn_limit': learn_limit,
413 'pid': os.getpid(), })
414
Neale Rannsc819fc62018-02-16 02:44:05 -0800415 def sw_interface_set_mac_address(self, sw_if_index, mac):
416 return self.api(self.papi.sw_interface_set_mac_address,
417 {'sw_if_index': sw_if_index,
418 'mac_address': mac})
419
Ole Troane1ade682019-03-04 23:55:43 +0100420 def p2p_ethernet_add(self, sw_if_index, remote_mac, subif_id):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200421 """Create p2p ethernet subinterface
422
423 :param sw_if_index: main (parent) interface
424 :param remote_mac: client (remote) mac address
425
426 """
427 return self.api(
428 self.papi.p2p_ethernet_add,
429 {'parent_if_index': sw_if_index,
430 'remote_mac': remote_mac,
431 'subif_id': subif_id})
432
Ole Troane1ade682019-03-04 23:55:43 +0100433 def p2p_ethernet_del(self, sw_if_index, remote_mac):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200434 """Delete p2p ethernet subinterface
435
436 :param sw_if_index: main (parent) interface
437 :param remote_mac: client (remote) mac address
438
439 """
440 return self.api(
441 self.papi.p2p_ethernet_del,
442 {'parent_if_index': sw_if_index,
443 'remote_mac': remote_mac})
444
Klement Sekeraf62ae122016-10-11 11:47:09 +0200445 def create_vlan_subif(self, sw_if_index, vlan):
446 """
447
448 :param vlan:
449 :param sw_if_index:
450
451 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100452 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200453 {'sw_if_index': sw_if_index,
454 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200455
Matej Klotton0178d522016-11-04 11:11:44 +0100456 def create_loopback(self, mac=''):
457 """
458
459 :param mac: (Optional)
460 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100461 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200462 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100463
Neale Ranns097fa662018-05-01 05:17:55 -0700464 def ip_table_add_del(self,
465 table_id,
466 is_add=1,
467 is_ipv6=0):
468 """
469
470 :param table_id
471 :param is_add: (Default value = 1)
472 :param is_ipv6: (Default value = 0)
473
474 """
475
476 return self.api(
477 self.papi.ip_table_add_del,
478 {'table':
479 {
480 'table_id': table_id,
481 'is_ip6': is_ipv6
482 },
483 'is_add': is_add})
484
485 def ip_table_dump(self):
486 return self.api(self.papi.ip_table_dump, {})
487
488 def ip_route_dump(self, table_id, is_ip6=False):
489 return self.api(self.papi.ip_route_dump,
490 {'table': {
491 'table_id': table_id,
492 'is_ip6': is_ip6
493 }})
494
Matej Klotton0178d522016-11-04 11:11:44 +0100495 def ip_neighbor_add_del(self,
496 sw_if_index,
497 mac_address,
Neale Ranns37029302018-08-10 05:30:06 -0700498 ip_address,
Matej Klotton0178d522016-11-04 11:11:44 +0100499 is_add=1,
Neale Ranns37029302018-08-10 05:30:06 -0700500 flags=0):
Matej Klotton0178d522016-11-04 11:11:44 +0100501 """ Add neighbor MAC to IPv4 or IPv6 address.
502
503 :param sw_if_index:
504 :param mac_address:
505 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100506 :param is_add: (Default value = 1)
Neale Ranns37029302018-08-10 05:30:06 -0700507 :param flags: (Default value = 0/NONE)
Matej Klotton0178d522016-11-04 11:11:44 +0100508 """
Matej Klotton0178d522016-11-04 11:11:44 +0100509 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100510 self.papi.ip_neighbor_add_del,
Neale Ranns37029302018-08-10 05:30:06 -0700511 {
512 'is_add': is_add,
513 'neighbor': {
514 'sw_if_index': sw_if_index,
515 'flags': flags,
516 'mac_address': mac_address,
517 'ip_address': ip_address
518 }
519 }
Matej Klotton0178d522016-11-04 11:11:44 +0100520 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100521
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800522 def proxy_arp_add_del(self,
Neale Ranns37029302018-08-10 05:30:06 -0700523 low,
524 hi,
525 table_id=0,
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800526 is_add=1):
527 """ Config Proxy Arp Range.
528
529 :param low_address: Start address in the rnage to Proxy for
530 :param hi_address: End address in the rnage to Proxy for
531 :param vrf_id: The VRF/table in which to proxy
532 """
533
534 return self.api(
535 self.papi.proxy_arp_add_del,
Neale Ranns0053de62018-05-22 08:40:52 -0700536 {'proxy':
Ole Troan9a475372019-03-05 16:58:24 +0100537 {
538 'table_id': table_id,
539 'low': low,
540 'hi': hi,
541 },
542 'is_add': is_add})
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800543
544 def proxy_arp_intfc_enable_disable(self,
545 sw_if_index,
546 is_enable=1):
547 """ Enable/Disable an interface for proxy ARP requests
548
549 :param sw_if_index: Interface
550 :param enable_disable: Enable/Disable
551 """
552
553 return self.api(
554 self.papi.proxy_arp_intfc_enable_disable,
555 {'sw_if_index': sw_if_index,
556 'enable_disable': is_enable
557 }
558 )
559
Neale Ranns5a8844b2019-04-16 07:15:35 +0000560 def gre_tunnel_add_del(self,
561 src,
562 dst,
Neale Ranns177bbdc2016-11-15 09:46:51 +0000563 outer_fib_id=0,
John Loa43ccae2018-02-13 17:15:23 -0500564 tunnel_type=0,
565 instance=0xFFFFFFFF,
566 session_id=0,
Neale Ranns5a8844b2019-04-16 07:15:35 +0000567 is_add=1):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000568 """ Add a GRE tunnel
569
570 :param src_address:
571 :param dst_address:
572 :param outer_fib_id: (Default value = 0)
John Loa43ccae2018-02-13 17:15:23 -0500573 :param tunnel_type: (Default value = 0)
574 :param instance: (Default value = 0xFFFFFFFF)
Paul Vinciguerra8feeaff2019-03-27 11:25:48 -0700575 :param session_id: (Default value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000576 :param is_add: (Default value = 1)
577 :param is_ipv6: (Default value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +0000578 """
579
580 return self.api(
Neale Ranns5a8844b2019-04-16 07:15:35 +0000581 self.papi.gre_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200582 {'is_add': is_add,
Neale Ranns5a8844b2019-04-16 07:15:35 +0000583 'tunnel':
584 {
585 'type': tunnel_type,
586 'instance': instance,
587 'src': src,
588 'dst': dst,
589 'outer_fib_id': outer_fib_id,
590 'session_id': session_id}
591 }
Neale Ranns177bbdc2016-11-15 09:46:51 +0000592 )
Neale Rannsad422ed2016-11-02 14:20:04 +0000593
Neale Rannsd0df49f2018-08-08 01:06:40 -0700594 def udp_encap_add(self,
Neale Rannsd0df49f2018-08-08 01:06:40 -0700595 src_ip,
596 dst_ip,
597 src_port,
598 dst_port,
599 table_id=0):
Neale Ranns810086d2017-11-05 16:26:46 -0800600 """ Add a GRE tunnel
Neale Ranns810086d2017-11-05 16:26:46 -0800601 :param src_ip:
602 :param dst_ip:
603 :param src_port:
604 :param dst_port:
605 :param outer_fib_id: (Default value = 0)
Neale Ranns810086d2017-11-05 16:26:46 -0800606 """
607
608 return self.api(
Neale Rannsd0df49f2018-08-08 01:06:40 -0700609 self.papi.udp_encap_add,
610 {
611 'udp_encap': {
Neale Rannsd0df49f2018-08-08 01:06:40 -0700612 'src_ip': src_ip,
613 'dst_ip': dst_ip,
614 'src_port': src_port,
615 'dst_port': dst_port,
616 'table_id': table_id
617 }
618 })
619
Neale Ranns097fa662018-05-01 05:17:55 -0700620 def udp_encap_del(self, id):
621 return self.api(self.papi.udp_encap_del, {'id': id})
622
623 def udp_encap_dump(self):
624 return self.api(self.papi.udp_encap_dump, {})
625
626 def want_udp_encap_stats(self, enable=1):
627 return self.api(self.papi.want_udp_encap_stats,
628 {'enable': enable,
629 'pid': os.getpid()})
630
631 def mpls_route_dump(self, table_id):
632 return self.api(self.papi.mpls_route_dump,
633 {'table': {
634 'mt_table_id': table_id
635 }})
636
637 def mpls_table_dump(self):
638 return self.api(self.papi.mpls_table_dump, {})
639
Neale Ranns15002542017-09-10 04:39:11 -0700640 def mpls_table_add_del(
641 self,
642 table_id,
643 is_add=1):
644 """
645
646 :param table_id
647 :param is_add: (Default value = 1)
648
649 """
650
651 return self.api(
652 self.papi.mpls_table_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700653 {'mt_table':
654 {
655 'mt_table_id': table_id,
656 },
Neale Ranns15002542017-09-10 04:39:11 -0700657 'mt_is_add': is_add})
658
Neale Ranns097fa662018-05-01 05:17:55 -0700659 def mpls_route_add_del(self,
660 table_id,
661 label,
662 eos,
663 eos_proto,
664 is_multicast,
665 paths,
666 is_add,
667 is_multipath):
668 """ MPLS Route add/del """
669 return self.api(
670 self.papi.mpls_route_add_del,
671 {'mr_route':
672 {
673 'mr_table_id': table_id,
674 'mr_label': label,
675 'mr_eos': eos,
676 'mr_eos_proto': eos_proto,
677 'mr_is_multicast': is_multicast,
678 'mr_n_paths': len(paths),
679 'mr_paths': paths,
680 },
681 'mr_is_add': is_add,
682 'mr_is_multipath': is_multipath})
683
Neale Rannsad422ed2016-11-02 14:20:04 +0000684 def mpls_ip_bind_unbind(
685 self,
686 label,
Neale Ranns097fa662018-05-01 05:17:55 -0700687 prefix,
Neale Rannsad422ed2016-11-02 14:20:04 +0000688 table_id=0,
689 ip_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000690 is_bind=1):
691 """
692 """
693 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100694 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200695 {'mb_mpls_table_id': table_id,
696 'mb_label': label,
697 'mb_ip_table_id': ip_table_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200698 'mb_is_bind': is_bind,
Neale Ranns097fa662018-05-01 05:17:55 -0700699 'mb_prefix': prefix})
Neale Rannsad422ed2016-11-02 14:20:04 +0000700
701 def mpls_tunnel_add_del(
702 self,
703 tun_sw_if_index,
Neale Ranns097fa662018-05-01 05:17:55 -0700704 paths,
Neale Rannsad422ed2016-11-02 14:20:04 +0000705 is_add=1,
Neale Ranns0f26c5a2017-03-01 15:12:11 -0800706 l2_only=0,
707 is_multicast=0):
Neale Rannsad422ed2016-11-02 14:20:04 +0000708 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000709 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000710 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100711 self.papi.mpls_tunnel_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700712 {'mt_is_add': is_add,
713 'mt_tunnel':
714 {
715 'mt_sw_if_index': tun_sw_if_index,
716 'mt_l2_only': l2_only,
717 'mt_is_multicast': is_multicast,
718 'mt_n_paths': len(paths),
719 'mt_paths': paths,
720 }})
Matus Fabiande886752016-12-07 03:38:19 -0800721
Steve Shin7957d6e2016-12-19 09:24:50 -0800722 def classify_add_del_table(
723 self,
724 is_add,
725 mask,
726 match_n_vectors=1,
727 table_index=0xFFFFFFFF,
728 nbuckets=2,
729 memory_size=2097152,
730 skip_n_vectors=0,
731 next_table_index=0xFFFFFFFF,
732 miss_next_index=0xFFFFFFFF,
733 current_data_flag=0,
734 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -0800735 """
736 :param is_add:
737 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +0100738 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100739 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -0800740 :param nbuckets: (Default value = 2)
741 :param memory_size: (Default value = 2097152)
742 :param skip_n_vectors: (Default value = 0)
743 :param next_table_index: (Default value = 0xFFFFFFFF)
744 :param miss_next_index: (Default value = 0xFFFFFFFF)
745 :param current_data_flag: (Default value = 0)
746 :param current_data_offset: (Default value = 0)
747 """
748
Juraj Sloboda75282452018-06-12 14:20:49 +0200749 mask_len = ((len(mask) - 1) / 16 + 1) * 16
750 mask = mask + '\0' * (mask_len - len(mask))
Steve Shin7957d6e2016-12-19 09:24:50 -0800751 return self.api(
752 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100753 {'is_add': is_add,
754 'table_index': table_index,
755 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -0800756 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100757 'skip_n_vectors': skip_n_vectors,
758 'match_n_vectors': match_n_vectors,
759 'next_table_index': next_table_index,
760 'miss_next_index': miss_next_index,
761 'current_data_flag': current_data_flag,
762 'current_data_offset': current_data_offset,
Juraj Sloboda75282452018-06-12 14:20:49 +0200763 'mask_len': mask_len,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100764 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -0800765
766 def classify_add_del_session(
767 self,
768 is_add,
769 table_index,
770 match,
771 opaque_index=0xFFFFFFFF,
772 hit_next_index=0xFFFFFFFF,
773 advance=0,
774 action=0,
775 metadata=0):
776 """
777 :param is_add:
778 :param table_index:
779 :param match:
780 :param opaque_index: (Default value = 0xFFFFFFFF)
781 :param hit_next_index: (Default value = 0xFFFFFFFF)
782 :param advance: (Default value = 0)
783 :param action: (Default value = 0)
784 :param metadata: (Default value = 0)
785 """
786
Juraj Sloboda75282452018-06-12 14:20:49 +0200787 match_len = ((len(match) - 1) / 16 + 1) * 16
788 match = match + '\0' * (match_len - len(match))
Steve Shin7957d6e2016-12-19 09:24:50 -0800789 return self.api(
790 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100791 {'is_add': is_add,
792 'table_index': table_index,
793 'hit_next_index': hit_next_index,
794 'opaque_index': opaque_index,
795 'advance': advance,
796 'action': action,
797 'metadata': metadata,
Juraj Sloboda75282452018-06-12 14:20:49 +0200798 'match_len': match_len,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100799 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -0800800
801 def input_acl_set_interface(
802 self,
803 is_add,
804 sw_if_index,
805 ip4_table_index=0xFFFFFFFF,
806 ip6_table_index=0xFFFFFFFF,
807 l2_table_index=0xFFFFFFFF):
808 """
809 :param is_add:
810 :param sw_if_index:
811 :param ip4_table_index: (Default value = 0xFFFFFFFF)
812 :param ip6_table_index: (Default value = 0xFFFFFFFF)
813 :param l2_table_index: (Default value = 0xFFFFFFFF)
814 """
815
816 return self.api(
817 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +0100818 {'sw_if_index': sw_if_index,
819 'ip4_table_index': ip4_table_index,
820 'ip6_table_index': ip6_table_index,
821 'l2_table_index': l2_table_index,
822 'is_add': is_add})
823
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100824 def output_acl_set_interface(
825 self,
826 is_add,
827 sw_if_index,
828 ip4_table_index=0xFFFFFFFF,
829 ip6_table_index=0xFFFFFFFF,
830 l2_table_index=0xFFFFFFFF):
831 """
832 :param is_add:
833 :param sw_if_index:
834 :param ip4_table_index: (Default value = 0xFFFFFFFF)
835 :param ip6_table_index: (Default value = 0xFFFFFFFF)
836 :param l2_table_index: (Default value = 0xFFFFFFFF)
837 """
838
839 return self.api(
840 self.papi.output_acl_set_interface,
841 {'sw_if_index': sw_if_index,
842 'ip4_table_index': ip4_table_index,
843 'ip6_table_index': ip6_table_index,
844 'l2_table_index': l2_table_index,
845 'is_add': is_add})
846
Klement Sekera77fabdb2017-01-02 07:46:14 +0100847 def set_ipfix_exporter(
848 self,
849 collector_address,
850 src_address,
851 path_mtu,
852 template_interval,
853 vrf_id=0,
854 collector_port=4739,
855 udp_checksum=0):
856 return self.api(
857 self.papi.set_ipfix_exporter,
858 {
859 'collector_address': collector_address,
860 'collector_port': collector_port,
861 'src_address': src_address,
862 'vrf_id': vrf_id,
863 'path_mtu': path_mtu,
864 'template_interval': template_interval,
865 'udp_checksum': udp_checksum,
866 })
Neale Rannsfca0c242017-01-13 07:57:46 -0800867
Neale Ranns32e1c012016-11-22 17:07:28 +0000868 def ip_mroute_add_del(self,
Neale Ranns097fa662018-05-01 05:17:55 -0700869 table_id,
870 prefix,
Neale Ranns32e1c012016-11-22 17:07:28 +0000871 e_flags,
Neale Ranns097fa662018-05-01 05:17:55 -0700872 rpf_id,
873 paths,
Neale Ranns32e1c012016-11-22 17:07:28 +0000874 is_add=1,
Neale Ranns097fa662018-05-01 05:17:55 -0700875 is_multipath=1):
Neale Ranns32e1c012016-11-22 17:07:28 +0000876 """
Neale Rannsd792d9c2017-10-21 10:53:20 -0700877 IP Multicast Route add/del
Neale Ranns32e1c012016-11-22 17:07:28 +0000878 """
879 return self.api(
880 self.papi.ip_mroute_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -0700881 {
882 'is_add': is_add,
883 'is_multipath': is_multipath,
884 'route': {
885 'table_id': table_id,
886 'entry_flags': e_flags,
887 'rpf_id': rpf_id,
888 'prefix': prefix,
889 'n_paths': len(paths),
890 'paths': paths,
891 }
892 })
893
894 def mfib_signal_dump(self):
895 return self.api(self.papi.mfib_signal_dump, {})
896
897 def ip_mroute_dump(self, table_id, is_ip6=False):
898 return self.api(self.papi.ip_mroute_dump,
899 {'table': {
900 'table_id': table_id,
901 'is_ip6': is_ip6
902 }})
Neale Ranns32e1c012016-11-22 17:07:28 +0000903
Filip Tehlar770e89e2017-01-31 10:39:16 +0100904 def lisp_enable_disable(self, is_enabled):
905 return self.api(
906 self.papi.lisp_enable_disable,
907 {
908 'is_en': is_enabled,
909 })
910
Ole Troane1ade682019-03-04 23:55:43 +0100911 def lisp_add_del_locator_set(self,
912 ls_name,
913 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100914 return self.api(
915 self.papi.lisp_add_del_locator_set,
916 {
917 'is_add': is_add,
918 'locator_set_name': ls_name
919 })
920
Ole Troane1ade682019-03-04 23:55:43 +0100921 def lisp_add_del_locator(self,
922 ls_name,
923 sw_if_index,
924 priority=1,
925 weight=1,
926 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100927 return self.api(
928 self.papi.lisp_add_del_locator,
929 {
930 'is_add': is_add,
931 'locator_set_name': ls_name,
932 'sw_if_index': sw_if_index,
933 'priority': priority,
934 'weight': weight
935 })
936
937 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
938 return self.api(
939 self.papi.lisp_locator_dump,
940 {
941 'is_index_set': is_index_set,
942 'ls_name': ls_name,
943 'ls_index': ls_index,
944 })
945
Ole Troane1ade682019-03-04 23:55:43 +0100946 def lisp_add_del_local_eid(self,
947 ls_name,
948 eid_type,
949 eid,
950 prefix_len,
951 vni=0,
952 key_id=0,
953 key="",
954 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100955 return self.api(
956 self.papi.lisp_add_del_local_eid,
957 {
958 'locator_set_name': ls_name,
959 'is_add': is_add,
960 'eid_type': eid_type,
961 'eid': eid,
962 'prefix_len': prefix_len,
963 'vni': vni,
964 'key_id': key_id,
965 'key': key
966 })
967
968 def lisp_eid_table_dump(self,
969 eid_set=0,
970 prefix_length=0,
971 vni=0,
972 eid_type=0,
973 eid=None,
974 filter_opt=0):
975 return self.api(
976 self.papi.lisp_eid_table_dump,
977 {
978 'eid_set': eid_set,
979 'prefix_length': prefix_length,
980 'vni': vni,
981 'eid_type': eid_type,
982 'eid': eid,
983 'filter': filter_opt,
984 })
985
Ole Troane1ade682019-03-04 23:55:43 +0100986 def lisp_add_del_remote_mapping(self,
987 eid_type,
988 eid,
989 eid_prefix_len=0,
990 vni=0,
991 rlocs=[],
992 rlocs_num=0,
993 is_src_dst=0,
994 is_add=1):
Filip Tehlar770e89e2017-01-31 10:39:16 +0100995 return self.api(
996 self.papi.lisp_add_del_remote_mapping,
997 {
998 'is_add': is_add,
999 'eid_type': eid_type,
1000 'eid': eid,
1001 'eid_len': eid_prefix_len,
1002 'rloc_num': rlocs_num,
1003 'rlocs': rlocs,
1004 'vni': vni,
1005 'is_src_dst': is_src_dst,
1006 })
1007
Ole Troane1ade682019-03-04 23:55:43 +01001008 def lisp_add_del_adjacency(self,
1009 leid,
1010 reid,
1011 leid_len,
1012 reid_len,
1013 eid_type,
1014 is_add=1,
1015 vni=0):
Filip Tehlar770e89e2017-01-31 10:39:16 +01001016 return self.api(
1017 self.papi.lisp_add_del_adjacency,
1018 {
1019 'is_add': is_add,
1020 'vni': vni,
1021 'eid_type': eid_type,
1022 'leid': leid,
1023 'reid': reid,
1024 'leid_len': leid_len,
1025 'reid_len': reid_len,
1026 })
1027
Hongjun Nief486b12017-04-12 19:21:16 +08001028 def gtpu_add_del_tunnel(
1029 self,
1030 src_addr,
1031 dst_addr,
1032 is_add=1,
1033 is_ipv6=0,
1034 mcast_sw_if_index=0xFFFFFFFF,
1035 encap_vrf_id=0,
1036 decap_next_index=0xFFFFFFFF,
1037 teid=0):
1038 """
1039
1040 :param is_add: (Default value = 1)
1041 :param is_ipv6: (Default value = 0)
1042 :param src_addr:
1043 :param dst_addr:
1044 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
1045 :param encap_vrf_id: (Default value = 0)
1046 :param decap_next_index: (Default value = 0xFFFFFFFF)
1047 :param teid: (Default value = 0)
1048
1049 """
1050 return self.api(self.papi.gtpu_add_del_tunnel,
1051 {'is_add': is_add,
1052 'is_ipv6': is_ipv6,
1053 'src_address': src_addr,
1054 'dst_address': dst_addr,
1055 'mcast_sw_if_index': mcast_sw_if_index,
1056 'encap_vrf_id': encap_vrf_id,
1057 'decap_next_index': decap_next_index,
1058 'teid': teid})
Hongjun Ni8a0a0ae2017-05-27 20:23:09 +08001059
1060 def vxlan_gpe_add_del_tunnel(
1061 self,
1062 src_addr,
1063 dst_addr,
1064 mcast_sw_if_index=0xFFFFFFFF,
1065 is_add=1,
1066 is_ipv6=0,
1067 encap_vrf_id=0,
1068 decap_vrf_id=0,
1069 protocol=3,
1070 vni=0):
1071 """
1072
1073 :param local:
1074 :param remote:
1075 :param is_add: (Default value = 1)
1076 :param is_ipv6: (Default value = 0)
1077 :param encap_vrf_id: (Default value = 0)
1078 :param decap_vrf_id: (Default value = 0)
1079 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
1080 :param protocol: (Default value = 3)
1081 :param vni: (Default value = 0)
1082
1083 """
1084 return self.api(self.papi.vxlan_gpe_add_del_tunnel,
1085 {'is_add': is_add,
1086 'is_ipv6': is_ipv6,
1087 'local': src_addr,
1088 'remote': dst_addr,
1089 'mcast_sw_if_index': mcast_sw_if_index,
1090 'encap_vrf_id': encap_vrf_id,
1091 'decap_vrf_id': decap_vrf_id,
1092 'protocol': protocol,
1093 'vni': vni})
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001094
Neale Ranns79a05f52018-09-11 07:39:43 -07001095 def vxlan_gbp_tunnel_dump(self, sw_if_index=0xffffffff):
1096 return self.api(self.papi.vxlan_gbp_tunnel_dump,
Ole Troan0bcad322018-12-11 13:04:01 +01001097 {'sw_if_index': sw_if_index,
1098 '_no_type_conversion': True})
Mohsin Kazmi61b94c62018-08-20 18:32:39 +02001099
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001100 def pppoe_add_del_session(
1101 self,
1102 client_ip,
1103 client_mac,
1104 session_id=0,
1105 is_add=1,
1106 is_ipv6=0,
1107 decap_vrf_id=0):
1108 """
1109
1110 :param is_add: (Default value = 1)
1111 :param is_ipv6: (Default value = 0)
1112 :param client_ip:
1113 :param session_id: (Default value = 0)
1114 :param client_mac:
1115 :param decap_vrf_id: (Default value = 0)
1116
1117 """
1118 return self.api(self.papi.pppoe_add_del_session,
1119 {'is_add': is_add,
1120 'is_ipv6': is_ipv6,
1121 'session_id': session_id,
1122 'client_ip': client_ip,
1123 'decap_vrf_id': decap_vrf_id,
1124 'client_mac': client_mac})
Kris Michielsen91074432017-06-22 13:00:20 +02001125
Neale Ranns7c922dc2018-08-30 06:12:27 -07001126 def sr_mpls_policy_add(self, bsid, weight, type, segments):
1127 return self.api(self.papi.sr_mpls_policy_add,
1128 {'bsid': bsid,
1129 'weight': weight,
1130 'type': type,
1131 'n_segments': len(segments),
1132 'segments': segments})
1133
1134 def sr_mpls_policy_del(self, bsid):
1135 return self.api(self.papi.sr_mpls_policy_del,
1136 {'bsid': bsid})
1137
Kris Michielsen91074432017-06-22 13:00:20 +02001138 def sr_localsid_add_del(self,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001139 localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02001140 behavior,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001141 nh_addr4,
1142 nh_addr6,
Kris Michielsen91074432017-06-22 13:00:20 +02001143 is_del=0,
1144 end_psp=0,
1145 sw_if_index=0xFFFFFFFF,
1146 vlan_index=0,
1147 fib_table=0,
1148 ):
1149 """ Add/del IPv6 SR local-SID.
1150
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001151 :param localsid:
Kris Michielsen91074432017-06-22 13:00:20 +02001152 :param behavior: END=1; END.X=2; END.DX2=4; END.DX6=5;
1153 :param behavior: END.DX4=6; END.DT6=7; END.DT4=8
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001154 :param nh_addr4:
1155 :param nh_addr6:
Kris Michielsen91074432017-06-22 13:00:20 +02001156 :param is_del: (Default value = 0)
1157 :param end_psp: (Default value = 0)
1158 :param sw_if_index: (Default value = 0xFFFFFFFF)
1159 :param vlan_index: (Default value = 0)
1160 :param fib_table: (Default value = 0)
1161 """
1162 return self.api(
1163 self.papi.sr_localsid_add_del,
1164 {'is_del': is_del,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001165 'localsid': localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02001166 'end_psp': end_psp,
1167 'behavior': behavior,
1168 'sw_if_index': sw_if_index,
1169 'vlan_index': vlan_index,
1170 'fib_table': fib_table,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02001171 'nh_addr4': nh_addr4,
1172 'nh_addr6': nh_addr6
Kris Michielsen91074432017-06-22 13:00:20 +02001173 }
1174 )
1175
1176 def sr_policy_add(
1177 self,
1178 bsid_addr,
1179 weight=1,
1180 is_encap=1,
1181 type=0,
1182 fib_table=0,
1183 n_segments=0,
1184 segments=[]):
1185 """
1186 :param bsid_addr: bindingSID of the SR Policy
1187 :param weight: weight of the sid list. optional. (default: 1)
1188 :param is_encap: (bool) whether SR policy should Encap or SRH insert \
1189 (default: Encap)
1190 :param type: type/behavior of the SR policy. (default or spray) \
1191 (default: default)
1192 :param fib_table: VRF where to install the FIB entry for the BSID \
1193 (default: 0)
1194 :param n_segments: number of segments \
1195 (default: 0)
1196 :param segments: a vector of IPv6 address composing the segment list \
1197 (default: [])
1198 """
1199 return self.api(
1200 self.papi.sr_policy_add,
1201 {'bsid_addr': bsid_addr,
1202 'weight': weight,
1203 'is_encap': is_encap,
1204 'type': type,
1205 'fib_table': fib_table,
1206 'n_segments': n_segments,
1207 'segments': segments
1208 }
1209 )
1210
1211 def sr_policy_del(
1212 self,
1213 bsid_addr,
1214 sr_policy_index=0):
1215 """
1216 :param bsid: bindingSID of the SR Policy
1217 :param sr_policy_index: index of the sr policy (default: 0)
1218 """
1219 return self.api(
1220 self.papi.sr_policy_del,
1221 {'bsid_addr': bsid_addr,
1222 'sr_policy_index': sr_policy_index
1223 })
1224
1225 def sr_steering_add_del(
1226 self,
1227 is_del,
1228 bsid_addr,
1229 sr_policy_index,
1230 table_id,
1231 prefix_addr,
1232 mask_width,
1233 sw_if_index,
1234 traffic_type):
1235 """
1236 Steer traffic L2 and L3 traffic through a given SR policy
1237
1238 :param is_del: delete or add
1239 :param bsid_addr: bindingSID of the SR Policy (alt to sr_policy_index)
1240 :param sr_policy: is the index of the SR Policy (alt to bsid)
1241 :param table_id: is the VRF where to install the FIB entry for the BSID
1242 :param prefix_addr: is the IPv4/v6 address for L3 traffic type
1243 :param mask_width: is the mask for L3 traffic type
1244 :param sw_if_index: is the incoming interface for L2 traffic
1245 :param traffic_type: type of traffic (IPv4: 4, IPv6: 6, L2: 2)
1246 """
1247 return self.api(
1248 self.papi.sr_steering_add_del,
1249 {'is_del': is_del,
1250 'bsid_addr': bsid_addr,
1251 'sr_policy_index': sr_policy_index,
1252 'table_id': table_id,
1253 'prefix_addr': prefix_addr,
1254 'mask_width': mask_width,
1255 'sw_if_index': sw_if_index,
1256 'traffic_type': traffic_type
1257 })
Pavel Kotucek932f7412017-09-07 14:44:52 +02001258
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001259 def acl_add_replace(self, acl_index, r, tag='',
1260 expected_retval=0):
1261 """Add/replace an ACL
1262 :param int acl_index: ACL index to replace, 2^32-1 to create new ACL.
1263 :param acl_rule r: ACL rules array.
1264 :param str tag: symbolic tag (description) for this ACL.
1265 :param int count: number of rules.
1266 """
1267 return self.api(self.papi.acl_add_replace,
1268 {'acl_index': acl_index,
1269 'r': r,
1270 'count': len(r),
1271 'tag': tag},
1272 expected_retval=expected_retval)
1273
Andrew Yourtchenko987abe92017-09-27 13:50:31 +02001274 def acl_del(self, acl_index, expected_retval=0):
1275 """
1276
1277 :param acl_index:
1278 :return:
1279 """
1280 return self.api(self.papi.acl_del,
1281 {'acl_index': acl_index},
1282 expected_retval=expected_retval)
1283
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001284 def acl_interface_set_acl_list(self, sw_if_index, n_input, acls,
1285 expected_retval=0):
1286 return self.api(self.papi.acl_interface_set_acl_list,
1287 {'sw_if_index': sw_if_index,
1288 'count': len(acls),
1289 'n_input': n_input,
1290 'acls': acls},
1291 expected_retval=expected_retval)
1292
Andrew Yourtchenkoc43b3f92018-02-06 17:42:32 +01001293 def acl_interface_set_etype_whitelist(self, sw_if_index,
1294 n_input, whitelist,
1295 expected_retval=0):
1296 return self.api(self.papi.acl_interface_set_etype_whitelist,
1297 {'sw_if_index': sw_if_index,
1298 'count': len(whitelist),
1299 'n_input': n_input,
1300 'whitelist': whitelist},
1301 expected_retval=expected_retval)
1302
Pavel Kotucek8daa80a2017-09-25 09:44:05 +02001303 def acl_interface_add_del(self,
1304 sw_if_index,
1305 acl_index,
1306 is_add=1):
1307 """ Add/Delete ACL to/from interface
1308
1309 :param sw_if_index:
1310 :param acl_index:
1311 :param is_add: (Default value = 1)
1312 """
1313
1314 return self.api(self.papi.acl_interface_add_del,
1315 {'is_add': is_add,
1316 'is_input': 1,
1317 'sw_if_index': sw_if_index,
1318 'acl_index': acl_index})
1319
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02001320 def acl_dump(self, acl_index, expected_retval=0):
1321 return self.api(self.papi.acl_dump,
1322 {'acl_index': acl_index},
1323 expected_retval=expected_retval)
1324
Andrew Yourtchenko0e89dfc2018-03-23 09:34:29 +01001325 def acl_interface_list_dump(self, sw_if_index=0xFFFFFFFF,
1326 expected_retval=0):
1327 return self.api(self.papi.acl_interface_list_dump,
1328 {'sw_if_index': sw_if_index},
1329 expected_retval=expected_retval)
1330
Pavel Kotucekc29940c2017-09-07 08:17:31 +02001331 def macip_acl_add(self, rules, tag=""):
1332 """ Add MACIP acl
1333
1334 :param rules: list of rules for given acl
1335 :param tag: acl tag
1336 """
1337
1338 return self.api(self.papi.macip_acl_add,
1339 {'r': rules,
1340 'count': len(rules),
1341 'tag': tag})
1342
Pavel Kotucek932f7412017-09-07 14:44:52 +02001343 def macip_acl_add_replace(self, rules, acl_index=0xFFFFFFFF, tag=""):
1344 """ Add MACIP acl
1345
1346 :param rules: list of rules for given acl
1347 :param tag: acl tag
1348 """
1349
Pavel Kotucekc29940c2017-09-07 08:17:31 +02001350 return self.api(self.papi.macip_acl_add_replace,
1351 {'acl_index': acl_index,
1352 'r': rules,
Pavel Kotucek932f7412017-09-07 14:44:52 +02001353 'count': len(rules),
1354 'tag': tag})
1355
Pavel Kotucek932f7412017-09-07 14:44:52 +02001356 def macip_acl_interface_add_del(self,
1357 sw_if_index,
1358 acl_index,
1359 is_add=1):
1360 """ Add MACIP acl to interface
1361
1362 :param sw_if_index:
1363 :param acl_index:
1364 :param is_add: (Default value = 1)
1365 """
1366
1367 return self.api(self.papi.macip_acl_interface_add_del,
1368 {'is_add': is_add,
1369 'sw_if_index': sw_if_index,
1370 'acl_index': acl_index})
1371
Pavel Kotucek932f7412017-09-07 14:44:52 +02001372 def macip_acl_dump(self, acl_index=4294967295):
1373 """ Return MACIP acl dump
1374 """
1375
1376 return self.api(
1377 self.papi.macip_acl_dump, {'acl_index': acl_index})
Neale Rannsd91c1db2017-07-31 02:30:50 -07001378
1379 def policer_add_del(self,
1380 name,
1381 cir,
1382 eir,
1383 cb,
1384 eb,
1385 is_add=1,
1386 rate_type=0,
1387 round_type=0,
1388 ptype=0,
1389 color_aware=0,
1390 conform_action_type=1,
1391 conform_dscp=0,
1392 exceed_action_type=0,
1393 exceed_dscp=0,
1394 violate_action_type=0,
1395 violate_dscp=0):
1396 return self.api(self.papi.policer_add_del,
1397 {'name': name,
1398 'cir': cir,
1399 'eir': eir,
1400 'cb': cb,
1401 'eb': eb,
1402 'is_add': is_add,
1403 'rate_type': rate_type,
1404 'round_type': round_type,
1405 'type': ptype,
1406 'color_aware': color_aware,
1407 'conform_action_type': conform_action_type,
1408 'conform_dscp': conform_dscp,
1409 'exceed_action_type': exceed_action_type,
1410 'exceed_dscp': exceed_dscp,
1411 'violate_action_type': violate_action_type,
1412 'violate_dscp': violate_dscp})
1413
1414 def ip_punt_police(self,
1415 policer_index,
1416 is_ip6=0,
1417 is_add=1):
1418 return self.api(self.papi.ip_punt_police,
1419 {'policer_index': policer_index,
1420 'is_add': is_add,
1421 'is_ip6': is_ip6})
1422
1423 def ip_punt_redirect(self,
1424 rx_sw_if_index,
1425 tx_sw_if_index,
Pavel Kotucek609e1212018-11-27 09:59:44 +01001426 address,
Neale Rannsd91c1db2017-07-31 02:30:50 -07001427 is_add=1):
1428 return self.api(self.papi.ip_punt_redirect,
Pavel Kotucek609e1212018-11-27 09:59:44 +01001429 {'punt': {'rx_sw_if_index': rx_sw_if_index,
1430 'tx_sw_if_index': tx_sw_if_index,
1431 'nh': address},
1432 'is_add': is_add})
1433
1434 def ip_punt_redirect_dump(self, sw_if_index, is_ipv6=0):
1435 return self.api(self.papi.ip_punt_redirect_dump,
1436 {'sw_if_index': sw_if_index,
1437 'is_ipv6': is_ipv6})
Neale Rannsd792d9c2017-10-21 10:53:20 -07001438
1439 def bier_table_add_del(self,
1440 bti,
1441 mpls_label,
1442 is_add=1):
1443 """ BIER Table add/del """
1444 return self.api(
1445 self.papi.bier_table_add_del,
1446 {'bt_tbl_id': {"bt_set": bti.set_id,
1447 "bt_sub_domain": bti.sub_domain_id,
1448 "bt_hdr_len_id": bti.hdr_len_id},
1449 'bt_label': mpls_label,
1450 'bt_is_add': is_add})
1451
1452 def bier_table_dump(self):
1453 return self.api(self.papi.bier_table_dump, {})
1454
1455 def bier_route_add_del(self,
1456 bti,
1457 bp,
Neale Ranns91286372017-12-05 13:24:04 -08001458 paths,
Neale Rannsef90ed02018-09-13 08:45:12 -07001459 is_add=1,
1460 is_replace=0):
Neale Rannsd792d9c2017-10-21 10:53:20 -07001461 """ BIER Route add/del """
1462 return self.api(
1463 self.papi.bier_route_add_del,
Neale Ranns097fa662018-05-01 05:17:55 -07001464 {
1465 'br_route': {
1466 'br_tbl_id': {"bt_set": bti.set_id,
1467 "bt_sub_domain": bti.sub_domain_id,
1468 "bt_hdr_len_id": bti.hdr_len_id},
1469 'br_bp': bp,
1470 'br_n_paths': len(paths),
1471 'br_paths': paths,
1472 },
1473 'br_is_add': is_add,
1474 'br_is_replace': is_replace
1475 })
Neale Rannsd792d9c2017-10-21 10:53:20 -07001476
1477 def bier_route_dump(self, bti):
1478 return self.api(
1479 self.papi.bier_route_dump,
1480 {'br_tbl_id': {"bt_set": bti.set_id,
1481 "bt_sub_domain": bti.sub_domain_id,
1482 "bt_hdr_len_id": bti.hdr_len_id}})
1483
1484 def bier_imp_add(self,
1485 bti,
1486 src,
1487 ibytes,
1488 is_add=1):
1489 """ BIER Imposition Add """
1490 return self.api(
1491 self.papi.bier_imp_add,
1492 {'bi_tbl_id': {"bt_set": bti.set_id,
1493 "bt_sub_domain": bti.sub_domain_id,
1494 "bt_hdr_len_id": bti.hdr_len_id},
1495 'bi_src': src,
1496 'bi_n_bytes': len(ibytes),
1497 'bi_bytes': ibytes})
1498
1499 def bier_imp_del(self, bi_index):
1500 """ BIER Imposition del """
1501 return self.api(
1502 self.papi.bier_imp_del,
1503 {'bi_index': bi_index})
1504
1505 def bier_imp_dump(self):
1506 return self.api(self.papi.bier_imp_dump, {})
1507
1508 def bier_disp_table_add_del(self,
1509 bdti,
1510 is_add=1):
1511 """ BIER Disposition Table add/del """
1512 return self.api(
1513 self.papi.bier_disp_table_add_del,
1514 {'bdt_tbl_id': bdti,
1515 'bdt_is_add': is_add})
1516
1517 def bier_disp_table_dump(self):
1518 return self.api(self.papi.bier_disp_table_dump, {})
1519
1520 def bier_disp_entry_add_del(self,
1521 bdti,
1522 bp,
1523 payload_proto,
Neale Rannsf0510722018-01-31 11:35:41 -08001524 next_hop_afi,
Neale Rannsd792d9c2017-10-21 10:53:20 -07001525 next_hop,
1526 next_hop_tbl_id=0,
1527 next_hop_rpf_id=~0,
1528 next_hop_is_ip4=1,
1529 is_add=1):
1530 """ BIER Route add/del """
Neale Ranns31ed7442018-02-23 05:29:09 -08001531 lstack = []
1532 while (len(lstack) < 16):
1533 lstack.append({})
Neale Rannsd792d9c2017-10-21 10:53:20 -07001534 return self.api(
1535 self.papi.bier_disp_entry_add_del,
1536 {'bde_tbl_id': bdti,
1537 'bde_bp': bp,
1538 'bde_payload_proto': payload_proto,
1539 'bde_n_paths': 1,
Paul Vinciguerra79a32a42019-07-11 19:09:30 -04001540 'bde_paths': [{'table_id': next_hop_tbl_id,
Neale Rannsd792d9c2017-10-21 10:53:20 -07001541 'rpf_id': next_hop_rpf_id,
1542 'n_labels': 0,
Neale Ranns31ed7442018-02-23 05:29:09 -08001543 'label_stack': lstack}],
Neale Rannsd792d9c2017-10-21 10:53:20 -07001544 'bde_is_add': is_add})
1545
1546 def bier_disp_entry_dump(self, bdti):
1547 return self.api(
1548 self.papi.bier_disp_entry_dump,
1549 {'bde_tbl_id': bdti})
Gabriel Ganne8527f122017-10-02 11:41:24 +02001550
Florin Coras3ea6ce22017-12-11 09:09:05 -08001551 def session_enable_disable(self, is_enabled):
1552 return self.api(
1553 self.papi.session_enable_disable,
1554 {'is_enable': is_enabled})
“mystarrocks”23f0c452017-12-11 07:11:51 -08001555
1556 def ipsec_spd_add_del(self, spd_id, is_add=1):
1557 """ SPD add/del - Wrapper to add or del ipsec SPD
1558 Sample CLI : 'ipsec spd add 1'
1559
1560 :param spd_id - SPD ID to be created in the vpp . mandatory
1561 :param is_add - create (1) or delete(0) SPD (Default 1 - add) .
1562 optional
1563 :returns: reply from the API
1564 """
1565 return self.api(
1566 self.papi.ipsec_spd_add_del, {
1567 'spd_id': spd_id, 'is_add': is_add})
1568
Neale Ranns311124e2019-01-24 04:52:25 -08001569 def ipsec_spds_dump(self):
1570 return self.api(self.papi.ipsec_spds_dump, {})
1571
“mystarrocks”23f0c452017-12-11 07:11:51 -08001572 def ipsec_interface_add_del_spd(self, spd_id, sw_if_index, is_add=1):
1573 """ IPSEC interface SPD add/del - \
1574 Wrapper to associate/disassociate SPD to interface in VPP
1575 Sample CLI : 'set interface ipsec spd GigabitEthernet0/6/0 1'
1576
1577 :param spd_id - SPD ID to associate with the interface . mandatory
1578 :param sw_if_index - Interface Index which needs to ipsec \
1579 association mandatory
1580 :param is_add - add(1) or del(0) association with interface \
1581 (Default 1 - add) . optional
1582 :returns: reply from the API
1583 """
1584 return self.api(
Klement Sekera4b089f22018-04-17 18:04:57 +02001585 self.papi.ipsec_interface_add_del_spd,
1586 {'spd_id': spd_id, 'sw_if_index': sw_if_index, 'is_add': is_add})
“mystarrocks”23f0c452017-12-11 07:11:51 -08001587
Neale Ranns311124e2019-01-24 04:52:25 -08001588 def ipsec_spd_interface_dump(self, spd_index=None):
1589 return self.api(self.papi.ipsec_spd_interface_dump,
1590 {'spd_index': spd_index if spd_index else 0,
1591 'spd_index_valid': 1 if spd_index else 0})
1592
Neale Ranns17dcec02019-01-09 21:22:20 -08001593 def ipsec_sad_entry_add_del(self,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001594 sad_id,
1595 spi,
Klement Sekera31da2e32018-06-24 22:49:55 +02001596 integrity_algorithm,
1597 integrity_key,
1598 crypto_algorithm,
1599 crypto_key,
1600 protocol,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001601 tunnel_src_address='',
1602 tunnel_dst_address='',
Neale Ranns17dcec02019-01-09 21:22:20 -08001603 flags=0,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001604 salt=0,
Neale Ranns17dcec02019-01-09 21:22:20 -08001605 is_add=1):
“mystarrocks”23f0c452017-12-11 07:11:51 -08001606 """ IPSEC SA add/del
Klement Sekera31da2e32018-06-24 22:49:55 +02001607 :param sad_id: security association ID
1608 :param spi: security param index of the SA in decimal
1609 :param integrity_algorithm:
1610 :param integrity_key:
1611 :param crypto_algorithm:
1612 :param crypto_key:
1613 :param protocol: AH(0) or ESP(1) protocol
1614 :param tunnel_src_address: tunnel mode outer src address
1615 :param tunnel_dst_address: tunnel mode outer dst address
1616 :param is_add:
1617 :param is_tunnel:
“mystarrocks”23f0c452017-12-11 07:11:51 -08001618 :** reference /vpp/src/vnet/ipsec/ipsec.h file for enum values of
1619 crypto and ipsec algorithms
1620 """
1621 return self.api(
Neale Ranns17dcec02019-01-09 21:22:20 -08001622 self.papi.ipsec_sad_entry_add_del,
1623 {
1624 'is_add': is_add,
1625 'entry':
Ole Troan9a475372019-03-05 16:58:24 +01001626 {
1627 'sad_id': sad_id,
1628 'spi': spi,
1629 'tunnel_src': tunnel_src_address,
1630 'tunnel_dst': tunnel_dst_address,
1631 'protocol': protocol,
1632 'integrity_algorithm': integrity_algorithm,
1633 'integrity_key': {
1634 'length': len(integrity_key),
1635 'data': integrity_key,
1636 },
1637 'crypto_algorithm': crypto_algorithm,
1638 'crypto_key': {
1639 'length': len(crypto_key),
1640 'data': crypto_key,
1641 },
1642 'flags': flags,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001643 'salt': salt,
Ole Troan9a475372019-03-05 16:58:24 +01001644 }
Neale Ranns17dcec02019-01-09 21:22:20 -08001645 })
“mystarrocks”23f0c452017-12-11 07:11:51 -08001646
Neale Ranns311124e2019-01-24 04:52:25 -08001647 def ipsec_sa_dump(self, sa_id=None):
1648 return self.api(self.papi.ipsec_sa_dump,
1649 {'sa_id': sa_id if sa_id else 0xffffffff})
1650
Neale Ranns17dcec02019-01-09 21:22:20 -08001651 def ipsec_spd_entry_add_del(self,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001652 spd_id,
Klement Sekera31da2e32018-06-24 22:49:55 +02001653 sa_id,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001654 local_address_start,
1655 local_address_stop,
1656 remote_address_start,
1657 remote_address_stop,
1658 local_port_start=0,
1659 local_port_stop=65535,
1660 remote_port_start=0,
1661 remote_port_stop=65535,
1662 protocol=0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001663 policy=0,
1664 priority=100,
1665 is_outbound=1,
1666 is_add=1,
Klement Sekera611864f2018-09-26 11:19:00 +02001667 is_ipv6=0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08001668 is_ip_any=0):
1669 """ IPSEC policy SPD add/del -
1670 Wrapper to configure ipsec SPD policy entries in VPP
Klement Sekera31da2e32018-06-24 22:49:55 +02001671 :param spd_id: SPD ID for the policy
1672 :param local_address_start: local-ip-range start address
1673 :param local_address_stop : local-ip-range stop address
1674 :param remote_address_start: remote-ip-range start address
1675 :param remote_address_stop : remote-ip-range stop address
1676 :param local_port_start: (Default value = 0)
1677 :param local_port_stop: (Default value = 65535)
1678 :param remote_port_start: (Default value = 0)
1679 :param remote_port_stop: (Default value = 65535)
1680 :param protocol: Any(0), AH(51) & ESP(50) protocol (Default value = 0)
1681 :param sa_id: Security Association ID for mapping it to SPD
1682 :param policy: bypass(0), discard(1), resolve(2) or protect(3) action
1683 (Default value = 0)
1684 :param priority: value for the spd action (Default value = 100)
1685 :param is_outbound: flag for inbound(0) or outbound(1)
1686 (Default value = 1)
1687 :param is_add: (Default value = 1)
“mystarrocks”23f0c452017-12-11 07:11:51 -08001688 """
1689 return self.api(
Neale Ranns17dcec02019-01-09 21:22:20 -08001690 self.papi.ipsec_spd_entry_add_del,
1691 {
1692 'is_add': is_add,
1693 'entry':
Ole Troan9a475372019-03-05 16:58:24 +01001694 {
1695 'spd_id': spd_id,
1696 'sa_id': sa_id,
1697 'local_address_start': local_address_start,
1698 'local_address_stop': local_address_stop,
1699 'remote_address_start': remote_address_start,
1700 'remote_address_stop': remote_address_stop,
1701 'local_port_start': local_port_start,
1702 'local_port_stop': local_port_stop,
1703 'remote_port_start': remote_port_start,
1704 'remote_port_stop': remote_port_stop,
1705 'protocol': protocol,
1706 'policy': policy,
1707 'priority': priority,
1708 'is_outbound': is_outbound,
Ole Troan9a475372019-03-05 16:58:24 +01001709 }
Neale Ranns17dcec02019-01-09 21:22:20 -08001710 })
Florin Corasb795bd02017-12-14 11:30:48 -08001711
Neale Ranns311124e2019-01-24 04:52:25 -08001712 def ipsec_spd_dump(self, spd_id, sa_id=0xffffffff):
1713 return self.api(self.papi.ipsec_spd_dump,
1714 {'spd_id': spd_id,
1715 'sa_id': sa_id})
1716
Klement Sekera31da2e32018-06-24 22:49:55 +02001717 def ipsec_tunnel_if_add_del(self, local_ip, remote_ip, local_spi,
1718 remote_spi, crypto_alg, local_crypto_key,
1719 remote_crypto_key, integ_alg, local_integ_key,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001720 remote_integ_key, is_add=1, esn=0, salt=0,
Neale Rannsa6bee0a2019-06-14 01:13:25 -07001721 anti_replay=1, renumber=0,
1722 udp_encap=0, show_instance=0):
Klement Sekera31da2e32018-06-24 22:49:55 +02001723 return self.api(
1724 self.papi.ipsec_tunnel_if_add_del,
Kingwel Xie1ba5bc82019-03-20 07:21:58 -04001725 {
1726 'local_ip': local_ip,
1727 'remote_ip': remote_ip,
1728 'local_spi': local_spi,
1729 'remote_spi': remote_spi,
1730 'crypto_alg': crypto_alg,
1731 'local_crypto_key_len': len(local_crypto_key),
1732 'local_crypto_key': local_crypto_key,
1733 'remote_crypto_key_len': len(remote_crypto_key),
1734 'remote_crypto_key': remote_crypto_key,
1735 'integ_alg': integ_alg,
1736 'local_integ_key_len': len(local_integ_key),
1737 'local_integ_key': local_integ_key,
1738 'remote_integ_key_len': len(remote_integ_key),
1739 'remote_integ_key': remote_integ_key,
1740 'is_add': is_add,
1741 'esn': esn,
1742 'anti_replay': anti_replay,
1743 'renumber': renumber,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001744 'show_instance': show_instance,
Neale Rannsa6bee0a2019-06-14 01:13:25 -07001745 'udp_encap': udp_encap,
Neale Ranns80f6fd52019-04-16 02:41:34 +00001746 'salt': salt
Kingwel Xie1ba5bc82019-03-20 07:21:58 -04001747 })
Klement Sekera31da2e32018-06-24 22:49:55 +02001748
Klement Sekerab4d30532018-11-08 13:00:02 +01001749 def ipsec_select_backend(self, protocol, index):
1750 return self.api(self.papi.ipsec_select_backend,
1751 {'protocol': protocol, 'index': index})
1752
1753 def ipsec_backend_dump(self):
1754 return self.api(self.papi.ipsec_backend_dump, {})
1755
Ole Troane1ade682019-03-04 23:55:43 +01001756 def app_namespace_add_del(self,
1757 namespace_id,
1758 ip4_fib_id=0,
1759 ip6_fib_id=0,
1760 sw_if_index=0xFFFFFFFF,
1761 secret=0):
Florin Corasb795bd02017-12-14 11:30:48 -08001762 return self.api(
1763 self.papi.app_namespace_add_del,
1764 {'secret': secret,
1765 'sw_if_index': sw_if_index,
1766 'ip4_fib_id': ip4_fib_id,
1767 'ip6_fib_id': ip6_fib_id,
1768 'namespace_id': namespace_id,
1769 'namespace_id_len': len(namespace_id)})
Klement Sekera75e7d132017-09-20 08:26:30 +02001770
Neale Ranns50f0ac02019-05-15 02:13:37 -07001771 def punt_socket_register(self, reg, pathname,
1772 header_version=1):
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001773 """ Register punt socket """
Klement Sekera75e7d132017-09-20 08:26:30 +02001774 return self.api(self.papi.punt_socket_register,
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001775 {'header_version': header_version,
Neale Ranns50f0ac02019-05-15 02:13:37 -07001776 'punt': reg,
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001777 'pathname': pathname})
1778
Neale Ranns50f0ac02019-05-15 02:13:37 -07001779 def punt_socket_deregister(self, reg):
Pavel Kotuceke88865d2018-11-28 07:42:11 +01001780 """ Unregister punt socket """
1781 return self.api(self.papi.punt_socket_deregister,
Neale Ranns50f0ac02019-05-15 02:13:37 -07001782 {'punt': reg})
Klement Sekera75e7d132017-09-20 08:26:30 +02001783
Neale Ranns4ba67722019-02-28 11:11:39 +00001784 def gbp_endpoint_add(self, sw_if_index, ips, mac, sclass, flags,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001785 tun_src, tun_dst):
Neale Rannsc0a93142018-09-05 15:42:26 -07001786 """ GBP endpoint Add """
1787 return self.api(self.papi.gbp_endpoint_add,
1788 {'endpoint': {
1789 'sw_if_index': sw_if_index,
1790 'ips': ips,
1791 'n_ips': len(ips),
1792 'mac': mac,
Neale Ranns4ba67722019-02-28 11:11:39 +00001793 'sclass': sclass,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001794 'flags': flags,
1795 'tun': {
1796 'src': tun_src,
1797 'dst': tun_dst,
1798 }}})
Neale Rannsc0a93142018-09-05 15:42:26 -07001799
1800 def gbp_endpoint_del(self, handle):
1801 """ GBP endpoint Del """
1802 return self.api(self.papi.gbp_endpoint_del,
1803 {'handle': handle})
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001804
1805 def gbp_endpoint_dump(self):
1806 """ GBP endpoint Dump """
Ole Troan0bcad322018-12-11 13:04:01 +01001807 return self.api(self.papi.gbp_endpoint_dump,
1808 {'_no_type_conversion': True})
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001809
Neale Ranns4ba67722019-02-28 11:11:39 +00001810 def gbp_endpoint_group_add(self, vnid, sclass, bd,
Neale Ranns32f6d8e2019-03-05 04:22:08 -08001811 rd, uplink_sw_if_index,
1812 retention):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001813 """ GBP endpoint group Add """
1814 return self.api(self.papi.gbp_endpoint_group_add,
1815 {'epg':
Ole Troan9a475372019-03-05 16:58:24 +01001816 {
1817 'uplink_sw_if_index': uplink_sw_if_index,
1818 'bd_id': bd,
1819 'rd_id': rd,
1820 'vnid': vnid,
1821 'sclass': sclass,
1822 'retention': retention
1823 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001824
Neale Ranns4ba67722019-02-28 11:11:39 +00001825 def gbp_endpoint_group_del(self, sclass):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001826 """ GBP endpoint group Del """
1827 return self.api(self.papi.gbp_endpoint_group_del,
Neale Ranns4ba67722019-02-28 11:11:39 +00001828 {'sclass': sclass})
Neale Ranns25b04942018-04-04 09:34:50 -07001829
Neale Ranns160c9232019-06-19 06:25:56 -07001830 def gbp_bridge_domain_add(self, bd_id, rd_id, flags,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001831 bvi_sw_if_index,
Neale Ranns879d11c2019-01-21 23:34:18 -08001832 uu_fwd_sw_if_index,
1833 bm_flood_sw_if_index):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001834 """ GBP bridge-domain Add """
1835 return self.api(self.papi.gbp_bridge_domain_add,
1836 {'bd':
Ole Troan9a475372019-03-05 16:58:24 +01001837 {
1838 'flags': flags,
1839 'bvi_sw_if_index': bvi_sw_if_index,
1840 'uu_fwd_sw_if_index': uu_fwd_sw_if_index,
1841 'bm_flood_sw_if_index': bm_flood_sw_if_index,
Neale Ranns160c9232019-06-19 06:25:56 -07001842 'bd_id': bd_id,
1843 'rd_id': rd_id
Ole Troan9a475372019-03-05 16:58:24 +01001844 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001845
1846 def gbp_bridge_domain_del(self, bd_id):
1847 """ GBP bridge-domain Del """
1848 return self.api(self.papi.gbp_bridge_domain_del,
1849 {'bd_id': bd_id})
1850
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001851 def gbp_route_domain_add(self, rd_id,
Neale Ranns160c9232019-06-19 06:25:56 -07001852 scope,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001853 ip4_table_id,
1854 ip6_table_id,
1855 ip4_uu_sw_if_index,
1856 ip6_uu_sw_if_index):
1857 """ GBP route-domain Add """
1858 return self.api(self.papi.gbp_route_domain_add,
1859 {'rd':
Ole Troan9a475372019-03-05 16:58:24 +01001860 {
Neale Ranns160c9232019-06-19 06:25:56 -07001861 'scope': scope,
Ole Troan9a475372019-03-05 16:58:24 +01001862 'ip4_table_id': ip4_table_id,
1863 'ip6_table_id': ip6_table_id,
1864 'ip4_uu_sw_if_index': ip4_uu_sw_if_index,
1865 'ip6_uu_sw_if_index': ip6_uu_sw_if_index,
1866 'rd_id': rd_id
1867 }})
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001868
1869 def gbp_route_domain_del(self, rd_id):
1870 """ GBP route-domain Del """
1871 return self.api(self.papi.gbp_route_domain_del,
1872 {'rd_id': rd_id})
1873
Neale Ranns4ba67722019-02-28 11:11:39 +00001874 def gbp_recirc_add_del(self, is_add, sw_if_index, sclass, is_ext):
Neale Ranns25b04942018-04-04 09:34:50 -07001875 """ GBP recirc Add/Del """
1876 return self.api(self.papi.gbp_recirc_add_del,
1877 {'is_add': is_add,
1878 'recirc': {
1879 'is_ext': is_ext,
1880 'sw_if_index': sw_if_index,
Neale Ranns4ba67722019-02-28 11:11:39 +00001881 'sclass': sclass}})
Neale Ranns25b04942018-04-04 09:34:50 -07001882
1883 def gbp_recirc_dump(self):
1884 """ GBP recirc Dump """
1885 return self.api(self.papi.gbp_recirc_dump, {})
1886
Benoît Ganneba6abfa2019-07-01 17:10:41 +02001887 def gbp_ext_itf_add_del(self, is_add, sw_if_index, bd_id, rd_id, flags):
Neale Rannsb6a47952018-11-21 05:44:35 -08001888 """ GBP recirc Add/Del """
1889 return self.api(self.papi.gbp_ext_itf_add_del,
1890 {'is_add': is_add,
1891 'ext_itf': {
1892 'sw_if_index': sw_if_index,
1893 'bd_id': bd_id,
Benoît Ganneba6abfa2019-07-01 17:10:41 +02001894 'rd_id': rd_id,
1895 'flags': flags}})
Neale Rannsb6a47952018-11-21 05:44:35 -08001896
1897 def gbp_ext_itf_dump(self):
1898 """ GBP recirc Dump """
1899 return self.api(self.papi.gbp_ext_itf_dump, {})
1900
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001901 def gbp_subnet_add_del(self, is_add, rd_id,
1902 prefix, type,
Neale Ranns25b04942018-04-04 09:34:50 -07001903 sw_if_index=0xffffffff,
Neale Ranns4ba67722019-02-28 11:11:39 +00001904 sclass=0xffff):
Neale Ranns25b04942018-04-04 09:34:50 -07001905 """ GBP Subnet Add/Del """
1906 return self.api(self.papi.gbp_subnet_add_del,
1907 {'is_add': is_add,
1908 'subnet': {
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001909 'type': type,
Neale Ranns25b04942018-04-04 09:34:50 -07001910 'sw_if_index': sw_if_index,
Neale Ranns4ba67722019-02-28 11:11:39 +00001911 'sclass': sclass,
Neale Rannsc0a93142018-09-05 15:42:26 -07001912 'prefix': prefix,
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001913 'rd_id': rd_id}})
Neale Ranns25b04942018-04-04 09:34:50 -07001914
1915 def gbp_subnet_dump(self):
1916 """ GBP Subnet Dump """
Ole Troan0bcad322018-12-11 13:04:01 +01001917 return self.api(self.papi.gbp_subnet_dump,
1918 {'_no_type_conversion': True})
Neale Ranns25b04942018-04-04 09:34:50 -07001919
Neale Rannsbc27d1b2018-02-05 01:13:38 -08001920 def gbp_contract_dump(self):
1921 """ GBP contract Dump """
1922 return self.api(self.papi.gbp_contract_dump, {})
Ole Troan6ee40512018-02-12 18:14:39 +01001923
Neale Ranns8da9fc62019-03-04 14:08:11 -08001924 def gbp_vxlan_tunnel_add(self, vni, bd_rd_id, mode, src):
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001925 """ GBP VXLAN tunnel add """
1926 return self.api(self.papi.gbp_vxlan_tunnel_add,
1927 {
1928 'tunnel': {
1929 'vni': vni,
1930 'mode': mode,
Neale Ranns8da9fc62019-03-04 14:08:11 -08001931 'bd_rd_id': bd_rd_id,
1932 'src': src
Neale Ranns93cc3ee2018-10-10 07:22:51 -07001933 }
1934 })
1935
1936 def gbp_vxlan_tunnel_del(self, vni):
1937 """ GBP VXLAN tunnel del """
1938 return self.api(self.papi.gbp_vxlan_tunnel_del,
1939 {
1940 'vni': vni,
1941 })
1942
1943 def gbp_vxlan_tunnel_dump(self):
1944 """ GBP VXLAN tunnel add/del """
1945 return self.api(self.papi.gbp_vxlan_tunnel_dump, {})
1946
Neale Ranns947ea622018-06-07 23:48:20 -07001947 def igmp_enable_disable(self, sw_if_index, enable, host):
1948 """ Enable/disable IGMP on a given interface """
1949 return self.api(self.papi.igmp_enable_disable,
1950 {'enable': enable,
1951 'mode': host,
1952 'sw_if_index': sw_if_index})
1953
Jakub Grajciar97748ca2018-10-04 11:05:35 +02001954 def igmp_proxy_device_add_del(self, vrf_id, sw_if_index, add):
1955 """ Add/del IGMP proxy device """
1956 return self.api(self.papi.igmp_proxy_device_add_del,
1957 {'vrf_id': vrf_id, 'sw_if_index': sw_if_index,
1958 'add': add})
1959
1960 def igmp_proxy_device_add_del_interface(self, vrf_id, sw_if_index, add):
1961 """ Add/del interface to/from IGMP proxy device """
1962 return self.api(self.papi.igmp_proxy_device_add_del_interface,
1963 {'vrf_id': vrf_id, 'sw_if_index': sw_if_index,
1964 'add': add})
1965
Neale Ranns947ea622018-06-07 23:48:20 -07001966 def igmp_listen(self, filter, sw_if_index, saddrs, gaddr):
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001967 """ Listen for new (S,G) on specified interface
1968
1969 :param enable: add/del
1970 :param sw_if_index: interface sw index
1971 :param saddr: source ip4 addr
1972 :param gaddr: group ip4 addr
1973 """
1974 return self.api(self.papi.igmp_listen,
Neale Ranns947ea622018-06-07 23:48:20 -07001975 {
1976 'group':
Ole Troan9a475372019-03-05 16:58:24 +01001977 {
1978 'filter': filter,
1979 'sw_if_index': sw_if_index,
1980 'n_srcs': len(saddrs),
1981 'saddrs': saddrs,
1982 'gaddr': gaddr
1983 }
Neale Ranns947ea622018-06-07 23:48:20 -07001984 })
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001985
Jakub Grajciar7b867a82017-12-08 16:28:42 +01001986 def igmp_clear_interface(self, sw_if_index):
1987 """ Remove all (S,G)s from specified interface
1988 doesn't send IGMP report!
1989 """
1990 return self.api(
1991 self.papi.igmp_clear_interface, {
1992 'sw_if_index': sw_if_index})
1993
1994 def want_igmp_events(self, enable=1):
1995 return self.api(self.papi.want_igmp_events, {'enable': enable,
1996 'pid': os.getpid()})
Steven9cd2d7a2017-12-20 12:43:01 -08001997
1998 def bond_create(
1999 self,
2000 mode,
2001 lb,
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002002 numa_only,
Steven9cd2d7a2017-12-20 12:43:01 -08002003 use_custom_mac,
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002004 mac_address='',
2005 interface_id=0xFFFFFFFF):
Steven9cd2d7a2017-12-20 12:43:01 -08002006 """
2007 :param mode: mode
2008 :param lb: load balance
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002009 :param numa_only: tx on local numa node for lacp mode
Steven9cd2d7a2017-12-20 12:43:01 -08002010 :param use_custom_mac: use custom mac
2011 :param mac_address: mac address
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002012 :param interface_id: custom interface ID
Steven9cd2d7a2017-12-20 12:43:01 -08002013 """
2014 return self.api(
2015 self.papi.bond_create,
2016 {'mode': mode,
2017 'lb': lb,
Zhiyong Yang751e3f32019-06-26 05:49:14 -04002018 'numa_only': numa_only,
Steven9cd2d7a2017-12-20 12:43:01 -08002019 'use_custom_mac': use_custom_mac,
Alexander Chernavinad9d5282018-12-13 09:08:09 -05002020 'mac_address': mac_address,
2021 'id': interface_id
Steven9cd2d7a2017-12-20 12:43:01 -08002022 })
2023
Neale Ranns17ff3c12018-07-04 10:24:24 -07002024 def pipe_delete(self, parent_sw_if_index):
2025 return self.api(self.papi.pipe_delete,
2026 {'parent_sw_if_index': parent_sw_if_index})
2027
Neale Rannsd1e68ab2018-10-01 01:42:13 -07002028 def svs_table_add_del(self, af, table_id, is_add=1):
2029 return self.api(self.papi.svs_table_add_del,
2030 {
2031 'table_id': table_id,
2032 'is_add': is_add,
2033 'af': af,
2034 })
2035
2036 def svs_route_add_del(self, table_id, prefix, src_table_id, is_add=1):
2037 return self.api(self.papi.svs_route_add_del,
2038 {
2039 'table_id': table_id,
2040 'source_table_id': src_table_id,
2041 'prefix': prefix,
2042 'is_add': is_add,
2043 })
2044
2045 def svs_enable_disable(self, af, table_id, sw_if_index, is_enable=1):
2046 return self.api(self.papi.svs_enable_disable,
2047 {
2048 'af': af,
2049 'table_id': table_id,
2050 'sw_if_index': sw_if_index,
2051 'is_enable': is_enable,
2052 })
Mohsin Kazmi29467b52019-10-08 19:42:38 +02002053
2054 def feature_gso_enable_disable(self, sw_if_index, enable_disable=1):
2055 return self.api(self.papi.feature_gso_enable_disable,
2056 {
2057 'sw_if_index': sw_if_index,
2058 'enable_disable': enable_disable,
2059 })