Skip to content

Commit

Permalink
Handle all cases where operand1/operand2 in alarm config evaluates to a
Browse files Browse the repository at this point in the history
list

Change-Id: I27c356cf81ee264d2194361bc17e47e1a051e52f
Closes-Bug: #1602789
  • Loading branch information
Sundaresan Rajangam committed Jul 13, 2016
1 parent 3df0ce2 commit 9591267
Show file tree
Hide file tree
Showing 3 changed files with 1,014 additions and 34 deletions.
63 changes: 43 additions & 20 deletions src/opserver/alarmgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,38 +384,61 @@ def _evaluate_uve_for_alarms(self, alarm_cfg, uve_key, uve):
and_list_fail = True
break
is_operand2_json_val = False
if isinstance(operand1_val, list):
if isinstance(operand1_val, list) or \
(is_operand2_json_val is False and \
isinstance(operand2_val, list)):
match_list = []
val2 = operand2_val
if not is_operand2_json_val:
if isinstance(operand2_val, list):
# TODO: Handle the case where both operand1_val and
# operand2_val are lists
and_list_fail = True
break
val2 = operand2_val['value']
for val1 in operand1_val:
if self._compare_operand_vals(val1['value'],
operand2_val, exp.operation):
match_list.append(self._get_alarm_match(
uve, exp, val1, val2,
is_operand2_json_val))
# both operand1_val and operand2_val are list
if isinstance(operand1_val, list) and \
(is_operand2_json_val is False and \
isinstance(operand2_val, list)):
if len(operand1_val) != len(operand2_val):
and_list_fail = True
break
for i in range(0, len(operand1_val)):
if self._compare_operand_vals(
operand1_val[i]['value'],
operand2_val[i]['value'],
exp.operation):
match_list.append(
self._get_alarm_match(
uve, exp, operand1_val[i],
operand2_val[i],
is_operand2_json_val))
# operand1_val is list and operand2_val is not list
elif isinstance(operand1_val, list):
val2 = operand2_val
if not is_operand2_json_val:
val2 = operand2_val['value']
for val1 in operand1_val:
if self._compare_operand_vals(val1['value'],
val2, exp.operation):
match_list.append(self._get_alarm_match(
uve, exp, val1, operand2_val,
is_operand2_json_val))
# operand1_val is not list and operand2_val is list
elif is_operand2_json_val is False and \
isinstance(operand2_val, list):
for val2 in operand2_val:
if self._compare_operand_vals(
operand1_val['value'], val2['value'],
exp.operation):
match_list.append(self._get_alarm_match(
uve, exp, operand1_val, val2,
is_operand2_json_val))
if match_list:
and_list.append(self._get_alarm_condition_match(
uve, exp, operand1_val, operand2_val,
is_operand2_json_val, match_list))
else:
and_list_fail = True
break
# Neither operand1_val nor operand2_val is a list
else:
val1 = operand1_val['value']
val2 = operand2_val
if not is_operand2_json_val:
if isinstance(operand2_val, list):
and_list_fail = True
break
val2 = operand2_val['value']
else:
val2 = operand2_val
if self._compare_operand_vals(val1, val2, exp.operation):
and_list.append(self._get_alarm_condition_match(
uve, exp, operand1_val, operand2_val,
Expand Down
8 changes: 0 additions & 8 deletions src/opserver/contrail-alarm-gen.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ partitions=30

[REDIS]
#redis_server_port=6379

[KEYSTONE]
#auth_host=127.0.0.1
#auth_protocol=http
#auth_port=35357
#admin_user=user1
#admin_password=password1
#admin_tenant_name=default-domain

0 comments on commit 9591267

Please sign in to comment.