summaryrefslogtreecommitdiffstats
path: root/test/vpp_papi_provider.py
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2019-04-15 18:52:43 +0200
committerOle Trøan <otroan@employees.org>2019-04-24 11:09:37 +0000
commitdd1e3e780cd480e3f29fc34df48e605ded1acb2c (patch)
tree29ecae4a0f965a65b96886ee06438adeb6a14d21 /test/vpp_papi_provider.py
parent58c7580b1641879c91ac708162f1c3fccbb67302 (diff)
NAT: VPP-1531 api cleanup & update
Change-Id: I2492400a67b39a3adbc24ab7cf1ba17a409e95a8 Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'test/vpp_papi_provider.py')
-rw-r--r--test/vpp_papi_provider.py239
1 files changed, 56 insertions, 183 deletions
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 8b637f0bd49..6b3358b2b23 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -122,23 +122,22 @@ defaultmapping = {
'mpls_tunnel_dump': {'sw_if_index': 4294967295, },
'nat44_add_del_address_range': {'is_add': 1, 'vrf_id': 4294967295, },
'nat44_add_del_identity_mapping': {'ip': b'0', 'sw_if_index': 4294967295,
- 'addr_only': 1, 'is_add': 1, },
+ 'is_add': 1, },
'nat44_add_del_interface_addr': {'is_add': 1, },
'nat44_add_del_lb_static_mapping': {'is_add': 1, },
'nat44_add_del_static_mapping': {'external_sw_if_index': 4294967295,
- 'addr_only': 1, 'is_add': 1, },
- 'nat44_del_session': {'is_in': 1, },
- 'nat44_interface_add_del_feature': {'is_inside': 1, 'is_add': 1, },
- 'nat44_interface_add_del_output_feature': {'is_inside': 1, 'is_add': 1, },
+ 'is_add': 1, },
+ 'nat44_interface_add_del_feature': {'is_add': 1, },
+ 'nat44_interface_add_del_output_feature': {'is_add': 1, },
'nat44_lb_static_mapping_add_del_local': {'is_add': 1, },
- 'nat64_add_del_interface': {'is_inside': 1, 'is_add': 1, },
+ 'nat64_add_del_interface': {'is_add': 1, },
'nat64_add_del_interface_addr': {'is_add': 1, },
'nat64_add_del_pool_addr_range': {'vrf_id': 4294967295, 'is_add': 1, },
'nat64_add_del_prefix': {'is_add': 1, },
'nat64_add_del_static_bib': {'is_add': 1, },
'nat64_bib_dump': {'protocol': 255, },
'nat64_st_dump': {'protocol': 255, },
- 'nat66_add_del_interface': {'is_inside': 1, 'is_add': 1, },
+ 'nat66_add_del_interface': {'is_add': 1, },
'nat66_add_del_static_mapping': {'is_add': 1, },
'nat_det_add_del_map': {'is_add': 1, },
'nat_ha_resync': {'want_resync_event': 1, },
@@ -763,35 +762,35 @@ class VppPapiProvider(object):
def nat44_interface_add_del_feature(
self,
sw_if_index,
- is_inside=1,
- is_add=1):
+ is_add=1,
+ flags=0):
"""Enable/disable NAT44 feature on the interface
:param sw_if_index: Software index of the interface
- :param is_inside: 1 if inside, 0 if outside (Default value = 1)
:param is_add: 1 if add, 0 if delete (Default value = 1)
+ :param flags: NAT_IS_INSIDE if inside else outside
"""
return self.api(
self.papi.nat44_interface_add_del_feature,
{'is_add': is_add,
- 'is_inside': is_inside,
+ 'flags': flags,
'sw_if_index': sw_if_index})
def nat44_interface_add_del_output_feature(
self,
sw_if_index,
- is_inside=1,
- is_add=1):
+ is_add=1,
+ flags=0):
"""Enable/disable NAT44 output feature on the interface
:param sw_if_index: Software index of the interface
- :param is_inside: 1 if inside, 0 if outside (Default value = 1)
:param is_add: 1 if add, 0 if delete (Default value = 1)
+ :param flags: NAT_IS_INSIDE if inside else outside
"""
return self.api(
self.papi.nat44_interface_add_del_output_feature,
{'is_add': is_add,
- 'is_inside': is_inside,
+ 'flags': flags,
'sw_if_index': sw_if_index})
def nat44_add_del_static_mapping(
@@ -801,14 +800,11 @@ class VppPapiProvider(object):
external_sw_if_index=0xFFFFFFFF,
local_port=0,
external_port=0,
- addr_only=1,
vrf_id=0,
protocol=0,
- twice_nat=0,
- self_twice_nat=0,
- out2in_only=0,
- tag="",
- is_add=1):
+ is_add=1,
+ flags=0,
+ tag=""):
"""Add/delete NAT44 static mapping
:param local_ip: Local IP address
@@ -816,31 +812,23 @@ class VppPapiProvider(object):
:param external_sw_if_index: External interface instead of IP address
:param local_port: Local port number (Default value = 0)
:param external_port: External port number (Default value = 0)
- :param addr_only: 1 if address only mapping, 0 if address and port
:param vrf_id: VRF ID
:param protocol: IP protocol (Default value = 0)
- :param twice_nat: 1 if translate external host address and port
- :param self_twice_nat: 1 if translate external host address and port
- whenever external host address equals
- local address of internal host
- :param out2in_only: if 1 rule is matching only out2in direction
- :param tag: Opaque string tag
+ :param flags: NAT configuration flags
:param is_add: 1 if add, 0 if delete (Default value = 1)
+ :param tag: Opaque string tag
"""
return self.api(
self.papi.nat44_add_del_static_mapping,
{'is_add': is_add,
- 'addr_only': addr_only,
+ 'flags': flags,
'local_ip_address': local_ip,
'external_ip_address': external_ip,
+ 'protocol': protocol,
'local_port': local_port,
'external_port': external_port,
'external_sw_if_index': external_sw_if_index,
'vrf_id': vrf_id,
- 'protocol': protocol,
- 'twice_nat': twice_nat,
- 'self_twice_nat': self_twice_nat,
- 'out2in_only': out2in_only,
'tag': tag})
def nat44_add_del_identity_mapping(
@@ -848,7 +836,7 @@ class VppPapiProvider(object):
ip=b'0',
sw_if_index=0xFFFFFFFF,
port=0,
- addr_only=1,
+ flags=0,
vrf_id=0,
protocol=0,
tag='',
@@ -858,7 +846,7 @@ class VppPapiProvider(object):
:param ip: IP address (Default value = 0)
:param sw_if_index: Interface instead of IP address
:param port: Port number (Default value = 0)
- :param addr_only: 1 if address only mapping, 0 if address and port
+ :param flags: NAT configuration flags (NAT_IS_ADDR_ONLY)
:param vrf_id: VRF ID
:param protocol: IP protocol (Default value = 0)
:param tag: Opaque string tag
@@ -867,13 +855,13 @@ class VppPapiProvider(object):
return self.api(
self.papi.nat44_add_del_identity_mapping,
{'is_add': is_add,
- 'addr_only': addr_only,
+ 'flags': flags,
'ip_address': ip,
+ 'protocol': protocol,
'port': port,
'sw_if_index': sw_if_index,
'vrf_id': vrf_id,
- 'tag': tag,
- 'protocol': protocol})
+ 'tag': tag})
def nat44_add_del_address_range(
self,
@@ -881,73 +869,69 @@ class VppPapiProvider(object):
last_ip_address,
is_add=1,
vrf_id=0xFFFFFFFF,
- twice_nat=0):
+ flags=0):
"""Add/del NAT44 address range
:param first_ip_address: First IP address
:param last_ip_address: Last IP address
:param vrf_id: VRF id for the address range
- :param twice_nat: twice NAT address for extenral hosts
:param is_add: 1 if add, 0 if delete (Default value = 1)
+ :param flags: NAT configuration flags (NAT_IS_TWICE_NAT)
"""
return self.api(
self.papi.nat44_add_del_address_range,
{'first_ip_address': first_ip_address,
'last_ip_address': last_ip_address,
'vrf_id': vrf_id,
- 'twice_nat': twice_nat,
- 'is_add': is_add})
+ 'is_add': is_add,
+ 'flags': flags})
def nat44_add_del_interface_addr(
self,
sw_if_index,
- twice_nat=0,
+ flags=0,
is_add=1):
"""Add/del NAT44 address from interface
:param sw_if_index: Software index of the interface
- :param twice_nat: twice NAT address for external hosts
+ :param flags: NAT configuration flags (NAT_IS_TWICE_NAT)
:param is_add: 1 if add, 0 if delete (Default value = 1)
"""
return self.api(
self.papi.nat44_add_del_interface_addr,
{'is_add': is_add,
'sw_if_index': sw_if_index,
- 'twice_nat': twice_nat})
+ 'flags': flags})
def nat44_add_del_lb_static_mapping(
self,
external_addr,
external_port,
protocol,
- twice_nat=0,
- self_twice_nat=0,
- out2in_only=0,
tag='',
affinity=0,
local_num=0,
locals=[],
+ flags=0,
is_add=1):
"""Add/delete NAT44 load balancing static mapping
- :param twice_nat: 1 if translate external host address and port
:param tag: Opaque string tag
:param affinity: if 0 disabled, otherwise client IP affinity timeout
+ :param flags: NAT configuration flags (NAT_IS_TWICE_NAT)
:param is_add - 1 if add, 0 if delete
"""
return self.api(
self.papi.nat44_add_del_lb_static_mapping,
{'is_add': is_add,
+ 'flags': flags,
'external_addr': external_addr,
'external_port': external_port,
'protocol': protocol,
- 'twice_nat': twice_nat,
- 'self_twice_nat': self_twice_nat,
- 'out2in_only': out2in_only,
- 'tag': tag,
'affinity': affinity,
'local_num': local_num,
- 'locals': locals})
+ 'locals': locals,
+ 'tag': tag})
def nat44_lb_static_mapping_add_del_local(
self,
@@ -988,7 +972,7 @@ class VppPapiProvider(object):
port,
protocol,
vrf_id=0,
- is_in=1,
+ flags=0,
ext_host_address=None,
ext_host_port=0):
"""Delete NAT44 session
@@ -997,29 +981,19 @@ class VppPapiProvider(object):
:param por: port number
:param protocol: IP protocol number
:param vrf_id: VRF ID
- :param is_in: 1 if inside network address and port pair, 0 if outside
+ :param flags: NAT configuration flags (NAT_IS_INSIDE)
:param ext_host_address: external host IPv4 address
:param ext_host_port: external host port
"""
- if ext_host_address is None:
- return self.api(
- self.papi.nat44_del_session,
- {'address': addr,
- 'port': port,
- 'protocol': protocol,
- 'vrf_id': vrf_id,
- 'is_in': is_in})
- else:
- return self.api(
- self.papi.nat44_del_session,
- {'address': addr,
- 'port': port,
- 'protocol': protocol,
- 'vrf_id': vrf_id,
- 'is_in': is_in,
- 'ext_host_valid': 1,
- 'ext_host_address': ext_host_address,
- 'ext_host_port': ext_host_port})
+ return self.api(
+ self.papi.nat44_del_session,
+ {'address': addr,
+ 'protocol': protocol,
+ 'port': port,
+ 'vrf_id': vrf_id,
+ 'flags': flags,
+ 'ext_host_address': ext_host_address,
+ 'ext_host_port': ext_host_port})
def nat44_forwarding_enable_disable(
self,
@@ -1032,56 +1006,6 @@ class VppPapiProvider(object):
self.papi.nat44_forwarding_enable_disable,
{'enable': enable})
- def nat_det_add_del_map(
- self,
- in_addr,
- in_plen,
- out_addr,
- out_plen,
- is_add=1):
- """Add/delete deterministic NAT mapping
-
- :param is_add - 1 if add, 0 if delete
- :param in_addr - inside IP address
- :param in_plen - inside IP address prefix length
- :param out_addr - outside IP address
- :param out_plen - outside IP address prefix length
- """
- return self.api(
- self.papi.nat_det_add_del_map,
- {'is_add': is_add,
- 'is_nat44': 1,
- 'in_addr': in_addr,
- 'in_plen': in_plen,
- 'out_addr': out_addr,
- 'out_plen': out_plen})
-
- def nat_det_forward(
- self,
- in_addr):
- """Get outside address and port range from inside address
-
- :param in_addr - inside IP address
- """
- return self.api(
- self.papi.nat_det_forward,
- {'in_addr': in_addr,
- 'is_nat44': 1})
-
- def nat_det_reverse(
- self,
- out_addr,
- out_port):
- """Get inside address from outside address and port
-
- :param out_addr - outside IP address
- :param out_port - outside port
- """
- return self.api(
- self.papi.nat_det_reverse,
- {'out_addr': out_addr,
- 'out_port': out_port})
-
def nat_det_map_dump(self):
"""Dump deterministic NAT mappings
@@ -1099,56 +1023,6 @@ class VppPapiProvider(object):
self.papi.nat_set_mss_clamping,
{'enable': enable, 'mss_value': mss_value})
- def nat_det_close_session_in(
- self,
- in_addr,
- in_port,
- ext_addr,
- ext_port):
- """Close deterministic NAT session using inside address and port
-
- :param in_addr - inside IP address
- :param in_port - inside port
- :param ext_addr - external host IP address
- :param ext_port - external host port
- """
- return self.api(
- self.papi.nat_det_close_session_in,
- {'in_addr': in_addr,
- 'in_port': in_port,
- 'ext_addr': ext_addr,
- 'ext_port': ext_port,
- 'is_nat44': 1})
-
- def nat_det_session_dump(
- self,
- user_addr):
- """Dump deterministic NAT sessions belonging to a user
-
- :param user_addr - inside IP address of the user
- :return: Dictionary of deterministic NAT sessions
- """
- return self.api(
- self.papi.nat_det_session_dump,
- {'is_nat44': 1,
- 'user_addr': user_addr})
-
- def nat64_add_del_interface(
- self,
- sw_if_index,
- is_inside=1,
- is_add=1):
- """Enable/disable NAT64 feature on the interface
- :param sw_if_index: Index of the interface
- :param is_inside: 1 if inside, 0 if outside (Default value = 1)
- :param is_add: 1 if add, 0 if delete (Default value = 1)
- """
- return self.api(
- self.papi.nat64_add_del_interface,
- {'sw_if_index': sw_if_index,
- 'is_inside': is_inside,
- 'is_add': is_add})
-
def nat64_add_del_static_bib(
self,
in_ip,
@@ -1194,18 +1068,16 @@ class VppPapiProvider(object):
"""
return self.api(self.papi.nat64_st_dump, {'proto': protocol})
- def nat64_add_del_prefix(self, prefix, plen, vrf_id=0, is_add=1):
+ def nat64_add_del_prefix(self, prefix, vrf_id=0, is_add=1):
"""Add/del NAT64 prefix
:param prefix: NAT64 prefix
- :param plen: NAT64 prefix length
:param vrf_id: VRF id of tenant (Default 0)
:param is_add: 1 if add, 0 if delete (Default value = 1)
"""
return self.api(
self.papi.nat64_add_del_prefix,
{'prefix': prefix,
- 'prefix_len': plen,
'vrf_id': vrf_id,
'is_add': is_add})
@@ -1246,18 +1118,19 @@ class VppPapiProvider(object):
def nat66_add_del_interface(
self,
sw_if_index,
- is_inside=1,
+ flags=0,
is_add=1):
"""Enable/disable NAT66 feature on the interface
+
:param sw_if_index: Index of the interface
- :param is_inside: 1 if inside, 0 if outside (Default value = 1)
+ :param flags: NAT configuration flags (NAT_IS_INSIDE)
:param is_add: 1 if add, 0 if delete (Default value = 1)
"""
return self.api(
self.papi.nat66_add_del_interface,
- {'sw_if_index': sw_if_index,
- 'is_inside': is_inside,
- 'is_add': is_add})
+ {'is_add': is_add,
+ 'flags': flags,
+ 'sw_if_index': sw_if_index})
def nat66_add_del_static_mapping(
self,