|
@@ -6,6 +6,8 @@ import ipaddress
|
|
|
import re
|
|
|
from copy import deepcopy
|
|
|
|
|
|
+import ffho
|
|
|
+
|
|
|
mac_prefix = "f2"
|
|
|
|
|
|
# VRF configuration map
|
|
@@ -1023,21 +1025,13 @@ def get_interface_config (node_config, sites_config, node_id = ""):
|
|
|
|
|
|
vlan_vxlan_iface_re = re.compile (r'^vlan(\d+)|^vx_v(\d+)_(\w+)')
|
|
|
|
|
|
-def _cmp (x, y):
|
|
|
- if x < y:
|
|
|
- return -1
|
|
|
- elif x == y:
|
|
|
- return 0
|
|
|
- else:
|
|
|
- return 1
|
|
|
-
|
|
|
def _iface_sort (iface_a, iface_b):
|
|
|
a = vlan_vxlan_iface_re.search (iface_a)
|
|
|
b = vlan_vxlan_iface_re.search (iface_b)
|
|
|
|
|
|
# At least one interface didn't match, do regular comparison
|
|
|
if not a or not b:
|
|
|
- return _cmp (iface_a, iface_b)
|
|
|
+ return ffho.cmp (iface_a, iface_b)
|
|
|
|
|
|
# Extract VLAN ID from VLAN interface (if given) or VXLAN
|
|
|
vid_a = a.group (1) if a.group (1) else a.group (2)
|
|
@@ -1045,17 +1039,17 @@ def _iface_sort (iface_a, iface_b):
|
|
|
|
|
|
# If it's different type of interfaces (one VLAN, one VXLAN), do regular comparison
|
|
|
if (a.group (1) == None) != (b.group (1) == None):
|
|
|
- return _cmp (iface_a, iface_b)
|
|
|
+ return ffho.cmp (iface_a, iface_b)
|
|
|
|
|
|
# Ok, t's two VLAN or two VXLAN interfaces
|
|
|
|
|
|
# If it's VXLAN interfaces and the VLAN ID is the same, sort by site name
|
|
|
if a.group (2) and vid_a == vid_b:
|
|
|
- return _cmp (a.groups (2), b.groups (2))
|
|
|
+ return ffho.cmp (a.groups (2), b.groups (2))
|
|
|
|
|
|
# If it's two VLANs or two VXLANs with different VLAN IDs, sort by VLAN ID
|
|
|
else:
|
|
|
- return _cmp (int (vid_a), int (vid_b))
|
|
|
+ return ffho.cmp (int (vid_a), int (vid_b))
|
|
|
|
|
|
|
|
|
def get_interface_list (ifaces):
|