diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index c35cb197156d..b5b4b2f3394c 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -447,7 +447,7 @@ RUN pip3 install "PyYAML==5.4.1" RUN pip3 install "lxml==4.6.2" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip3 install pexpect==4.8.0 diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 4987c143f542..44f7410df460 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -466,7 +466,7 @@ RUN pip2 install "lxml==4.6.5" RUN pip3 install "lxml==4.6.5" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip2 install pexpect==4.6.0 diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index 6d5009b313a2..93c6d21d41e4 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -371,7 +371,7 @@ RUN pip3 install "lxml==4.6.5" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip2 install pexpect==4.6.0 diff --git a/src/sonic-host-services/host_modules/showtech.py b/src/sonic-host-services/host_modules/showtech.py new file mode 100644 index 000000000000..2b603d4f52d3 --- /dev/null +++ b/src/sonic-host-services/host_modules/showtech.py @@ -0,0 +1,50 @@ +"""Show techsupport command handler""" + +import host_service +import subprocess +import re + +MOD_NAME = 'showtech' + +class Showtech(host_service.HostModule): + """DBus endpoint that executes the "show techsupport" command + """ + @host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is') + def info(self, date): + + ERROR_TAR_FAILED = 5 + ERROR_PROCFS_SAVE_FAILED = 6 + ERROR_INVALID_ARGUMENT = 10 + + err_dict = {ERROR_INVALID_ARGUMENT: 'Invalid input: Incorrect DateTime format', + ERROR_TAR_FAILED: 'Failure saving information into compressed output file', + ERROR_PROCFS_SAVE_FAILED: 'Saving of process information failed'} + + cmd = ['/usr/local/bin/generate_dump'] + if date: + cmd.append("-s") + cmd.append(date) + + try: + result = subprocess.run(cmd, capture_output=True, text=True, + check=True) + + except subprocess.CalledProcessError as err: + errmsg = err_dict.get(err.returncode) + + if errmsg is None: + output = 'Error: Failure code {:-5}'.format(err.returncode) + else: + output = errmsg + + print("%Error: Host side: Failed: " + str(err.returncode)) + return err.returncode, output + + output_file_match = re.search('\/var\/.*dump.*\.gz', result.stdout) + output_filename = output_file_match.group() + return result.returncode, output_filename + +def register(): + """Return the class name""" + return Showtech, MOD_NAME + diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 1cf2e990ef7b..70c14476e277 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -122,6 +122,7 @@ def run(self): './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', './yang-models/sonic-vrf.yang', + './yang-models/sonic-vlan-sub-interface.yang', './yang-models/sonic-warm-restart.yang', './yang-models/sonic-lldp.yang', './yang-models/sonic-scheduler.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 455eed24b01d..fd3476d6dd21 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -688,6 +688,15 @@ "speed": "11100", "tpid": "0x8100", "admin_status": "up" + }, + "Ethernet120": { + "alias": "Eth31/1", + "lanes": "121,122", + "description": "", + "fec": "fc", + "speed": "11100", + "tpid": "0x8100", + "admin_status": "up" } }, "ACL_TABLE": { @@ -845,6 +854,13 @@ "family": "IPv4" } }, + "VLAN_SUB_INTERFACE": { + "Ethernet120.10": { + "admin_status": "up" + }, + "Ethernet120.10|10.0.1.56/31": {}, + "Ethernet120.10|fc00::1:71/126": {} + }, "VLAN_MEMBER": { "Vlan111|Ethernet0": { "tagging_mode": "untagged" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json index 62ebf55b6867..070495b8df33 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json @@ -60,6 +60,27 @@ }, "DEVICE_METADATA_CORRECT_CLOUDTYPE_REGION_CONFIG": { "desc": "Verifying cloudtype and region configuration." - } + }, + "DEVICE_METADATA_VALID_SUBTYPE": { + "desc": "Verifying valid subtype value" + }, + "DEVICE_METADATA_INVALID_SUBTYPE": { + "desc": "Verifying invalid subtype value", + "eStrKey": "Pattern" + }, + "DEVICE_METADATA_VALID_PEER_SWITCH": { + "desc": "Verifying valid peer switch hostname" + }, + "DEVICE_METADATA_INVALID_PEER_SWITCH": { + "desc": "Verifying test fails with hostname that is too long", + "eStrKey": "Range" + }, + "DEVICE_METADATA_VALID_STORAGE_DEVICE": { + "desc": "Verifying valid storage device value" + }, + "DEVICE_METADATA_INVALID_STORAGE_DEVICE": { + "desc": "Verifying invalid storage device value", + "eStrKey": "InvalidValue" + } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json index 174dcc4de716..f936d7a0b80d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json @@ -66,5 +66,12 @@ "desc": "PORT_INVALID_TPID_TEST invalid tpid value failure.", "eStrKey" : "Pattern", "eStr": ["0x8100|0x9100|0x9200|0x88a8|0x88A8"] + }, + "PORT_VALID_MUX_CABLE_TEST": { + "desc": "PORT_VALID_MUX_CABLE_TEST no failure." + }, + "PORT_INVALID_MUX_CABLE_TEST": { + "desc": "PORT_INVALID_MUX_CABLE_TEST non-boolean values, expect fail", + "eStrKey": "InvalidValue" } } 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 7f898d297c07..a872784ff236 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 @@ -56,5 +56,23 @@ }, "DHCPV6_SERVER_VALID_FORMAT": { "desc": "Add dhcpv6_server in correct format." + }, + "INVALID_VLAN_MAC": { + "desc": "VLAN with invalid MAC address", + "eStrKey": "Pattern" + }, + "VLAN_INTERFACE_VALID_GRAT_ARP": { + "desc": "VLAN_INTERFACE with valid grat_arp value" + }, + "VLAN_INTERFACE_VALID_PROXY_ARP": { + "desc": "VLAN_INTERFACE with valid proxy_arp value" + }, + "VLAN_INTERFACE_INVALID_GRAT_ARP": { + "desc": "VLAN_INTERFACE with invalid grat_arp value", + "eStrKey": "Pattern" + }, + "VLAN_INTERFACE_INVALID_PROXY_ARP": { + "desc": "VLAN_INTERFACE with invalid proxy_arp value", + "eStrKey": "Pattern" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json new file mode 100644 index 000000000000..789b7ddd364a --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json @@ -0,0 +1,29 @@ +{ + "VLAN_SUB_INTERFACE_MUST_CONDITION_TRUE_TEST": { + "desc": "Configure valid vlan sub interface must condition true." + }, + "VLAN_SUB_INTERFACE_MUST_CONDITION_FALSE_TEST": { + "desc": "Configure vlan sub interface must condition false.", + "eStrKey": "Must" + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_PORT_NON_EXISTING_LEAF_TEST": { + "desc": "Configure ip prefix vlan sub interface with non-existing reference.", + "eStrKey": "LeafRef" + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_TEST": { + "desc": "Configure vlan sub interface with invalid vlan id.", + "eStrKey": "Pattern" + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_WITH_LEADING_ZERO_TEST": { + "desc": "Configure vlan sub interface with invalid vlan id with leading zeros.", + "eStrKey": "Pattern" + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_EMPTY_STRING_TEST": { + "desc": "Configure ip prefix vlan sub interface with empty ip prefx.", + "eStrKey": "InvalidValue" + }, + "VLAN_SUB_INTERFACE_INVALID_NAME_TEST": { + "desc": "Configure invalid vlan sub interface name with no separator.", + "eStrKey": "Pattern" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json index 545b34337646..950d9d874c24 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json @@ -159,5 +159,59 @@ } } } + }, + "DEVICE_METADATA_VALID_SUBTYPE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "subtype": "DualToR" + } + } + } + }, + "DEVICE_METADATA_INVALID_SUBTYPE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "subtype": "FakeSubtype" + } + } + } + }, + "DEVICE_METADATA_VALID_PEER_SWITCH": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "peer_switch": "peer_01_hostname" + } + } + } + }, + "DEVICE_METADATA_INVALID_PEER_SWITCH": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "peer_switch": "this_super_duper_long_hostname_is_too_long_according_to_RFC_1035" + } + } + } + }, + "DEVICE_METADATA_VALID_STORAGE_DEVICE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "storage_device": "true" + } + } + } + }, + "DEVICE_METADATA_INVALID_STORAGE_DEVICE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "storage_device": "yes" + } + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json index 7423ecd6d419..5d7fff2cd878 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json @@ -275,5 +275,44 @@ ] } } + }, + + "PORT_VALID_MUX_CABLE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 50000, + "mux_cable": "true" + }, + { + "name": "Ethernet12", + "alias": "eth12", + "lanes": "6", + "speed": 50000, + "mux_cable": "false" + } + ] + } + } + }, + + "PORT_INVALID_MUX_CABLE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 50000, + "mux_cable": "enabled" + } + ] + } + } } } 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 9f6bdd8b3ad5..2ae87a7b822e 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 @@ -21,7 +21,8 @@ "10.186.72.66" ], "mtu": "9100", - "name": "Vlan200" + "name": "Vlan200", + "mac": "00:aa:bb:cc:dd:ee" } ] } @@ -524,5 +525,94 @@ ] } } + }, + "INVALID_VLAN_MAC": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "admin_status": "up", + "name": "Vlan1000", + "mac": "12345678" + } + ] + } + } + }, + "VLAN_INTERFACE_VALID_GRAT_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + }, + { + "name": "Vlan2000" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "grat_arp": "enabled" + }, + { + "name": "Vlan2000", + "grat_arp": "disabled" + } + ] + } + } + }, + "VLAN_INTERFACE_VALID_PROXY_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + }, + { + "name": "Vlan2000" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "proxy_arp": "enabled" + }, + { + "name": "Vlan2000", + "proxy_arp": "disabled" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_GRAT_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "grat_arp": "true" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_PROXY_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "proxy_arp": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json new file mode 100644 index 000000000000..f95b1af8f049 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json @@ -0,0 +1,226 @@ +{ + "VLAN_SUB_INTERFACE_MUST_CONDITION_TRUE_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_MUST_CONDITION_FALSE_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet12", + "admin_status": "up", + "alias": "Ethernet12/1", + "description": "Ethernet12", + "lanes": "49,50,51,52", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_PORT_NON_EXISTING_LEAF_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.20", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.4095" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.4095", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_WITH_LEADING_ZERO_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.095" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.095", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_EMPTY_STRING_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_NAME_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet810" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet810", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index 7ca7f44915ff..8c736997e172 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -56,9 +56,7 @@ module sonic-device_metadata { } leaf hostname { - type string { - length 1..255; - } + type stypes:hostname; } leaf platform { @@ -128,6 +126,20 @@ module sonic-device_metadata { leaf region { type string; } + + leaf subtype { + type string { + pattern "DualToR"; + } + } + + leaf peer_switch { + type stypes:hostname; + } + + leaf storage_device { + type boolean; + } } /* end of container localhost */ } diff --git a/src/sonic-yang-models/yang-models/sonic-port.yang b/src/sonic-yang-models/yang-models/sonic-port.yang index 0e1c5db0b8f0..b2031688af75 100644 --- a/src/sonic-yang-models/yang-models/sonic-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-port.yang @@ -138,6 +138,10 @@ module sonic-port{ type stypes:tpid_type; } + leaf mux_cable { + type boolean; + } + } /* end of list PORT_LIST */ } /* end of container PORT */ diff --git a/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang b/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang new file mode 100644 index 000000000000..6ce391033ab0 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang @@ -0,0 +1,80 @@ +module sonic-vlan-sub-interface { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-vlan-sub-interface"; + + prefix vlan-sub-interface; + + import sonic-types { + prefix stypes; + } + + import sonic-port { + prefix port; + } + + import sonic-vrf { + prefix vrf; + } + + description "VLAN sub interface for SONiC OS"; + + revision 2021-11-11 { + description "Initial version"; + } + + container sonic-vlan-sub-interface { + container VLAN_SUB_INTERFACE { + + description "VLAN SUB INTERFACE part of config_db.json"; + + list VLAN_SUB_INTERFACE_LIST { + + description "VLAN_SUB_INTERFACE part of config_db.json with vrf"; + + key "name"; + + leaf name { + must "substring-before(current(), '.') = /port:sonic-port/port:PORT/port:PORT_LIST/port:name" + { + error-message "Must condition not satisfied, Try adding PORT: {}, Example: 'Ethernet0': {}"; + } + + // check if the vlan sub interface have the form as . + // the vlan_id should be chosen from range [1, 4094] + type string { + pattern '(\w+)\.([1-9][0-9]{0,2}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + } + } + + leaf admin_status { + type stypes:admin_status; + } + + leaf vrf_name { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + } + } + + list VLAN_SUB_INTERFACE_IPPREFIX_LIST { + + description "VLAN_SUB_INTERFACE part of config_db.json with ip-prefix"; + + key "name ip-prefix"; + + leaf name { + type leafref { + path "../../VLAN_SUB_INTERFACE_LIST/name"; + } + } + + leaf ip-prefix { + type stypes:sonic-ip-prefix; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index 5c45b9a93bb3..960f4b44c0d0 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -9,6 +9,10 @@ module sonic-vlan { prefix inet; } + import ietf-yang-types { + prefix yang; + } + import sonic-types { prefix stypes; } @@ -85,6 +89,18 @@ module sonic-vlan { enum disable; } } + + leaf grat_arp { + type string { + pattern "enabled|disabled"; + } + } + + leaf proxy_arp { + type string { + pattern "enabled|disabled"; + } + } } /* end of VLAN_INTERFACE_LIST */ @@ -184,6 +200,10 @@ module sonic-vlan { leaf admin_status { type stypes:admin_status; } + + leaf mac { + type yang:mac-address; + } } /* end of VLAN_LIST */ } diff --git a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 index 04aff692d6ee..2c381af29792 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -229,9 +229,14 @@ module sonic-types { } } + typedef hostname { + type string { + length 1..63; + } + } - /* Required for CVL */ {% if yang_model_type == "cvl" %} + /* Required for CVL */ container operation { description "This definition is used internally by CVL and