From cc36a145cbff85453f29885737a46c2062c20b99 Mon Sep 17 00:00:00 2001 From: ArthiSivanantham Date: Sun, 28 Mar 2021 00:51:11 -0700 Subject: [PATCH] [yang]: SONiC Yang model for PORTCHANNEL_INTERFACE table (#7034) * SONiC Yang model for PORTCHANNEL_INTERFACE table Signed-off-by: Arthi Sivanantham --- .../tests/yang_model_tests/test_yang_model.py | 8 +++++ .../tests/yang_model_tests/yangTest.json | 33 +++++++++++++++++++ .../yang-models/sonic-acl.yang | 1 - .../yang-models/sonic-portchannel.yang | 31 ++++++++++++++++- .../yang-models/sonic-types.yang | 7 ++++ 5 files changed, 78 insertions(+), 2 deletions(-) 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 bc560df6f..973c6ae8d 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 @@ class Test_yang_models: '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 974bbd6d2..7300aa6a4 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 7e9db71ed..83318a744 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 f4444fa62..6794da959 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 { @@ -85,6 +90,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 0bfcddc56..93842a11f 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;