Support L1 & L3 Config generation in SONiC (#7637)

Why I did it
This provides support for: PR #7074.

How I did it
Extend sonic-config-engine/config_samples.py to provide support for l1 & l3
This commit is contained in:
VenkatCisco 2021-07-07 22:57:58 -07:00 committed by Judy Joseph
parent 98281c58ca
commit 027b6d1dc5
9 changed files with 1313 additions and 1 deletions

View File

@ -10,6 +10,31 @@ if sys.version_info.major == 3:
else:
UNICODE_TYPE = unicode
# The following config generation methods exits:
# 't1': generate_t1_sample_config,
# 'l2': generate_l2_config,
# 'empty': generate_empty_config,
# 'l1': generate_l1_config,
# 'l3': generate_l3_config
def generate_l1_config(data):
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
return data;
def generate_l3_config(data):
data['LOOPBACK_INTERFACE'] = {"Loopback0": {},
"Loopback0|10.1.0.1/32": {}}
data['BGP_NEIGHBOR'] = {}
data['DEVICE_NEIGHBOR'] = {}
data['INTERFACE'] = {}
for port in natsorted(data['PORT']):
data['PORT'][port]['admin_status'] = 'up'
data['PORT'][port]['mtu'] = '9100'
data['INTERFACE']['{}'.format(port)] = {}
return data;
def generate_t1_sample_config(data):
data['DEVICE_METADATA']['localhost']['hostname'] = 'sonic'
data['DEVICE_METADATA']['localhost']['type'] = 'LeafRouter'
@ -126,7 +151,9 @@ def generate_l2_config(data):
_sample_generators = {
't1': generate_t1_sample_config,
'l2': generate_l2_config,
'empty': generate_empty_config
'empty': generate_empty_config,
'l1': generate_l1_config,
'l3': generate_l3_config
}
def get_available_config():

View File

@ -0,0 +1,26 @@
{
"DEVICE_METADATA": {
"localhost" : {
"hwsku" : "{{ DEVICE_METADATA.localhost.hwsku }}"
}
},
{% set ns = {'firstPrinted': False} -%}
"PORT": {
{%- for key, value in PORT.items() -%}
{%- if ns.firstPrinted %},{% endif %}
"{{ key }}": {
{%- for keyPort, valuePort in value.items() %}
{% if keyPort != "admin_status" %}"{{ keyPort }}": "{{ valuePort }}",{% endif %}
{%- endfor %}
"admin_status": "{{ value.admin_status|default("up") }}",
"mtu": "9100"
}
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
{%- endfor %}
}
}

View File

@ -0,0 +1,65 @@
{
"DEVICE_METADATA": {
"localhost" : {
"hwsku" : "{{ DEVICE_METADATA.localhost.hwsku }}"
}
},
{% set ns = {'firstPrinted': False} -%}
"PORT": {
{%- for key, value in PORT.items() -%}
{%- if ns.firstPrinted %},{% endif %}
"{{ key }}": {
{%- for keyPort, valuePort in value.items() %}
{% if keyPort != "admin_status" %}"{{ keyPort }}": "{{ valuePort }}",{% endif %}
{%- endfor %}
"admin_status": "{{ value.admin_status|default("up") }}",
"mtu": "9100"
}
{%- if ns.update({'firstPrinted': True}) %}{% endif -%}
{%- endfor %}
},
"LOOPBACK_INTERFACE": {
"Loopback0": {},
"Loopback0|10.1.0.1/32": {}
},
"BGP_NEIGHBOR": {},
"DEVICE_NEIGHBOR": {},
"INTERFACE": {
"Ethernet0": {},
"Ethernet1": {},
"Ethernet2": {},
"Ethernet3": {},
"Ethernet4": {},
"Ethernet5": {},
"Ethernet6": {},
"Ethernet7": {},
"Ethernet8": {},
"Ethernet9": {},
"Ethernet10": {},
"Ethernet11": {},
"Ethernet12": {},
"Ethernet13": {},
"Ethernet14": {},
"Ethernet15": {},
"Ethernet16": {},
"Ethernet17": {},
"Ethernet18": {},
"Ethernet19": {},
"Ethernet20": {},
"Ethernet21": {},
"Ethernet22": {},
"Ethernet23": {},
"Ethernet24": {},
"Ethernet25": {},
"Ethernet26": {},
"Ethernet27": {},
"Ethernet28": {},
"Ethernet29": {},
"Ethernet30": {},
"Ethernet31": {}
}
}

View File

@ -0,0 +1,33 @@
# name lanes alias index speed
Ethernet0 1296,1297,1298,1299 Ethernet0 0 100000
Ethernet1 1300,1301,1302,1303 Ethernet1 1 100000
Ethernet2 1288,1289,1290,1291 Ethernet2 2 100000
Ethernet3 1292,1293,1294,1295 Ethernet3 3 100000
Ethernet4 1280,1281,1282,1283 Ethernet4 4 100000
Ethernet5 1284,1285,1286,1287 Ethernet5 5 100000
Ethernet6 1032,1033,1034,1035 Ethernet6 6 100000
Ethernet7 1036,1037,1038,1039 Ethernet7 7 100000
Ethernet8 1024,1025,1026,1027 Ethernet8 8 100000
Ethernet9 1028,1029,1030,1031 Ethernet9 9 100000
Ethernet10 772,773,774,775 Ethernet10 10 100000
Ethernet11 768,769,770,771 Ethernet11 11 100000
Ethernet12 780,781,782,783 Ethernet12 12 100000
Ethernet13 776,777,778,779 Ethernet13 13 100000
Ethernet14 528,529,530,531 Ethernet14 14 100000
Ethernet15 532,533,534,535 Ethernet15 15 100000
Ethernet16 520,521,522,523 Ethernet16 16 100000
Ethernet17 524,525,526,527 Ethernet17 17 100000
Ethernet18 512,513,514,515 Ethernet18 18 100000
Ethernet19 516,517,518,519 Ethernet19 19 100000
Ethernet20 272,273,274,275 Ethernet20 20 100000
Ethernet21 276,277,278,279 Ethernet21 21 100000
Ethernet22 264,265,266,267 Ethernet22 22 100000
Ethernet23 268,269,270,271 Ethernet23 23 100000
Ethernet24 256,257,258,259 Ethernet24 24 100000
Ethernet25 260,261,262,263 Ethernet25 25 100000
Ethernet26 16,17,18,19 Ethernet26 26 100000
Ethernet27 20,21,22,23 Ethernet27 27 100000
Ethernet28 8,9,10,11 Ethernet28 28 100000
Ethernet29 12,13,14,15 Ethernet29 29 100000
Ethernet30 0,1,2,3 Ethernet30 30 100000
Ethernet31 4,5,6,7 Ethernet31 31 100000

View File

@ -0,0 +1,261 @@
{
"DEVICE_METADATA": {"localhost": {"hwsku": "32x1000Gb"}},
"PORT": {
"Ethernet0": {
"admin_status": "up",
"alias": "Ethernet0",
"index": "0",
"lanes": "1296,1297,1298,1299",
"mtu": "9100",
"speed": "100000"
},
"Ethernet1": {
"admin_status": "up",
"alias": "Ethernet1",
"index": "1",
"lanes": "1300,1301,1302,1303",
"mtu": "9100",
"speed": "100000"
},
"Ethernet10": {
"admin_status": "up",
"alias": "Ethernet10",
"index": "10",
"lanes": "772,773,774,775",
"mtu": "9100",
"speed": "100000"
},
"Ethernet11": {
"admin_status": "up",
"alias": "Ethernet11",
"index": "11",
"lanes": "768,769,770,771",
"mtu": "9100",
"speed": "100000"
},
"Ethernet12": {
"admin_status": "up",
"alias": "Ethernet12",
"index": "12",
"lanes": "780,781,782,783",
"mtu": "9100",
"speed": "100000"
},
"Ethernet13": {
"admin_status": "up",
"alias": "Ethernet13",
"index": "13",
"lanes": "776,777,778,779",
"mtu": "9100",
"speed": "100000"
},
"Ethernet14": {
"admin_status": "up",
"alias": "Ethernet14",
"index": "14",
"lanes": "528,529,530,531",
"mtu": "9100",
"speed": "100000"
},
"Ethernet15": {
"admin_status": "up",
"alias": "Ethernet15",
"index": "15",
"lanes": "532,533,534,535",
"mtu": "9100",
"speed": "100000"
},
"Ethernet16": {
"admin_status": "up",
"alias": "Ethernet16",
"index": "16",
"lanes": "520,521,522,523",
"mtu": "9100",
"speed": "100000"
},
"Ethernet17": {
"admin_status": "up",
"alias": "Ethernet17",
"index": "17",
"lanes": "524,525,526,527",
"mtu": "9100",
"speed": "100000"
},
"Ethernet18": {
"admin_status": "up",
"alias": "Ethernet18",
"index": "18",
"lanes": "512,513,514,515",
"mtu": "9100",
"speed": "100000"
},
"Ethernet19": {
"admin_status": "up",
"alias": "Ethernet19",
"index": "19",
"lanes": "516,517,518,519",
"mtu": "9100",
"speed": "100000"
},
"Ethernet2": {
"admin_status": "up",
"alias": "Ethernet2",
"index": "2",
"lanes": "1288,1289,1290,1291",
"mtu": "9100",
"speed": "100000"
},
"Ethernet20": {
"admin_status": "up",
"alias": "Ethernet20",
"index": "20",
"lanes": "272,273,274,275",
"mtu": "9100",
"speed": "100000"
},
"Ethernet21": {
"admin_status": "up",
"alias": "Ethernet21",
"index": "21",
"lanes": "276,277,278,279",
"mtu": "9100",
"speed": "100000"
},
"Ethernet22": {
"admin_status": "up",
"alias": "Ethernet22",
"index": "22",
"lanes": "264,265,266,267",
"mtu": "9100",
"speed": "100000"
},
"Ethernet23": {
"admin_status": "up",
"alias": "Ethernet23",
"index": "23",
"lanes": "268,269,270,271",
"mtu": "9100",
"speed": "100000"
},
"Ethernet24": {
"admin_status": "up",
"alias": "Ethernet24",
"index": "24",
"lanes": "256,257,258,259",
"mtu": "9100",
"speed": "100000"
},
"Ethernet25": {
"admin_status": "up",
"alias": "Ethernet25",
"index": "25",
"lanes": "260,261,262,263",
"mtu": "9100",
"speed": "100000"
},
"Ethernet26": {
"admin_status": "up",
"alias": "Ethernet26",
"index": "26",
"lanes": "16,17,18,19",
"mtu": "9100",
"speed": "100000"
},
"Ethernet27": {
"admin_status": "up",
"alias": "Ethernet27",
"index": "27",
"lanes": "20,21,22,23",
"mtu": "9100",
"speed": "100000"
},
"Ethernet28": {
"admin_status": "up",
"alias": "Ethernet28",
"index": "28",
"lanes": "8,9,10,11",
"mtu": "9100",
"speed": "100000"
},
"Ethernet29": {
"admin_status": "up",
"alias": "Ethernet29",
"index": "29",
"lanes": "12,13,14,15",
"mtu": "9100",
"speed": "100000"
},
"Ethernet3": {
"admin_status": "up",
"alias": "Ethernet3",
"index": "3",
"lanes": "1292,1293,1294,1295",
"mtu": "9100",
"speed": "100000"
},
"Ethernet30": {
"admin_status": "up",
"alias": "Ethernet30",
"index": "30",
"lanes": "0,1,2,3",
"mtu": "9100",
"speed": "100000"
},
"Ethernet31": {
"admin_status": "up",
"alias": "Ethernet31",
"index": "31",
"lanes": "4,5,6,7",
"mtu": "9100",
"speed": "100000"
},
"Ethernet4": {
"admin_status": "up",
"alias": "Ethernet4",
"index": "4",
"lanes": "1280,1281,1282,1283",
"mtu": "9100",
"speed": "100000"
},
"Ethernet5": {
"admin_status": "up",
"alias": "Ethernet5",
"index": "5",
"lanes": "1284,1285,1286,1287",
"mtu": "9100",
"speed": "100000"
},
"Ethernet6": {
"admin_status": "up",
"alias": "Ethernet6",
"index": "6",
"lanes": "1032,1033,1034,1035",
"mtu": "9100",
"speed": "100000"
},
"Ethernet7": {
"admin_status": "up",
"alias": "Ethernet7",
"index": "7",
"lanes": "1036,1037,1038,1039",
"mtu": "9100",
"speed": "100000"
},
"Ethernet8": {
"admin_status": "up",
"alias": "Ethernet8",
"index": "8",
"lanes": "1024,1025,1026,1027",
"mtu": "9100",
"speed": "100000"
},
"Ethernet9": {
"admin_status": "up",
"alias": "Ethernet9",
"index": "9",
"lanes": "1028,1029,1030,1031",
"mtu": "9100",
"speed": "100000"
}
}
}

View File

@ -0,0 +1,301 @@
{
"DEVICE_METADATA": {"localhost": {"hwsku": "32x1000Gb"}},
"PORT": {
"Ethernet0": {
"admin_status": "up",
"alias": "Ethernet0",
"index": "0",
"lanes": "1296,1297,1298,1299",
"mtu": "9100",
"speed": "100000"
},
"Ethernet1": {
"admin_status": "up",
"alias": "Ethernet1",
"index": "1",
"lanes": "1300,1301,1302,1303",
"mtu": "9100",
"speed": "100000"
},
"Ethernet10": {
"admin_status": "up",
"alias": "Ethernet10",
"index": "10",
"lanes": "772,773,774,775",
"mtu": "9100",
"speed": "100000"
},
"Ethernet11": {
"admin_status": "up",
"alias": "Ethernet11",
"index": "11",
"lanes": "768,769,770,771",
"mtu": "9100",
"speed": "100000"
},
"Ethernet12": {
"admin_status": "up",
"alias": "Ethernet12",
"index": "12",
"lanes": "780,781,782,783",
"mtu": "9100",
"speed": "100000"
},
"Ethernet13": {
"admin_status": "up",
"alias": "Ethernet13",
"index": "13",
"lanes": "776,777,778,779",
"mtu": "9100",
"speed": "100000"
},
"Ethernet14": {
"admin_status": "up",
"alias": "Ethernet14",
"index": "14",
"lanes": "528,529,530,531",
"mtu": "9100",
"speed": "100000"
},
"Ethernet15": {
"admin_status": "up",
"alias": "Ethernet15",
"index": "15",
"lanes": "532,533,534,535",
"mtu": "9100",
"speed": "100000"
},
"Ethernet16": {
"admin_status": "up",
"alias": "Ethernet16",
"index": "16",
"lanes": "520,521,522,523",
"mtu": "9100",
"speed": "100000"
},
"Ethernet17": {
"admin_status": "up",
"alias": "Ethernet17",
"index": "17",
"lanes": "524,525,526,527",
"mtu": "9100",
"speed": "100000"
},
"Ethernet18": {
"admin_status": "up",
"alias": "Ethernet18",
"index": "18",
"lanes": "512,513,514,515",
"mtu": "9100",
"speed": "100000"
},
"Ethernet19": {
"admin_status": "up",
"alias": "Ethernet19",
"index": "19",
"lanes": "516,517,518,519",
"mtu": "9100",
"speed": "100000"
},
"Ethernet2": {
"admin_status": "up",
"alias": "Ethernet2",
"index": "2",
"lanes": "1288,1289,1290,1291",
"mtu": "9100",
"speed": "100000"
},
"Ethernet20": {
"admin_status": "up",
"alias": "Ethernet20",
"index": "20",
"lanes": "272,273,274,275",
"mtu": "9100",
"speed": "100000"
},
"Ethernet21": {
"admin_status": "up",
"alias": "Ethernet21",
"index": "21",
"lanes": "276,277,278,279",
"mtu": "9100",
"speed": "100000"
},
"Ethernet22": {
"admin_status": "up",
"alias": "Ethernet22",
"index": "22",
"lanes": "264,265,266,267",
"mtu": "9100",
"speed": "100000"
},
"Ethernet23": {
"admin_status": "up",
"alias": "Ethernet23",
"index": "23",
"lanes": "268,269,270,271",
"mtu": "9100",
"speed": "100000"
},
"Ethernet24": {
"admin_status": "up",
"alias": "Ethernet24",
"index": "24",
"lanes": "256,257,258,259",
"mtu": "9100",
"speed": "100000"
},
"Ethernet25": {
"admin_status": "up",
"alias": "Ethernet25",
"index": "25",
"lanes": "260,261,262,263",
"mtu": "9100",
"speed": "100000"
},
"Ethernet26": {
"admin_status": "up",
"alias": "Ethernet26",
"index": "26",
"lanes": "16,17,18,19",
"mtu": "9100",
"speed": "100000"
},
"Ethernet27": {
"admin_status": "up",
"alias": "Ethernet27",
"index": "27",
"lanes": "20,21,22,23",
"mtu": "9100",
"speed": "100000"
},
"Ethernet28": {
"admin_status": "up",
"alias": "Ethernet28",
"index": "28",
"lanes": "8,9,10,11",
"mtu": "9100",
"speed": "100000"
},
"Ethernet29": {
"admin_status": "up",
"alias": "Ethernet29",
"index": "29",
"lanes": "12,13,14,15",
"mtu": "9100",
"speed": "100000"
},
"Ethernet3": {
"admin_status": "up",
"alias": "Ethernet3",
"index": "3",
"lanes": "1292,1293,1294,1295",
"mtu": "9100",
"speed": "100000"
},
"Ethernet30": {
"admin_status": "up",
"alias": "Ethernet30",
"index": "30",
"lanes": "0,1,2,3",
"mtu": "9100",
"speed": "100000"
},
"Ethernet31": {
"admin_status": "up",
"alias": "Ethernet31",
"index": "31",
"lanes": "4,5,6,7",
"mtu": "9100",
"speed": "100000"
},
"Ethernet4": {
"admin_status": "up",
"alias": "Ethernet4",
"index": "4",
"lanes": "1280,1281,1282,1283",
"mtu": "9100",
"speed": "100000"
},
"Ethernet5": {
"admin_status": "up",
"alias": "Ethernet5",
"index": "5",
"lanes": "1284,1285,1286,1287",
"mtu": "9100",
"speed": "100000"
},
"Ethernet6": {
"admin_status": "up",
"alias": "Ethernet6",
"index": "6",
"lanes": "1032,1033,1034,1035",
"mtu": "9100",
"speed": "100000"
},
"Ethernet7": {
"admin_status": "up",
"alias": "Ethernet7",
"index": "7",
"lanes": "1036,1037,1038,1039",
"mtu": "9100",
"speed": "100000"
},
"Ethernet8": {
"admin_status": "up",
"alias": "Ethernet8",
"index": "8",
"lanes": "1024,1025,1026,1027",
"mtu": "9100",
"speed": "100000"
},
"Ethernet9": {
"admin_status": "up",
"alias": "Ethernet9",
"index": "9",
"lanes": "1028,1029,1030,1031",
"mtu": "9100",
"speed": "100000"
}
},
"LOOPBACK_INTERFACE": {
"Loopback0": {},
"Loopback0|10.1.0.1/32": {}
},
"BGP_NEIGHBOR": {},
"DEVICE_NEIGHBOR": {},
"INTERFACE": {
"Ethernet0": {},
"Ethernet1": {},
"Ethernet2": {},
"Ethernet3": {},
"Ethernet4": {},
"Ethernet5": {},
"Ethernet6": {},
"Ethernet7": {},
"Ethernet8": {},
"Ethernet9": {},
"Ethernet10": {},
"Ethernet11": {},
"Ethernet12": {},
"Ethernet13": {},
"Ethernet14": {},
"Ethernet15": {},
"Ethernet16": {},
"Ethernet17": {},
"Ethernet18": {},
"Ethernet19": {},
"Ethernet20": {},
"Ethernet21": {},
"Ethernet22": {},
"Ethernet23": {},
"Ethernet24": {},
"Ethernet25": {},
"Ethernet26": {},
"Ethernet27": {},
"Ethernet28": {},
"Ethernet29": {},
"Ethernet30": {},
"Ethernet31": {}
}
}

View File

@ -0,0 +1,261 @@
{
"DEVICE_METADATA": {"localhost": {"hwsku": "32x1000Gb"}},
"PORT": {
"Ethernet0": {
"admin_status": "up",
"alias": "Ethernet0",
"index": "0",
"lanes": "1296,1297,1298,1299",
"mtu": "9100",
"speed": "100000"
},
"Ethernet1": {
"admin_status": "up",
"alias": "Ethernet1",
"index": "1",
"lanes": "1300,1301,1302,1303",
"mtu": "9100",
"speed": "100000"
},
"Ethernet10": {
"admin_status": "up",
"alias": "Ethernet10",
"index": "10",
"lanes": "772,773,774,775",
"mtu": "9100",
"speed": "100000"
},
"Ethernet11": {
"admin_status": "up",
"alias": "Ethernet11",
"index": "11",
"lanes": "768,769,770,771",
"mtu": "9100",
"speed": "100000"
},
"Ethernet12": {
"admin_status": "up",
"alias": "Ethernet12",
"index": "12",
"lanes": "780,781,782,783",
"mtu": "9100",
"speed": "100000"
},
"Ethernet13": {
"admin_status": "up",
"alias": "Ethernet13",
"index": "13",
"lanes": "776,777,778,779",
"mtu": "9100",
"speed": "100000"
},
"Ethernet14": {
"admin_status": "up",
"alias": "Ethernet14",
"index": "14",
"lanes": "528,529,530,531",
"mtu": "9100",
"speed": "100000"
},
"Ethernet15": {
"admin_status": "up",
"alias": "Ethernet15",
"index": "15",
"lanes": "532,533,534,535",
"mtu": "9100",
"speed": "100000"
},
"Ethernet16": {
"admin_status": "up",
"alias": "Ethernet16",
"index": "16",
"lanes": "520,521,522,523",
"mtu": "9100",
"speed": "100000"
},
"Ethernet17": {
"admin_status": "up",
"alias": "Ethernet17",
"index": "17",
"lanes": "524,525,526,527",
"mtu": "9100",
"speed": "100000"
},
"Ethernet18": {
"admin_status": "up",
"alias": "Ethernet18",
"index": "18",
"lanes": "512,513,514,515",
"mtu": "9100",
"speed": "100000"
},
"Ethernet19": {
"admin_status": "up",
"alias": "Ethernet19",
"index": "19",
"lanes": "516,517,518,519",
"mtu": "9100",
"speed": "100000"
},
"Ethernet2": {
"admin_status": "up",
"alias": "Ethernet2",
"index": "2",
"lanes": "1288,1289,1290,1291",
"mtu": "9100",
"speed": "100000"
},
"Ethernet20": {
"admin_status": "up",
"alias": "Ethernet20",
"index": "20",
"lanes": "272,273,274,275",
"mtu": "9100",
"speed": "100000"
},
"Ethernet21": {
"admin_status": "up",
"alias": "Ethernet21",
"index": "21",
"lanes": "276,277,278,279",
"mtu": "9100",
"speed": "100000"
},
"Ethernet22": {
"admin_status": "up",
"alias": "Ethernet22",
"index": "22",
"lanes": "264,265,266,267",
"mtu": "9100",
"speed": "100000"
},
"Ethernet23": {
"admin_status": "up",
"alias": "Ethernet23",
"index": "23",
"lanes": "268,269,270,271",
"mtu": "9100",
"speed": "100000"
},
"Ethernet24": {
"admin_status": "up",
"alias": "Ethernet24",
"index": "24",
"lanes": "256,257,258,259",
"mtu": "9100",
"speed": "100000"
},
"Ethernet25": {
"admin_status": "up",
"alias": "Ethernet25",
"index": "25",
"lanes": "260,261,262,263",
"mtu": "9100",
"speed": "100000"
},
"Ethernet26": {
"admin_status": "up",
"alias": "Ethernet26",
"index": "26",
"lanes": "16,17,18,19",
"mtu": "9100",
"speed": "100000"
},
"Ethernet27": {
"admin_status": "up",
"alias": "Ethernet27",
"index": "27",
"lanes": "20,21,22,23",
"mtu": "9100",
"speed": "100000"
},
"Ethernet28": {
"admin_status": "up",
"alias": "Ethernet28",
"index": "28",
"lanes": "8,9,10,11",
"mtu": "9100",
"speed": "100000"
},
"Ethernet29": {
"admin_status": "up",
"alias": "Ethernet29",
"index": "29",
"lanes": "12,13,14,15",
"mtu": "9100",
"speed": "100000"
},
"Ethernet3": {
"admin_status": "up",
"alias": "Ethernet3",
"index": "3",
"lanes": "1292,1293,1294,1295",
"mtu": "9100",
"speed": "100000"
},
"Ethernet30": {
"admin_status": "up",
"alias": "Ethernet30",
"index": "30",
"lanes": "0,1,2,3",
"mtu": "9100",
"speed": "100000"
},
"Ethernet31": {
"admin_status": "up",
"alias": "Ethernet31",
"index": "31",
"lanes": "4,5,6,7",
"mtu": "9100",
"speed": "100000"
},
"Ethernet4": {
"admin_status": "up",
"alias": "Ethernet4",
"index": "4",
"lanes": "1280,1281,1282,1283",
"mtu": "9100",
"speed": "100000"
},
"Ethernet5": {
"admin_status": "up",
"alias": "Ethernet5",
"index": "5",
"lanes": "1284,1285,1286,1287",
"mtu": "9100",
"speed": "100000"
},
"Ethernet6": {
"admin_status": "up",
"alias": "Ethernet6",
"index": "6",
"lanes": "1032,1033,1034,1035",
"mtu": "9100",
"speed": "100000"
},
"Ethernet7": {
"admin_status": "up",
"alias": "Ethernet7",
"index": "7",
"lanes": "1036,1037,1038,1039",
"mtu": "9100",
"speed": "100000"
},
"Ethernet8": {
"admin_status": "up",
"alias": "Ethernet8",
"index": "8",
"lanes": "1024,1025,1026,1027",
"mtu": "9100",
"speed": "100000"
},
"Ethernet9": {
"admin_status": "up",
"alias": "Ethernet9",
"index": "9",
"lanes": "1028,1029,1030,1031",
"mtu": "9100",
"speed": "100000"
}
}
}

View File

@ -0,0 +1,301 @@
{
"DEVICE_METADATA": {"localhost": {"hwsku": "32x1000Gb"}},
"PORT": {
"Ethernet0": {
"admin_status": "up",
"alias": "Ethernet0",
"index": "0",
"lanes": "1296,1297,1298,1299",
"mtu": "9100",
"speed": "100000"
},
"Ethernet1": {
"admin_status": "up",
"alias": "Ethernet1",
"index": "1",
"lanes": "1300,1301,1302,1303",
"mtu": "9100",
"speed": "100000"
},
"Ethernet10": {
"admin_status": "up",
"alias": "Ethernet10",
"index": "10",
"lanes": "772,773,774,775",
"mtu": "9100",
"speed": "100000"
},
"Ethernet11": {
"admin_status": "up",
"alias": "Ethernet11",
"index": "11",
"lanes": "768,769,770,771",
"mtu": "9100",
"speed": "100000"
},
"Ethernet12": {
"admin_status": "up",
"alias": "Ethernet12",
"index": "12",
"lanes": "780,781,782,783",
"mtu": "9100",
"speed": "100000"
},
"Ethernet13": {
"admin_status": "up",
"alias": "Ethernet13",
"index": "13",
"lanes": "776,777,778,779",
"mtu": "9100",
"speed": "100000"
},
"Ethernet14": {
"admin_status": "up",
"alias": "Ethernet14",
"index": "14",
"lanes": "528,529,530,531",
"mtu": "9100",
"speed": "100000"
},
"Ethernet15": {
"admin_status": "up",
"alias": "Ethernet15",
"index": "15",
"lanes": "532,533,534,535",
"mtu": "9100",
"speed": "100000"
},
"Ethernet16": {
"admin_status": "up",
"alias": "Ethernet16",
"index": "16",
"lanes": "520,521,522,523",
"mtu": "9100",
"speed": "100000"
},
"Ethernet17": {
"admin_status": "up",
"alias": "Ethernet17",
"index": "17",
"lanes": "524,525,526,527",
"mtu": "9100",
"speed": "100000"
},
"Ethernet18": {
"admin_status": "up",
"alias": "Ethernet18",
"index": "18",
"lanes": "512,513,514,515",
"mtu": "9100",
"speed": "100000"
},
"Ethernet19": {
"admin_status": "up",
"alias": "Ethernet19",
"index": "19",
"lanes": "516,517,518,519",
"mtu": "9100",
"speed": "100000"
},
"Ethernet2": {
"admin_status": "up",
"alias": "Ethernet2",
"index": "2",
"lanes": "1288,1289,1290,1291",
"mtu": "9100",
"speed": "100000"
},
"Ethernet20": {
"admin_status": "up",
"alias": "Ethernet20",
"index": "20",
"lanes": "272,273,274,275",
"mtu": "9100",
"speed": "100000"
},
"Ethernet21": {
"admin_status": "up",
"alias": "Ethernet21",
"index": "21",
"lanes": "276,277,278,279",
"mtu": "9100",
"speed": "100000"
},
"Ethernet22": {
"admin_status": "up",
"alias": "Ethernet22",
"index": "22",
"lanes": "264,265,266,267",
"mtu": "9100",
"speed": "100000"
},
"Ethernet23": {
"admin_status": "up",
"alias": "Ethernet23",
"index": "23",
"lanes": "268,269,270,271",
"mtu": "9100",
"speed": "100000"
},
"Ethernet24": {
"admin_status": "up",
"alias": "Ethernet24",
"index": "24",
"lanes": "256,257,258,259",
"mtu": "9100",
"speed": "100000"
},
"Ethernet25": {
"admin_status": "up",
"alias": "Ethernet25",
"index": "25",
"lanes": "260,261,262,263",
"mtu": "9100",
"speed": "100000"
},
"Ethernet26": {
"admin_status": "up",
"alias": "Ethernet26",
"index": "26",
"lanes": "16,17,18,19",
"mtu": "9100",
"speed": "100000"
},
"Ethernet27": {
"admin_status": "up",
"alias": "Ethernet27",
"index": "27",
"lanes": "20,21,22,23",
"mtu": "9100",
"speed": "100000"
},
"Ethernet28": {
"admin_status": "up",
"alias": "Ethernet28",
"index": "28",
"lanes": "8,9,10,11",
"mtu": "9100",
"speed": "100000"
},
"Ethernet29": {
"admin_status": "up",
"alias": "Ethernet29",
"index": "29",
"lanes": "12,13,14,15",
"mtu": "9100",
"speed": "100000"
},
"Ethernet3": {
"admin_status": "up",
"alias": "Ethernet3",
"index": "3",
"lanes": "1292,1293,1294,1295",
"mtu": "9100",
"speed": "100000"
},
"Ethernet30": {
"admin_status": "up",
"alias": "Ethernet30",
"index": "30",
"lanes": "0,1,2,3",
"mtu": "9100",
"speed": "100000"
},
"Ethernet31": {
"admin_status": "up",
"alias": "Ethernet31",
"index": "31",
"lanes": "4,5,6,7",
"mtu": "9100",
"speed": "100000"
},
"Ethernet4": {
"admin_status": "up",
"alias": "Ethernet4",
"index": "4",
"lanes": "1280,1281,1282,1283",
"mtu": "9100",
"speed": "100000"
},
"Ethernet5": {
"admin_status": "up",
"alias": "Ethernet5",
"index": "5",
"lanes": "1284,1285,1286,1287",
"mtu": "9100",
"speed": "100000"
},
"Ethernet6": {
"admin_status": "up",
"alias": "Ethernet6",
"index": "6",
"lanes": "1032,1033,1034,1035",
"mtu": "9100",
"speed": "100000"
},
"Ethernet7": {
"admin_status": "up",
"alias": "Ethernet7",
"index": "7",
"lanes": "1036,1037,1038,1039",
"mtu": "9100",
"speed": "100000"
},
"Ethernet8": {
"admin_status": "up",
"alias": "Ethernet8",
"index": "8",
"lanes": "1024,1025,1026,1027",
"mtu": "9100",
"speed": "100000"
},
"Ethernet9": {
"admin_status": "up",
"alias": "Ethernet9",
"index": "9",
"lanes": "1028,1029,1030,1031",
"mtu": "9100",
"speed": "100000"
}
},
"LOOPBACK_INTERFACE": {
"Loopback0": {},
"Loopback0|10.1.0.1/32": {}
},
"BGP_NEIGHBOR": {},
"DEVICE_NEIGHBOR": {},
"INTERFACE": {
"Ethernet0": {},
"Ethernet1": {},
"Ethernet2": {},
"Ethernet3": {},
"Ethernet4": {},
"Ethernet5": {},
"Ethernet6": {},
"Ethernet7": {},
"Ethernet8": {},
"Ethernet9": {},
"Ethernet10": {},
"Ethernet11": {},
"Ethernet12": {},
"Ethernet13": {},
"Ethernet14": {},
"Ethernet15": {},
"Ethernet16": {},
"Ethernet17": {},
"Ethernet18": {},
"Ethernet19": {},
"Ethernet20": {},
"Ethernet21": {},
"Ethernet22": {},
"Ethernet23": {},
"Ethernet24": {},
"Ethernet25": {},
"Ethernet26": {},
"Ethernet27": {},
"Ethernet28": {},
"Ethernet29": {},
"Ethernet30": {},
"Ethernet31": {}
}
}

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.l1_l3_port_config = os.path.join(self.test_dir, 'l1-l3-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')
@ -118,6 +119,42 @@ class TestJ2Files(TestCase):
output_json = json.loads(output)
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
def test_l1_ports_template(self):
argument = '-k 32x1000Gb --preset l1 -p ' + self.l1_l3_port_config
output = self.run_script(argument)
output_json = json.loads(output)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'l1_intfs.json')
with open(sample_output_file) as sample_output_fd:
sample_output_json = json.load(sample_output_fd)
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
template_dir = os.path.join(self.test_dir, '..', 'data', 'l1intf.j2')
argument = '-t ' + template_dir + ' -k 32x1000Gb -p ' + self.l1_l3_port_config
output = self.run_script(argument)
output_json = json.loads(output)
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
def test_l3_ports_template(self):
argument = '-k 32x1000Gb --preset l3 -p ' + self.l1_l3_port_config
output = self.run_script(argument)
output_json = json.loads(output)
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'l3_intfs.json')
with open(sample_output_file) as sample_output_fd:
sample_output_json = json.load(sample_output_fd)
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
template_dir = os.path.join(self.test_dir, '..', 'data', 'l3intf.j2')
argument = '-t ' + template_dir + ' -k 32x1000Gb -p ' + self.l1_l3_port_config
output = self.run_script(argument)
output_json = json.loads(output)
self.assertTrue(json.dumps(sample_output_json, sort_keys=True) == json.dumps(output_json, sort_keys=True))
def test_l2switch_template_dualtor(self):
extra_args = {