From 054db007711983291bf4ccf40f9d904a202f6339 Mon Sep 17 00:00:00 2001 From: tjchadaga <85581939+tjchadaga@users.noreply.github.com> Date: Tue, 26 Jul 2022 18:27:15 -0700 Subject: [PATCH] Add bgp_device_global yang model (#11343) --- src/sonic-yang-models/doc/Configuration.md | 15 ++++++++ src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 5 +++ .../tests/bgp_device_global.json | 16 ++++++++ .../tests_config/bgp_device_global.json | 38 +++++++++++++++++++ .../yang-models/sonic-bgp-device-global.yang | 36 ++++++++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json create mode 100644 src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index e66927b4a8..6c01344f63 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -9,6 +9,7 @@ Table of Contents * [Incremental Configuration](#incremental-configuration) * [Redis and Json Schema](#redis-and-json-schema) * [ACL and Mirroring](#acl-and-mirroring) + * [BGP Device Global](#bgp-device-global) * [BGP Sessions](#bgp-sessions) * [BUFFER_PG](#buffer_pg) * [Buffer pool](#buffer-pool) @@ -335,7 +336,21 @@ and migration plan } } ``` +### BGP Device Global +The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. +It has a STATE object containing device state like **tsa_enabled** +which is set to true if device is currently isolated using +traffic-shift-away (TSA) route-maps in BGP + +``` +{ +"BGP_DEVICE_GLOBAL": { + "STATE": { + "tsa_enabled": "true" + } +} +``` ### BGP Sessions BGP session configuration is defined in **BGP_NEIGHBOR** table. BGP diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 6a7d78bdf4..6e99873763 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -80,6 +80,7 @@ setup( ('yang-models', ['./yang-models/sonic-acl.yang', './yang-models/sonic-auto_techsupport.yang', './yang-models/sonic-bgp-common.yang', + './yang-models/sonic-bgp-device-global.yang', './yang-models/sonic-bgp-global.yang', './yang-models/sonic-bgp-monitor.yang', './yang-models/sonic-bgp-internal-neighbor.yang', 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 be8e6fb659..332172d925 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1305,6 +1305,11 @@ "default|ipv4_unicast|21.0.0.0/8": { } }, + "BGP_DEVICE_GLOBAL": { + "STATE": { + "tsa_enabled": "false" + } + }, "BGP_PEER_RANGE": { "BGPSLBPassive": { "ip_range": [ diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json new file mode 100644 index 0000000000..536736f82d --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json @@ -0,0 +1,16 @@ +{ + "BGP_DEVICE_GLOBAL_WITH_DEFAULT_VALUES": { + "desc": "Load bgp device global table with fields set to default values" + }, + "BGP_DEVICE_GLOBAL_WITH_TSA_TEST": { + "desc": "Load bgp device global table with tsa_enabled set to true" + }, + "BGP_DEVICE_GLOBAL_WITH_TSB_TEST": { + "desc": "Load bgp device global table with tsa_enabled set to false" + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE": { + "desc": "Load bgp device global table with invalid value", + "eStrKey": "InvalidValue", + "eStr": ["tsa_enabled"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json new file mode 100644 index 0000000000..f96de59df3 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json @@ -0,0 +1,38 @@ +{ + "BGP_DEVICE_GLOBAL_WITH_DEFAULT_VALUES": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "false" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_TSA_TEST": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "true" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_TSB_TEST": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "false" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "FALSE" + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang new file mode 100644 index 0000000000..728714c7d5 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang @@ -0,0 +1,36 @@ +module sonic-bgp-device-global { + namespace "http://github.com/Azure/sonic-bgp-device-global"; + prefix bgp_device_global; + yang-version 1.1; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC Device-specific BGP global data"; + + revision 2022-06-26 { + description + "Initial revision"; + } + + container sonic-bgp-device-global { + container BGP_DEVICE_GLOBAL { + container STATE { + description "BGP device-specific global data"; + leaf tsa_enabled { + type boolean; + default "false"; + description + "When set to true, Traffic is shifted away (TSA), i.e, BGP routes are not advertised to neighboring routers"; + } + } /* end of STATE container */ + } /* end of BGP_DEVICE_GLOBAL container */ + + } /* end of top level container */ + +} /* end of module sonic-bgp-device-global */ +