state normalization support
Change-Id: Ieb9cf923cbe2b8ab737da9e4951b4fd28d26d923
This commit is contained in:
parent
b56311901a
commit
b6454136e8
@ -134,7 +134,7 @@ The following template demonstrates
|
||||
|
||||
Example 2: Deduced state based on alarm
|
||||
---------------------------------------
|
||||
The following template will change the state of a resource to "ERROR" if there is any alarm of severity "HIGH" on it. Also note that entity ids can be strings as well.
|
||||
The following template will change the state of a resource to "ERROR" if there is any alarm of severity "CRITICAL" on it. Also note that entity ids can be strings as well.
|
||||
|
||||
::
|
||||
|
||||
@ -147,7 +147,7 @@ The following template will change the state of a resource to "ERROR" if there i
|
||||
template_id: a_resource # entity ids are any string
|
||||
- entity:
|
||||
category: ALARM
|
||||
severity: HIGH
|
||||
severity: CRITICAL
|
||||
template_id: high_alarm # entity ids are any string
|
||||
relationships:
|
||||
- relationship:
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
|
||||
class AlarmState(object):
|
||||
HIGH = 'HIGH'
|
||||
MEDIUM = 'MEDIUM'
|
||||
LOW = 'LOW'
|
||||
OK = 'OK'
|
||||
CRITICAL = 'CRITICAL'
|
||||
SEVER = 'SEVER'
|
||||
WARNING = 'WARNING'
|
||||
DISABLED = 'DISABLED'
|
||||
UNKNOWN = 'UNKNOWN'
|
||||
|
@ -50,21 +50,24 @@ class StateManager(object):
|
||||
|
||||
def aggregated_state(self, state1, state2, plugin_name,
|
||||
is_normalized=False):
|
||||
upper_state1 = state1 if not state1 else state1.upper()
|
||||
upper_state2 = state2 if not state2 else state2.upper()
|
||||
if plugin_name in self.states_plugins:
|
||||
upper_state1 = state1 if not state1 else state1.upper()
|
||||
upper_state2 = state2 if not state2 else state2.upper()
|
||||
|
||||
normalized_state1 = upper_state1.upper() if is_normalized else \
|
||||
self.normalize_state(plugin_name, upper_state1)
|
||||
normalized_state2 = upper_state2.upper() if is_normalized else \
|
||||
self.normalize_state(plugin_name, upper_state2)
|
||||
normalized_state1 = upper_state1.upper() if is_normalized else \
|
||||
self.normalize_state(plugin_name, upper_state1)
|
||||
normalized_state2 = upper_state2.upper() if is_normalized else \
|
||||
self.normalize_state(plugin_name, upper_state2)
|
||||
|
||||
priority_state1 = self.state_priority(plugin_name,
|
||||
normalized_state1)
|
||||
priority_state2 = self.state_priority(plugin_name,
|
||||
normalized_state2)
|
||||
priority_state1 = self.state_priority(plugin_name,
|
||||
normalized_state1)
|
||||
priority_state2 = self.state_priority(plugin_name,
|
||||
normalized_state2)
|
||||
|
||||
return normalized_state1 if priority_state1 > priority_state2 \
|
||||
else normalized_state2
|
||||
return normalized_state1 if priority_state1 > priority_state2 \
|
||||
else normalized_state2
|
||||
else:
|
||||
return ResourceState.UNDEFINED
|
||||
|
||||
def _load_state_configurations(self):
|
||||
states_plugins = {}
|
||||
|
@ -6,20 +6,20 @@ states:
|
||||
original states:
|
||||
- name: UNKNOWN
|
||||
- normalized state:
|
||||
name: HIGH
|
||||
name: CRITICAL
|
||||
priority: 40
|
||||
original states:
|
||||
- name: CRITITCAL
|
||||
- name: DOWN
|
||||
- normalized state:
|
||||
name: MEDIUM
|
||||
name: SEVER
|
||||
priority: 30
|
||||
original states:
|
||||
- name: WARNING
|
||||
- normalized state:
|
||||
name: LOW
|
||||
name: WARNING
|
||||
priority: 20
|
||||
original states:
|
||||
- name: WARNING
|
||||
- normalized state:
|
||||
name: OK
|
||||
priority: 10
|
||||
|
Loading…
Reference in New Issue
Block a user