From 9b1adabefb2393ac2c061ef5831bb6c51a7b545c Mon Sep 17 00:00:00 2001 From: Sundaresan Rajangam Date: Tue, 2 Aug 2016 22:21:48 -0700 Subject: [PATCH] Change in alarm sandesh structure Change in operand2 type in alarm sandesh structure to be in sync with the alarm schema changes Change-Id: I4a9df87aff03b6718e3bbf5c3828a69078842d41 Closes-Bug: #1607030 Closes-Bug: #1605395 --- library/common/sandesh_alarm_base.sandesh | 88 ++----------------- .../pysandesh/test/sandesh_uve_alarm_test.py | 2 +- 2 files changed, 8 insertions(+), 82 deletions(-) diff --git a/library/common/sandesh_alarm_base.sandesh b/library/common/sandesh_alarm_base.sandesh index 495c6b09..2a2e6e8a 100644 --- a/library/common/sandesh_alarm_base.sandesh +++ b/library/common/sandesh_alarm_base.sandesh @@ -7,66 +7,23 @@ * */ -struct Operand1 { - 1: list keys - 2: optional map vars - 3: optional byte json -} - -union Operand2 { - 1: list keys - 2: string json_value -} -/** - * An AlarmTemplate consists of a comparison operator, - * and two operands to be compared - * - * operand1 contains a list of keys used to examine the UVE's JSON tree - * As we process these keys against the UVE's JSON tree: - * - If we are at the last key, use the value of the current subtree. - * Processing is finished. - * - Otherwise - * - If the current subtree is a JSON object, go deeper into the subtree - * according to this key. Process the next key in the list - * - If the current subtree is a JSON array, process each element of the - * array with the current key - * - Any other situation is unexpected; this UVE tree cannot be processed - * with this operand specification - * Also, we will use the "vars" attributes to print parts of the UVE other than - * the operand1 and operand2 value inthe Alarm description - * - * operand2 is what we want to compare the first operand to - * It can be either: - * - a list of keys to find which part of the UVE - * to compare operand1 to. There is no "vars" element. - * "vars" can be specified with operand1 only. - * - JSON string representing a fixed value - * (The special value "null" is used to check for whether operand1 exists, - * using the operators "!=" and "==" - * - */ -struct AlarmTemplate { - 1: string oper - 2: Operand1 operand1 - 3: Operand2 operand2 +union AlarmOperand2 { + 1: optional string uve_attribute + 2: optional string json_value } struct AlarmCondition { 1: string operation 2: string operand1 - 3: string operand2 - /* "vars" is being deprecated */ - 4: optional list vars - 5: optional list variables + 3: AlarmOperand2 operand2 + 4: optional list variables } struct AlarmMatch { 1: string json_operand1_value 2: optional string json_operand2_value - /* "json_vars" is being deprecated */ - 3: optional map json_vars - 4: optional map json_variables + 3: optional map json_variables } struct AlarmConditionMatch { @@ -74,10 +31,6 @@ struct AlarmConditionMatch { 2: list match } -struct AlarmRuleMatch { - 1: list rule -} - struct AlarmAndList { 1: list and_list } @@ -86,30 +39,6 @@ struct AlarmRules { 1: list or_list } -/** - * AlarmElement is used to explain why an Alarm was raised. - * It contains: - * - The AlarmTemplate that was violated - * - When we examined the UVE, we also noted some parts of the UVE - * whose values need to be reported along with the alarm. (from - * the "var" attribute of operand1 of the AlarmTemplate) - * This is reported as a map, with the the key being the - * fully-qualified name of the var - * - json string of value seen for operand1. - * - json string of value seen for operand2, - * if operand2 was not a fixed value - */ -struct AlarmElement { - 1: AlarmTemplate rule - 2: optional map json_vars - 3: string json_operand1_value - 4: optional string json_operand2_value -} - -struct AllOf { - 1: list all_of -} - /** * UVEAlarmInfo is used to report any Alarm * It contains: @@ -124,10 +53,7 @@ struct AllOf { */ struct UVEAlarmInfo { 1: string type - /** "any_of" is deprecated */ - 8: optional list any_of - 9: list rules - 10: AlarmRules alarm_rules + 2: AlarmRules alarm_rules 3: bool ack 4: u64 timestamp 5: byte severity diff --git a/library/python/pysandesh/test/sandesh_uve_alarm_test.py b/library/python/pysandesh/test/sandesh_uve_alarm_test.py index 9aa16d8f..abe4bcf6 100755 --- a/library/python/pysandesh/test/sandesh_uve_alarm_test.py +++ b/library/python/pysandesh/test/sandesh_uve_alarm_test.py @@ -233,7 +233,7 @@ def _create_uve_alarm_info(self): uve_alarm_info.type = 'ProcessStatus' condition = AlarmCondition(operation='==', operand1='NodeStatus.process_info.process_state', - operand2=json.dumps('null')) + operand2=AlarmOperand2(json_value=json.dumps('null'))) match1 = AlarmMatch(json_operand1_value=json.dumps('null')) condition_match = AlarmConditionMatch(condition, [match1]) and_list = AlarmAndList(and_list=[condition_match])