* yang mode support for neighbor metadata * add description in leaf node * modify description Co-authored-by: jcaiMR <111116206+jcaiMR@users.noreply.github.com>
This commit is contained in:
parent
e9a2e1b6a5
commit
1496d1d28c
@ -264,14 +264,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
|
||||
|
||||
@ -395,13 +405,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)
|
||||
|
@ -203,39 +203,40 @@ class TestCfgGenCaseInsensitive(TestCase):
|
||||
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': {
|
||||
'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': {
|
||||
'hwsku': 'server-sku',
|
||||
'lo_addr': '10.10.10.2/32',
|
||||
'lo_addr_v6': 'fe80::0002/128',
|
||||
'lo_addr': '10.10.10.2/32',
|
||||
'mgmt_addr': '10.0.0.2/32',
|
||||
'hwsku': 'server-sku',
|
||||
'type': 'Server'
|
||||
},
|
||||
'server1': {
|
||||
'lo_addr_v6': 'fe80::0001/80',
|
||||
'lo_addr': '10.10.10.1/32',
|
||||
'mgmt_addr': '10.0.0.1/32',
|
||||
'hwsku': 'server-sku',
|
||||
'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)
|
||||
|
@ -250,10 +250,11 @@ class TestMultiNpuCfgGen(TestCase):
|
||||
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])
|
||||
@ -267,9 +268,10 @@ class TestMultiNpuCfgGen(TestCase):
|
||||
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])
|
||||
|
@ -103,6 +103,7 @@ setup(
|
||||
'./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',
|
||||
@ -170,6 +171,7 @@ setup(
|
||||
'./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',
|
||||
|
@ -372,6 +372,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",
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
module sonic-device_neighbor_metadata {
|
||||
|
||||
yang-version 1.1;
|
||||
|
||||
namespace "http://github.com/Azure/sonic-device_neighbor_metadata";
|
||||
prefix device_neighbor_metadata;
|
||||
|
||||
import ietf-yang-types {
|
||||
prefix yang;
|
||||
}
|
||||
|
||||
import ietf-inet-types {
|
||||
prefix inet;
|
||||
}
|
||||
|
||||
import sonic-types {
|
||||
prefix stypes;
|
||||
}
|
||||
|
||||
description "DEVICE_NEIGHBOR_METADATA YANG Module for SONiC OS";
|
||||
|
||||
revision 2022-08-25 {
|
||||
description "First Revision";
|
||||
}
|
||||
|
||||
container sonic-device_neighbor_metadata {
|
||||
|
||||
container DEVICE_NEIGHBOR_METADATA {
|
||||
|
||||
description "DEVICE_NEIGHBOR_METADATA part of config_db.json";
|
||||
|
||||
list DEVICE_NEIGHBOR_METADATA_LIST {
|
||||
|
||||
key "name";
|
||||
|
||||
leaf name {
|
||||
description "Host name string, max length 255";
|
||||
type string {
|
||||
length 1..255;
|
||||
}
|
||||
}
|
||||
|
||||
leaf hwsku {
|
||||
type stypes:hwsku;
|
||||
}
|
||||
|
||||
leaf lo_addr {
|
||||
description "Device loopback ipv4 address, type of ietf-inet
|
||||
ipv4-prefix or ipv4-address";
|
||||
type union {
|
||||
type inet:ipv4-prefix;
|
||||
type inet:ipv4-address;
|
||||
}
|
||||
}
|
||||
|
||||
leaf lo_addr_v6 {
|
||||
description "Device loopback ipv6 address, type of ietf-inet
|
||||
ipv6-prefix or ipv6-address";
|
||||
type union {
|
||||
type inet:ipv6-prefix;
|
||||
type inet:ipv6-address;
|
||||
}
|
||||
}
|
||||
|
||||
leaf mgmt_addr {
|
||||
description "Device management ipv4 address, type of ietf-inet
|
||||
ipv4-prefix or ipv4-address";
|
||||
type union {
|
||||
type inet:ipv4-prefix;
|
||||
type inet:ipv4-address;
|
||||
}
|
||||
}
|
||||
|
||||
leaf mgmt_addr_v6 {
|
||||
description "Device management ipv6 address, type of ietf-inet
|
||||
ipv6-prefix or ipv6-address";
|
||||
type union {
|
||||
type inet:ipv6-prefix;
|
||||
type inet:ipv6-address;
|
||||
}
|
||||
}
|
||||
|
||||
leaf type {
|
||||
description "Network element type";
|
||||
type string {
|
||||
pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC|Asic|Supervior|MgmtToRRouter|SpineRouter|BackEndToRRouter|BackEndLeafRouter|EPMS|MgmtTsToR|BmcMgmtToRRouter|Server|MiniPower|SmartCable|Ixia|not-provisioned";
|
||||
}
|
||||
}
|
||||
|
||||
leaf deployment_id {
|
||||
type uint32;
|
||||
}
|
||||
}
|
||||
/* end of list DEVICE_NEIGHBOR_METADATA_LIST */
|
||||
}
|
||||
/* end of container DEVICE_NEIGHBOR_METADATA */
|
||||
}
|
||||
/* end of container sonic-device_neighbor_metadata */
|
||||
}
|
||||
/* end of module sonic-device_neighbor_metadata */
|
Reference in New Issue
Block a user