diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 3e833b1617e..350882515fb 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -18,6 +18,10 @@ "mtu": "9100" } }, + "PORTCHANNEL_MEMBER": { + "PortChannel0003|Ethernet1": {}, + "PortChannel0004|Ethernet2": {} + }, "VLAN_INTERFACE": { "Vlan111": {}, "Vlan777": {}, diff --git a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py index 973c6ae8dac..c45b6e38fa9 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py +++ b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py @@ -65,6 +65,18 @@ def initTest(self): 'desc': 'Configure a member port in PORT_CHANNEL table.', 'eStr': self.defaultYANGFailure['None'] }, + 'PORTCHANNEL_MEMEBER_WITH_NON_EXIST_PORTCHANNEL': { + 'desc': 'Configure PortChannel in PORTCHANNEL_MEMEBER table \ + which does not exist in PORTCHANNEL table.', + 'eStr': self.defaultYANGFailure['LeafRef'] + \ + ['portchannel', 'name'] + }, + 'PORTCHANNEL_MEMEBER_WITH_NON_EXIST_PORT': { + 'desc': 'Configure Port in PORTCHANNEL_MEMEBER table \ + which does not exist in PORT table.', + 'eStr': self.defaultYANGFailure['LeafRef'] + \ + ['port', 'name'] + }, 'PORTCHANNEL_INTERFACE_IP_ADDR_TEST': { 'desc': 'Configure IP address on PORTCHANNEL_INTERFACE table.', 'eStr': self.defaultYANGFailure['None'] @@ -74,7 +86,7 @@ def initTest(self): 'eStr': self.defaultYANGFailure['LeafRef'] }, 'VLAN_MEMEBER_WITH_NON_EXIST_VLAN': { - 'desc': 'Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN table.', + 'desc': 'Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN table.', 'eStr': self.defaultYANGFailure['LeafRef'] }, 'TAGGING_MODE_WRONG_VALUE': { diff --git a/src/sonic-yang-models/tests/yang_model_tests/yangTest.json b/src/sonic-yang-models/tests/yang_model_tests/yangTest.json index 7300aa6a4aa..b2efdcbd1e6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/yangTest.json +++ b/src/sonic-yang-models/tests/yang_model_tests/yangTest.json @@ -108,6 +108,42 @@ } }, + "PORTCHANNEL_MEMEBER_WITH_NON_EXIST_PORTCHANNEL": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL_MEMBER": { + "PORTCHANNEL_MEMBER_LIST": [{ + "name": "PortChannel0002", + "port": "Ethernet0" + }] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [{ + "name": "Ethernet0", + "speed": 25000, + "lanes": "65" + }] + } + } + }, + "PORTCHANNEL_MEMEBER_WITH_NON_EXIST_PORT": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL_MEMBER": { + "PORTCHANNEL_MEMBER_LIST": [{ + "name": "PortChannel0002", + "port": "Ethernet0" + }] + }, + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [{ + "name": "PortChannel0002", + "admin_status": "up" + }] + } + } + }, + "PORT_CHANNEL_TEST": { "sonic-portchannel:sonic-portchannel": { "sonic-portchannel:PORTCHANNEL": { @@ -1354,4 +1390,3 @@ } } } - diff --git a/src/sonic-yang-models/yang-models/sonic-portchannel.yang b/src/sonic-yang-models/yang-models/sonic-portchannel.yang index 6794da959b2..fe4b6c13dc8 100644 --- a/src/sonic-yang-models/yang-models/sonic-portchannel.yang +++ b/src/sonic-yang-models/yang-models/sonic-portchannel.yang @@ -32,6 +32,7 @@ module sonic-portchannel { container sonic-portchannel { + container PORTCHANNEL { description "PORTCHANNEL part of config_db.json"; @@ -90,6 +91,29 @@ module sonic-portchannel { } /* end of container PORTCHANNEL */ + container PORTCHANNEL_MEMBER { + + description "PORTCHANNEL_MEMBER part of config_db.json"; + + list PORTCHANNEL_MEMBER_LIST { + + key "name port"; + + leaf name { + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + + leaf port { + /* key elements are mandatory by default */ + type leafref { + path /port:sonic-port/port:PORT/port:PORT_LIST/port:name; + } + } + } /* end of list PORTCHANNEL_MEMBER_LIST */ + + } /* end of container PORTCHANNEL_MEMBER */ container PORTCHANNEL_INTERFACE {