add a new service list api

Story: 2004897
Task: 29205
Change-Id: Iecb2ae810dd2a6a6b544c2ed7dbfe6288f393178
This commit is contained in:
Eyal 2019-02-03 15:08:11 +02:00
parent a7b134c0bd
commit c293cbd2d5
9 changed files with 119 additions and 27 deletions

View File

@ -168,6 +168,7 @@ You'll find complete documentation on the shell by running
resource count Show a count of all resources
resource list List resources
resource show Show a resource
service list List all services
template add Add a template
template delete Delete a template
template list List all templates
@ -740,6 +741,34 @@ resource count::
"SUBOPTIMAL": 8
}
Service Examples
----------------
Note: To see complete usage: 'vitrage help' and 'vitrage help <command>'
service list
^^^^^^^^^^^^
A list of all vitrage services and their status::
vitrage service list
+----------------------------------+------------+--------------+---------------------------+
| Name | Process Id | Hostname | Created At |
+----------------------------------+------------+--------------+---------------------------+
| ApiWorker worker(0) | 23161 | controller-1 | 2019-02-10T11:07:15+00:00 |
| EvaluatorWorker worker(0) | 23153 | controller-1 | 2019-02-10T11:07:15+00:00 |
| EvaluatorWorker worker(1) | 23155 | controller-1 | 2019-02-10T11:07:15+00:00 |
| EvaluatorWorker worker(2) | 23157 | controller-1 | 2019-02-10T11:07:15+00:00 |
| EvaluatorWorker worker(3) | 23158 | controller-1 | 2019-02-10T11:07:15+00:00 |
| MachineLearningService worker(0) | 23366 | controller-1 | 2019-02-10T11:07:33+00:00 |
| PersistorService worker(0) | 23475 | controller-1 | 2019-02-10T11:07:35+00:00 |
| SnmpParsingService worker(0) | 23164 | controller-1 | 2019-02-10T11:07:15+00:00 |
| vitrageuWSGI worker 1 | 25698 | controller-1 | 2019-02-10T11:14:30+00:00 |
| vitrageuWSGI worker 2 | 25699 | controller-1 | 2019-02-10T11:14:30+00:00 |
| VitrageNotifierService worker(0) | 23352 | controller-1 | 2019-02-10T11:07:32+00:00 |
+----------------------------------+------------+--------------+---------------------------+
Alarms Examples
---------------
Note: To see complete usage: 'vitrage help' and 'vitrage help <command>'

View File

@ -1,6 +0,0 @@
[DEFAULT]
# The list of modules to copy from oslo-incubator.git
# The base module to hold the copy of openstack.common
base=vitrageclient

View File

@ -0,0 +1,4 @@
---
features:
- Added a new cli command ``service list`` to display all the vitrage
services present in the system.

View File

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

View File

@ -5,36 +5,38 @@ _vitrage()
_get_comp_words_by_ref -n : cur prev words
# Command data:
cmds='alarm complete event healthcheck help rca resource template topology webhook'
cmds='alarm complete event healthcheck help rca resource service template topology webhook'
cmds_alarm='count history list show'
cmds_alarm_count='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --all-tenants'
cmds_alarm_history='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column --all-tenants --limit --marker --start --end'
cmds_alarm_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column --all-tenants --limit --marker'
cmds_alarm_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
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'
cmds_alarm_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants --limit --marker'
cmds_alarm_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
cmds_complete='-h --help --name --shell'
cmds_event='post'
cmds_event_post='-h --help --type --time --details'
cmds_healthcheck='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
cmds_healthcheck='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
cmds_help='-h --help'
cmds_rca='show'
cmds_rca_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --all-tenants'
cmds_resource='list show'
cmds_resource_count='-h --help --type --all-tenants --filter --group-by'
cmds_resource_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column --type --all-tenants --filter'
cmds_resource_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
cmds_rca_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --all-tenants'
cmds_resource='count list show'
cmds_resource_count='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --type --all-tenants --filter --group-by'
cmds_resource_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --type --all-tenants --filter'
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_template='add delete list show validate'
cmds_template_add='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column --path --type'
cmds_template_add='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --path --type'
cmds_template_delete='-h --help'
cmds_template_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column'
cmds_template_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
cmds_template_validate='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --path --type'
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'
cmds_template_validate='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --path --type'
cmds_topology='show'
cmds_topology_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --filter --limit --root --graph-type --all-tenants'
cmds_topology_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --filter --limit --root --graph-type --all-tenants'
cmds_webhook='add delete list show'
cmds_webhook_add='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --url --regex_filter --headers'
cmds_webhook_delete='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
cmds_webhook_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --quote --noindent --sort-column --all-tenants'
cmds_webhook_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
cmds_webhook_add='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty --url --regex_filter --headers'
cmds_webhook_delete='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
cmds_webhook_list='-h --help -f --format -c --column --quote --noindent --max-width --fit-width --print-empty --sort-column --all-tenants'
cmds_webhook_show='-h --help -f --format -c --column --noindent --variable --prefix --max-width --fit-width --print-empty'
dash=-
underscore=_

View File

@ -38,6 +38,7 @@ from vitrageclient.v1.cli import event
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 template
from vitrageclient.v1.cli import topology
from vitrageclient.v1.cli import webhook
@ -67,7 +68,8 @@ class VitrageCommandManager(commandmanager.CommandManager):
'webhook delete': webhook.WebhookDelete,
'webhook add': webhook.WebhookAdd,
'webhook list': webhook.WebhookList,
'webhook show': webhook.WebhookShow
'webhook show': webhook.WebhookShow,
'service list': service.ServiceList
}
def load_commands(self, namespace):

View File

@ -0,0 +1,34 @@
# 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 lister
from vitrageclient.common import utils
class ServiceList(lister.Lister):
"""List all services"""
def get_parser(self, prog_name):
parser = super(ServiceList, self).get_parser(prog_name)
return parser
def take_action(self, parsed_args):
service = utils.get_client(self).service.list()
return utils.list2cols_with_rename(
(
('Name', 'name'),
('Process Id', 'process'),
('Hostname', 'hostname'),
('Created At', 'created'),
), service)

View File

@ -18,6 +18,7 @@ from vitrageclient.v1 import event
from vitrageclient.v1 import healthcheck
from vitrageclient.v1 import rca
from vitrageclient.v1 import resource
from vitrageclient.v1 import service
from vitrageclient.v1 import template
from vitrageclient.v1 import topology
from vitrageclient.v1 import webhook
@ -37,3 +38,4 @@ class Client(object):
self.event = event.Event(self._api)
self.healthcheck = healthcheck.HealthCheck(self._api)
self.webhook = webhook.Webhook(self._api)
self.service = service.Service(self._api)

View File

@ -0,0 +1,24 @@
# 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 Service(object):
url = 'v1/service/'
def __init__(self, api):
self.api = api
def list(self):
"""Get service list"""
return self.api.get(self.url).json()