From 1509f433fd21fb2d0d783545aca780390d4e26b3 Mon Sep 17 00:00:00 2001 From: arlakshm <55814491+arlakshm@users.noreply.github.com> Date: Tue, 7 Dec 2021 14:12:26 -0800 Subject: [PATCH] [yang] syslog yang model (#9265) Why I did it Add yang model for syslog server How I did it Add new file sonic-syslog.yang and new files for tests How to verify it Compile target/python-wheels/sonic_yang_mgmt-1.0-py3-none-any.whl Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com --- src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 5 ++ .../tests/yang_model_tests/tests/syslog.json | 18 +++++++ .../yang_model_tests/tests_config/syslog.json | 52 +++++++++++++++++++ .../yang-models/sonic-syslog.yang | 30 +++++++++++ 5 files changed, 106 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json create mode 100644 src/sonic-yang-models/yang-models/sonic-syslog.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index dab1243ac1..87637e2889 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -114,6 +114,7 @@ setup( './yang-models/sonic-route-map.yang', './yang-models/sonic-routing-policy-sets.yang', './yang-models/sonic-sflow.yang', + './yang-models/sonic-syslog.yang', './yang-models/sonic-system-aaa.yang', './yang-models/sonic-system-tacacs.yang', './yang-models/sonic-types.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 fc266af5b5..28c31e2e4d 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -370,6 +370,11 @@ "23.92.29.245": {}, "2001:aa:aa::aa": {} }, + "SYSLOG_SERVER" : { + "10.13.14.17": {}, + "20.1.1.1": {}, + "2001:aa:aa::aa": {} + }, "PORT": { "Ethernet0": { "alias": "Eth1/1", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json new file mode 100644 index 0000000000..ee45cf4d28 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/syslog.json @@ -0,0 +1,18 @@ +{ + "SYSLOG_SERVER_TEST": { + "desc": "Load syslog server table with ipv4 address as syslog servers." + }, + "SYSLOG_SERVER_1_NEG_TEST": { + "desc": "Load syslog server table with empty address as syslog server.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_SERVER_INVALID_IPADDR_TEST": { + "desc": "Load syslog server table with invalid ipv4 address as syslog server.", + "eStrKey": "InvalidValue" + }, + "SYSLOG_SERVER_INVALID_IPV6_ADDR_TEST": { + "desc": "Load syslog server table with invalid ipv6 address as syslog server.", + "eStrKey": "InvalidValue" + } + +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json new file mode 100644 index 0000000000..ed153c0d6c --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/syslog.json @@ -0,0 +1,52 @@ +{ + "SYSLOG_SERVER_TEST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_SERVER": { + "SYSLOG_SERVER_LIST": [ + { + "server_address": "1111::22" + }, + { + "server_address": "20.1.1.1" + }, + { + "server_address" : "1001:0ab8:0001:0000:0000:0abc:d012:0102" + } + ] + } + } + }, + "SYSLOG_SERVER_1_NEG_TEST": { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_SERVER": { + "SYSLOG_SERVER_LIST": [ + { + "server_address": "" + } + ] + } + } + }, + "SYSLOG_SERVER_INVALID_IPADDR_TEST" : { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_SERVER": { + "SYSLOG_SERVER_LIST": [ + { + "server_address": "1111.22.33.1" + } + ] + } + } + }, + "SYSLOG_SERVER_INVALID_IPV6_ADDR_TEST" : { + "sonic-syslog:sonic-syslog": { + "sonic-syslog:SYSLOG_SERVER": { + "SYSLOG_SERVER_LIST": [ + { + "server_address": "1111::22.33.1" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-syslog.yang b/src/sonic-yang-models/yang-models/sonic-syslog.yang new file mode 100644 index 0000000000..2bb05a0297 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-syslog.yang @@ -0,0 +1,30 @@ +module sonic-syslog { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-system-syslog"; + prefix syslog; + + import ietf-inet-types { + prefix inet; + } + + container sonic-syslog { + + container SYSLOG_SERVER { + + description "SYSLOG SERVER part of config_db.json"; + + list SYSLOG_SERVER_LIST { + + key "server_address"; + + leaf server_address { + description "syslog server ip address"; + type inet:ip-address; + } + } /* end of list SYSLOG_SERVER_LIST */ + + } /* end of container SYSLOG_SERVER */ + } +}