From e147c43dac808a4b48a9bbb3d0de758484123fc4 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Wed, 20 Oct 2021 06:33:05 +0000 Subject: [PATCH 1/8] Add SONiC Yang for static anycast gateway --- src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 14 ++- .../tests/static_anycast_gateway.json | 9 ++ .../tests/yang_model_tests/tests/vlan.json | 7 ++ .../tests_config/static_anycast_gateway.json | 20 ++++ .../yang_model_tests/tests_config/vlan.json | 104 ++++++++++++++++++ .../sonic-static-anycast-gateway.yang | 30 +++++ .../yang-models/sonic-vlan.yang | 8 +- 8 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/static_anycast_gateway.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json create mode 100644 src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 8c19b719e34d..cfd63791294d 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -74,6 +74,7 @@ './yang-models/sonic-vlan.yang', './yang-models/sonic-vrf.yang', './yang-models/sonic-lldp.yang', + './yang-models/sonic-static-anycast-gateway.yang', './yang-models/sonic_yang_tree']), ], zip_safe=False, 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 0778a7a87ad6..edad5a627610 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -38,7 +38,8 @@ }, "VLAN_INTERFACE": { "Vlan111": { - "nat_zone": "0" + "nat_zone": "0", + "static-anycast-gateway": "true" }, "Vlan777": {}, "Vlan111|2a04:5555:45:6709::1/64": { @@ -921,7 +922,7 @@ }, "AAA": { "authentication": { - "login": "local" + "login": "local" } }, "TACPLUS": { @@ -1036,7 +1037,7 @@ }, "PREFIX_SET": { "prefix1": { - } + } }, "PREFIX": { "prefix1|1|10.0.0.0/8|8..16": { @@ -1077,6 +1078,11 @@ "mode": "TRANSMIT", "enabled": "true" } + }, + "SAG": { + "GLOBAL": { + "gwmac": "00:11:22:33:44:55" + } } }, @@ -1086,5 +1092,5 @@ "Error": "This Table is for testing, This Table does not have YANG models." } } - + } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/static_anycast_gateway.json b/src/sonic-yang-models/tests/yang_model_tests/tests/static_anycast_gateway.json new file mode 100644 index 000000000000..900ab226a649 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/static_anycast_gateway.json @@ -0,0 +1,9 @@ +{ + "SAG_GLOBAL_MAC_TEST": { + "desc": "Configure a entry in SAG table." + }, + "SAG_GLOBAL_WITH_INVALID_MAC_TEST": { + "desc": "Configure a invalid MAC address format in SAG table.", + "eStrKey" : "Pattern" + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json index 2d38ef453c32..073f031c347a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json @@ -43,5 +43,12 @@ }, "VLAN_INTERFACE_VALID_NAT_ZONE_RANGE": { "desc": "Configure valid value for nat zone." + }, + "VLAN_INTERFACE_VALID_STATIC_ANYCAST_GATEWAY": { + "desc": "Configure valid value for static anycast gateway" + }, + "VLAN_INTERFACE_INVALID_STATIC_ANYCAST_GATEWAY": { + "desc": "Configure invalid value for static anycast gateway", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json new file mode 100644 index 000000000000..ec13ab9f3cdf --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json @@ -0,0 +1,20 @@ +{ + "SAG_GLOBAL_MAC_TEST": { + "sonic-static-anycast-gateway:sonic-static-anycast-gateway": { + "sonic-static-anycast-gateway:SAG": { + "sonic-static-anycast-gateway:GLOBAL": { + "gwmac": "00:11:22:33:44:55" + } + } + } + }, + "SAG_GLOBAL_WITH_INVALID_MAC_TEST": { + "sonic-static-anycast-gateway:sonic-static-anycast-gateway": { + "sonic-static-anycast-gateway:SAG": { + "sonic-static-anycast-gateway:GLOBAL": { + "gwmac": "001122334455" + } + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json index 0faa3926b21e..411dfc77b3f3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json @@ -367,5 +367,109 @@ ] } } + }, + "VLAN_INTERFACE_VALID_STATIC_ANYCAST_GATEWAY": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "mtu": 9000, + "lanes": "1", + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "description": "vlan_nat", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "10.0.0.1/24", + "scope": "global", + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100", + "static-anycast-gateway": "true" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_STATIC_ANYCAST_GATEWAY": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "mtu": 9000, + "lanes": "1", + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "description": "vlan_nat", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "10.0.0.1/24", + "scope": "global", + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100", + "static-anycast-gateway": "enabled" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang b/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang new file mode 100644 index 000000000000..b7dc752c1581 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang @@ -0,0 +1,30 @@ +module sonic-static-anycast-gateway { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-static-anycast-gateway"; + prefix sag; + + import ietf-yang-types { + prefix yang; + } + + description "SAG yang Module for SONiC OS"; + + revision 2021-10-20 { + description + "Initial version"; + } + + container sonic-static-anycast-gateway { + container SAG { + container GLOBAL { + description "Global static anycast gateway configuration"; + + leaf gwmac { + type yang:mac-address; + } + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index c63bc6b46ac4..ecc4e9474b3a 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -87,6 +87,12 @@ module sonic-vlan { enum disable; } } + + leaf static-anycast-gateway { + description "Enable/disable static anycast gateway for the vlan interface"; + type boolean; + default false; + } } /* end of VLAN_INTERFACE_LIST */ @@ -144,7 +150,7 @@ module sonic-vlan { list VLAN_LIST { key "name"; - + leaf name { type string { pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; From e132699dbaa28860873eefd5830d885480142328 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Wed, 20 Oct 2021 06:46:11 +0000 Subject: [PATCH 2/8] Fix yang indent format --- src/sonic-yang-models/yang-models/sonic-vlan.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index ecc4e9474b3a..add92105d4b4 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -92,7 +92,7 @@ module sonic-vlan { description "Enable/disable static anycast gateway for the vlan interface"; type boolean; default false; - } + } } /* end of VLAN_INTERFACE_LIST */ From 622c18ae2dc27b9de3260fabbbbeb3ac072e1959 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Wed, 3 Nov 2021 01:26:46 +0000 Subject: [PATCH 3/8] Refine field name for consistency --- src/sonic-yang-models/tests/files/sample_config_db.json | 4 ++-- .../yang_model_tests/tests_config/static_anycast_gateway.json | 4 ++-- .../tests/yang_model_tests/tests_config/vlan.json | 4 ++-- .../yang-models/sonic-static-anycast-gateway.yang | 2 +- src/sonic-yang-models/yang-models/sonic-vlan.yang | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) 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 c1cee1df5f06..433163681e00 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -39,7 +39,7 @@ "VLAN_INTERFACE": { "Vlan111": { "nat_zone": "0", - "static-anycast-gateway": "true" + "static_anycast_gateway": "true" }, "Vlan777": {}, "Vlan111|2a04:5555:45:6709::1/64": { @@ -1092,7 +1092,7 @@ }, "SAG": { "GLOBAL": { - "gwmac": "00:11:22:33:44:55" + "gateway_mac": "00:11:22:33:44:55" } }, "FEATURE": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json index ec13ab9f3cdf..287121bdea0a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/static_anycast_gateway.json @@ -3,7 +3,7 @@ "sonic-static-anycast-gateway:sonic-static-anycast-gateway": { "sonic-static-anycast-gateway:SAG": { "sonic-static-anycast-gateway:GLOBAL": { - "gwmac": "00:11:22:33:44:55" + "gateway_mac": "00:11:22:33:44:55" } } } @@ -12,7 +12,7 @@ "sonic-static-anycast-gateway:sonic-static-anycast-gateway": { "sonic-static-anycast-gateway:SAG": { "sonic-static-anycast-gateway:GLOBAL": { - "gwmac": "001122334455" + "gateway_mac": "001122334455" } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json index 411dfc77b3f3..92b09246587e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json @@ -414,7 +414,7 @@ "VLAN_INTERFACE_LIST": [ { "name": "Vlan100", - "static-anycast-gateway": "true" + "static_anycast_gateway": "true" } ] } @@ -466,7 +466,7 @@ "VLAN_INTERFACE_LIST": [ { "name": "Vlan100", - "static-anycast-gateway": "enabled" + "static_anycast_gateway": "enabled" } ] } diff --git a/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang b/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang index b7dc752c1581..9857b6eaffc7 100644 --- a/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang +++ b/src/sonic-yang-models/yang-models/sonic-static-anycast-gateway.yang @@ -21,7 +21,7 @@ module sonic-static-anycast-gateway { container GLOBAL { description "Global static anycast gateway configuration"; - leaf gwmac { + leaf gateway_mac { type yang:mac-address; } } diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index add92105d4b4..944a2872c428 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -88,7 +88,7 @@ module sonic-vlan { } } - leaf static-anycast-gateway { + leaf static_anycast_gateway { description "Enable/disable static anycast gateway for the vlan interface"; type boolean; default false; From f2f94a337ed4a1329da5f102443947ea3165df16 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Fri, 14 Jan 2022 06:35:33 +0000 Subject: [PATCH 4/8] Unified indentation to spaces --- .../yang-models/sonic-vlan.yang | 491 +++++++++--------- 1 file changed, 246 insertions(+), 245 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index 956b9a262bc0..74dc89a16f80 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -2,254 +2,255 @@ module sonic-vlan { yang-version 1.1; - namespace "http://github.com/Azure/sonic-vlan"; - prefix vlan; - - import ietf-inet-types { - prefix inet; - } - - import ietf-yang-types { - prefix yang; - } - - import sonic-types { - prefix stypes; - } - - import sonic-extension { - prefix ext; - } - - import sonic-port { - prefix port; - revision-date 2019-07-01; - } - - import sonic-portchannel { - prefix lag; - } - - import sonic-vrf { - prefix vrf; - } - - description "VLAN yang Module for SONiC OS"; - - revision 2021-04-22 { - description "Modify Vlan Member to include PortChannel along with Port"; - } - - revision 2021-03-30 { - description "Modify the type of vrf name"; - } - - revision 2019-07-01 { - description "First Revision"; - } - - container sonic-vlan { - - container VLAN_INTERFACE { - - description "VLAN_INTERFACE part of config_db.json"; - - list VLAN_INTERFACE_LIST { - - description "VLAN INTERFACE part of config_db.json with vrf"; - - key "name"; - - leaf name { - type leafref { - path /vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name; - } - } - - leaf vrf_name { - type leafref{ - path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; - } - } - - leaf nat_zone { - description "NAT Zone for the vlan interface"; - type uint8 { - range "0..3" { - error-message "Invalid nat zone for the vlan interface."; - error-app-tag nat-zone-invalid; - } - } - default "0"; - } - leaf mpls { - description "Enable/disable MPLS routing for the vlan interface"; - type enumeration { - enum enable; - enum disable; - } - } - - leaf static_anycast_gateway { - description "Enable/disable static anycast gateway for the vlan interface"; - type boolean; - default false; + namespace "http://github.com/Azure/sonic-vlan"; + prefix vlan; + + import ietf-inet-types { + prefix inet; + } + + import ietf-yang-types { + prefix yang; + } + + import sonic-types { + prefix stypes; + } + + import sonic-extension { + prefix ext; + } + + import sonic-port { + prefix port; + revision-date 2019-07-01; + } + + import sonic-portchannel { + prefix lag; + } + + import sonic-vrf { + prefix vrf; + } + + description "VLAN yang Module for SONiC OS"; + + revision 2021-04-22 { + description "Modify Vlan Member to include PortChannel along with Port"; + } + + revision 2021-03-30 { + description "Modify the type of vrf name"; + } + + revision 2019-07-01 { + description "First Revision"; + } + + container sonic-vlan { + + container VLAN_INTERFACE { + + description "VLAN_INTERFACE part of config_db.json"; + + list VLAN_INTERFACE_LIST { + + description "VLAN INTERFACE part of config_db.json with vrf"; + + key "name"; + + leaf name { + type leafref { + path /vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name; + } + } + + leaf vrf_name { + type leafref{ + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + } + + leaf nat_zone { + description "NAT Zone for the vlan interface"; + type uint8 { + range "0..3" { + error-message "Invalid nat zone for the vlan interface."; + error-app-tag nat-zone-invalid; + } + } + default "0"; + } + + leaf mpls { + description "Enable/disable MPLS routing for the vlan interface"; + type enumeration { + enum enable; + enum disable; + } + } + + leaf static_anycast_gateway { + description "Enable/disable static anycast gateway for the vlan interface"; + type boolean; + default false; + } + + leaf grat_arp { + type string { + pattern "enabled|disabled"; + } + } + + leaf proxy_arp { + type string { + pattern "enabled|disabled"; + } + } + } + /* end of VLAN_INTERFACE_LIST */ + + list VLAN_INTERFACE_IPPREFIX_LIST { + + key "name ip-prefix"; + + leaf name { + /* This node must be present in VLAN_INTERFACE_LIST */ + must "(current() = ../../VLAN_INTERFACE_LIST[name=current()]/name)" + { + error-message "Must condition not satisfied, Try adding Vlan: {}, Example: 'Vlan100': {}"; + } + + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + } + } + + leaf ip-prefix { + type union { + type stypes:sonic-ip4-prefix; + type stypes:sonic-ip6-prefix; + } + } + + leaf scope { + type enumeration { + enum global; + enum local; + } + } + + leaf family { + + /* family leaf needed for backward compatibility + Both ip4 and ip6 address are string in IETF RFC 6021, + so must statement can check based on : or ., family + should be IPv4 or IPv6 according. + */ + + must "(contains(../ip-prefix, ':') and current()='IPv6') or + (contains(../ip-prefix, '.') and current()='IPv4')"; + type stypes:ip-family; + } + } + /* end of VLAN_INTERFACE_LIST */ } - - leaf grat_arp { - type string { - pattern "enabled|disabled"; - } - } - - leaf proxy_arp { - type string { - pattern "enabled|disabled"; - } - } - } - /* end of VLAN_INTERFACE_LIST */ - - list VLAN_INTERFACE_IPPREFIX_LIST { - - key "name ip-prefix"; - - leaf name { - /* This node must be present in VLAN_INTERFACE_LIST */ - must "(current() = ../../VLAN_INTERFACE_LIST[name=current()]/name)" - { - error-message "Must condition not satisfied, Try adding Vlan: {}, Example: 'Vlan100': {}"; - } - - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - } - } - - leaf ip-prefix { - type union { - type stypes:sonic-ip4-prefix; - type stypes:sonic-ip6-prefix; - } - } - - leaf scope { - type enumeration { - enum global; - enum local; - } - } - - leaf family { - - /* family leaf needed for backward compatibility - Both ip4 and ip6 address are string in IETF RFC 6021, - so must statement can check based on : or ., family - should be IPv4 or IPv6 according. - */ - - must "(contains(../ip-prefix, ':') and current()='IPv6') or - (contains(../ip-prefix, '.') and current()='IPv4')"; - type stypes:ip-family; - } - } - /* end of VLAN_INTERFACE_LIST */ - } - /* end of VLAN_INTERFACE container */ - - container VLAN { - - description "VLAN part of config_db.json"; - - list VLAN_LIST { - - key "name"; - - leaf name { - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; - } - } - - leaf vlanid { - type uint16 { - range 1..4094; - } - } - - leaf alias { - type string; - } - - leaf description { - type string { - length 1..255; - } - } - - leaf-list dhcp_servers { - description "Configure the dhcp v4 servers"; - type inet:ip-address; - } - - leaf-list dhcpv6_servers { - description "Configure the dhcp v6 servers"; - type inet:ipv6-address; - } - - leaf mtu { - type uint16 { - range 1..9216; - } - } - - leaf admin_status { - type stypes:admin_status; - } - - leaf mac { - type yang:mac-address; - } - } - /* end of VLAN_LIST */ - } - /* end of container VLAN */ - - container VLAN_MEMBER { - - description "VLAN_MEMBER part of config_db.json"; - - list VLAN_MEMBER_LIST { - - key "name port"; - - leaf name { - type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - } - } - - leaf port { - /* key elements are mandatory by default */ - type union { - type leafref { - path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; - } - type leafref { - path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; - } - } - } - - leaf tagging_mode { - mandatory true; - type stypes:vlan_tagging_mode; - } - } + /* end of VLAN_INTERFACE container */ + + container VLAN { + + description "VLAN part of config_db.json"; + + list VLAN_LIST { + + key "name"; + + leaf name { + type string { + pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + } + } + + leaf vlanid { + type uint16 { + range 1..4094; + } + } + + leaf alias { + type string; + } + + leaf description { + type string { + length 1..255; + } + } + + leaf-list dhcp_servers { + description "Configure the dhcp v4 servers"; + type inet:ip-address; + } + + leaf-list dhcpv6_servers { + description "Configure the dhcp v6 servers"; + type inet:ipv6-address; + } + + leaf mtu { + type uint16 { + range 1..9216; + } + } + + leaf admin_status { + type stypes:admin_status; + } + + leaf mac { + type yang:mac-address; + } + } + /* end of VLAN_LIST */ + } + /* end of container VLAN */ + + container VLAN_MEMBER { + + description "VLAN_MEMBER part of config_db.json"; + + list VLAN_MEMBER_LIST { + + key "name port"; + + leaf name { + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + } + } + + leaf port { + /* key elements are mandatory by default */ + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + } + + leaf tagging_mode { + mandatory true; + type stypes:vlan_tagging_mode; + } + } /* end of list VLAN_MEMBER_LIST */ - } + } /* end of container VLAN_MEMBER */ - } + } /* end of container sonic-vlan */ } /* end of module sonic-vlan */ From d102127fb69c731defcb42e42fa7e33a8a4e1906 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Thu, 20 Jan 2022 02:26:22 +0000 Subject: [PATCH 5/8] Add revision for modified yang model --- src/sonic-yang-models/yang-models/sonic-vlan.yang | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index 74dc89a16f80..fe388cac6382 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -23,7 +23,6 @@ module sonic-vlan { import sonic-port { prefix port; - revision-date 2019-07-01; } import sonic-portchannel { @@ -36,6 +35,10 @@ module sonic-vlan { description "VLAN yang Module for SONiC OS"; + revision 2022-01-20 { + description "Add SAG support"; + } + revision 2021-04-22 { description "Modify Vlan Member to include PortChannel along with Port"; } From e7f4ed67d1117aecfe0ddaf60a7bebc9bddf9490 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Thu, 31 Mar 2022 06:33:20 +0000 Subject: [PATCH 6/8] Fix yang-model test failed --- src/sonic-yang-models/tests/files/sample_config_db.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 77a9de5c934a..9d7eeadaa64f 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1327,6 +1327,11 @@ "rfc6939_support": "true" } }, + "SAG": { + "GLOBAL": { + "gateway_mac": "00:11:22:33:44:55" + } + }, "SCHEDULER": { "TEST@0": { "cbs": "256", @@ -1337,7 +1342,6 @@ "type": "DWRR", "weight": "20" }, - "TEST@1": { "cbs": "1024", "cir": "1280000", From 800000fcf31140f1e8c312c8cbc5ed1a0f063715 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Thu, 15 Jun 2023 09:32:15 +0000 Subject: [PATCH 7/8] Fix sonic-yang-mgmt test error --- src/sonic-yang-models/tests/files/sample_config_db.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 28756987089e..387d246d1a93 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -138,7 +138,7 @@ "VLAN_INTERFACE": { "Vlan111": { "nat_zone": "0", - "static_anycast_gateway": "true" + "static_anycast_gateway": "true", "loopback_action": "forward" }, "Vlan777": {}, From 93c2349cd26b3589d3875d9fc127d40dfcc50df3 Mon Sep 17 00:00:00 2001 From: Jimi Chen Date: Mon, 19 Jun 2023 05:56:10 +0000 Subject: [PATCH 8/8] Remove duplicated content and fix indent --- .../tests/files/sample_config_db.json | 5 --- .../yang-models/sonic-vlan.yang | 40 +++++++++---------- 2 files changed, 20 insertions(+), 25 deletions(-) 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 c74485a9c783..317105701638 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1744,11 +1744,6 @@ "enabled": "true" } }, - "SAG": { - "GLOBAL": { - "gateway_mac": "00:11:22:33:44:55" - } - }, "FEATURE": { "bgp": { "auto_restart": "enabled", diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index c3ce52ad8f2b..b43ec65a1ba0 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -1,8 +1,8 @@ module sonic-vlan { - yang-version 1.1; + yang-version 1.1; - namespace "http://github.com/sonic-net/sonic-vlan"; + namespace "http://github.com/sonic-net/sonic-vlan"; prefix vlan; import ietf-inet-types { @@ -36,9 +36,9 @@ module sonic-vlan { description "VLAN yang Module for SONiC OS"; - revision 2023-02-13 { - description "Add SAG support"; - } + revision 2023-02-13 { + description "Add SAG support"; + } revision 2021-04-22 { description "Modify Vlan Member to include PortChannel along with Port"; @@ -106,16 +106,16 @@ module sonic-vlan { } } - leaf loopback_action { - description "Packet action when a packet ingress and gets routed on the same IP interface"; - type stypes:loopback_action; - } - - leaf static_anycast_gateway { - description "Enable/disable static anycast gateway for the vlan interface"; - type boolean; - default false; - } + leaf loopback_action { + description "Packet action when a packet ingress and gets routed on the same IP interface"; + type stypes:loopback_action; + } + + leaf static_anycast_gateway { + description "Enable/disable static anycast gateway for the vlan interface"; + type boolean; + default false; + } leaf ipv6_use_link_local_only { description "Enable/Disable IPv6 link local address on vlan interface"; @@ -261,10 +261,10 @@ module sonic-vlan { type stypes:vlan_tagging_mode; } } - /* end of list VLAN_MEMBER_LIST */ - } - /* end of container VLAN_MEMBER */ - } - /* end of container sonic-vlan */ + /* end of list VLAN_MEMBER_LIST */ + } + /* end of container VLAN_MEMBER */ + } + /* end of container sonic-vlan */ } /* end of module sonic-vlan */