diff --git a/doc/source/contributor/cli.rst b/doc/source/contributor/cli.rst index 8de97c9..066c521 100644 --- a/doc/source/contributor/cli.rst +++ b/doc/source/contributor/cli.rst @@ -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 ' + +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 ' diff --git a/openstack-common.conf b/openstack-common.conf deleted file mode 100644 index f640884..0000000 --- a/openstack-common.conf +++ /dev/null @@ -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 diff --git a/releasenotes/notes/add_service_list-0d0720c6bd41e10e.yaml b/releasenotes/notes/add_service_list-0d0720c6bd41e10e.yaml new file mode 100644 index 0000000..4f6cff6 --- /dev/null +++ b/releasenotes/notes/add_service_list-0d0720c6bd41e10e.yaml @@ -0,0 +1,4 @@ +--- +features: + - Added a new cli command ``service list`` to display all the vitrage + services present in the system. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 47b23a8..71e144b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tools/vitrage.bash_completion b/tools/vitrage.bash_completion index b59d463..7c060f0 100755 --- a/tools/vitrage.bash_completion +++ b/tools/vitrage.bash_completion @@ -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=_ diff --git a/vitrageclient/shell.py b/vitrageclient/shell.py index d665fc7..1dd66cc 100755 --- a/vitrageclient/shell.py +++ b/vitrageclient/shell.py @@ -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): diff --git a/vitrageclient/v1/cli/service.py b/vitrageclient/v1/cli/service.py new file mode 100644 index 0000000..486aefb --- /dev/null +++ b/vitrageclient/v1/cli/service.py @@ -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) diff --git a/vitrageclient/v1/client.py b/vitrageclient/v1/client.py index 0be8b81..fe9cb01 100644 --- a/vitrageclient/v1/client.py +++ b/vitrageclient/v1/client.py @@ -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) diff --git a/vitrageclient/v1/service.py b/vitrageclient/v1/service.py new file mode 100644 index 0000000..90e597e --- /dev/null +++ b/vitrageclient/v1/service.py @@ -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()