Add new api vitrage status

To Check if vitrage is ready then you can check its
status some users don't want to check on every api call
if vitrage is ready, in that case you can check ad hoc

Change-Id: I0817016538a6b286816b99176339262c6453dc08
This commit is contained in:
Eyal 2019-07-01 12:55:49 +03:00
parent 4b4bf371cf
commit ba5f71fecc
8 changed files with 71 additions and 3 deletions

View File

@ -1117,6 +1117,17 @@ webhook add
+--------------+--------------------------------------+
Status Example
--------------
::
vitrage status
+--------+-------+
| Field | Value |
+--------+-------+
| reason | OK |
+--------+-------+
Python API
----------

View File

@ -0,0 +1,3 @@
---
features:
- Added a new API to show vitrage status.

View File

@ -63,6 +63,7 @@ openstack.rca.v1 =
rca_webhook_list = vitrageclient.v1.cli.webhook:WebhookList
rca_webhook_show = vitrageclient.v1.cli.webhook:WebhookShow
rca_service_list = vitrageclient.v1.cli.service:ServiceList
rca_status = vitrageclient.v1.cli.status:Status
vitrageclient.formatter.show =
graphml = vitrageclient.common.formatters:GraphMLFormatter

View File

@ -5,7 +5,7 @@ _vitrage()
_get_comp_words_by_ref -n : cur prev words
# Command data:
cmds='alarm complete event healthcheck help rca resource service template topology webhook'
cmds='alarm complete event healthcheck help rca resource service status template topology webhook'
cmds_alarm='count history list show'
cmds_alarm_count='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --all-tenants'
cmds_alarm_history='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants --limit --marker --start --end'
@ -24,8 +24,9 @@ _vitrage()
cmds_resource_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
cmds_service='list'
cmds_service_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column'
cmds_status='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
cmds_template='add delete list show validate versions'
cmds_template_add='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --path --type --params --wait'
cmds_template_add='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --path --type --params --wait --overwrite'
cmds_template_delete='-h --help --wait'
cmds_template_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column'
cmds_template_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'

View File

@ -39,6 +39,7 @@ from vitrageclient.v1.cli import healthcheck
from vitrageclient.v1.cli import rca
from vitrageclient.v1.cli import resource
from vitrageclient.v1.cli import service
from vitrageclient.v1.cli import status
from vitrageclient.v1.cli import template
from vitrageclient.v1.cli import topology
from vitrageclient.v1.cli import webhook
@ -70,7 +71,8 @@ class VitrageCommandManager(commandmanager.CommandManager):
'webhook add': webhook.WebhookAdd,
'webhook list': webhook.WebhookList,
'webhook show': webhook.WebhookShow,
'service list': service.ServiceList
'service list': service.ServiceList,
'status': status.Status,
}
def load_commands(self, namespace):

View File

@ -0,0 +1,23 @@
# Copyright 2019 - Nokia Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cliff import show
# noinspection PyAbstractClass
class Status(show.ShowOne):
"""Check api health status"""
def take_action(self, parsed_args):
return self.dict2columns(self.app.client.status.get())

View File

@ -19,6 +19,7 @@ from vitrageclient.v1 import healthcheck
from vitrageclient.v1 import rca
from vitrageclient.v1 import resource
from vitrageclient.v1 import service
from vitrageclient.v1 import status
from vitrageclient.v1 import template
from vitrageclient.v1 import topology
from vitrageclient.v1 import webhook
@ -39,3 +40,4 @@ class Client(object):
self.healthcheck = healthcheck.HealthCheck(self._api)
self.webhook = webhook.Webhook(self._api)
self.service = service.Service(self._api)
self.status = status.Status(self._api)

View File

@ -0,0 +1,25 @@
# Copyright 2019 - Nokia Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class Status(object):
URL = 'v1/status/'
def __init__(self, api):
self.api = api
def get(self):
"""Get Status result"""
resp = self.api.get(self.URL)
return resp.json()