Skip to content

Commit

Permalink
Change in alarm sandesh structure
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sundaresan Rajangam committed Aug 3, 2016
1 parent 9d7773b commit 9b1adab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 82 deletions.
88 changes: 7 additions & 81 deletions library/common/sandesh_alarm_base.sandesh
Expand Up @@ -7,77 +7,30 @@
*
*/

struct Operand1 {
1: list<string> keys
2: optional map<byte, string> vars
3: optional byte json
}

union Operand2 {
1: list<string> 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<string> vars
5: optional list<string> variables
3: AlarmOperand2 operand2
4: optional list<string> variables
}

struct AlarmMatch {
1: string json_operand1_value
2: optional string json_operand2_value
/* "json_vars" is being deprecated */
3: optional map<string, string> json_vars
4: optional map<string, string> json_variables
3: optional map<string, string> json_variables
}

struct AlarmConditionMatch {
1: AlarmCondition condition
2: list<AlarmMatch> match
}

struct AlarmRuleMatch {
1: list<AlarmConditionMatch> rule
}

struct AlarmAndList {
1: list<AlarmConditionMatch> and_list
}
Expand All @@ -86,30 +39,6 @@ struct AlarmRules {
1: list<AlarmAndList> 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<string,string> json_vars
3: string json_operand1_value
4: optional string json_operand2_value
}

struct AllOf {
1: list <AlarmElement> all_of
}

/**
* UVEAlarmInfo is used to report any Alarm
* It contains:
Expand All @@ -124,10 +53,7 @@ struct AllOf {
*/
struct UVEAlarmInfo {
1: string type
/** "any_of" is deprecated */
8: optional list<AllOf> any_of
9: list<AlarmRuleMatch> rules
10: AlarmRules alarm_rules
2: AlarmRules alarm_rules
3: bool ack
4: u64 timestamp
5: byte severity
Expand Down
2 changes: 1 addition & 1 deletion library/python/pysandesh/test/sandesh_uve_alarm_test.py
Expand Up @@ -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])
Expand Down

0 comments on commit 9b1adab

Please sign in to comment.