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 bc560df6f90..973c6ae8dac 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,14 @@ def initTest(self): 'desc': 'Configure a member port in PORT_CHANNEL table.', 'eStr': self.defaultYANGFailure['None'] }, + 'PORTCHANNEL_INTERFACE_IP_ADDR_TEST': { + 'desc': 'Configure IP address on PORTCHANNEL_INTERFACE table.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'PORTCHANNEL_INTERFACE_IP_ADDR_ON_NON_EXIST_PO': { + 'desc': 'Configure IP address on a non existent PortChannel.', + '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.', 'eStr': self.defaultYANGFailure['LeafRef'] 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 c86fb4f14f7..1210639d7ff 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/yangTest.json +++ b/src/sonic-yang-models/tests/yang_model_tests/yangTest.json @@ -137,6 +137,39 @@ } }, + "PORTCHANNEL_INTERFACE_IP_ADDR_TEST": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [{ + "name": "PortChannel0001", + "admin_status": "up" + }] + }, + "sonic-portchannel:PORTCHANNEL_INTERFACE": { + "PORTCHANNEL_INTERFACE_IPPREFIX_LIST": [{ + "name": "PortChannel0001", + "ip_prefix": "1.1.1.1/24" + }] + } + } + }, + + "PORTCHANNEL_INTERFACE_IP_ADDR_ON_NON_EXIST_PO": { + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [{ + "name": "PortChannel0001" + }] + }, + "sonic-portchannel:PORTCHANNEL_INTERFACE": { + "PORTCHANNEL_INTERFACE_IPPREFIX_LIST": [{ + "name": "PortChannel0002", + "ip_prefix": "2.2.2.2/24" + }] + } + } + }, + "PORT_CHANNEL_WRONG_PATTERN": { "sonic-portchannel:sonic-portchannel": { "sonic-portchannel:PORTCHANNEL": { diff --git a/src/sonic-yang-models/yang-models/sonic-acl.yang b/src/sonic-yang-models/yang-models/sonic-acl.yang index ef7b77c72d6..19c8b048c27 100644 --- a/src/sonic-yang-models/yang-models/sonic-acl.yang +++ b/src/sonic-yang-models/yang-models/sonic-acl.yang @@ -26,7 +26,6 @@ module sonic-acl { import sonic-portchannel { prefix lag; - revision-date 2019-07-01; } description "ACL YANG Module for SONiC OS"; diff --git a/src/sonic-yang-models/yang-models/sonic-portchannel.yang b/src/sonic-yang-models/yang-models/sonic-portchannel.yang index c0abd025f80..0f5d858b2e6 100644 --- a/src/sonic-yang-models/yang-models/sonic-portchannel.yang +++ b/src/sonic-yang-models/yang-models/sonic-portchannel.yang @@ -22,10 +22,15 @@ module sonic-portchannel { description "PORTCHANNEL yang Module for SONiC OS"; + revision 2021-03-15 { + description "Add SONiC PortChannel Interface model"; + } + revision 2019-07-01 { description "First Revision"; } + container sonic-portchannel { container PORTCHANNEL { @@ -89,6 +94,30 @@ module sonic-portchannel { } /* end of container PORTCHANNEL */ + + container PORTCHANNEL_INTERFACE { + + description "PORTCHANNEL_INTERFACE part of config_db.json"; + + list PORTCHANNEL_INTERFACE_IPPREFIX_LIST { + + key "name ip_prefix"; + + leaf name { + /* key elements are mandatory by default */ + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + + leaf ip_prefix { + /* key elements are mandatory by default */ + type stypes:sonic-ip-prefix; + } + } /* end of list PORTCHANNEL_INTERFACE_IPPREFIX_LIST */ + + } /* end of container PORTCHANNEL_INTERFACE */ + } /* end of container sonic-portchannel */ -} /* end of module sonic-port */ +} /* end of module sonic-portchannel */ diff --git a/src/sonic-yang-models/yang-models/sonic-types.yang b/src/sonic-yang-models/yang-models/sonic-types.yang index 0bfcddc5610..93842a11f51 100644 --- a/src/sonic-yang-models/yang-models/sonic-types.yang +++ b/src/sonic-yang-models/yang-models/sonic-types.yang @@ -44,6 +44,13 @@ module sonic-types { } } + typedef sonic-ip-prefix { + type union { + type sonic-ip4-prefix; + type sonic-ip6-prefix; + } + } + typedef admin_status { type enumeration { enum up;