Fix device type and add cluster in DEVICE_NEIGHBOR_METADATA yang model (#17049) (#17251)

Why I did it
The current DEVICE_NEIGHBOR_METADATA yang model has two issues that would block GCU operation when it checks if the current config aligns with the YANG model:

Missing cluster field in YANG
Incomplete set of device type. The device type in YANG model doesn't include all the device type.
Work item tracking
Microsoft ADO (number only): 25577813
How I did it
Add cluster field in DEVICE_NEIGHBOR_METADATA YANG model.
Change device type to string.
Fix the UT test accordingly.
How to verify it
Build the image and verify the unit tests passed.

Signed-off-by: zitingguo-ms <zitingguo@microsoft.com>
This commit is contained in:
zitingguo-ms 2023-11-28 10:06:37 +08:00 committed by GitHub
parent 03fd20410a
commit edd094593c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 55 deletions

View File

@ -348,6 +348,7 @@
<a:IPPrefix>10.7.0.196/26</a:IPPrefix> <a:IPPrefix>10.7.0.196/26</a:IPPrefix>
</ManagementAddress> </ManagementAddress>
<Hostname>switch2-t0</Hostname> <Hostname>switch2-t0</Hostname>
<ClusterName>DB5PrdApp11</ClusterName>
<HwSku>Force10-S6000</HwSku> <HwSku>Force10-S6000</HwSku>
</Device> </Device>
<Device i:type="LeafRouter"> <Device i:type="LeafRouter">
@ -359,7 +360,8 @@
<DeviceLocation i:nil="true"/> <DeviceLocation i:nil="true"/>
<ManagementAddress xmlns:a="Microsoft.Search.Autopilot.NetMux"> <ManagementAddress xmlns:a="Microsoft.Search.Autopilot.NetMux">
<a:IPPrefix>10.7.0.196/26</a:IPPrefix> <a:IPPrefix>10.7.0.196/26</a:IPPrefix>
</ManagementAddress> </ManagementAddress>
<ClusterName>DB5PrdApp11</ClusterName>
<HwSku>Force10-S6000</HwSku> <HwSku>Force10-S6000</HwSku>
</Device> </Device>
<Device i:type="SmartCable"> <Device i:type="SmartCable">

View File

@ -209,6 +209,7 @@ class TestCfgGenCaseInsensitive(TestCase):
expected_table = { expected_table = {
'switch2-t0': { 'switch2-t0': {
'cluster': 'DB5PrdApp11',
'lo_addr': '25.1.1.10/32', 'lo_addr': '25.1.1.10/32',
'mgmt_addr': '10.7.0.196/26', 'mgmt_addr': '10.7.0.196/26',
'hwsku': 'Force10-S6000', 'hwsku': 'Force10-S6000',
@ -228,7 +229,8 @@ class TestCfgGenCaseInsensitive(TestCase):
'hwsku': 'server-sku', 'hwsku': 'server-sku',
'type': 'Server' 'type': 'Server'
}, },
'switch-01t1': { 'switch-01t1': {
'cluster': 'DB5PrdApp11',
'lo_addr': '10.1.0.186/32', 'lo_addr': '10.1.0.186/32',
'deployment_id': '2', 'deployment_id': '2',
'hwsku': 'Force10-S6000', 'hwsku': 'Force10-S6000',

View File

@ -842,12 +842,14 @@ instance is supported in SONiC.
{ {
"DEVICE_NEIGHBOR_METADATA": { "DEVICE_NEIGHBOR_METADATA": {
"ARISTA01T1": { "ARISTA01T1": {
"cluster": "AAA00PrdStr00",
"lo_addr": "None", "lo_addr": "None",
"mgmt_addr": "10.11.150.45", "mgmt_addr": "10.11.150.45",
"hwsku": "Arista-VM", "hwsku": "Arista-VM",
"type": "LeafRouter" "type": "LeafRouter"
}, },
"ARISTA02T1": { "ARISTA02T1": {
"cluster": "AAA00PrdStr00",
"lo_addr": "None", "lo_addr": "None",
"mgmt_addr": "10.11.150.46", "mgmt_addr": "10.11.150.46",
"hwsku": "Arista-VM", "hwsku": "Arista-VM",

View File

@ -2,17 +2,6 @@
"DEVICE_NEIGHBOR_METADATA_TABLE": { "DEVICE_NEIGHBOR_METADATA_TABLE": {
"desc": "DEVICE_NEIGHBOR_METADATA_TABLE config pattern." "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_INCORRECT_PATTERN_BMC": {
"desc": "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN pattern failure with IncorrectTypeBmc.",
"eStrKey" : "Pattern"
},
"DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": { "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": {
"desc": "DEVICE_NEIGHBOR_METADATA correct value for type field for Bmc" "desc": "DEVICE_NEIGHBOR_METADATA correct value for type field for Bmc"
}, },

View File

@ -1,43 +1,4 @@
{ {
"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_INCORRECT_PATTERN_BMC": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [
{
"name": "Ethernet116",
"hwsku": "DUMMY_BMC_SKU",
"type": "IncorrectTypeBmc"
}
]
}
}
},
"DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": { "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": {
"sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": { "sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": {
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
@ -69,6 +30,7 @@
"sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": {
"DEVICE_NEIGHBOR_METADATA_LIST": [ "DEVICE_NEIGHBOR_METADATA_LIST": [
{ {
"cluster": "AAA00PrdStr00",
"lo_addr": "25.77.193.11/32", "lo_addr": "25.77.193.11/32",
"mgmt_addr": "0.0.0.0/0", "mgmt_addr": "0.0.0.0/0",
"name": "dccsw01.nw", "name": "dccsw01.nw",
@ -77,6 +39,7 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"lo_addr": "0.0.0.0/0", "lo_addr": "0.0.0.0/0",
"mgmt_addr": "10.11.150.46/26", "mgmt_addr": "10.11.150.46/26",
"name": "dccsw02.nw", "name": "dccsw02.nw",
@ -85,6 +48,7 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"lo_addr_v6": "2a04:5555:40:a709::2/126", "lo_addr_v6": "2a04:5555:40:a709::2/126",
"mgmt_addr": "10.11.150.47/26", "mgmt_addr": "10.11.150.47/26",
"name": "dccsw03.nw", "name": "dccsw03.nw",
@ -93,6 +57,7 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"name": "dccsw04.nw", "name": "dccsw04.nw",
"mgmt_addr_v6": "2a04:5555:40:a708::2/126", "mgmt_addr_v6": "2a04:5555:40:a708::2/126",
"hwsku": "Arista", "hwsku": "Arista",
@ -100,12 +65,14 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"name": "dccsw05.nw", "name": "dccsw05.nw",
"hwsku": "Arista", "hwsku": "Arista",
"type": "LeafRouter", "type": "LeafRouter",
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"lo_addr_v6": "2a04:5555:40:a710::2/126", "lo_addr_v6": "2a04:5555:40:a710::2/126",
"name": "dccsw06.nw", "name": "dccsw06.nw",
"hwsku": "Arista", "hwsku": "Arista",
@ -113,6 +80,7 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"lo_addr": "25.77.193.11/32", "lo_addr": "25.77.193.11/32",
"name": "dccsw07.nw", "name": "dccsw07.nw",
"hwsku": "Arista", "hwsku": "Arista",
@ -120,6 +88,7 @@
"deployment_id": "1" "deployment_id": "1"
}, },
{ {
"cluster": "AAA00PrdStr00",
"mgmt_addr": "10.11.150.48/26", "mgmt_addr": "10.11.150.48/26",
"name": "dccsw08.nw", "name": "dccsw08.nw",
"hwsku": "Arista", "hwsku": "Arista",

View File

@ -40,6 +40,11 @@ module sonic-device_neighbor_metadata {
} }
} }
leaf cluster {
description "The switch is a member of this cluster";
type string;
}
leaf hwsku { leaf hwsku {
type stypes:hwsku; type stypes:hwsku;
} }
@ -82,9 +87,7 @@ module sonic-device_neighbor_metadata {
leaf type { leaf type {
description "Network element type"; description "Network element type";
type string { type string;
pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC|Asic|Supervior|MgmtToRRouter|MgmtLeafRouter|SpineRouter|BackEndToRRouter|BackEndLeafRouter|EPMS|MgmtTsToR|BmcMgmtToRRouter|Server|Bmc|MiniPower|SmartCable|Ixia|not-provisioned";
}
} }
leaf deployment_id { leaf deployment_id {