Changes to support new alarm counts api in vitrage
This change is to support the new api as introduced by the alarm-counts-api blueprint. - There is a new cli added as well to expose the new api: vitrage alarm count - The bash completion file was also updated Change-Id: I47b5b2cbb32c742ca15478ee294d341c0137e0b5 Depends-On: I6061b63c068580dcd25df5c624d9b3bd88f30cca Implements: blueprint alarm-counts-api Signed-off-by: Tyler Smith <tyler.smith@windriver.com>
This commit is contained in:
parent
76d348e182
commit
86f34ebb30
3
tools/vitrage.bash_completion
Normal file → Executable file
3
tools/vitrage.bash_completion
Normal file → Executable file
@ -6,8 +6,9 @@ _vitrage()
|
|||||||
|
|
||||||
# Command data:
|
# Command data:
|
||||||
cmds='alarm complete event healthcheck help rca resource template topology'
|
cmds='alarm complete event healthcheck help rca resource template topology'
|
||||||
cmds_alarm='list'
|
cmds_alarm='list count'
|
||||||
cmds_alarm_list='-h --help -f --format -c --column --max-width --print-empty --noindent --quote --all-tenants'
|
cmds_alarm_list='-h --help -f --format -c --column --max-width --print-empty --noindent --quote --all-tenants'
|
||||||
|
cmds_alarm_count='-h --help -f --format -c --column --max-width --print-empty --noindent --quote --all-tenants'
|
||||||
cmds_complete='-h --help --name --shell'
|
cmds_complete='-h --help --name --shell'
|
||||||
cmds_event='post'
|
cmds_event='post'
|
||||||
cmds_event_post='-h --help --type --time --details'
|
cmds_event_post='-h --help --type --time --details'
|
||||||
|
1
vitrageclient/shell.py
Normal file → Executable file
1
vitrageclient/shell.py
Normal file → Executable file
@ -51,6 +51,7 @@ class VitrageCommandManager(commandmanager.CommandManager):
|
|||||||
'resource show': resource.ResourceShow,
|
'resource show': resource.ResourceShow,
|
||||||
'resource list': resource.ResourceList,
|
'resource list': resource.ResourceList,
|
||||||
'alarm list': alarm.AlarmList,
|
'alarm list': alarm.AlarmList,
|
||||||
|
'alarm count': alarm.AlarmCount,
|
||||||
'rca show': rca.RcaShow,
|
'rca show': rca.RcaShow,
|
||||||
'template validate': template.TemplateValidate,
|
'template validate': template.TemplateValidate,
|
||||||
'template list': template.TemplateList,
|
'template list': template.TemplateList,
|
||||||
|
8
vitrageclient/v1/alarm.py
Normal file → Executable file
8
vitrageclient/v1/alarm.py
Normal file → Executable file
@ -26,3 +26,11 @@ class Alarm(object):
|
|||||||
params = dict(vitrage_id=vitrage_id,
|
params = dict(vitrage_id=vitrage_id,
|
||||||
all_tenants=all_tenants)
|
all_tenants=all_tenants)
|
||||||
return self.api.get(self.url, params=params).json()
|
return self.api.get(self.url, params=params).json()
|
||||||
|
|
||||||
|
def count(self, all_tenants=False):
|
||||||
|
"""Get a count of all alarms present
|
||||||
|
|
||||||
|
:param all_tenants: should return all tenants alarms
|
||||||
|
"""
|
||||||
|
params = dict(all_tenants=all_tenants)
|
||||||
|
return self.api.get(self.url + 'count/', params=params).json()
|
||||||
|
29
vitrageclient/v1/cli/alarm.py
Normal file → Executable file
29
vitrageclient/v1/cli/alarm.py
Normal file → Executable file
@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from cliff import lister
|
from cliff import lister
|
||||||
|
from cliff import show
|
||||||
|
|
||||||
from vitrageclient.common import utils
|
from vitrageclient.common import utils
|
||||||
|
|
||||||
@ -49,3 +50,31 @@ class AlarmList(lister.Lister):
|
|||||||
'vitrage_aggregated_severity',
|
'vitrage_aggregated_severity',
|
||||||
'vitrage_operational_severity',
|
'vitrage_operational_severity',
|
||||||
'update_timestamp'), alarms)
|
'update_timestamp'), alarms)
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyAbstractClass
|
||||||
|
class AlarmCount(show.ShowOne):
|
||||||
|
"""Show a count of all alarms"""
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(AlarmCount, self).get_parser(prog_name)
|
||||||
|
parser.add_argument('--all-tenants',
|
||||||
|
default=False,
|
||||||
|
dest='all_tenants',
|
||||||
|
action='store_true',
|
||||||
|
help='Shows counts for alarms of all '
|
||||||
|
'the tenants')
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@property
|
||||||
|
def formatter_default(self):
|
||||||
|
return 'json'
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
all_tenants = parsed_args.all_tenants
|
||||||
|
|
||||||
|
counts = utils.get_client(self).alarm.count(
|
||||||
|
all_tenants=all_tenants)
|
||||||
|
|
||||||
|
return self.dict2columns(counts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user