Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1 | import os |
| 2 | import fnmatch |
| 3 | import time |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 4 | from hook import Hook |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 5 | from collections import deque |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 6 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 7 | # Sphinx creates auto-generated documentation by importing the python source |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 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. |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 11 | do_import = True |
| 12 | try: |
| 13 | no_vpp_papi = os.getenv("NO_VPP_PAPI") |
| 14 | if no_vpp_papi == "1": |
| 15 | do_import = False |
| 16 | except: |
| 17 | pass |
| 18 | |
| 19 | if do_import: |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 20 | from vpp_papi import VPP |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 21 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 22 | # from vnet/vnet/mpls/mpls_types.h |
| 23 | MPLS_IETF_MAX_LABEL = 0xfffff |
| 24 | MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1 |
| 25 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 26 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 27 | class L2_VTR_OP: |
| 28 | L2_POP_1 = 3 |
| 29 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 30 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 31 | class VppPapiProvider(object): |
| 32 | """VPP-api provider using vpp-papi |
| 33 | |
| 34 | @property hook: hook object providing before and after api/cli hooks |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 35 | """ |
| 36 | |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 37 | _zero, _negative = range(2) |
| 38 | |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 39 | def __init__(self, name, shm_prefix, test_class): |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 40 | self.hook = Hook("vpp-papi-provider") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 41 | self.name = name |
| 42 | self.shm_prefix = shm_prefix |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 43 | self.test_class = test_class |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 44 | self._expect_api_retval = self._zero |
| 45 | self._expect_stack = [] |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 46 | jsonfiles = [] |
| 47 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 48 | install_dir = os.getenv('VPP_TEST_INSTALL_PATH') |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 49 | for root, dirnames, filenames in os.walk(install_dir): |
| 50 | for filename in fnmatch.filter(filenames, '*.api.json'): |
| 51 | jsonfiles.append(os.path.join(root, filename)) |
| 52 | |
| 53 | self.papi = VPP(jsonfiles) |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 54 | self._events = deque() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 55 | |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 56 | def __enter__(self): |
| 57 | return self |
| 58 | |
| 59 | def expect_negative_api_retval(self): |
| 60 | """ Expect API failure """ |
| 61 | self._expect_stack.append(self._expect_api_retval) |
| 62 | self._expect_api_retval = self._negative |
| 63 | return self |
| 64 | |
| 65 | def expect_zero_api_retval(self): |
| 66 | """ Expect API success """ |
| 67 | self._expect_stack.append(self._expect_api_retval) |
| 68 | self._expect_api_retval = self._zero |
| 69 | return self |
| 70 | |
| 71 | def __exit__(self, exc_type, exc_value, traceback): |
| 72 | self._expect_api_retval = self._expect_stack.pop() |
| 73 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 74 | def register_hook(self, hook): |
| 75 | """Replace hook registration with new hook |
| 76 | |
| 77 | :param hook: |
| 78 | |
| 79 | """ |
| 80 | self.hook = hook |
| 81 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 82 | def collect_events(self): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 83 | """ Collect all events from the internal queue and clear the queue. """ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 84 | e = self._events |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 85 | self._events = deque() |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 86 | return e |
| 87 | |
| 88 | def wait_for_event(self, timeout, name=None): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 89 | """ Wait for and return next event. """ |
| 90 | if self._events: |
| 91 | self.test_class.logger.debug("Not waiting, event already queued") |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 92 | limit = time.time() + timeout |
| 93 | while time.time() < limit: |
| 94 | if self._events: |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 95 | e = self._events.popleft() |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 96 | if name and type(e).__name__ != name: |
| 97 | raise Exception( |
| 98 | "Unexpected event received: %s, expected: %s" % |
| 99 | (type(e).__name__, name)) |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 100 | self.test_class.logger.debug("Returning event %s:%s" % |
| 101 | (name, e)) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 102 | return e |
| 103 | time.sleep(0) # yield |
| 104 | if name is not None: |
| 105 | raise Exception("Event %s did not occur within timeout" % name) |
| 106 | raise Exception("Event did not occur within timeout") |
| 107 | |
| 108 | def __call__(self, name, event): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 109 | """ Enqueue event in the internal event queue. """ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 110 | # FIXME use the name instead of relying on type(e).__name__ ? |
| 111 | # FIXME #2 if this throws, it is eaten silently, Ole? |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 112 | self.test_class.logger.debug("New event: %s: %s" % (name, event)) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 113 | self._events.append(event) |
| 114 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 115 | def connect(self): |
| 116 | """Connect the API to VPP""" |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 117 | self.papi.connect(self.name, self.shm_prefix) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 118 | self.papi.register_event_callback(self) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 119 | |
| 120 | def disconnect(self): |
| 121 | """Disconnect the API from VPP""" |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 122 | self.papi.disconnect() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 123 | |
| 124 | def api(self, api_fn, api_args, expected_retval=0): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 125 | """ Call API function and check it's return value. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 126 | Call the appropriate hooks before and after the API call |
| 127 | |
| 128 | :param api_fn: API function to call |
| 129 | :param api_args: tuple of API function arguments |
| 130 | :param expected_retval: Expected return value (Default value = 0) |
| 131 | :returns: reply from the API |
| 132 | |
| 133 | """ |
| 134 | self.hook.before_api(api_fn.__name__, api_args) |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 135 | reply = api_fn(**api_args) |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 136 | if self._expect_api_retval == self._negative: |
| 137 | if hasattr(reply, 'retval') and reply.retval >= 0: |
| 138 | msg = "API call passed unexpectedly: expected negative "\ |
| 139 | "return value instead of %d in %s" % \ |
| 140 | (reply.retval, repr(reply)) |
| 141 | self.test_class.logger.info(msg) |
| 142 | raise Exception(msg) |
| 143 | elif self._expect_api_retval == self._zero: |
| 144 | if hasattr(reply, 'retval') and reply.retval != expected_retval: |
| 145 | msg = "API call failed, expected zero return value instead "\ |
| 146 | "of %d in %s" % (expected_retval, repr(reply)) |
| 147 | self.test_class.logger.info(msg) |
| 148 | raise Exception(msg) |
| 149 | else: |
| 150 | raise Exception("Internal error, unexpected value for " |
| 151 | "self._expect_api_retval %s" % |
| 152 | self._expect_api_retval) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 153 | self.hook.after_api(api_fn.__name__, api_args) |
| 154 | return reply |
| 155 | |
| 156 | def cli(self, cli): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 157 | """ Execute a CLI, calling the before/after hooks appropriately. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 158 | |
| 159 | :param cli: CLI to execute |
| 160 | :returns: CLI output |
| 161 | |
| 162 | """ |
| 163 | self.hook.before_cli(cli) |
| 164 | cli += '\n' |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 165 | r = self.papi.cli_inband(length=len(cli), cmd=cli) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 166 | self.hook.after_cli(cli) |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 167 | if hasattr(r, 'reply'): |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 168 | return r.reply.decode().rstrip('\x00') |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 169 | |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 170 | def ppcli(self, cli): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 171 | """ Helper method to print CLI command in case of info logging level. |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 172 | |
| 173 | :param cli: CLI to execute |
| 174 | :returns: CLI output |
| 175 | """ |
Ed Warnicke | b8ff5d6 | 2016-11-28 13:59:22 -0600 | [diff] [blame] | 176 | return cli + "\n" + str(self.cli(cli)) |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 177 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 178 | def _convert_mac(self, mac): |
| 179 | return int(mac.replace(":", ""), 16) << 16 |
| 180 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 181 | def show_version(self): |
| 182 | """ """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 183 | return self.papi.show_version() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 184 | |
| 185 | def pg_create_interface(self, pg_index): |
| 186 | """ |
| 187 | |
| 188 | :param pg_index: |
| 189 | |
| 190 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 191 | return self.api(self.papi.pg_create_interface, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 192 | {"interface_id": pg_index}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 193 | |
| 194 | def sw_interface_dump(self, filter=None): |
| 195 | """ |
| 196 | |
| 197 | :param filter: (Default value = None) |
| 198 | |
| 199 | """ |
| 200 | if filter is not None: |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 201 | args = {"name_filter_valid": 1, "name_filter": filter} |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 202 | else: |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 203 | args = {} |
| 204 | return self.api(self.papi.sw_interface_dump, args) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 205 | |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 206 | def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 207 | """ Set the IPvX Table-id for the Interface |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 208 | |
| 209 | :param sw_if_index: |
| 210 | :param is_ipv6: |
| 211 | :param table_id: |
| 212 | |
| 213 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 214 | return self.api(self.papi.sw_interface_set_table, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 215 | {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6, |
| 216 | 'vrf_id': table_id}) |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 217 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 218 | def sw_interface_add_del_address(self, sw_if_index, addr, addr_len, |
| 219 | is_ipv6=0, is_add=1, del_all=0): |
| 220 | """ |
| 221 | |
| 222 | :param addr: param is_ipv6: (Default value = 0) |
| 223 | :param sw_if_index: |
| 224 | :param addr_len: |
| 225 | :param is_ipv6: (Default value = 0) |
| 226 | :param is_add: (Default value = 1) |
| 227 | :param del_all: (Default value = 0) |
| 228 | |
| 229 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 230 | return self.api(self.papi.sw_interface_add_del_address, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 231 | {'sw_if_index': sw_if_index, |
| 232 | 'is_add': is_add, |
| 233 | 'is_ipv6': is_ipv6, |
| 234 | 'del_all': del_all, |
| 235 | 'address_length': addr_len, |
| 236 | 'address': addr}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 237 | |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 238 | def sw_interface_enable_disable_mpls(self, sw_if_index, |
| 239 | is_enable=1): |
| 240 | """ |
| 241 | Enable/Disable MPLS on the interface |
| 242 | :param sw_if_index: |
| 243 | :param is_enable: (Default value = 1) |
| 244 | |
| 245 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 246 | return self.api(self.papi.sw_interface_set_mpls_enable, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 247 | {'sw_if_index': sw_if_index, |
| 248 | 'enable': is_enable}) |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 249 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 250 | def sw_interface_ra_suppress(self, sw_if_index): |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 251 | return self.api(self.papi.sw_interface_ip6nd_ra_config, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 252 | {'sw_if_index': sw_if_index}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 253 | |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 254 | def ip6_sw_interface_ra_config(self, sw_if_index, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame^] | 255 | no, |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 256 | suppress, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame^] | 257 | send_unicast): |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 258 | return self.api(self.papi.sw_interface_ip6nd_ra_config, |
| 259 | {'sw_if_index': sw_if_index, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame^] | 260 | 'is_no': no, |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 261 | 'suppress': suppress, |
| 262 | 'send_unicast': send_unicast}) |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 263 | |
| 264 | def ip6_sw_interface_enable_disable(self, sw_if_index, enable): |
| 265 | """ |
| 266 | Enable/Disable An interface for IPv6 |
| 267 | """ |
| 268 | return self.api(self.papi.sw_interface_ip6_enable_disable, |
| 269 | {'sw_if_index': sw_if_index, |
| 270 | 'enable': enable}) |
| 271 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 272 | def vxlan_add_del_tunnel( |
| 273 | self, |
| 274 | src_addr, |
| 275 | dst_addr, |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 276 | mcast_sw_if_index=0xFFFFFFFF, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 277 | is_add=1, |
| 278 | is_ipv6=0, |
| 279 | encap_vrf_id=0, |
| 280 | decap_next_index=0xFFFFFFFF, |
| 281 | vni=0): |
| 282 | """ |
| 283 | |
| 284 | :param dst_addr: |
| 285 | :param src_addr: |
| 286 | :param is_add: (Default value = 1) |
| 287 | :param is_ipv6: (Default value = 0) |
| 288 | :param encap_vrf_id: (Default value = 0) |
| 289 | :param decap_next_index: (Default value = 0xFFFFFFFF) |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 290 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 291 | :param vni: (Default value = 0) |
| 292 | |
| 293 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 294 | return self.api(self.papi.vxlan_add_del_tunnel, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 295 | {'is_add': is_add, |
| 296 | 'is_ipv6': is_ipv6, |
| 297 | 'src_address': src_addr, |
| 298 | 'dst_address': dst_addr, |
| 299 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 300 | 'encap_vrf_id': encap_vrf_id, |
| 301 | 'decap_next_index': decap_next_index, |
| 302 | 'vni': vni}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 303 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 304 | def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1, |
| 305 | learn=1, arp_term=0, is_add=1): |
| 306 | """Create/delete bridge domain. |
| 307 | |
| 308 | :param int bd_id: Bridge domain index. |
| 309 | :param int flood: Enable/disable bcast/mcast flooding in the BD. |
| 310 | (Default value = 1) |
| 311 | :param int uu_flood: Enable/disable unknown unicast flood in the BD. |
| 312 | (Default value = 1) |
| 313 | :param int forward: Enable/disable forwarding on all interfaces in |
| 314 | the BD. (Default value = 1) |
| 315 | :param int learn: Enable/disable learning on all interfaces in the BD. |
| 316 | (Default value = 1) |
| 317 | :param int arp_term: Enable/disable arp termination in the BD. |
| 318 | (Default value = 1) |
| 319 | :param int is_add: Add or delete flag. (Default value = 1) |
| 320 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 321 | return self.api(self.papi.bridge_domain_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 322 | {'bd_id': bd_id, |
| 323 | 'flood': flood, |
| 324 | 'uu_flood': uu_flood, |
| 325 | 'forward': forward, |
| 326 | 'learn': learn, |
| 327 | 'arp_term': arp_term, |
| 328 | 'is_add': is_add}) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 329 | |
| 330 | def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0, |
| 331 | filter_mac=0, bvi_mac=0): |
| 332 | """Create/delete L2 FIB entry. |
| 333 | |
| 334 | :param str mac: MAC address to create FIB entry for. |
| 335 | :param int bd_id: Bridge domain index. |
| 336 | :param int sw_if_index: Software interface index of the interface. |
| 337 | :param int is_add: Add or delete flag. (Default value = 1) |
| 338 | :param int static_mac: Set to 1 to create static MAC entry. |
| 339 | (Default value = 0) |
| 340 | :param int filter_mac: Set to 1 to drop packet that's source or |
| 341 | destination MAC address contains defined MAC address. |
| 342 | (Default value = 0) |
| 343 | :param int bvi_mac: Set to 1 to create entry that points to BVI |
| 344 | interface. (Default value = 0) |
| 345 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 346 | return self.api(self.papi.l2fib_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 347 | {'mac': self._convert_mac(mac), |
| 348 | 'bd_id': bd_id, |
| 349 | 'sw_if_index': sw_if_index, |
| 350 | 'is_add': is_add, |
| 351 | 'static_mac': static_mac, |
| 352 | 'filter_mac': filter_mac, |
| 353 | 'bvi_mac': bvi_mac}) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 354 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 355 | def sw_interface_set_l2_bridge(self, sw_if_index, bd_id, |
| 356 | shg=0, bvi=0, enable=1): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 357 | """Add/remove interface to/from bridge domain. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 358 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 359 | :param int sw_if_index: Software interface index of the interface. |
| 360 | :param int bd_id: Bridge domain index. |
| 361 | :param int shg: Split-horizon group index. (Default value = 0) |
| 362 | :param int bvi: Set interface as a bridge group virtual interface. |
| 363 | (Default value = 0) |
| 364 | :param int enable: Add or remove interface. (Default value = 1) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 365 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 366 | return self.api(self.papi.sw_interface_set_l2_bridge, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 367 | {'rx_sw_if_index': sw_if_index, |
| 368 | 'bd_id': bd_id, |
| 369 | 'shg': shg, |
| 370 | 'bvi': bvi, |
| 371 | 'enable': enable}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 372 | |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 373 | def bridge_flags(self, bd_id, is_set, feature_bitmap): |
| 374 | """Enable/disable required feature of the bridge domain with defined ID. |
| 375 | |
| 376 | :param int bd_id: Bridge domain ID. |
| 377 | :param int is_set: Set to 1 to enable, set to 0 to disable the feature. |
| 378 | :param int feature_bitmap: Bitmap value of the feature to be set: |
| 379 | - learn (1 << 0), |
| 380 | - forward (1 << 1), |
| 381 | - flood (1 << 2), |
| 382 | - uu-flood (1 << 3) or |
| 383 | - arp-term (1 << 4). |
| 384 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 385 | return self.api(self.papi.bridge_flags, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 386 | {'bd_id': bd_id, |
| 387 | 'is_set': is_set, |
| 388 | 'feature_bitmap': feature_bitmap}) |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 389 | |
| 390 | def bridge_domain_dump(self, bd_id=0): |
| 391 | """ |
| 392 | |
| 393 | :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all |
| 394 | existing bridge domains returned) |
| 395 | :return: Dictionary of bridge domain(s) data. |
| 396 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 397 | return self.api(self.papi.bridge_domain_dump, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 398 | {'bd_id': bd_id}) |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 399 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 400 | def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index, |
| 401 | enable): |
| 402 | """Create or delete unidirectional cross-connect from Tx interface to |
| 403 | Rx interface. |
| 404 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 405 | :param int rx_sw_if_index: Software interface index of Rx interface. |
| 406 | :param int tx_sw_if_index: Software interface index of Tx interface. |
| 407 | :param int enable: Create cross-connect if equal to 1, delete |
| 408 | cross-connect if equal to 0. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 409 | |
| 410 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 411 | return self.api(self.papi.sw_interface_set_l2_xconnect, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 412 | {'rx_sw_if_index': rx_sw_if_index, |
| 413 | 'tx_sw_if_index': tx_sw_if_index, |
| 414 | 'enable': enable}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 415 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 416 | def sw_interface_set_l2_tag_rewrite( |
| 417 | self, |
| 418 | sw_if_index, |
| 419 | vtr_oper, |
| 420 | push=0, |
| 421 | tag1=0, |
| 422 | tag2=0): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 423 | """L2 interface vlan tag rewrite configure request |
| 424 | :param client_index - opaque cookie to identify the sender |
| 425 | :param context - sender context, to match reply w/ request |
| 426 | :param sw_if_index - interface the operation is applied to |
| 427 | :param vtr_op - Choose from l2_vtr_op_t enum values |
| 428 | :param push_dot1q - first pushed flag dot1q id set, else dot1ad |
| 429 | :param tag1 - Needed for any push or translate vtr op |
| 430 | :param tag2 - Needed for any push 2 or translate x-2 vtr ops |
| 431 | |
| 432 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 433 | return self.api(self.papi.l2_interface_vlan_tag_rewrite, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 434 | {'sw_if_index': sw_if_index, |
| 435 | 'vtr_op': vtr_oper, |
| 436 | 'push_dot1q': push, |
| 437 | 'tag1': tag1, |
| 438 | 'tag2': tag2}) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 439 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 440 | def sw_interface_set_flags(self, sw_if_index, admin_up_down, |
| 441 | link_up_down=0, deleted=0): |
| 442 | """ |
| 443 | |
| 444 | :param admin_up_down: |
| 445 | :param sw_if_index: |
| 446 | :param link_up_down: (Default value = 0) |
| 447 | :param deleted: (Default value = 0) |
| 448 | |
| 449 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 450 | return self.api(self.papi.sw_interface_set_flags, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 451 | {'sw_if_index': sw_if_index, |
| 452 | 'admin_up_down': admin_up_down, |
| 453 | 'link_up_down': link_up_down, |
| 454 | 'deleted': deleted}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 455 | |
| 456 | def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan, |
| 457 | no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0, |
| 458 | default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0): |
| 459 | """Create subinterface |
| 460 | from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad |
| 461 | |
| 462 | :param sub_id: param inner_vlan: |
| 463 | :param sw_if_index: |
| 464 | :param outer_vlan: |
| 465 | :param inner_vlan: |
| 466 | :param no_tags: (Default value = 0) |
| 467 | :param one_tag: (Default value = 0) |
| 468 | :param two_tags: (Default value = 0) |
| 469 | :param dot1ad: (Default value = 0) |
| 470 | :param exact_match: (Default value = 0) |
| 471 | :param default_sub: (Default value = 0) |
| 472 | :param outer_vlan_id_any: (Default value = 0) |
| 473 | :param inner_vlan_id_any: (Default value = 0) |
| 474 | |
| 475 | """ |
| 476 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 477 | self.papi.create_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 478 | {'sw_if_index': sw_if_index, |
| 479 | 'sub_id': sub_id, |
| 480 | 'no_tags': no_tags, |
| 481 | 'one_tag': one_tag, |
| 482 | 'two_tags': two_tags, |
| 483 | 'dot1ad': dot1ad, |
| 484 | 'exact_match': exact_match, |
| 485 | 'default_sub': default_sub, |
| 486 | 'outer_vlan_id_any': outer_vlan_id_any, |
| 487 | 'inner_vlan_id_any': inner_vlan_id_any, |
| 488 | 'outer_vlan_id': outer_vlan, |
| 489 | 'inner_vlan_id': inner_vlan}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 490 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 491 | def delete_subif(self, sw_if_index): |
| 492 | """Delete subinterface |
| 493 | |
| 494 | :param sw_if_index: |
| 495 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 496 | return self.api(self.papi.delete_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 497 | {'sw_if_index': sw_if_index}) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 498 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 499 | def create_vlan_subif(self, sw_if_index, vlan): |
| 500 | """ |
| 501 | |
| 502 | :param vlan: |
| 503 | :param sw_if_index: |
| 504 | |
| 505 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 506 | return self.api(self.papi.create_vlan_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 507 | {'sw_if_index': sw_if_index, |
| 508 | 'vlan_id': vlan}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 509 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 510 | def create_loopback(self, mac=''): |
| 511 | """ |
| 512 | |
| 513 | :param mac: (Optional) |
| 514 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 515 | return self.api(self.papi.create_loopback, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 516 | {'mac_address': mac}) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 517 | |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 518 | def delete_loopback(self, sw_if_index): |
| 519 | return self.api(self.papi.delete_loopback, |
| 520 | {'sw_if_index': sw_if_index, }) |
| 521 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 522 | def ip_add_del_route( |
| 523 | self, |
| 524 | dst_address, |
| 525 | dst_address_length, |
| 526 | next_hop_address, |
| 527 | next_hop_sw_if_index=0xFFFFFFFF, |
| 528 | table_id=0, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 529 | next_hop_table_id=0, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 530 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 531 | next_hop_n_out_labels=0, |
| 532 | next_hop_out_label_stack=[], |
| 533 | next_hop_via_label=MPLS_LABEL_INVALID, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 534 | create_vrf_if_needed=0, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 535 | is_resolve_host=0, |
| 536 | is_resolve_attached=0, |
| 537 | classify_table_index=0xFFFFFFFF, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 538 | is_add=1, |
| 539 | is_drop=0, |
Juraj Sloboda | 86a2c57 | 2016-10-27 10:44:25 +0200 | [diff] [blame] | 540 | is_unreach=0, |
| 541 | is_prohibit=0, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 542 | is_ipv6=0, |
| 543 | is_local=0, |
| 544 | is_classify=0, |
| 545 | is_multipath=0, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 546 | not_last=0): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 547 | """ |
| 548 | |
| 549 | :param dst_address_length: |
| 550 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 551 | :param dst_address: |
| 552 | :param next_hop_address: |
| 553 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 554 | :param vrf_id: (Default value = 0) |
| 555 | :param lookup_in_vrf: (Default value = 0) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 556 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
| 557 | :param create_vrf_if_needed: (Default value = 0) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 558 | :param is_add: (Default value = 1) |
| 559 | :param is_drop: (Default value = 0) |
| 560 | :param is_ipv6: (Default value = 0) |
| 561 | :param is_local: (Default value = 0) |
| 562 | :param is_classify: (Default value = 0) |
| 563 | :param is_multipath: (Default value = 0) |
| 564 | :param is_resolve_host: (Default value = 0) |
| 565 | :param is_resolve_attached: (Default value = 0) |
| 566 | :param not_last: (Default value = 0) |
| 567 | :param next_hop_weight: (Default value = 1) |
| 568 | |
| 569 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 570 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 571 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 572 | self.papi.ip_add_del_route, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 573 | {'next_hop_sw_if_index': next_hop_sw_if_index, |
| 574 | 'table_id': table_id, |
| 575 | 'classify_table_index': classify_table_index, |
| 576 | 'next_hop_table_id': next_hop_table_id, |
| 577 | 'create_vrf_if_needed': create_vrf_if_needed, |
| 578 | 'is_add': is_add, |
| 579 | 'is_drop': is_drop, |
| 580 | 'is_unreach': is_unreach, |
| 581 | 'is_prohibit': is_prohibit, |
| 582 | 'is_ipv6': is_ipv6, |
| 583 | 'is_local': is_local, |
| 584 | 'is_classify': is_classify, |
| 585 | 'is_multipath': is_multipath, |
| 586 | 'is_resolve_host': is_resolve_host, |
| 587 | 'is_resolve_attached': is_resolve_attached, |
| 588 | 'not_last': not_last, |
| 589 | 'next_hop_weight': next_hop_weight, |
| 590 | 'dst_address_length': dst_address_length, |
| 591 | 'dst_address': dst_address, |
| 592 | 'next_hop_address': next_hop_address, |
| 593 | 'next_hop_n_out_labels': next_hop_n_out_labels, |
| 594 | 'next_hop_via_label': next_hop_via_label, |
| 595 | 'next_hop_out_label_stack': next_hop_out_label_stack}) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 596 | |
Matej Klotton | 16a14cd | 2016-12-07 15:09:13 +0100 | [diff] [blame] | 597 | def ip_fib_dump(self): |
| 598 | return self.api(self.papi.ip_fib_dump, {}) |
| 599 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 600 | def ip_neighbor_add_del(self, |
| 601 | sw_if_index, |
| 602 | mac_address, |
| 603 | dst_address, |
| 604 | vrf_id=0, |
| 605 | is_add=1, |
| 606 | is_ipv6=0, |
| 607 | is_static=0, |
| 608 | ): |
| 609 | """ Add neighbor MAC to IPv4 or IPv6 address. |
| 610 | |
| 611 | :param sw_if_index: |
| 612 | :param mac_address: |
| 613 | :param dst_address: |
| 614 | :param vrf_id: (Default value = 0) |
| 615 | :param is_add: (Default value = 1) |
| 616 | :param is_ipv6: (Default value = 0) |
| 617 | :param is_static: (Default value = 0) |
| 618 | """ |
| 619 | |
| 620 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 621 | self.papi.ip_neighbor_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 622 | {'vrf_id': vrf_id, |
| 623 | 'sw_if_index': sw_if_index, |
| 624 | 'is_add': is_add, |
| 625 | 'is_ipv6': is_ipv6, |
| 626 | 'is_static': is_static, |
| 627 | 'mac_address': mac_address, |
| 628 | 'dst_address': dst_address |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 629 | } |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 630 | ) |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 631 | |
Jan | e546d3b | 2016-12-08 13:10:03 +0100 | [diff] [blame] | 632 | def reset_vrf(self, |
| 633 | vrf_id, |
| 634 | is_ipv6=0, |
| 635 | ): |
| 636 | """ Reset VRF (remove all routes etc.) request. |
| 637 | |
| 638 | :param int vrf_id: ID of the FIB table / VRF to reset. |
| 639 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 640 | """ |
| 641 | |
| 642 | return self.api( |
| 643 | self.papi.reset_vrf, |
| 644 | {'vrf_id': vrf_id, |
| 645 | 'is_ipv6': is_ipv6, |
| 646 | } |
| 647 | ) |
| 648 | |
| 649 | def reset_fib(self, |
| 650 | vrf_id, |
| 651 | is_ipv6=0, |
| 652 | ): |
| 653 | """ Reset VRF (remove all routes etc.) request. |
| 654 | |
| 655 | :param int vrf_id: ID of the FIB table / VRF to reset. |
| 656 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 657 | """ |
| 658 | |
| 659 | return self.api( |
| 660 | self.papi.reset_fib, |
| 661 | {'vrf_id': vrf_id, |
| 662 | 'is_ipv6': is_ipv6, |
| 663 | } |
| 664 | ) |
| 665 | |
| 666 | def ip_dump(self, |
| 667 | is_ipv6=0, |
| 668 | ): |
| 669 | """ Return IP dump. |
| 670 | |
| 671 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 672 | """ |
| 673 | |
| 674 | return self.api( |
| 675 | self.papi.ip_dump, |
| 676 | {'is_ipv6': is_ipv6, |
| 677 | } |
| 678 | ) |
| 679 | |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 680 | def sw_interface_span_enable_disable( |
Ole Troan | 399ca1c | 2016-12-06 23:00:38 +0100 | [diff] [blame] | 681 | self, sw_if_index_from, sw_if_index_to, state=1): |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 682 | """ |
| 683 | |
| 684 | :param sw_if_index_from: |
| 685 | :param sw_if_index_to: |
Matej Klotton | deb6984 | 2016-12-09 15:05:46 +0100 | [diff] [blame] | 686 | :param state: |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 687 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 688 | return self.api(self.papi.sw_interface_span_enable_disable, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 689 | {'sw_if_index_from': sw_if_index_from, |
| 690 | 'sw_if_index_to': sw_if_index_to, |
| 691 | 'state': state}) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 692 | |
| 693 | def gre_tunnel_add_del(self, |
| 694 | src_address, |
| 695 | dst_address, |
| 696 | outer_fib_id=0, |
| 697 | is_teb=0, |
| 698 | is_add=1, |
| 699 | is_ip6=0): |
| 700 | """ Add a GRE tunnel |
| 701 | |
| 702 | :param src_address: |
| 703 | :param dst_address: |
| 704 | :param outer_fib_id: (Default value = 0) |
| 705 | :param is_add: (Default value = 1) |
| 706 | :param is_ipv6: (Default value = 0) |
| 707 | :param is_teb: (Default value = 0) |
| 708 | """ |
| 709 | |
| 710 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 711 | self.papi.gre_add_del_tunnel, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 712 | {'is_add': is_add, |
| 713 | 'is_ipv6': is_ip6, |
| 714 | 'teb': is_teb, |
| 715 | 'src_address': src_address, |
| 716 | 'dst_address': dst_address, |
| 717 | 'outer_fib_id': outer_fib_id} |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 718 | ) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 719 | |
| 720 | def mpls_route_add_del( |
| 721 | self, |
| 722 | label, |
| 723 | eos, |
| 724 | next_hop_proto_is_ip4, |
| 725 | next_hop_address, |
| 726 | next_hop_sw_if_index=0xFFFFFFFF, |
| 727 | table_id=0, |
| 728 | next_hop_table_id=0, |
| 729 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 730 | next_hop_n_out_labels=0, |
| 731 | next_hop_out_label_stack=[], |
| 732 | next_hop_via_label=MPLS_LABEL_INVALID, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 733 | create_vrf_if_needed=0, |
| 734 | is_resolve_host=0, |
| 735 | is_resolve_attached=0, |
| 736 | is_add=1, |
| 737 | is_drop=0, |
| 738 | is_multipath=0, |
| 739 | classify_table_index=0xFFFFFFFF, |
| 740 | is_classify=0, |
| 741 | not_last=0): |
| 742 | """ |
| 743 | |
| 744 | :param dst_address_length: |
| 745 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 746 | :param dst_address: |
| 747 | :param next_hop_address: |
| 748 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 749 | :param vrf_id: (Default value = 0) |
| 750 | :param lookup_in_vrf: (Default value = 0) |
| 751 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
| 752 | :param create_vrf_if_needed: (Default value = 0) |
| 753 | :param is_add: (Default value = 1) |
| 754 | :param is_drop: (Default value = 0) |
| 755 | :param is_ipv6: (Default value = 0) |
| 756 | :param is_local: (Default value = 0) |
| 757 | :param is_classify: (Default value = 0) |
| 758 | :param is_multipath: (Default value = 0) |
| 759 | :param is_resolve_host: (Default value = 0) |
| 760 | :param is_resolve_attached: (Default value = 0) |
| 761 | :param not_last: (Default value = 0) |
| 762 | :param next_hop_weight: (Default value = 1) |
| 763 | |
| 764 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 765 | |
| 766 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 767 | self.papi.mpls_route_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 768 | {'mr_label': label, |
| 769 | 'mr_eos': eos, |
| 770 | 'mr_table_id': table_id, |
| 771 | 'mr_classify_table_index': classify_table_index, |
| 772 | 'mr_create_table_if_needed': create_vrf_if_needed, |
| 773 | 'mr_is_add': is_add, |
| 774 | 'mr_is_classify': is_classify, |
| 775 | 'mr_is_multipath': is_multipath, |
| 776 | 'mr_is_resolve_host': is_resolve_host, |
| 777 | 'mr_is_resolve_attached': is_resolve_attached, |
| 778 | 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4, |
| 779 | 'mr_next_hop_weight': next_hop_weight, |
| 780 | 'mr_next_hop': next_hop_address, |
| 781 | 'mr_next_hop_n_out_labels': next_hop_n_out_labels, |
| 782 | 'mr_next_hop_sw_if_index': next_hop_sw_if_index, |
| 783 | 'mr_next_hop_table_id': next_hop_table_id, |
| 784 | 'mr_next_hop_via_label': next_hop_via_label, |
| 785 | 'mr_next_hop_out_label_stack': next_hop_out_label_stack}) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 786 | |
| 787 | def mpls_ip_bind_unbind( |
| 788 | self, |
| 789 | label, |
| 790 | dst_address, |
| 791 | dst_address_length, |
| 792 | table_id=0, |
| 793 | ip_table_id=0, |
| 794 | is_ip4=1, |
| 795 | create_vrf_if_needed=0, |
| 796 | is_bind=1): |
| 797 | """ |
| 798 | """ |
| 799 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 800 | self.papi.mpls_ip_bind_unbind, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 801 | {'mb_mpls_table_id': table_id, |
| 802 | 'mb_label': label, |
| 803 | 'mb_ip_table_id': ip_table_id, |
| 804 | 'mb_create_table_if_needed': create_vrf_if_needed, |
| 805 | 'mb_is_bind': is_bind, |
| 806 | 'mb_is_ip4': is_ip4, |
| 807 | 'mb_address_length': dst_address_length, |
| 808 | 'mb_address': dst_address}) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 809 | |
| 810 | def mpls_tunnel_add_del( |
| 811 | self, |
| 812 | tun_sw_if_index, |
| 813 | next_hop_proto_is_ip4, |
| 814 | next_hop_address, |
| 815 | next_hop_sw_if_index=0xFFFFFFFF, |
| 816 | next_hop_table_id=0, |
| 817 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 818 | next_hop_n_out_labels=0, |
| 819 | next_hop_out_label_stack=[], |
| 820 | next_hop_via_label=MPLS_LABEL_INVALID, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 821 | create_vrf_if_needed=0, |
| 822 | is_add=1, |
| 823 | l2_only=0): |
| 824 | """ |
| 825 | |
| 826 | :param dst_address_length: |
| 827 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 828 | :param dst_address: |
| 829 | :param next_hop_address: |
| 830 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 831 | :param vrf_id: (Default value = 0) |
| 832 | :param lookup_in_vrf: (Default value = 0) |
| 833 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
| 834 | :param create_vrf_if_needed: (Default value = 0) |
| 835 | :param is_add: (Default value = 1) |
| 836 | :param is_drop: (Default value = 0) |
| 837 | :param is_ipv6: (Default value = 0) |
| 838 | :param is_local: (Default value = 0) |
| 839 | :param is_classify: (Default value = 0) |
| 840 | :param is_multipath: (Default value = 0) |
| 841 | :param is_resolve_host: (Default value = 0) |
| 842 | :param is_resolve_attached: (Default value = 0) |
| 843 | :param not_last: (Default value = 0) |
| 844 | :param next_hop_weight: (Default value = 1) |
| 845 | |
| 846 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 847 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 848 | self.papi.mpls_tunnel_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 849 | {'mt_sw_if_index': tun_sw_if_index, |
| 850 | 'mt_is_add': is_add, |
| 851 | 'mt_l2_only': l2_only, |
| 852 | 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4, |
| 853 | 'mt_next_hop_weight': next_hop_weight, |
| 854 | 'mt_next_hop': next_hop_address, |
| 855 | 'mt_next_hop_n_out_labels': next_hop_n_out_labels, |
| 856 | 'mt_next_hop_sw_if_index': next_hop_sw_if_index, |
| 857 | 'mt_next_hop_table_id': next_hop_table_id, |
| 858 | 'mt_next_hop_out_label_stack': next_hop_out_label_stack}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 859 | |
| 860 | def snat_interface_add_del_feature( |
| 861 | self, |
| 862 | sw_if_index, |
| 863 | is_inside=1, |
| 864 | is_add=1): |
| 865 | """Enable/disable S-NAT feature on the interface |
| 866 | |
| 867 | :param sw_if_index: Software index of the interface |
| 868 | :param is_inside: 1 if inside, 0 if outside (Default value = 1) |
| 869 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 870 | """ |
| 871 | return self.api( |
| 872 | self.papi.snat_interface_add_del_feature, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 873 | {'is_add': is_add, |
| 874 | 'is_inside': is_inside, |
| 875 | 'sw_if_index': sw_if_index}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 876 | |
| 877 | def snat_add_static_mapping( |
| 878 | self, |
| 879 | local_ip, |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 880 | external_ip=0, |
| 881 | external_sw_if_index=0xFFFFFFFF, |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 882 | local_port=0, |
| 883 | external_port=0, |
| 884 | addr_only=1, |
| 885 | vrf_id=0, |
| 886 | is_add=1, |
| 887 | is_ip4=1): |
| 888 | """Add/delete S-NAT static mapping |
| 889 | |
| 890 | :param local_ip: Local IP address |
| 891 | :param external_ip: External IP address |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 892 | :param external_sw_if_index: External interface instead of IP address |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 893 | :param local_port: Local port number (Default value = 0) |
| 894 | :param external_port: External port number (Default value = 0) |
| 895 | :param addr_only: 1 if address only mapping, 0 if address and port |
| 896 | :param vrf_id: VRF ID |
| 897 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 898 | :param is_ip4: 1 if address type is IPv4 (Default value = 1) |
| 899 | """ |
| 900 | return self.api( |
| 901 | self.papi.snat_add_static_mapping, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 902 | {'is_add': is_add, |
| 903 | 'is_ip4': is_ip4, |
| 904 | 'addr_only': addr_only, |
| 905 | 'local_ip_address': local_ip, |
| 906 | 'external_ip_address': external_ip, |
| 907 | 'local_port': local_port, |
| 908 | 'external_port': external_port, |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 909 | 'external_sw_if_index': external_sw_if_index, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 910 | 'vrf_id': vrf_id}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 911 | |
| 912 | def snat_add_address_range( |
| 913 | self, |
| 914 | first_ip_address, |
| 915 | last_ip_address, |
| 916 | is_add=1, |
| 917 | is_ip4=1): |
| 918 | """Add/del S-NAT address range |
| 919 | |
| 920 | :param first_ip_address: First IP address |
| 921 | :param last_ip_address: Last IP address |
| 922 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 923 | :param is_ip4: 1 if address type is IPv4 (Default value = 1) |
| 924 | """ |
| 925 | return self.api( |
| 926 | self.papi.snat_add_address_range, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 927 | {'is_ip4': is_ip4, |
| 928 | 'first_ip_address': first_ip_address, |
| 929 | 'last_ip_address': last_ip_address, |
| 930 | 'is_add': is_add}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 931 | |
| 932 | def snat_address_dump(self): |
| 933 | """Dump S-NAT addresses |
| 934 | :return: Dictionary of S-NAT addresses |
| 935 | """ |
| 936 | return self.api(self.papi.snat_address_dump, {}) |
| 937 | |
| 938 | def snat_interface_dump(self): |
| 939 | """Dump interfaces with S-NAT feature |
| 940 | :return: Dictionary of interfaces with S-NAT feature |
| 941 | """ |
| 942 | return self.api(self.papi.snat_interface_dump, {}) |
| 943 | |
| 944 | def snat_static_mapping_dump(self): |
| 945 | """Dump S-NAT static mappings |
| 946 | :return: Dictionary of S-NAT static mappings |
| 947 | """ |
| 948 | return self.api(self.papi.snat_static_mapping_dump, {}) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 949 | |
Matus Fabian | 9902fcd | 2016-12-21 23:58:46 -0800 | [diff] [blame] | 950 | def snat_show_config(self): |
| 951 | """Show S-NAT config |
| 952 | :return: S-NAT config parameters |
| 953 | """ |
| 954 | return self.api(self.papi.snat_show_config, {}) |
| 955 | |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 956 | def snat_add_interface_addr( |
| 957 | self, |
| 958 | sw_if_index, |
| 959 | is_add=1): |
| 960 | """Add/del S-NAT address from interface |
| 961 | |
| 962 | :param sw_if_index: Software index of the interface |
| 963 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 964 | """ |
| 965 | return self.api(self.papi.snat_add_del_interface_addr, |
| 966 | {'is_add': is_add, 'sw_if_index': sw_if_index}) |
| 967 | |
| 968 | def snat_interface_addr_dump(self): |
| 969 | """Dump S-NAT addresses interfaces |
| 970 | :return: Dictionary of S-NAT addresses interfaces |
| 971 | """ |
| 972 | return self.api(self.papi.snat_interface_addr_dump, {}) |
| 973 | |
Matus Fabian | eea28d7 | 2017-01-13 04:15:54 -0800 | [diff] [blame] | 974 | def snat_ipfix( |
| 975 | self, |
| 976 | domain_id=1, |
| 977 | src_port=4739, |
| 978 | enable=1): |
| 979 | """Enable/disable S-NAT IPFIX logging |
| 980 | |
| 981 | :param domain_id: Observation domain ID (Default value = 1) |
| 982 | :param src_port: Source port number (Default value = 4739) |
| 983 | :param enable: 1 if enable, 0 if disable (Default value = 1) |
| 984 | """ |
| 985 | return self.api( |
| 986 | self.papi.snat_ipfix_enable_disable, |
| 987 | {'domain_id': domain_id, |
| 988 | 'src_port': src_port, |
| 989 | 'enable': enable}) |
| 990 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 991 | def control_ping(self): |
| 992 | self.api(self.papi.control_ping) |
| 993 | |
| 994 | def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx, |
| 995 | detect_mult, local_addr, peer_addr, is_ipv6=0): |
| 996 | return self.api(self.papi.bfd_udp_add, |
| 997 | { |
| 998 | 'sw_if_index': sw_if_index, |
| 999 | 'desired_min_tx': desired_min_tx, |
| 1000 | 'required_min_rx': required_min_rx, |
| 1001 | 'local_addr': local_addr, |
| 1002 | 'peer_addr': peer_addr, |
| 1003 | 'is_ipv6': is_ipv6, |
| 1004 | 'detect_mult': detect_mult, |
| 1005 | }) |
| 1006 | |
| 1007 | def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0): |
| 1008 | return self.api(self.papi.bfd_udp_del, |
| 1009 | { |
| 1010 | 'sw_if_index': sw_if_index, |
| 1011 | 'local_addr': local_addr, |
| 1012 | 'peer_addr': peer_addr, |
| 1013 | 'is_ipv6': is_ipv6, |
| 1014 | }) |
| 1015 | |
| 1016 | def bfd_udp_session_dump(self): |
| 1017 | return self.api(self.papi.bfd_udp_session_dump, {}) |
| 1018 | |
| 1019 | def bfd_session_set_flags(self, bs_idx, admin_up_down): |
| 1020 | return self.api(self.papi.bfd_session_set_flags, { |
| 1021 | 'bs_index': bs_idx, |
| 1022 | 'admin_up_down': admin_up_down, |
| 1023 | }) |
| 1024 | |
| 1025 | def want_bfd_events(self, enable_disable=1): |
| 1026 | return self.api(self.papi.want_bfd_events, { |
| 1027 | 'enable_disable': enable_disable, |
| 1028 | 'pid': os.getpid(), |
| 1029 | }) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1030 | |
| 1031 | def classify_add_del_table( |
| 1032 | self, |
| 1033 | is_add, |
| 1034 | mask, |
| 1035 | match_n_vectors=1, |
| 1036 | table_index=0xFFFFFFFF, |
| 1037 | nbuckets=2, |
| 1038 | memory_size=2097152, |
| 1039 | skip_n_vectors=0, |
| 1040 | next_table_index=0xFFFFFFFF, |
| 1041 | miss_next_index=0xFFFFFFFF, |
| 1042 | current_data_flag=0, |
| 1043 | current_data_offset=0): |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1044 | """ |
| 1045 | :param is_add: |
| 1046 | :param mask: |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 1047 | :param match_n_vectors: (Default value = 1) |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 1048 | :param table_index: (Default value = 0xFFFFFFFF) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1049 | :param nbuckets: (Default value = 2) |
| 1050 | :param memory_size: (Default value = 2097152) |
| 1051 | :param skip_n_vectors: (Default value = 0) |
| 1052 | :param next_table_index: (Default value = 0xFFFFFFFF) |
| 1053 | :param miss_next_index: (Default value = 0xFFFFFFFF) |
| 1054 | :param current_data_flag: (Default value = 0) |
| 1055 | :param current_data_offset: (Default value = 0) |
| 1056 | """ |
| 1057 | |
| 1058 | return self.api( |
| 1059 | self.papi.classify_add_del_table, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 1060 | {'is_add': is_add, |
| 1061 | 'table_index': table_index, |
| 1062 | 'nbuckets': nbuckets, |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1063 | 'memory_size': memory_size, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 1064 | 'skip_n_vectors': skip_n_vectors, |
| 1065 | 'match_n_vectors': match_n_vectors, |
| 1066 | 'next_table_index': next_table_index, |
| 1067 | 'miss_next_index': miss_next_index, |
| 1068 | 'current_data_flag': current_data_flag, |
| 1069 | 'current_data_offset': current_data_offset, |
| 1070 | 'mask': mask}) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1071 | |
| 1072 | def classify_add_del_session( |
| 1073 | self, |
| 1074 | is_add, |
| 1075 | table_index, |
| 1076 | match, |
| 1077 | opaque_index=0xFFFFFFFF, |
| 1078 | hit_next_index=0xFFFFFFFF, |
| 1079 | advance=0, |
| 1080 | action=0, |
| 1081 | metadata=0): |
| 1082 | """ |
| 1083 | :param is_add: |
| 1084 | :param table_index: |
| 1085 | :param match: |
| 1086 | :param opaque_index: (Default value = 0xFFFFFFFF) |
| 1087 | :param hit_next_index: (Default value = 0xFFFFFFFF) |
| 1088 | :param advance: (Default value = 0) |
| 1089 | :param action: (Default value = 0) |
| 1090 | :param metadata: (Default value = 0) |
| 1091 | """ |
| 1092 | |
| 1093 | return self.api( |
| 1094 | self.papi.classify_add_del_session, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 1095 | {'is_add': is_add, |
| 1096 | 'table_index': table_index, |
| 1097 | 'hit_next_index': hit_next_index, |
| 1098 | 'opaque_index': opaque_index, |
| 1099 | 'advance': advance, |
| 1100 | 'action': action, |
| 1101 | 'metadata': metadata, |
| 1102 | 'match': match}) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 1103 | |
| 1104 | def input_acl_set_interface( |
| 1105 | self, |
| 1106 | is_add, |
| 1107 | sw_if_index, |
| 1108 | ip4_table_index=0xFFFFFFFF, |
| 1109 | ip6_table_index=0xFFFFFFFF, |
| 1110 | l2_table_index=0xFFFFFFFF): |
| 1111 | """ |
| 1112 | :param is_add: |
| 1113 | :param sw_if_index: |
| 1114 | :param ip4_table_index: (Default value = 0xFFFFFFFF) |
| 1115 | :param ip6_table_index: (Default value = 0xFFFFFFFF) |
| 1116 | :param l2_table_index: (Default value = 0xFFFFFFFF) |
| 1117 | """ |
| 1118 | |
| 1119 | return self.api( |
| 1120 | self.papi.input_acl_set_interface, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 1121 | {'sw_if_index': sw_if_index, |
| 1122 | 'ip4_table_index': ip4_table_index, |
| 1123 | 'ip6_table_index': ip6_table_index, |
| 1124 | 'l2_table_index': l2_table_index, |
| 1125 | 'is_add': is_add}) |
| 1126 | |
| 1127 | def set_ipfix_exporter( |
| 1128 | self, |
| 1129 | collector_address, |
| 1130 | src_address, |
| 1131 | path_mtu, |
| 1132 | template_interval, |
| 1133 | vrf_id=0, |
| 1134 | collector_port=4739, |
| 1135 | udp_checksum=0): |
| 1136 | return self.api( |
| 1137 | self.papi.set_ipfix_exporter, |
| 1138 | { |
| 1139 | 'collector_address': collector_address, |
| 1140 | 'collector_port': collector_port, |
| 1141 | 'src_address': src_address, |
| 1142 | 'vrf_id': vrf_id, |
| 1143 | 'path_mtu': path_mtu, |
| 1144 | 'template_interval': template_interval, |
| 1145 | 'udp_checksum': udp_checksum, |
| 1146 | }) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1147 | |
| 1148 | def dhcp_proxy_config(self, |
| 1149 | dhcp_server, |
| 1150 | dhcp_src_address, |
| 1151 | rx_table_id=0, |
| 1152 | server_table_id=0, |
| 1153 | is_add=1, |
| 1154 | is_ipv6=0, |
| 1155 | insert_circuit_id=0): |
| 1156 | return self.api( |
| 1157 | self.papi.dhcp_proxy_config_2, |
| 1158 | { |
| 1159 | 'rx_vrf_id': rx_table_id, |
| 1160 | 'server_vrf_id': server_table_id, |
| 1161 | 'is_ipv6': is_ipv6, |
| 1162 | 'is_add': is_add, |
| 1163 | 'insert_circuit_id': insert_circuit_id, |
| 1164 | 'dhcp_server': dhcp_server, |
| 1165 | 'dhcp_src_address': dhcp_src_address, |
| 1166 | }) |
| 1167 | |
| 1168 | def dhcp_proxy_set_vss(self, |
| 1169 | table_id, |
| 1170 | fib_id, |
| 1171 | oui, |
| 1172 | is_add=1, |
| 1173 | is_ip6=0): |
| 1174 | return self.api( |
| 1175 | self.papi.dhcp_proxy_set_vss, |
| 1176 | { |
| 1177 | 'tbl_id': table_id, |
| 1178 | 'fib_id': fib_id, |
| 1179 | 'is_ipv6': is_ip6, |
| 1180 | 'is_add': is_add, |
| 1181 | 'oui': oui, |
| 1182 | }) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame^] | 1183 | |
| 1184 | def ip_mroute_add_del(self, |
| 1185 | src_address, |
| 1186 | grp_address, |
| 1187 | grp_address_length, |
| 1188 | e_flags, |
| 1189 | next_hop_sw_if_index, |
| 1190 | i_flags, |
| 1191 | table_id=0, |
| 1192 | create_vrf_if_needed=0, |
| 1193 | is_add=1, |
| 1194 | is_ipv6=0, |
| 1195 | is_local=0): |
| 1196 | """ |
| 1197 | """ |
| 1198 | return self.api( |
| 1199 | self.papi.ip_mroute_add_del, |
| 1200 | {'next_hop_sw_if_index': next_hop_sw_if_index, |
| 1201 | 'entry_flags': e_flags, |
| 1202 | 'itf_flags': i_flags, |
| 1203 | 'create_vrf_if_needed': create_vrf_if_needed, |
| 1204 | 'is_add': is_add, |
| 1205 | 'is_ipv6': is_ipv6, |
| 1206 | 'is_local': is_local, |
| 1207 | 'grp_address_length': grp_address_length, |
| 1208 | 'grp_address': grp_address, |
| 1209 | 'src_address': src_address}) |
| 1210 | |
| 1211 | def mfib_signal_dump(self): |
| 1212 | return self.api(self.papi.mfib_signal_dump, {}) |