diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 1f9b51b0c5..e0bacac194 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -84,6 +84,7 @@ setup( './yang-models/sonic-bgp-monitor.yang', './yang-models/sonic-bgp-neighbor.yang', './yang-models/sonic-bgp-peergroup.yang', + './yang-models/sonic-bgp-peerrange.yang', './yang-models/sonic-breakout_cfg.yang', './yang-models/sonic-buffer-pg.yang', './yang-models/sonic-buffer-pool.yang', @@ -150,6 +151,7 @@ setup( './cvlyang-models/sonic-bgp-monitor.yang', './cvlyang-models/sonic-bgp-neighbor.yang', './cvlyang-models/sonic-bgp-peergroup.yang', + './cvlyang-models/sonic-bgp-peerrange.yang', './cvlyang-models/sonic-breakout_cfg.yang', './cvlyang-models/sonic-copp.yang', './cvlyang-models/sonic-crm.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 e64b241349..e46d0acc1f 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1147,6 +1147,24 @@ "default|ipv4_unicast|21.0.0.0/8": { } }, + "BGP_PEER_RANGE": { + "BGPSLBPassive": { + "ip_range": [ + "10.255.0.0/25" + ], + "name": "BGPSLBPassive", + "src_address": "10.1.0.32" + }, + "BGPVac": { + "ip_range": [ + "192.168.0.0/21", + "192.169.0.0/21", + "192.170.0.0/21" + ], + "name": "BGPVac", + "src_address": "10.1.0.32" + } + }, "BGP_MONITORS": { "5.6.7.8": { "admin_status": "up", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index a8b003c3b9..8f92f2d905 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -154,6 +154,9 @@ "BGP_MONITORS_NEG_INVALID_ASN": { "desc": "Invalid local AS number.", "eStrKey" : "InvalidValue" + }, + "BGP_PEERRANGE_ALL_VALID": { + "desc": "Configure BGP peer range table." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index 3fec22eb46..62bfdc4269 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -1402,6 +1402,24 @@ ] } } + }, + + "BGP_PEERRANGE_ALL_VALID": { + "sonic-bgp-peerrange:sonic-bgp-peerrange": { + "sonic-bgp-peerrange:BGP_PEER_RANGE": { + "BGP_PEER_RANGE_LIST": [ + { + "peer_range_name": "BGPSLBPassive", + "name": "BGPSLBPassive", + "src_address": "10.1.0.32", + "peer_asn": "65200", + "ip_range": [ + "10.255.0.0/25" + ] + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-peerrange.yang b/src/sonic-yang-models/yang-models/sonic-bgp-peerrange.yang new file mode 100644 index 0000000000..88d39d82d6 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-peerrange.yang @@ -0,0 +1,64 @@ +module sonic-bgp-peerrange { + namespace "http://github.com/Azure/sonic-bgp-peerrange"; + prefix pr; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-types { + prefix stypes; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP Peer Range YANG"; + + revision 2022-02-24 { + description + "Initial revision."; + } + + container sonic-bgp-peerrange { + container BGP_PEER_RANGE { + list BGP_PEER_RANGE_LIST { + key "peer_range_name"; + + leaf peer_range_name { + type string; + description "Peer range name"; + } + + leaf name { + type string; + must "(current() = current()/../peer_range_name)" { + error-message "Invalid name"; + } + } + + leaf src_address { + type inet:ip-address; + description "Source address to use for connection"; + } + + leaf peer_asn { + type uint32 { + range "1..4294967295"; + } + description "Peer AS number"; + } + + leaf-list ip_range { + type stypes:sonic-ip-prefix; + description "A range of addresses"; + } + } + } + } +}