add alarm show to client

Depends-On: Ia675c6d74ec947729d4520007eac1423cdf58ce9
Change-Id: I4be7ebc7e977ae8ea0a2daf86777ba08f1d4ad61
Implements: blueprint add-alarm-show-api
This commit is contained in:
Idan Hefetz 2018-01-02 12:32:15 +00:00
parent bf718e0e99
commit ed9c28867b
5 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
features:
- Created a new API to show all alarm properties, with a mandatory parameter
``vitrage_id`` of the alarm. The path for the api is ``/v1/alarm/_id_``.

View File

@ -6,9 +6,10 @@ _vitrage()
# Command data:
cmds='alarm complete event healthcheck help rca resource template topology'
cmds_alarm='list count'
cmds_alarm='list show count'
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_alarm_show='-h --help'
cmds_complete='-h --help --name --shell'
cmds_event='post'
cmds_event_post='-h --help --type --time --details'

View File

@ -51,6 +51,7 @@ class VitrageCommandManager(commandmanager.CommandManager):
'resource show': resource.ResourceShow,
'resource list': resource.ResourceList,
'alarm list': alarm.AlarmList,
'alarm show': alarm.AlarmShow,
'alarm count': alarm.AlarmCount,
'rca show': rca.RcaShow,
'template validate': template.TemplateValidate,

View File

@ -27,6 +27,14 @@ class Alarm(object):
all_tenants=all_tenants)
return self.api.get(self.url, params=params).json()
def get(self, vitrage_id):
"""Get an alarm
:param vitrage_id: the vitrage_id of the alarm
"""
url = self.url + vitrage_id
return self.api.get(url).json()
def count(self, all_tenants=False):
"""Get a count of all alarms present

View File

@ -52,6 +52,20 @@ class AlarmList(lister.Lister):
'update_timestamp'), alarms)
class AlarmShow(show.ShowOne):
"""Show an alarm"""
def get_parser(self, prog_name):
parser = super(AlarmShow, self).get_parser(prog_name)
parser.add_argument("vitrage_id", help="Vitrage id of the alarm")
return parser
def take_action(self, parsed_args):
vitrage_id = parsed_args.vitrage_id
alarm = utils.get_client(self).alarm.get(vitrage_id=vitrage_id)
return self.dict2columns(alarm)
# noinspection PyAbstractClass
class AlarmCount(show.ShowOne):
"""Show a count of all alarms"""