Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yang model table DEVICE_NEIGHBOR_METADATA creation #11894

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,24 @@ def parse_png(png, hname, dpg_ecmp_content = None):
if child.tag == str(QName(ns, "Devices")):
for device in child.findall(str(QName(ns, "Device"))):
(lo_prefix, lo_prefix_v6, mgmt_prefix, mgmt_prefix_v6, name, hwsku, d_type, deployment_id, cluster, d_subtype) = parse_device(device)
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku}
if cluster:
device_data = {}
if hwsku != None:
device_data['hwsku'] = hwsku
if cluster != None:
device_data['cluster'] = cluster
if deployment_id:
if deployment_id != None:
device_data['deployment_id'] = deployment_id
if lo_prefix_v6:
if lo_prefix != None:
device_data['lo_addr'] = lo_prefix
if lo_prefix_v6 != None:
device_data['lo_addr_v6'] = lo_prefix_v6
if d_subtype:
if mgmt_prefix != None:
device_data['mgmt_addr'] = mgmt_prefix
if mgmt_prefix_v6 != None:
device_data['mgmt_addr_v6'] = mgmt_prefix_v6
if d_type != None:
device_data['type'] = d_type
if d_subtype != None:
device_data['subtype'] = d_subtype
devices[name] = device_data

Expand Down Expand Up @@ -393,13 +403,23 @@ def parse_asic_png(png, asic_name, hostname):
if child.tag == str(QName(ns, "Devices")):
for device in child.findall(str(QName(ns, "Device"))):
(lo_prefix, lo_prefix_v6, mgmt_prefix, mgmt_prefix_v6, name, hwsku, d_type, deployment_id, cluster, _) = parse_device(device)
device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku }
if cluster:
device_data = {}
if hwsku != None:
device_data['hwsku'] = hwsku
if cluster != None:
device_data['cluster'] = cluster
if deployment_id:
if deployment_id != None:
device_data['deployment_id'] = deployment_id
if lo_prefix_v6:
device_data['lo_addr_v6']= lo_prefix_v6
if lo_prefix != None:
device_data['lo_addr'] = lo_prefix
if lo_prefix_v6 != None:
device_data['lo_addr_v6'] = lo_prefix_v6
if mgmt_prefix != None:
device_data['mgmt_addr'] = mgmt_prefix
if mgmt_prefix_v6 != None:
device_data['mgmt_addr_v6'] = mgmt_prefix_v6
if d_type != None:
device_data['type'] = d_type
devices[name] = device_data

return (neighbors, devices, port_speeds)
Expand Down
39 changes: 20 additions & 19 deletions src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,39 +203,40 @@ def test_minigraph_neighbor_metadata(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_NEIGHBOR_METADATA"'

expected_table = {
'switch-01t1': {
'lo_addr': '10.1.0.186/32',
'mgmt_addr': '10.7.0.196/26',
'hwsku': 'Force10-S6000',
'type': 'LeafRouter',
'deployment_id': '2'
},
'switch2-t0': {
'hwsku': 'Force10-S6000',
'lo_addr': '25.1.1.10/32',
'mgmt_addr': '10.7.0.196/26',
'hwsku': 'Force10-S6000',
'type': 'ToRRouter'
},
'server1': {
'server2': {
'lo_addr_v6': 'fe80::0002/128',
'lo_addr': '10.10.10.2/32',
'mgmt_addr': '10.0.0.2/32',
'hwsku': 'server-sku',
'lo_addr': '10.10.10.1/32',
'lo_addr_v6': 'fe80::0001/80',
'mgmt_addr': '10.0.0.1/32',
'type': 'Server'
},
'server2': {
'server1': {
'lo_addr_v6': 'fe80::0001/80',
'lo_addr': '10.10.10.1/32',
'mgmt_addr': '10.0.0.1/32',
'hwsku': 'server-sku',
'lo_addr': '10.10.10.2/32',
'lo_addr_v6': 'fe80::0002/128',
'mgmt_addr': '10.0.0.2/32',
'type': 'Server'
},
'switch-01t1': {
'lo_addr': '10.1.0.186/32',
'deployment_id': '2',
'hwsku': 'Force10-S6000',
'type': 'LeafRouter',
'mgmt_addr': '10.7.0.196/26'
},
'server1-SC': {
'hwsku': 'smartcable-sku',
'lo_addr': '0.0.0.0/0',
'lo_addr_v6': '::/0',
'mgmt_addr': '0.0.0.0/0',
'type': 'SmartCable'
'hwsku': 'smartcable-sku',
'lo_addr': '0.0.0.0/0',
'type': 'SmartCable',
'mgmt_addr_v6': '::/0',
}
}
output = self.run_script(argument)
Expand Down
12 changes: 7 additions & 5 deletions src/sonic-config-engine/tests/test_multinpu_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ def test_frontend_asic_device_neigh(self):
def test_frontend_asic_device_neigh_metadata(self):
argument = "-m {} -p {} -n asic0 --var-json \"DEVICE_NEIGHBOR_METADATA\"".format(self.sample_graph, self.port_config[0])
output = json.loads(self.run_script(argument))
print(output)
self.assertDictEqual(output, \
{'01T2': {'lo_addr': None, 'mgmt_addr': '89.139.132.40', 'hwsku': 'VM', 'type': 'SpineRouter'},
'ASIC3': {'lo_addr': '0.0.0.0/0', 'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'type': 'Asic'},
'ASIC2': {'lo_addr': '0.0.0.0/0', 'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'type': 'Asic'}})
{'01T2': {'mgmt_addr': '89.139.132.40', 'hwsku': 'VM', 'type': 'SpineRouter'},
'ASIC3': {'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'lo_addr': '0.0.0.0/0', 'type': 'Asic', 'mgmt_addr_v6': '::/0'},
'ASIC2': {'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'lo_addr': '0.0.0.0/0', 'type': 'Asic', 'mgmt_addr_v6': '::/0'}})

def test_backend_asic_device_neigh(self):
argument = "-m {} -p {} -n asic3 --var-json \"DEVICE_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
Expand All @@ -267,9 +268,10 @@ def test_backend_asic_device_neigh(self):
def test_backend_device_neigh_metadata(self):
argument = "-m {} -p {} -n asic3 --var-json \"DEVICE_NEIGHBOR_METADATA\"".format(self.sample_graph, self.port_config[3])
output = json.loads(self.run_script(argument))
print(output)
self.assertDictEqual(output, \
{'ASIC1': {'lo_addr': '0.0.0.0/0', 'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'type': 'Asic'},
'ASIC0': {'lo_addr': '0.0.0.0/0', 'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'type': 'Asic'}})
{'ASIC1': {'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'lo_addr': '0.0.0.0/0', 'type': 'Asic', 'mgmt_addr_v6': '::/0'},
'ASIC0': {'lo_addr_v6': '::/0', 'mgmt_addr': '0.0.0.0/0', 'hwsku': 'multi-npu-asic', 'lo_addr': '0.0.0.0/0', 'type': 'Asic', 'mgmt_addr_v6': '::/0'}})

def test_frontend_bgp_neighbor(self):
argument = "-m {} -p {} -n asic0 --var-json \"BGP_NEIGHBOR\"".format(self.sample_graph, self.port_config[0])
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def run(self):
'./yang-models/sonic-default-lossless-buffer-parameter.yang',
'./yang-models/sonic-device_metadata.yang',
'./yang-models/sonic-device_neighbor.yang',
'./yang-models/sonic-device_neighbor_metadata.yang',
'./yang-models/sonic-dhcpv6-relay.yang',
'./yang-models/sonic-extension.yang',
'./yang-models/sonic-flex_counter.yang',
Expand Down Expand Up @@ -170,6 +171,7 @@ def run(self):
'./cvlyang-models/sonic-crm.yang',
'./cvlyang-models/sonic-device_metadata.yang',
'./cvlyang-models/sonic-device_neighbor.yang',
'./cvlyang-models/sonic-device_neighbor_metadata.yang',
'./cvlyang-models/sonic-extension.yang',
'./cvlyang-models/sonic-flex_counter.yang',
'./cvlyang-models/sonic-feature.yang',
Expand Down
20 changes: 20 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,26 @@
"port": "Eth18"
}
},
"DEVICE_NEIGHBOR_METADATA": {
"dccsw01.nw": {
"lo_addr": "0.0.0.0/0",
"mgmt_addr": "10.184.228.211/32",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
"dccsw02.nw": {
"mgmt_addr_v6": "2a04:5555:40:a709::2/128",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
"dccsw03.nw": {
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
}
},
"MGMT_PORT": {
"eth0": {
"alias": "eth0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"DEVICE_NEIGHBOR_METADATA_TABLE": {
"desc": "DEVICE_NEIGHBOR_METADATA_TABLE config pattern."
},
"DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN": {
"desc": "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN pattern failure.",
"eStrKey" : "Pattern"
},
"DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN": {
"desc": "DEVICE_NEIGHBOR_METADATA correct value for Type field"
},
"DEVICE_NEIGHBOR_METADATA_TYPE_NOT_PROVISIONED_PATTERN": {
"desc": "DEVICE_NEIGHBOR_METADATA value as not-provisioned for Type field"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [
{
"name": "Ethernet116",
"hwsku": "Arista",
"type": "ToRrouter"
}
]
}
}
},
"DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [
{
"name": "Ethernet116",
"hwsku": "Arista",
"type": "BackEndToRRouter"
}
]
}
}
},
"DEVICE_NEIGHBOR_METADATA_TYPE_NOT_PROVISIONED_PATTERN": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [
{
"name": "Ethernet116",
"hwsku": "Arista",
"type": "not-provisioned"
}
]
}
}
},
"DEVICE_NEIGHBOR_METADATA_TABLE": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [
{
"lo_addr": "25.77.193.11/32",
"mgmt_addr": "0.0.0.0/0",
"name": "dccsw01.nw",
"hwsku": "Arista",
"type": "ToRRouter",
"deployment_id": "1"
},
{
"lo_addr": "0.0.0.0/0",
"mgmt_addr": "10.11.150.46/26",
"name": "dccsw02.nw",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
{
"lo_addr_v6": "2a04:5555:40:a709::2/126",
"mgmt_addr": "10.11.150.47/26",
"name": "dccsw03.nw",
"hwsku": "Arista",
"type": "SpineRouter",
"deployment_id": "1"
},
{
"name": "dccsw04.nw",
"mgmt_addr_v6": "2a04:5555:40:a708::2/126",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
{
"name": "dccsw05.nw",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
{
"lo_addr_v6": "2a04:5555:40:a710::2/126",
"name": "dccsw06.nw",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
{
"lo_addr": "25.77.193.11/32",
"name": "dccsw07.nw",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
},
{
"mgmt_addr": "10.11.150.48/26",
"name": "dccsw08.nw",
"hwsku": "Arista",
"type": "LeafRouter",
"deployment_id": "1"
}
]
}
}
}
}
Loading