Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding prouter connectivity alarm to check if the prouter is appropri…
…ately connected to vrouter-agent Closes-Bug: #1550888 (cherry picked from commit 71ba1ed) Conflicts: src/opserver/SConscript Change-Id: Ia76d8687484b6d141786c9f36ac4554d499461a8
- Loading branch information
Raj Reddy
committed
Apr 7, 2016
1 parent
a04ab11
commit fe8f31a
Showing
6 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/opserver/plugins/alarm_prouter_connectivity/SConscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- mode: python; -*- | ||
|
||
# | ||
# Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. | ||
# | ||
|
||
import sys | ||
Import('OpEnv') | ||
|
||
env = OpEnv.Clone() | ||
|
||
setup_sources = [ | ||
'setup.py', | ||
] | ||
|
||
setup_sources_rules = [] | ||
for file in setup_sources: | ||
setup_sources_rules.append(env.Install(".", | ||
"#/controller/src/opserver/plugins/alarm_prouter_connectivity/" + file)) | ||
|
||
local_sources = [ | ||
'__init__.py', | ||
'main.py', | ||
] | ||
local_sources_rules = [] | ||
for file in local_sources: | ||
local_sources_rules.append(env.Install(Dir("alarm_prouter_connectivity"), file)) | ||
|
||
sdist_depends = [setup_sources_rules, local_sources_rules] | ||
cd_cmd = 'cd ' + Dir('.').path + ' && ' | ||
sdist_gen = env.Command('dist/alarm_prouter_connectivity-0.1dev.tar.gz', 'setup.py', | ||
cd_cmd + 'python setup.py sdist') | ||
env.Depends(sdist_gen, sdist_depends) | ||
env.Default(sdist_gen) | ||
OpEnv['ALARM_PROUTER_CONNNECTIVITY_PKG'] = sdist_gen | ||
|
||
if 'install' in BUILD_TARGETS: | ||
install_cmd = env.Command(None, | ||
'setup.py', | ||
cd_cmd + 'python setup.py install %s' % | ||
env['PYTHON_INSTALL_OPT']) | ||
env.Depends(install_cmd, sdist_depends) | ||
env.Alias('install', install_cmd) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. | ||
# | ||
|
||
from opserver.plugins.alarm_base import * | ||
from opserver.sandesh.alarmgen_ctrl.sandesh_alarm_base.ttypes import * | ||
import json | ||
|
||
class ProuterConnectivity(AlarmBase): | ||
"""Prouter connectivity to controlling tor agent does not exist | ||
we look for non-empty value for connected_agent_list""" | ||
|
||
def __init__(self): | ||
AlarmBase.__init__(self, AlarmBase.SYS_ERR) | ||
|
||
def __call__(self, uve_key, uve_data): | ||
#check to see if prouter is configured to be managed by vrouter-agent | ||
contrail_config = uve_data.get("ContrailConfig", None) | ||
if not contrail_config or\ | ||
not "elements" in contrail_config: | ||
return None | ||
uattr = contrail_config["elements"] | ||
if isinstance(uattr,list): | ||
uattr = uattr[0][0] | ||
if not "virtual_router_refs" in uattr: | ||
return None | ||
|
||
or_list = [] | ||
v2 = None | ||
v1 = uve_data.get("ProuterData",None) | ||
if v1 is not None: | ||
v2 = v1.get("connected_agent_list",None) | ||
if v2 is None: | ||
or_list.append(AllOf(all_of=[AlarmElement(\ | ||
rule=AlarmTemplate(oper="==", | ||
operand1=Operand1(keys=["ProuterData","connected_agent_list"]), | ||
operand2=Operand2(json_value="null")), | ||
json_operand1_value="null")])) | ||
return or_list | ||
|
||
if not (len(v2) == 1): | ||
or_list.append(AllOf(all_of=[AlarmElement(\ | ||
rule=AlarmTemplate(oper="size!=", | ||
operand1=Operand1(keys=["ProuterData","connected_agent_list"]), | ||
operand2=Operand2(json_value=json.dumps(1))), | ||
json_operand1_value=json.dumps(v2))])) | ||
return or_list | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. | ||
# | ||
|
||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='alarm_prouter_connectivity', | ||
version='0.1dev', | ||
packages=find_packages(), | ||
entry_points = { | ||
'contrail.analytics.alarms': [ | ||
'ObjectPRouter = alarm_prouter_connectivity.main:ProuterConnectivity', | ||
], | ||
}, | ||
zip_safe=False, | ||
long_description="ProuterConnectivity alarm" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters