From a9ec9e98d9e5c1c98ee41ad1916120d4b6689629 Mon Sep 17 00:00:00 2001 From: Azmy Ali Date: Mon, 6 May 2024 07:22:10 +0300 Subject: [PATCH] Adding local-users-passwords-reset feature service, YANG model and its tests --- files/build_templates/init_cfg.json.j2 | 5 ++++ src/sonic-yang-models/setup.py | 2 ++ .../tests/files/sample_config_db.json | 5 ++++ .../tests/local-users-passwords-reset.json | 5 ++++ .../local-users-passwords-reset.json | 11 ++++++++ .../sonic-local-users-passwords-reset.yang | 26 +++++++++++++++++++ 6 files changed, 54 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/local-users-passwords-reset.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/local-users-passwords-reset.json create mode 100644 src/sonic-yang-models/yang-models/sonic-local-users-passwords-reset.yang diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index b2e1d2348c2a..9cdaa91ffd79 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -134,6 +134,11 @@ "special_class": "true" } }, + "LOCAL_USERS_PASSWORDS_RESET": { + "global": { + "state": "disabled" + } + }, "SYSTEM_DEFAULTS" : { {%- if include_mux == "y" %} "mux_tunnel_egress_acl": { diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index e20c10da05db..88894c738a4a 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -79,6 +79,7 @@ def run(self): data_files=[ ('yang-models', ['./yang-models/sonic-acl.yang', './yang-models/sonic-auto_techsupport.yang', + './yang-models/sonic-local-users-passwords-reset', './yang-models/sonic-bgp-common.yang', './yang-models/sonic-bgp-device-global.yang', './yang-models/sonic-bgp-global.yang', @@ -192,6 +193,7 @@ def run(self): './yang-models/sonic-macsec.yang', './yang-models/sonic-bgp-sentinel.yang']), ('cvlyang-models', ['./cvlyang-models/sonic-acl.yang', + './cvlyang-models/sonic-local-users-passwords-reset', './cvlyang-models/sonic-bgp-common.yang', './cvlyang-models/sonic-bgp-global.yang', './cvlyang-models/sonic-bgp-monitor.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 1e01dcbdba66..2375b1837f65 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2487,6 +2487,11 @@ } } }, + "LOCAL_USERS_PASSWORDS_RESET": { + "global": { + "state": "disabled" + } + }, "SAMPLE_CONFIG_DB_UNKNOWN": { "UNKNOWN_TABLE": { "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/local-users-passwords-reset.json b/src/sonic-yang-models/tests/yang_model_tests/tests/local-users-passwords-reset.json new file mode 100644 index 000000000000..af4ff540b06c --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/local-users-passwords-reset.json @@ -0,0 +1,5 @@ +{ + "LOCAL_USERS_PASSWORDS_RESET_TEST_STATE": { + "desc": "Configure Local users' passwords reset feature state." + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/local-users-passwords-reset.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/local-users-passwords-reset.json new file mode 100644 index 000000000000..f48199da3caa --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/local-users-passwords-reset.json @@ -0,0 +1,11 @@ +{ + "LOCAL_USERS_PASSWORDS_RESET_TEST_STATE": { + "sonic-local-users-passwords-reset:sonic-local-users-passwords-reset": { + "sonic-local-users-passwords-reset:LOCAL_USERS_PASSWORDS_RESET": { + "global": { + "state": "enabled" + } + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-local-users-passwords-reset.yang b/src/sonic-yang-models/yang-models/sonic-local-users-passwords-reset.yang new file mode 100644 index 000000000000..594c719a1e22 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-local-users-passwords-reset.yang @@ -0,0 +1,26 @@ +module local-users-passwords-reset { + yang-version 1.1; + namespace "http://github.com/sonic-net/local-users-passwords-reset"; + + import sonic-types { + prefix stypes; + } + + description "LONG_RESET_BUTTON YANG Module for SONiC-based OS"; + revision 2024-01-04 { + description "First Revision"; + } + + container sonic-local-users-passwords-reset { + container LOCAL_USERS_PASSWORDS_RESET { + description "LOCAL_USERS_PASSWORDS_RESET part of config_db.json"; + container global { + leaf state { + type stypes:admin_mode; + description "Local users' passwords reset feature state"; + default disabled; + } + } /* end of container global */ + } /* end of container LOCAL_USERS_PASSWORDS_RESET */ + } /* end of top level container */ +} \ No newline at end of file