From 24be87504f353ce583d20719d3a78b05376362e7 Mon Sep 17 00:00:00 2001 From: Zain Budhwani <99770260+zbud-msft@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:47:32 -0800 Subject: [PATCH] Change bgp notification leaf name and mem_usage leaf type (#13012) #### Why I did it Improve naming convention for bgp notification events and change type of leaf for sonic-events-host mem usage from uint64 to decimal64 #### How I did it Replace "-" with "_" Replace uint64 with decimal64 #### How to verify it Run yang model unit tests #### Description for the changelog Change YANG model leaf naming convention for bgp notification --- dockers/docker-fpm-frr/bgp_regex.json | 2 +- .../tests_config/sonic-events-bgp.json | 36 +++++++++---------- .../tests_config/sonic-events-host.json | 10 +++--- .../yang-models/sonic-events-bgp.yang | 6 ++-- .../yang-models/sonic-events-host.yang | 4 ++- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/dockers/docker-fpm-frr/bgp_regex.json b/dockers/docker-fpm-frr/bgp_regex.json index f02ae53ed2..c657aa89dc 100644 --- a/dockers/docker-fpm-frr/bgp_regex.json +++ b/dockers/docker-fpm-frr/bgp_regex.json @@ -12,7 +12,7 @@ { "tag": "notification", "regex": "NOTIFICATION: (received|sent) (?:to|from) neighbor ([0-9a-f:.]*[0-9a-f+]*)\\s*.* (\\d*)\/(\\d*)", - "params": [ "is-sent", "ip", "major-code", "minor-code" ] + "params": [ "is_sent", "ip", "major_code", "minor_code" ] } ] diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json index 2fa562f5ef..ac747180f3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-bgp.json @@ -38,10 +38,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MAJOR_CODE": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": "INCORRECT_MAJOR_CODE", - "minor-code": 2, + "major_code": "INCORRECT_MAJOR_CODE", + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -49,10 +49,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_MINOR_CODE": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": "INCORRECT_MINOR_CODE", + "major_code": 2, + "minor_code": "INCORRECT_MINOR_CODE", "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -60,10 +60,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IP": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "INCORRECT_IP", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -71,10 +71,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_IS-SENT": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": "INCORRECT_VALUE", + "is_sent": "INCORRECT_VALUE", "timestamp": "1985-04-12T23:20:50.52Z" } } @@ -82,10 +82,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_INCORRECT_TIMESTAMP": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "INCORRECT_TIMESTAMP" } } @@ -93,10 +93,10 @@ "SONIC_EVENTS_BGP_NOTIFICATION_VALID": { "sonic-events-bgp:sonic-events-bgp": { "sonic-events-bgp:notification": { - "major-code": 2, - "minor-code": 2, + "major_code": 2, + "minor_code": 2, "ip": "10.0.0.0", - "is-sent": true, + "is_sent": true, "timestamp": "1985-04-12T23:20:50.52Z" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json index 5c771de041..98ee755b51 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-events-host.json @@ -263,7 +263,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "Invalid$", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } @@ -273,7 +273,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "invalid-length-for-ctr-name-too-long", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } @@ -293,7 +293,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": "INCORRECT_THRESHOLD", "timestamp": "1985-04-12T23:20:50.52Z" } @@ -303,7 +303,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "INCORRECT_TIMESTAMP" } @@ -313,7 +313,7 @@ "sonic-events-host:sonic-events-host": { "sonic-events-host:mem-threshold-exceeded": { "ctr_name": "container_name", - "mem_usage": 123456, + "mem_usage": "123456.78", "threshold": 123456, "timestamp": "1985-04-12T23:20:50.52Z" } diff --git a/src/sonic-yang-models/yang-models/sonic-events-bgp.yang b/src/sonic-yang-models/yang-models/sonic-events-bgp.yang index 26d2b85e95..df9945d783 100644 --- a/src/sonic-yang-models/yang-models/sonic-events-bgp.yang +++ b/src/sonic-yang-models/yang-models/sonic-events-bgp.yang @@ -57,12 +57,12 @@ module sonic-events-bgp { The error codes as per IANA. The other params are as in the message"; - leaf major-code { + leaf major_code { type uint8; description "Major IANA error code; [RFC4271][RFC7313]"; } - leaf minor-code { + leaf minor_code { type uint8; description "Minor IANA error code; [RFC4271][RFC7313]"; } @@ -72,7 +72,7 @@ module sonic-events-bgp { description "IP of neighbor associated with this notification"; } - leaf is-sent { + leaf is_sent { type boolean; description "true - if this notification was for sent messages; false if it was for received."; } diff --git a/src/sonic-yang-models/yang-models/sonic-events-host.yang b/src/sonic-yang-models/yang-models/sonic-events-host.yang index cbb129d9fe..edd98d247c 100644 --- a/src/sonic-yang-models/yang-models/sonic-events-host.yang +++ b/src/sonic-yang-models/yang-models/sonic-events-host.yang @@ -196,7 +196,9 @@ module sonic-events-host { } leaf mem_usage { - type uint64; + type decimal64 { + fraction-digits 2; + } description "Memory usage of process"; }