class L2_VTR_OP:
+ L2_DISABLED = 0
+ L2_PUSH_1 = 1
+ L2_PUSH_2 = 2
L2_POP_1 = 3
+ L2_POP_2 = 4
+ L2_TRANSLATE_1_1 = 5
+ L2_TRANSLATE_1_2 = 6
+ L2_TRANSLATE_2_1 = 7
+ L2_TRANSLATE_2_2 = 8
class UnexpectedApiReturnValueError(Exception):
'arp_term': arp_term,
'is_add': is_add})
+ def bd_ip_mac_add_del(self, bd_id, mac, ip, is_ipv6=0, is_add=1):
+ return self.api(self.papi.bd_ip_mac_add_del,
+ {'bd_id': bd_id,
+ 'is_add': is_add,
+ 'is_ipv6': is_ipv6,
+ 'ip_address': ip,
+ 'mac_address': mac})
+
def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
filter_mac=0, bvi_mac=0):
"""Create/delete L2 FIB entry.
'tag1': tag1,
'tag2': tag2})
- def sw_interface_set_flags(self, sw_if_index, admin_up_down,
- link_up_down=0, deleted=0):
+ def sw_interface_set_flags(self, sw_if_index, admin_up_down):
"""
:param admin_up_down:
:param sw_if_index:
- :param link_up_down: (Default value = 0)
- :param deleted: (Default value = 0)
"""
return self.api(self.papi.sw_interface_set_flags,
{'sw_if_index': sw_if_index,
- 'admin_up_down': admin_up_down,
- 'link_up_down': link_up_down,
- 'deleted': deleted})
+ 'admin_up_down': admin_up_down})
def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
'outer_vlan_id': outer_vlan,
'inner_vlan_id': inner_vlan})
+ def create_p2pethernet_subif(self, sw_if_index, remote_mac, subif_id):
+ """Create p2p ethernet subinterface
+
+ :param sw_if_index: main (parent) interface
+ :param remote_mac: client (remote) mac address
+
+ """
+ return self.api(
+ self.papi.p2p_ethernet_add,
+ {'parent_if_index': sw_if_index,
+ 'remote_mac': remote_mac,
+ 'subif_id': subif_id})
+
def delete_subif(self, sw_if_index):
"""Delete subinterface
return self.api(self.papi.delete_subif,
{'sw_if_index': sw_if_index})
+ def delete_p2pethernet_subif(self, sw_if_index, remote_mac):
+ """Delete p2p ethernet subinterface
+
+ :param sw_if_index: main (parent) interface
+ :param remote_mac: client (remote) mac address
+
+ """
+ return self.api(
+ self.papi.p2p_ethernet_del,
+ {'parent_if_index': sw_if_index,
+ 'remote_mac': remote_mac})
+
def create_vlan_subif(self, sw_if_index, vlan):
"""
)
def sw_interface_span_enable_disable(
- self, sw_if_index_from, sw_if_index_to, state=1):
+ self, sw_if_index_from, sw_if_index_to, state=1, is_l2=0):
"""
:param sw_if_index_from:
:param sw_if_index_to:
:param state:
+ :param is_l2:
"""
return self.api(self.papi.sw_interface_span_enable_disable,
{'sw_if_index_from': sw_if_index_from,
'sw_if_index_to': sw_if_index_to,
- 'state': state})
+ 'state': state,
+ 'is_l2': is_l2,
+ })
def gre_tunnel_add_del(self,
src_address,
self,
label,
eos,
- next_hop_proto_is_ip4,
+ next_hop_proto,
next_hop_address,
next_hop_sw_if_index=0xFFFFFFFF,
table_id=0,
'mr_is_resolve_attached': is_resolve_attached,
'mr_is_interface_rx': is_interface_rx,
'mr_is_rpf_id': is_rpf_id,
- 'mr_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
+ 'mr_next_hop_proto': next_hop_proto,
'mr_next_hop_weight': next_hop_weight,
'mr_next_hop': next_hop_address,
'mr_next_hop_n_out_labels': next_hop_n_out_labels,
'is_inside': is_inside,
'sw_if_index': sw_if_index})
+ def snat_interface_add_del_output_feature(
+ self,
+ sw_if_index,
+ is_inside=1,
+ is_add=1):
+ """Enable/disable S-NAT 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)
+ """
+ return self.api(
+ self.papi.snat_interface_add_del_output_feature,
+ {'is_add': is_add,
+ 'is_inside': is_inside,
+ 'sw_if_index': sw_if_index})
+
def snat_add_static_mapping(
self,
local_ip,
"""
return self.api(self.papi.snat_interface_dump, {})
+ def snat_interface_output_feature_dump(self):
+ """Dump interfaces with S-NAT output feature
+ :return: Dictionary of interfaces with S-NAT output feature
+ """
+ return self.api(self.papi.snat_interface_output_feature_dump, {})
+
def snat_static_mapping_dump(self):
"""Dump S-NAT static mappings
:return: Dictionary of S-NAT static mappings
tcp_incoming_syn=6):
"""Set values of timeouts for NAT64 (in seconds)
- :param udp - UDP timeout (Default value = 300)
- :param icmp - ICMP timeout (Default value = 60)
- :param tcp_trans - TCP transitory timeout (Default value = 240)
- :param tcp_est - TCP established timeout (Default value = 7440)
- :param tcp_incoming_syn - TCP incoming SYN timeout (Default value = 6)
+ :param udpi: UDP timeout (Default value = 300)
+ :param icmp: ICMP timeout (Default value = 60)
+ :param tcp_trans: TCP transitory timeout (Default value = 240)
+ :param tcp_est: TCP established timeout (Default value = 7440)
+ :param tcp_incoming_syn: TCP incoming SYN timeout (Default value = 6)
"""
return self.api(
self.papi.nat64_set_timeouts,
"""
return self.api(self.papi.nat64_st_dump, {'proto': protocol})
+ def nat64_add_del_prefix(self, prefix, plen, 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})
+
+ def nat64_prefix_dump(self):
+ """Dump NAT64 prefix
+
+ :returns: Dictionary of NAT64 prefixes
+ """
+ return self.api(self.papi.nat64_prefix_dump, {})
+
def control_ping(self):
self.api(self.papi.control_ping)
'oui': oui,
})
+ def dhcp_client(self,
+ sw_if_index,
+ hostname,
+ client_id='',
+ is_add=1,
+ want_dhcp_events=0):
+ return self.api(
+ self.papi.dhcp_client_config,
+ {
+ 'sw_if_index': sw_if_index,
+ 'hostname': hostname,
+ 'client_id': client_id,
+ 'is_add': is_add,
+ 'want_dhcp_event': want_dhcp_events,
+ 'pid': os.getpid(),
+ })
+
def ip_mroute_add_del(self,
src_address,
grp_address,
'decap_vrf_id': decap_vrf_id,
'protocol': protocol,
'vni': vni})
+
+ def pppoe_add_del_session(
+ self,
+ client_ip,
+ client_mac,
+ session_id=0,
+ is_add=1,
+ is_ipv6=0,
+ decap_vrf_id=0):
+ """
+
+ :param is_add: (Default value = 1)
+ :param is_ipv6: (Default value = 0)
+ :param client_ip:
+ :param session_id: (Default value = 0)
+ :param client_mac:
+ :param decap_vrf_id: (Default value = 0)
+
+ """
+ return self.api(self.papi.pppoe_add_del_session,
+ {'is_add': is_add,
+ 'is_ipv6': is_ipv6,
+ 'session_id': session_id,
+ 'client_ip': client_ip,
+ 'decap_vrf_id': decap_vrf_id,
+ 'client_mac': client_mac})