diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json index 33f87167d68..6ed1e7aa299 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json @@ -10,6 +10,17 @@ "NEIGH_INVALID_VLAN": { "desc": "Load NEIGH missing VLAN", - "eStr": ["does not satisfy the constraint"] + "eStrKey": "InvalidValue", + "eStr": ["port"] + }, + + "VALID_NEIGH_PORTCHANNEL": { + "desc": "Load valid PORTCHANNEL" + }, + + "NEIGH_INVALID_PORTCHANNEL": { + "desc": "Load NEIGH missing PORTCHANNEL", + "eStrKey": "InvalidValue", + "eStr": ["port"] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json index 165bbb6b864..b2d532e71d4 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json @@ -13,13 +13,13 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.3", "neigh": "00:02:02:03:04:05", "family": "IPv4" }, { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.4", "family": "IPv4" } @@ -42,7 +42,7 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "Vlan1000", + "port": "Vlan1000", "neigh": "00:02:02:03:04:05", "family": "IPv4" } @@ -56,18 +56,73 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "INVALIDVlan", + "port": "INVALIDVlan", "neighbor": "100.1.1.3", "neigh": "00:02:02:03:04:05", "family": "IPv4" }, { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.4", "family": "IPv4" } ] } } + }, + + "VALID_NEIGH_PORTCHANNEL": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "port": "PortChannel1024", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + }, + { + "port": "PortChannel1024", + "neighbor": "100.1.1.4", + "family": "IPv4" + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "name": "PortChannel1024" + } + ] + } + } + }, + + "NEIGH_INVALID_PORTCHANNEL": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "port": "PortChannel10", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "name": "PortChannel11" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-neigh.yang b/src/sonic-yang-models/yang-models/sonic-neigh.yang index 32e6065b16b..85220ee7f21 100644 --- a/src/sonic-yang-models/yang-models/sonic-neigh.yang +++ b/src/sonic-yang-models/yang-models/sonic-neigh.yang @@ -11,6 +11,9 @@ module sonic-neigh { prefix yang; } + import sonic-portchannel { + prefix lag; + } // TODO: Uncomment the following lines when sonic-vlan.yang is available // import sonic-vlan { // prefix svlan; @@ -29,18 +32,22 @@ module sonic-neigh { container NEIGH { description "NEIGH configuration"; list NEIGH_LIST { - key "vlan neighbor"; + key "port neighbor"; - leaf vlan { - // TODO: Remove the following lines when sonic-vlan.yang is available - description "Neighbor Vlan interface ex. Vlan1000"; - type string { - pattern "Vlan[0-9]+"; + leaf port { + description "Neighbor interface ex. Vlan1000, PortChannel1024"; + type union { + type leafref { + path /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name; + } + type string { + pattern "Vlan[0-9]+"; + } + // TODO: Uncomment the following lines when sonic-vlan.yang is available + // type leafref { + // path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; + // } } - // TODO: Uncomment the following lines when sonic-vlan.yang is available - // type leafref { - // path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; - // } } leaf neighbor {