[l2-preset]: Add all dual ToR required fields (#7318)

- Add peer_switch field to DEVICE_METADATA table
- In PORT table:
   - Set used ports to admin status up
   - Set mux_cable to true for downlinks in use
- In MUX_CABLE table:
   - Only add entry if the downlink is in use

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
This commit is contained in:
Lawrence Lee 2021-04-14 17:38:14 -07:00 committed by Guohan Lu
parent c7c9141a6f
commit d7b4c62f6a
5 changed files with 831 additions and 339 deletions

View File

@ -1,5 +1,6 @@
import sys
from collections import defaultdict
from ipaddress import ip_interface
from natsort import natsorted
@ -37,7 +38,7 @@ def generate_t1_sample_config(data):
'keepalive': '60'
}
port_count += 1
return data;
return data
def generate_empty_config(data):
new_data = {'DEVICE_METADATA': data['DEVICE_METADATA']}
@ -47,49 +48,79 @@ def generate_empty_config(data):
new_data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
return new_data
def generate_global_dualtor_tables():
data = defaultdict(lambda: defaultdict(dict))
data['LOOPBACK_INTERFACE'] = {
'Loopback2': {},
'Loopback2|3.3.3.3': {}
}
data['MUX_CABLE'] = {}
data['PEER_SWITCH'] = {
"peer_switch_hostname": {
"address_ipv4": "1.1.1.1"
}
}
data['TUNNEL'] = {
"MuxTunnel0": {
"dscp_mode": "uniform",
"dst_ip": "2.2.2.2",
"ecn_mode": "copy_from_outer",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
}
return data
def generate_l2_config(data):
# Check if dual ToR configs are needed
if 'is_dualtor' in data and data['is_dualtor']:
is_dualtor = True
data.pop('is_dualtor')
else:
is_dualtor = False
if 'uplinks' in data:
uplinks = data['uplinks']
data.pop('uplinks')
if 'downlinks' in data:
downlinks = data['downlinks']
data.pop('downlinks')
# VLAN initial data
data['VLAN'] = {'Vlan1000': {'vlanid': '1000'}}
data['VLAN_MEMBER'] = {}
if is_dualtor:
data['DEVICE_METADATA']['localhost']['subtype'] = 'DualToR'
data['LOOPBACK_INTERFACE'] = {
'Loopback2': {},
'Loopback2|3.3.3.3': {}
}
data['MUX_CABLE'] = {}
data['PEER_SWITCH'] = {
"peer_switch_hostname": {
"address_ipv4": "1.1.1.1"
}
}
data['TUNNEL'] = {
"MuxTunnel0": {
"dscp_mode": "uniform",
"dst_ip": "2.2.2.2",
"ecn_mode": "copy_from_outer",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
}
data['DEVICE_METADATA']['localhost']['peer_switch'] = 'peer_switch_hostname'
data.update(generate_global_dualtor_tables())
server_ipv4_base = ip_interface(UNICODE_TYPE('192.168.0.1/32'))
server_ipv6_base = ip_interface(UNICODE_TYPE('fc02:1000::1/128'))
for i, port in enumerate(natsorted(data['PORT'])):
data['PORT'][port].setdefault('admin_status', 'up')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
server_offset = 1
for port in natsorted(data['PORT']):
if is_dualtor:
mux_cable_entry = {
'server_ipv4': str(server_ipv4_base + i),
'server_ipv6': str(server_ipv6_base + i),
'state': 'auto'
}
data['MUX_CABLE'][port] = mux_cable_entry
# Ports in use should be admin up, unused ports default to admin down
if port in downlinks or port in uplinks:
data['PORT'][port].setdefault('admin_status', 'up')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
# Downlinks (connected to mux cable) need a MUX_CABLE entry
# as well as the `mux_cable` field in the PORT table
if port in downlinks:
mux_cable_entry = {
'server_ipv4': str(server_ipv4_base + server_offset),
'server_ipv6': str(server_ipv6_base + server_offset),
'state': 'auto'
}
server_offset += 1
data['MUX_CABLE'][port] = mux_cable_entry
data['PORT'][port]['mux_cable'] = 'true'
else:
data['PORT'][port].setdefault('admin_status', 'up')
data['VLAN_MEMBER']['Vlan1000|{}'.format(port)] = {'tagging_mode': 'untagged'}
return data
_sample_generators = {

View File

@ -1,170 +1,403 @@
{
"DEVICE_METADATA": {
"localhost": {
"hwsku": "Mellanox-SN2700",
"subtype": "DualToR"
"hwsku": "Arista-7050CX3-32S-D48C8",
"subtype": "DualToR",
"peer_switch": "peer_switch_hostname"
}
},
"PORT": {
"Ethernet0": {
"alias": "fortyGigE0/0",
"lanes": "29,30,31,32",
"admin_status": "up"
"lanes": "1,2",
"alias": "Ethernet1/1",
"index": "1",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet2": {
"lanes": "3,4",
"alias": "Ethernet1/3",
"index": "1",
"speed": "50000"
},
"Ethernet4": {
"alias": "fortyGigE0/4",
"lanes": "25,26,27,28",
"admin_status": "up"
"lanes": "5,6",
"alias": "Ethernet2/1",
"index": "2",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet6": {
"lanes": "7,8",
"alias": "Ethernet2/3",
"index": "2",
"speed": "50000"
},
"Ethernet8": {
"alias": "fortyGigE0/8",
"lanes": "37,38,39,40",
"admin_status": "up"
"lanes": "9,10",
"alias": "Ethernet3/1",
"index": "3",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet10": {
"lanes": "11,12",
"alias": "Ethernet3/3",
"index": "3",
"speed": "50000"
},
"Ethernet12": {
"alias": "fortyGigE0/12",
"lanes": "33,34,35,36",
"admin_status": "up"
"lanes": "13,14",
"alias": "Ethernet4/1",
"index": "4",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet14": {
"lanes": "15,16",
"alias": "Ethernet4/3",
"index": "4",
"speed": "50000"
},
"Ethernet16": {
"alias": "fortyGigE0/16",
"lanes": "41,42,43,44",
"admin_status": "up"
"lanes": "21,22",
"alias": "Ethernet5/1",
"index": "5",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet18": {
"lanes": "23,24",
"alias": "Ethernet5/3",
"index": "5",
"speed": "50000"
},
"Ethernet20": {
"alias": "fortyGigE0/20",
"lanes": "45,46,47,48",
"admin_status": "up"
"lanes": "17,18",
"alias": "Ethernet6/1",
"index": "6",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet22": {
"lanes": "19,20",
"alias": "Ethernet6/3",
"index": "6",
"speed": "50000"
},
"Ethernet24": {
"alias": "fortyGigE0/24",
"lanes": "5,6,7,8",
"lanes": "25,26,27,28",
"alias": "Ethernet7/1",
"index": "7",
"speed": "100000",
"admin_status": "up"
},
"Ethernet28": {
"alias": "fortyGigE0/28",
"lanes": "1,2,3,4",
"lanes": "29,30,31,32",
"alias": "Ethernet8/1",
"index": "8",
"speed": "100000",
"admin_status": "up"
},
"Ethernet32": {
"alias": "fortyGigE0/32",
"lanes": "9,10,11,12",
"lanes": "37,38,39,40",
"alias": "Ethernet9/1",
"index": "9",
"speed": "100000",
"admin_status": "up"
},
"Ethernet36": {
"alias": "fortyGigE0/36",
"lanes": "13,14,15,16",
"lanes": "33,34,35,36",
"alias": "Ethernet10/1",
"index": "10",
"speed": "100000",
"admin_status": "up"
},
"Ethernet40": {
"alias": "fortyGigE0/40",
"lanes": "21,22,23,24",
"admin_status": "up"
"lanes": "41,42",
"alias": "Ethernet11/1",
"index": "11",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet42": {
"lanes": "43,44",
"alias": "Ethernet11/3",
"index": "11",
"speed": "50000"
},
"Ethernet44": {
"alias": "fortyGigE0/44",
"lanes": "17,18,19,20",
"admin_status": "up"
"lanes": "45,46",
"alias": "Ethernet12/1",
"index": "12",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet46": {
"lanes": "47,48",
"alias": "Ethernet12/3",
"index": "12",
"speed": "50000"
},
"Ethernet48": {
"alias": "fortyGigE0/48",
"lanes": "49,50,51,52",
"admin_status": "up"
"lanes": "53,54",
"alias": "Ethernet13/1",
"index": "13",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet50": {
"lanes": "55,56",
"alias": "Ethernet13/3",
"index": "13",
"speed": "50000"
},
"Ethernet52": {
"alias": "fortyGigE0/52",
"lanes": "53,54,55,56",
"admin_status": "up"
"lanes": "49,50",
"alias": "Ethernet14/1",
"index": "14",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet54": {
"lanes": "51,52",
"alias": "Ethernet14/3",
"index": "14",
"speed": "50000"
},
"Ethernet56": {
"alias": "fortyGigE0/56",
"lanes": "61,62,63,64",
"admin_status": "up"
"lanes": "57,58",
"alias": "Ethernet15/1",
"index": "15",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet58": {
"lanes": "59,60",
"alias": "Ethernet15/3",
"index": "15",
"speed": "50000"
},
"Ethernet60": {
"alias": "fortyGigE0/60",
"lanes": "57,58,59,60",
"admin_status": "up"
"lanes": "61,62",
"alias": "Ethernet16/1",
"index": "16",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet62": {
"lanes": "63,64",
"alias": "Ethernet16/3",
"index": "16",
"speed": "50000"
},
"Ethernet64": {
"alias": "fortyGigE0/64",
"lanes": "65,66,67,68",
"admin_status": "up"
"lanes": "69,70",
"alias": "Ethernet17/1",
"index": "17",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet66": {
"lanes": "71,72",
"alias": "Ethernet17/3",
"index": "17",
"speed": "50000"
},
"Ethernet68": {
"alias": "fortyGigE0/68",
"lanes": "69,70,71,72",
"admin_status": "up"
"lanes": "65,66",
"alias": "Ethernet18/1",
"index": "18",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet70": {
"lanes": "67,68",
"alias": "Ethernet18/3",
"index": "18",
"speed": "50000"
},
"Ethernet72": {
"alias": "fortyGigE0/72",
"lanes": "77,78,79,80",
"admin_status": "up"
"lanes": "73,74",
"alias": "Ethernet19/1",
"index": "19",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet74": {
"lanes": "75,76",
"alias": "Ethernet19/3",
"index": "19",
"speed": "50000"
},
"Ethernet76": {
"alias": "fortyGigE0/76",
"lanes": "73,74,75,76",
"admin_status": "up"
"lanes": "77,78",
"alias": "Ethernet20/1",
"index": "20",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet78": {
"lanes": "79,80",
"alias": "Ethernet20/3",
"index": "20",
"speed": "50000"
},
"Ethernet80": {
"alias": "fortyGigE0/80",
"lanes": "105,106,107,108",
"admin_status": "up"
"lanes": "85,86",
"alias": "Ethernet21/1",
"index": "21",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet82": {
"lanes": "87,88",
"alias": "Ethernet21/3",
"index": "21",
"speed": "50000"
},
"Ethernet84": {
"alias": "fortyGigE0/84",
"lanes": "109,110,111,112",
"admin_status": "up"
"lanes": "81,82",
"alias": "Ethernet22/1",
"index": "22",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet86": {
"lanes": "83,84",
"alias": "Ethernet22/3",
"index": "22",
"speed": "50000"
},
"Ethernet88": {
"alias": "fortyGigE0/88",
"lanes": "117,118,119,120",
"lanes": "89,90,91,92",
"alias": "Ethernet23/1",
"index": "23",
"speed": "100000",
"admin_status": "up"
},
"Ethernet92": {
"alias": "fortyGigE0/92",
"lanes": "113,114,115,116",
"lanes": "93,94,95,96",
"alias": "Ethernet24/1",
"index": "24",
"speed": "100000",
"admin_status": "up"
},
"Ethernet96": {
"alias": "fortyGigE0/96",
"lanes": "121,122,123,124",
"lanes": "101,102,103,104",
"alias": "Ethernet25/1",
"index": "25",
"speed": "100000",
"admin_status": "up"
},
"Ethernet100": {
"alias": "fortyGigE0/100",
"lanes": "125,126,127,128",
"lanes": "97,98,99,100",
"alias": "Ethernet26/1",
"index": "26",
"speed": "100000",
"admin_status": "up"
},
"Ethernet104": {
"alias": "fortyGigE0/104",
"lanes": "85,86,87,88",
"admin_status": "up"
"lanes": "105,106",
"alias": "Ethernet27/1",
"index": "27",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet106": {
"lanes": "107,108",
"alias": "Ethernet27/3",
"index": "27",
"speed": "50000"
},
"Ethernet108": {
"alias": "fortyGigE0/108",
"lanes": "81,82,83,84",
"admin_status": "up"
"lanes": "109,110",
"alias": "Ethernet28/1",
"index": "28",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet110": {
"lanes": "111,112",
"alias": "Ethernet28/3",
"index": "28",
"speed": "50000"
},
"Ethernet112": {
"alias": "fortyGigE0/112",
"lanes": "89,90,91,92",
"admin_status": "up"
"lanes": "117,118",
"alias": "Ethernet29/1",
"index": "29",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet114": {
"lanes": "119,120",
"alias": "Ethernet29/3",
"index": "29",
"speed": "50000"
},
"Ethernet116": {
"alias": "fortyGigE0/116",
"lanes": "93,94,95,96",
"admin_status": "up"
"lanes": "113,114",
"alias": "Ethernet30/1",
"index": "30",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet118": {
"lanes": "115,116",
"alias": "Ethernet30/3",
"index": "30",
"speed": "50000"
},
"Ethernet120": {
"alias": "fortyGigE0/120",
"lanes": "97,98,99,100",
"admin_status": "up"
"lanes": "121,122",
"alias": "Ethernet31/1",
"index": "31",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet122": {
"lanes": "123,124",
"alias": "Ethernet31/3",
"index": "31",
"speed": "50000"
},
"Ethernet124": {
"alias": "fortyGigE0/124",
"lanes": "101,102,103,104",
"admin_status": "up"
"lanes": "125,126",
"alias": "Ethernet32/1",
"index": "32",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet126": {
"lanes": "127,128",
"alias": "Ethernet32/3",
"index": "32",
"speed": "50000"
}
},
"VLAN": {
@ -289,166 +522,126 @@
"Loopback2": {},
"Loopback2|3.3.3.3": {}
},
"MUX_CABLE":{
"MUX_CABLE": {
"Ethernet0": {
"server_ipv4": "192.168.0.1/32",
"server_ipv6": "fc02:1000::1/128",
"state": "auto"
},
"Ethernet4": {
"server_ipv4": "192.168.0.2/32",
"server_ipv6": "fc02:1000::2/128",
"state": "auto"
},
"Ethernet8": {
"Ethernet4": {
"server_ipv4": "192.168.0.3/32",
"server_ipv6": "fc02:1000::3/128",
"state": "auto"
},
"Ethernet12": {
"Ethernet8": {
"server_ipv4": "192.168.0.4/32",
"server_ipv6": "fc02:1000::4/128",
"state": "auto"
},
"Ethernet16": {
"Ethernet12": {
"server_ipv4": "192.168.0.5/32",
"server_ipv6": "fc02:1000::5/128",
"state": "auto"
},
"Ethernet20": {
"Ethernet16": {
"server_ipv4": "192.168.0.6/32",
"server_ipv6": "fc02:1000::6/128",
"state": "auto"
},
"Ethernet24": {
"Ethernet20": {
"server_ipv4": "192.168.0.7/32",
"server_ipv6": "fc02:1000::7/128",
"state": "auto"
},
"Ethernet28": {
"Ethernet40": {
"server_ipv4": "192.168.0.8/32",
"server_ipv6": "fc02:1000::8/128",
"state": "auto"
},
"Ethernet32": {
"Ethernet44": {
"server_ipv4": "192.168.0.9/32",
"server_ipv6": "fc02:1000::9/128",
"state": "auto"
},
"Ethernet36": {
"Ethernet48": {
"server_ipv4": "192.168.0.10/32",
"server_ipv6": "fc02:1000::a/128",
"state": "auto"
},
"Ethernet40": {
"Ethernet52": {
"server_ipv4": "192.168.0.11/32",
"server_ipv6": "fc02:1000::b/128",
"state": "auto"
},
"Ethernet44": {
"Ethernet56": {
"server_ipv4": "192.168.0.12/32",
"server_ipv6": "fc02:1000::c/128",
"state": "auto"
},
"Ethernet48": {
"Ethernet60": {
"server_ipv4": "192.168.0.13/32",
"server_ipv6": "fc02:1000::d/128",
"state": "auto"
},
"Ethernet52": {
"Ethernet64": {
"server_ipv4": "192.168.0.14/32",
"server_ipv6": "fc02:1000::e/128",
"state": "auto"
},
"Ethernet56": {
"Ethernet68": {
"server_ipv4": "192.168.0.15/32",
"server_ipv6": "fc02:1000::f/128",
"state": "auto"
},
"Ethernet60": {
"Ethernet72": {
"server_ipv4": "192.168.0.16/32",
"server_ipv6": "fc02:1000::10/128",
"state": "auto"
},
"Ethernet64": {
"Ethernet76": {
"server_ipv4": "192.168.0.17/32",
"server_ipv6": "fc02:1000::11/128",
"state": "auto"
},
"Ethernet68": {
"Ethernet80": {
"server_ipv4": "192.168.0.18/32",
"server_ipv6": "fc02:1000::12/128",
"state": "auto"
},
"Ethernet72": {
"Ethernet84": {
"server_ipv4": "192.168.0.19/32",
"server_ipv6": "fc02:1000::13/128",
"state": "auto"
},
"Ethernet76": {
"Ethernet104": {
"server_ipv4": "192.168.0.20/32",
"server_ipv6": "fc02:1000::14/128",
"state": "auto"
},
"Ethernet80": {
"Ethernet108": {
"server_ipv4": "192.168.0.21/32",
"server_ipv6": "fc02:1000::15/128",
"state": "auto"
},
"Ethernet84": {
"Ethernet112": {
"server_ipv4": "192.168.0.22/32",
"server_ipv6": "fc02:1000::16/128",
"state": "auto"
},
"Ethernet88": {
"Ethernet116": {
"server_ipv4": "192.168.0.23/32",
"server_ipv6": "fc02:1000::17/128",
"state": "auto"
},
"Ethernet92": {
"Ethernet120": {
"server_ipv4": "192.168.0.24/32",
"server_ipv6": "fc02:1000::18/128",
"state": "auto"
},
"Ethernet96": {
"Ethernet124": {
"server_ipv4": "192.168.0.25/32",
"server_ipv6": "fc02:1000::19/128",
"state": "auto"
},
"Ethernet100": {
"server_ipv4": "192.168.0.26/32",
"server_ipv6": "fc02:1000::1a/128",
"state": "auto"
},
"Ethernet104": {
"server_ipv4": "192.168.0.27/32",
"server_ipv6": "fc02:1000::1b/128",
"state": "auto"
},
"Ethernet108": {
"server_ipv4": "192.168.0.28/32",
"server_ipv6": "fc02:1000::1c/128",
"state": "auto"
},
"Ethernet112": {
"server_ipv4": "192.168.0.29/32",
"server_ipv6": "fc02:1000::1d/128",
"state": "auto"
},
"Ethernet116": {
"server_ipv4": "192.168.0.30/32",
"server_ipv6": "fc02:1000::1e/128",
"state": "auto"
},
"Ethernet120": {
"server_ipv4": "192.168.0.31/32",
"server_ipv6": "fc02:1000::1f/128",
"state": "auto"
},
"Ethernet124": {
"server_ipv4": "192.168.0.32/32",
"server_ipv6": "fc02:1000::20/128",
"state": "auto"
}
}
}

View File

@ -1,170 +1,403 @@
{
"DEVICE_METADATA": {
"localhost": {
"hwsku": "Mellanox-SN2700",
"subtype": "DualToR"
"hwsku": "Arista-7050CX3-32S-D48C8",
"subtype": "DualToR",
"peer_switch": "peer_switch_hostname"
}
},
"PORT": {
"Ethernet0": {
"alias": "fortyGigE0/0",
"lanes": "29,30,31,32",
"admin_status": "up"
"lanes": "1,2",
"alias": "Ethernet1/1",
"index": "1",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet2": {
"lanes": "3,4",
"alias": "Ethernet1/3",
"index": "1",
"speed": "50000"
},
"Ethernet4": {
"alias": "fortyGigE0/4",
"lanes": "25,26,27,28",
"admin_status": "up"
"lanes": "5,6",
"alias": "Ethernet2/1",
"index": "2",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet6": {
"lanes": "7,8",
"alias": "Ethernet2/3",
"index": "2",
"speed": "50000"
},
"Ethernet8": {
"alias": "fortyGigE0/8",
"lanes": "37,38,39,40",
"admin_status": "up"
"lanes": "9,10",
"alias": "Ethernet3/1",
"index": "3",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet10": {
"lanes": "11,12",
"alias": "Ethernet3/3",
"index": "3",
"speed": "50000"
},
"Ethernet12": {
"alias": "fortyGigE0/12",
"lanes": "33,34,35,36",
"admin_status": "up"
"lanes": "13,14",
"alias": "Ethernet4/1",
"index": "4",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet14": {
"lanes": "15,16",
"alias": "Ethernet4/3",
"index": "4",
"speed": "50000"
},
"Ethernet16": {
"alias": "fortyGigE0/16",
"lanes": "41,42,43,44",
"admin_status": "up"
"lanes": "21,22",
"alias": "Ethernet5/1",
"index": "5",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet18": {
"lanes": "23,24",
"alias": "Ethernet5/3",
"index": "5",
"speed": "50000"
},
"Ethernet20": {
"alias": "fortyGigE0/20",
"lanes": "45,46,47,48",
"admin_status": "up"
"lanes": "17,18",
"alias": "Ethernet6/1",
"index": "6",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet22": {
"lanes": "19,20",
"alias": "Ethernet6/3",
"index": "6",
"speed": "50000"
},
"Ethernet24": {
"alias": "fortyGigE0/24",
"lanes": "5,6,7,8",
"lanes": "25,26,27,28",
"alias": "Ethernet7/1",
"index": "7",
"speed": "100000",
"admin_status": "up"
},
"Ethernet28": {
"alias": "fortyGigE0/28",
"lanes": "1,2,3,4",
"lanes": "29,30,31,32",
"alias": "Ethernet8/1",
"index": "8",
"speed": "100000",
"admin_status": "up"
},
"Ethernet32": {
"alias": "fortyGigE0/32",
"lanes": "9,10,11,12",
"lanes": "37,38,39,40",
"alias": "Ethernet9/1",
"index": "9",
"speed": "100000",
"admin_status": "up"
},
"Ethernet36": {
"alias": "fortyGigE0/36",
"lanes": "13,14,15,16",
"lanes": "33,34,35,36",
"alias": "Ethernet10/1",
"index": "10",
"speed": "100000",
"admin_status": "up"
},
"Ethernet40": {
"alias": "fortyGigE0/40",
"lanes": "21,22,23,24",
"admin_status": "up"
"lanes": "41,42",
"alias": "Ethernet11/1",
"index": "11",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet42": {
"lanes": "43,44",
"alias": "Ethernet11/3",
"index": "11",
"speed": "50000"
},
"Ethernet44": {
"alias": "fortyGigE0/44",
"lanes": "17,18,19,20",
"admin_status": "up"
"lanes": "45,46",
"alias": "Ethernet12/1",
"index": "12",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet46": {
"lanes": "47,48",
"alias": "Ethernet12/3",
"index": "12",
"speed": "50000"
},
"Ethernet48": {
"alias": "fortyGigE0/48",
"lanes": "49,50,51,52",
"admin_status": "up"
"lanes": "53,54",
"alias": "Ethernet13/1",
"index": "13",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet50": {
"lanes": "55,56",
"alias": "Ethernet13/3",
"index": "13",
"speed": "50000"
},
"Ethernet52": {
"alias": "fortyGigE0/52",
"lanes": "53,54,55,56",
"admin_status": "up"
"lanes": "49,50",
"alias": "Ethernet14/1",
"index": "14",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet54": {
"lanes": "51,52",
"alias": "Ethernet14/3",
"index": "14",
"speed": "50000"
},
"Ethernet56": {
"alias": "fortyGigE0/56",
"lanes": "61,62,63,64",
"admin_status": "up"
"lanes": "57,58",
"alias": "Ethernet15/1",
"index": "15",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet58": {
"lanes": "59,60",
"alias": "Ethernet15/3",
"index": "15",
"speed": "50000"
},
"Ethernet60": {
"alias": "fortyGigE0/60",
"lanes": "57,58,59,60",
"admin_status": "up"
"lanes": "61,62",
"alias": "Ethernet16/1",
"index": "16",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet62": {
"lanes": "63,64",
"alias": "Ethernet16/3",
"index": "16",
"speed": "50000"
},
"Ethernet64": {
"alias": "fortyGigE0/64",
"lanes": "65,66,67,68",
"admin_status": "up"
"lanes": "69,70",
"alias": "Ethernet17/1",
"index": "17",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet66": {
"lanes": "71,72",
"alias": "Ethernet17/3",
"index": "17",
"speed": "50000"
},
"Ethernet68": {
"alias": "fortyGigE0/68",
"lanes": "69,70,71,72",
"admin_status": "up"
"lanes": "65,66",
"alias": "Ethernet18/1",
"index": "18",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet70": {
"lanes": "67,68",
"alias": "Ethernet18/3",
"index": "18",
"speed": "50000"
},
"Ethernet72": {
"alias": "fortyGigE0/72",
"lanes": "77,78,79,80",
"admin_status": "up"
"lanes": "73,74",
"alias": "Ethernet19/1",
"index": "19",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet74": {
"lanes": "75,76",
"alias": "Ethernet19/3",
"index": "19",
"speed": "50000"
},
"Ethernet76": {
"alias": "fortyGigE0/76",
"lanes": "73,74,75,76",
"admin_status": "up"
"lanes": "77,78",
"alias": "Ethernet20/1",
"index": "20",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet78": {
"lanes": "79,80",
"alias": "Ethernet20/3",
"index": "20",
"speed": "50000"
},
"Ethernet80": {
"alias": "fortyGigE0/80",
"lanes": "105,106,107,108",
"admin_status": "up"
"lanes": "85,86",
"alias": "Ethernet21/1",
"index": "21",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet82": {
"lanes": "87,88",
"alias": "Ethernet21/3",
"index": "21",
"speed": "50000"
},
"Ethernet84": {
"alias": "fortyGigE0/84",
"lanes": "109,110,111,112",
"admin_status": "up"
"lanes": "81,82",
"alias": "Ethernet22/1",
"index": "22",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet86": {
"lanes": "83,84",
"alias": "Ethernet22/3",
"index": "22",
"speed": "50000"
},
"Ethernet88": {
"alias": "fortyGigE0/88",
"lanes": "117,118,119,120",
"lanes": "89,90,91,92",
"alias": "Ethernet23/1",
"index": "23",
"speed": "100000",
"admin_status": "up"
},
"Ethernet92": {
"alias": "fortyGigE0/92",
"lanes": "113,114,115,116",
"lanes": "93,94,95,96",
"alias": "Ethernet24/1",
"index": "24",
"speed": "100000",
"admin_status": "up"
},
"Ethernet96": {
"alias": "fortyGigE0/96",
"lanes": "121,122,123,124",
"lanes": "101,102,103,104",
"alias": "Ethernet25/1",
"index": "25",
"speed": "100000",
"admin_status": "up"
},
"Ethernet100": {
"alias": "fortyGigE0/100",
"lanes": "125,126,127,128",
"lanes": "97,98,99,100",
"alias": "Ethernet26/1",
"index": "26",
"speed": "100000",
"admin_status": "up"
},
"Ethernet104": {
"alias": "fortyGigE0/104",
"lanes": "85,86,87,88",
"admin_status": "up"
"lanes": "105,106",
"alias": "Ethernet27/1",
"index": "27",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet106": {
"lanes": "107,108",
"alias": "Ethernet27/3",
"index": "27",
"speed": "50000"
},
"Ethernet108": {
"alias": "fortyGigE0/108",
"lanes": "81,82,83,84",
"admin_status": "up"
"lanes": "109,110",
"alias": "Ethernet28/1",
"index": "28",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet110": {
"lanes": "111,112",
"alias": "Ethernet28/3",
"index": "28",
"speed": "50000"
},
"Ethernet112": {
"alias": "fortyGigE0/112",
"lanes": "89,90,91,92",
"admin_status": "up"
"lanes": "117,118",
"alias": "Ethernet29/1",
"index": "29",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet114": {
"lanes": "119,120",
"alias": "Ethernet29/3",
"index": "29",
"speed": "50000"
},
"Ethernet116": {
"alias": "fortyGigE0/116",
"lanes": "93,94,95,96",
"admin_status": "up"
"lanes": "113,114",
"alias": "Ethernet30/1",
"index": "30",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet118": {
"lanes": "115,116",
"alias": "Ethernet30/3",
"index": "30",
"speed": "50000"
},
"Ethernet120": {
"alias": "fortyGigE0/120",
"lanes": "97,98,99,100",
"admin_status": "up"
"lanes": "121,122",
"alias": "Ethernet31/1",
"index": "31",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet122": {
"lanes": "123,124",
"alias": "Ethernet31/3",
"index": "31",
"speed": "50000"
},
"Ethernet124": {
"alias": "fortyGigE0/124",
"lanes": "101,102,103,104",
"admin_status": "up"
"lanes": "125,126",
"alias": "Ethernet32/1",
"index": "32",
"speed": "50000",
"admin_status": "up",
"mux_cable": "true"
},
"Ethernet126": {
"lanes": "127,128",
"alias": "Ethernet32/3",
"index": "32",
"speed": "50000"
}
},
"VLAN": {
@ -289,166 +522,126 @@
"Loopback2": {},
"Loopback2|3.3.3.3": {}
},
"MUX_CABLE":{
"MUX_CABLE": {
"Ethernet0": {
"server_ipv4": "192.168.0.1/32",
"server_ipv6": "fc02:1000::1/128",
"state": "auto"
},
"Ethernet4": {
"server_ipv4": "192.168.0.2/32",
"server_ipv6": "fc02:1000::2/128",
"state": "auto"
},
"Ethernet8": {
"Ethernet4": {
"server_ipv4": "192.168.0.3/32",
"server_ipv6": "fc02:1000::3/128",
"state": "auto"
},
"Ethernet12": {
"Ethernet8": {
"server_ipv4": "192.168.0.4/32",
"server_ipv6": "fc02:1000::4/128",
"state": "auto"
},
"Ethernet16": {
"Ethernet12": {
"server_ipv4": "192.168.0.5/32",
"server_ipv6": "fc02:1000::5/128",
"state": "auto"
},
"Ethernet20": {
"Ethernet16": {
"server_ipv4": "192.168.0.6/32",
"server_ipv6": "fc02:1000::6/128",
"state": "auto"
},
"Ethernet24": {
"Ethernet20": {
"server_ipv4": "192.168.0.7/32",
"server_ipv6": "fc02:1000::7/128",
"state": "auto"
},
"Ethernet28": {
"Ethernet40": {
"server_ipv4": "192.168.0.8/32",
"server_ipv6": "fc02:1000::8/128",
"state": "auto"
},
"Ethernet32": {
"Ethernet44": {
"server_ipv4": "192.168.0.9/32",
"server_ipv6": "fc02:1000::9/128",
"state": "auto"
},
"Ethernet36": {
"Ethernet48": {
"server_ipv4": "192.168.0.10/32",
"server_ipv6": "fc02:1000::a/128",
"state": "auto"
},
"Ethernet40": {
"Ethernet52": {
"server_ipv4": "192.168.0.11/32",
"server_ipv6": "fc02:1000::b/128",
"state": "auto"
},
"Ethernet44": {
"Ethernet56": {
"server_ipv4": "192.168.0.12/32",
"server_ipv6": "fc02:1000::c/128",
"state": "auto"
},
"Ethernet48": {
"Ethernet60": {
"server_ipv4": "192.168.0.13/32",
"server_ipv6": "fc02:1000::d/128",
"state": "auto"
},
"Ethernet52": {
"Ethernet64": {
"server_ipv4": "192.168.0.14/32",
"server_ipv6": "fc02:1000::e/128",
"state": "auto"
},
"Ethernet56": {
"Ethernet68": {
"server_ipv4": "192.168.0.15/32",
"server_ipv6": "fc02:1000::f/128",
"state": "auto"
},
"Ethernet60": {
"Ethernet72": {
"server_ipv4": "192.168.0.16/32",
"server_ipv6": "fc02:1000::10/128",
"state": "auto"
},
"Ethernet64": {
"Ethernet76": {
"server_ipv4": "192.168.0.17/32",
"server_ipv6": "fc02:1000::11/128",
"state": "auto"
},
"Ethernet68": {
"Ethernet80": {
"server_ipv4": "192.168.0.18/32",
"server_ipv6": "fc02:1000::12/128",
"state": "auto"
},
"Ethernet72": {
"Ethernet84": {
"server_ipv4": "192.168.0.19/32",
"server_ipv6": "fc02:1000::13/128",
"state": "auto"
},
"Ethernet76": {
"Ethernet104": {
"server_ipv4": "192.168.0.20/32",
"server_ipv6": "fc02:1000::14/128",
"state": "auto"
},
"Ethernet80": {
"Ethernet108": {
"server_ipv4": "192.168.0.21/32",
"server_ipv6": "fc02:1000::15/128",
"state": "auto"
},
"Ethernet84": {
"Ethernet112": {
"server_ipv4": "192.168.0.22/32",
"server_ipv6": "fc02:1000::16/128",
"state": "auto"
},
"Ethernet88": {
"Ethernet116": {
"server_ipv4": "192.168.0.23/32",
"server_ipv6": "fc02:1000::17/128",
"state": "auto"
},
"Ethernet92": {
"Ethernet120": {
"server_ipv4": "192.168.0.24/32",
"server_ipv6": "fc02:1000::18/128",
"state": "auto"
},
"Ethernet96": {
"Ethernet124": {
"server_ipv4": "192.168.0.25/32",
"server_ipv6": "fc02:1000::19/128",
"state": "auto"
},
"Ethernet100": {
"server_ipv4": "192.168.0.26/32",
"server_ipv6": "fc02:1000::1a/128",
"state": "auto"
},
"Ethernet104": {
"server_ipv4": "192.168.0.27/32",
"server_ipv6": "fc02:1000::1b/128",
"state": "auto"
},
"Ethernet108": {
"server_ipv4": "192.168.0.28/32",
"server_ipv6": "fc02:1000::1c/128",
"state": "auto"
},
"Ethernet112": {
"server_ipv4": "192.168.0.29/32",
"server_ipv6": "fc02:1000::1d/128",
"state": "auto"
},
"Ethernet116": {
"server_ipv4": "192.168.0.30/32",
"server_ipv6": "fc02:1000::1e/128",
"state": "auto"
},
"Ethernet120": {
"server_ipv4": "192.168.0.31/32",
"server_ipv6": "fc02:1000::1f/128",
"state": "auto"
},
"Ethernet124": {
"server_ipv4": "192.168.0.32/32",
"server_ipv6": "fc02:1000::20/128",
"state": "auto"
}
}
}

View File

@ -0,0 +1,57 @@
# name lanes alias index speed
Ethernet0 1,2 Ethernet1/1 1 50000
Ethernet2 3,4 Ethernet1/3 1 50000
Ethernet4 5,6 Ethernet2/1 2 50000
Ethernet6 7,8 Ethernet2/3 2 50000
Ethernet8 9,10 Ethernet3/1 3 50000
Ethernet10 11,12 Ethernet3/3 3 50000
Ethernet12 13,14 Ethernet4/1 4 50000
Ethernet14 15,16 Ethernet4/3 4 50000
Ethernet16 21,22 Ethernet5/1 5 50000
Ethernet18 23,24 Ethernet5/3 5 50000
Ethernet20 17,18 Ethernet6/1 6 50000
Ethernet22 19,20 Ethernet6/3 6 50000
Ethernet24 25,26,27,28 Ethernet7/1 7 100000
Ethernet28 29,30,31,32 Ethernet8/1 8 100000
Ethernet32 37,38,39,40 Ethernet9/1 9 100000
Ethernet36 33,34,35,36 Ethernet10/1 10 100000
Ethernet40 41,42 Ethernet11/1 11 50000
Ethernet42 43,44 Ethernet11/3 11 50000
Ethernet44 45,46 Ethernet12/1 12 50000
Ethernet46 47,48 Ethernet12/3 12 50000
Ethernet48 53,54 Ethernet13/1 13 50000
Ethernet50 55,56 Ethernet13/3 13 50000
Ethernet52 49,50 Ethernet14/1 14 50000
Ethernet54 51,52 Ethernet14/3 14 50000
Ethernet56 57,58 Ethernet15/1 15 50000
Ethernet58 59,60 Ethernet15/3 15 50000
Ethernet60 61,62 Ethernet16/1 16 50000
Ethernet62 63,64 Ethernet16/3 16 50000
Ethernet64 69,70 Ethernet17/1 17 50000
Ethernet66 71,72 Ethernet17/3 17 50000
Ethernet68 65,66 Ethernet18/1 18 50000
Ethernet70 67,68 Ethernet18/3 18 50000
Ethernet72 73,74 Ethernet19/1 19 50000
Ethernet74 75,76 Ethernet19/3 19 50000
Ethernet76 77,78 Ethernet20/1 20 50000
Ethernet78 79,80 Ethernet20/3 20 50000
Ethernet80 85,86 Ethernet21/1 21 50000
Ethernet82 87,88 Ethernet21/3 21 50000
Ethernet84 81,82 Ethernet22/1 22 50000
Ethernet86 83,84 Ethernet22/3 22 50000
Ethernet88 89,90,91,92 Ethernet23/1 23 100000
Ethernet92 93,94,95,96 Ethernet24/1 24 100000
Ethernet96 101,102,103,104 Ethernet25/1 25 100000
Ethernet100 97,98,99,100 Ethernet26/1 26 100000
Ethernet104 105,106 Ethernet27/1 27 50000
Ethernet106 107,108 Ethernet27/3 27 50000
Ethernet108 109,110 Ethernet28/1 28 50000
Ethernet110 111,112 Ethernet28/3 28 50000
Ethernet112 117,118 Ethernet29/1 29 50000
Ethernet114 119,120 Ethernet29/3 29 50000
Ethernet116 113,114 Ethernet30/1 30 50000
Ethernet118 115,116 Ethernet30/3 30 50000
Ethernet120 121,122 Ethernet31/1 31 50000
Ethernet122 123,124 Ethernet31/3 31 50000
Ethernet124 125,126 Ethernet32/1 32 50000
Ethernet126 127,128 Ethernet32/3 32 50000

View File

@ -17,6 +17,7 @@ class TestJ2Files(TestCase):
self.t0_mvrf_minigraph = os.path.join(self.test_dir, 't0-sample-graph-mvrf.xml')
self.pc_minigraph = os.path.join(self.test_dir, 'pc-test-graph.xml')
self.t0_port_config = os.path.join(self.test_dir, 't0-sample-port-config.ini')
self.t0_7050cx3_port_config = os.path.join(self.test_dir, 't0_7050cx3_d48c8_port_config.ini')
self.t1_mlnx_minigraph = os.path.join(self.test_dir, 't1-sample-graph-mlnx.xml')
self.mlnx_port_config = os.path.join(self.test_dir, 'sample-port-config-mlnx.ini')
self.dell6100_t0_minigraph = os.path.join(self.test_dir, 'sample-dell-6100-t0-minigraph.xml')
@ -133,7 +134,24 @@ class TestJ2Files(TestCase):
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
def test_l2switch_template_dualtor(self):
argument = '-a \'{"is_dualtor": true}\' -k Mellanox-SN2700 --preset l2 -p ' + self.t0_port_config
extra_args = {
"is_dualtor": True,
"uplinks": [
"Ethernet24", "Ethernet28", "Ethernet32", "Ethernet36",
"Ethernet88", "Ethernet92", "Ethernet96", "Ethernet100"
],
"downlinks": [
"Ethernet0", "Ethernet4", "Ethernet8", "Ethernet12",
"Ethernet16", "Ethernet20", "Ethernet40", "Ethernet44",
"Ethernet48", "Ethernet52", "Ethernet56", "Ethernet60",
"Ethernet64", "Ethernet68", "Ethernet72", "Ethernet76",
"Ethernet80", "Ethernet84", "Ethernet104", "Ethernet108",
"Ethernet112", "Ethernet116", "Ethernet120", "Ethernet124"
]
}
argument = '-a \'{}\' -k Arista-7050CX3-32S-D48C8 --preset l2 -p {}'.format(
json.dumps(extra_args), self.t0_7050cx3_port_config
)
output = self.run_script(argument)
output_json = json.loads(output)