Integrate gnocchi for OpenStack Telemetry

Add python-gnocchi and python-gnocchiclient.
Update in python-openstackclient:
 Remove the support of celiometer CLI extensions.
Update in python-ceilometer:
 Install ceilometer publisher instead of dispatcher.

Story: 2002825
Task: 22871
Depends-On: https://review.openstack.org/587279

Change-Id: I3b0dde2c8668f7e623bcf128a13010b26667d802
Signed-off-by: Don Penney <don.penney@windriver.com>
Signed-off-by: Jack Ding <jack.ding@windriver.com>
This commit is contained in:
Angie Wang
2018-06-13 01:21:21 -04:00
committed by Jack Ding
parent 1a7e61ed51
commit 71aaf7b58c
18 changed files with 850 additions and 492 deletions

View File

@@ -1,24 +0,0 @@
From 9d598a1ee8f1a98ce5f14d76f88123d4a7614e1c Mon Sep 17 00:00:00 2001
From: Sen Yang <sen.yang@windriver.com>
Date: Thu, 15 Feb 2018 11:52:09 -0500
Subject: [PATCH 1/1] US106901 Openstack-CLI-Adoption
---
SPECS/python-openstackclient.spec | 1 +
1 file changed, 1 insertion(+)
diff --git a/SPECS/python-openstackclient.spec b/SPECS/python-openstackclient.spec
index 4b1682e..6b582ce 100644
--- a/SPECS/python-openstackclient.spec
+++ b/SPECS/python-openstackclient.spec
@@ -26,6 +26,7 @@ Patch0005: 0001-US101470-Openstackclient-implementation-of-novaclien.patc
Patch0006: 0002-US101470-Openstackclient-implementation-of-novaclien.patch
Patch0007: 0001-US106901-Openstack-CLI-Adoption.patch
Patch0008: 0002-US106901-Openstack-CLI-Adoption.patch
+Patch0009: 0003-US106901-Openstack-CLI-Adoption.patch
BuildArch: noarch
--
1.8.3.1

View File

@@ -1,20 +0,0 @@
diff --git a/SPECS/python-openstackclient.spec b/SPECS/python-openstackclient.spec
index 6b582ce..5d75107 100644
--- a/SPECS/python-openstackclient.spec
+++ b/SPECS/python-openstackclient.spec
@@ -55,6 +55,7 @@ BuildRequires: python-keystoneclient
BuildRequires: python-novaclient
BuildRequires: python-cinderclient
BuildRequires: python-neutronclient
+BuildRequires: python-ceilometerclient
BuildRequires: python-mock
BuildRequires: python-requests-mock
BuildRequires: python-os-client-config
@@ -84,6 +85,7 @@ Requires: python-keystoneclient
Requires: python-novaclient
Requires: python-cinderclient
Requires: python-neutronclient
+Requires: python-ceilometerclient
Requires: python-six
Requires: python-osc-lib
Requires: python-%{client}-lang = %{version}-%{release}

View File

@@ -1,24 +1,23 @@
From ab8fc2b85ab7b60bdfeca496a32e90bc8f575478 Mon Sep 17 00:00:00 2001
From: Kam Nasim <kam.nasim@windriver.com>
Date: Fri, 11 May 2018 13:13:15 -0400
From ac2faa010188a6d824a8958c2971bcefe2a56ab9 Mon Sep 17 00:00:00 2001
From: Angie Wang <angie.Wang@windriver.com>
Date: Fri, 8 Jun 2018 16:05:52 -0400
Subject: [PATCH] meta patch for endpoint groups
Signed-off-by: Kam Nasim <kam.nasim@windriver.com>
---
SPECS/python-openstackclient.spec | 3 +++
1 file changed, 3 insertions(+)
diff --git a/SPECS/python-openstackclient.spec b/SPECS/python-openstackclient.spec
index 5d75107..26941e4 100644
index 4b1682e..c192b2b 100644
--- a/SPECS/python-openstackclient.spec
+++ b/SPECS/python-openstackclient.spec
@@ -27,6 +27,9 @@ Patch0006: 0002-US101470-Openstackclient-implementation-of-novaclien.patc
@@ -26,6 +26,9 @@ Patch0005: 0001-US101470-Openstackclient-implementation-of-novaclien.patc
Patch0006: 0002-US101470-Openstackclient-implementation-of-novaclien.patch
Patch0007: 0001-US106901-Openstack-CLI-Adoption.patch
Patch0008: 0002-US106901-Openstack-CLI-Adoption.patch
Patch0009: 0003-US106901-Openstack-CLI-Adoption.patch
+Patch0010: 0001-Optimize-getting-endpoint-list.patch
+Patch0011: 0002-Add-support-for-endpoing-filter-commands.patch
+Patch0012: 0003-Add-support-for-endpoint-group-commands.patch
+Patch0009: 0001-Optimize-getting-endpoint-list.patch
+Patch0010: 0002-Add-support-for-endpoing-filter-commands.patch
+Patch0011: 0003-Add-support-for-endpoint-group-commands.patch
BuildArch: noarch

View File

@@ -12,6 +12,4 @@
0002-meta-us101470.patch
0001-meta-US106901-Openstack-CLI-Adoption.patch
0002-meta-US106901-Openstack-CLI-Adoption.patch
0003-meta-US106901-Openstack-CLI-Adoption.patch
1002-require-python-ceilometerclient.patch
1003-meta-patch-for-endpoint-groups.patch

View File

@@ -1,435 +0,0 @@
From 6f1c69328515b4aa1591c999dedbbf88eefacfbe Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Wed, 14 Feb 2018 22:19:17 -0500
Subject: [PATCH 1/1] US106901: OSC equivalence for Ceilometer OSC
equivalence achieved for the following ceilometer commands
ceilometer clis:
ceilometer metertype-list
ceilometer pipeline-list
ceilometer pipeline-show
ceilometer pipeline-update
OSC equivalence:
openstack telemetry metertype list
openstack telemetry pipeline list
openstack telemetry pipeline show
openstack telemetry pipeline update
---
openstackclient/common/extension.py | 22 +++++
openstackclient/common/module.py | 2 +-
openstackclient/telemetry/__init__.py | 0
openstackclient/telemetry/client.py | 68 ++++++++++++++
openstackclient/telemetry/v2/__init__.py | 0
openstackclient/telemetry/v2/metertype.py | 67 ++++++++++++++
openstackclient/telemetry/v2/pipeline.py | 146 ++++++++++++++++++++++++++++++
requirements.txt | 1 +
setup.cfg | 6 ++
9 files changed, 311 insertions(+), 1 deletion(-)
create mode 100644 openstackclient/telemetry/__init__.py
create mode 100644 openstackclient/telemetry/client.py
create mode 100644 openstackclient/telemetry/v2/__init__.py
create mode 100644 openstackclient/telemetry/v2/metertype.py
create mode 100644 openstackclient/telemetry/v2/pipeline.py
diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py
index 139f43a..c1b0347 100644
--- a/openstackclient/common/extension.py
+++ b/openstackclient/common/extension.py
@@ -12,6 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
#
+# Copyright (c) 2013-2018 Wind River Systems, Inc.
+#
+#
+#
+#
+#
"""Extension action implementations"""
@@ -55,6 +61,13 @@ class ListExtension(command.Lister):
default=False,
help=_('List extensions for the Block Storage API'),
)
+ # WRS extension
+ parser.add_argument(
+ '--telemetry',
+ action='store_true',
+ default=False,
+ help=_('List extensions for Ceilometer API'),
+ )
parser.add_argument(
'--long',
action='store_true',
@@ -111,6 +124,15 @@ class ListExtension(command.Lister):
message = _("Failed to retrieve extensions list "
"from Network API")
LOG.warning(message)
+ # WRS extension
+ if parsed_args.telemetry or show_all:
+ telemetry_client = self.app.client_manager.telemetry
+ try:
+ data += telemetry_client.list_extensions.show_all()
+ except Exception:
+ message = _("Extensions list not supported by "
+ "Ceilometer API")
+ LOG.warning(message)
extension_tuples = (
utils.get_item_properties(
diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py
index 20497f2..12d2038 100644
--- a/openstackclient/common/module.py
+++ b/openstackclient/common/module.py
@@ -35,7 +35,7 @@ class ListCommand(command.Lister):
'--group',
metavar='<group-keyword>',
help=_('Show commands filtered by a command group, for example: '
- 'identity, volume, compute, image, network and '
+ 'identity, volume, compute, image, network, telemetry and '
'other keywords'),
)
return parser
diff --git a/openstackclient/telemetry/__init__.py b/openstackclient/telemetry/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/openstackclient/telemetry/client.py b/openstackclient/telemetry/client.py
new file mode 100644
index 0000000..0698a20
--- /dev/null
+++ b/openstackclient/telemetry/client.py
@@ -0,0 +1,68 @@
+# Copyright 2012-2018 OpenStack Foundation
+#
+# 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.
+#
+# Copyright (c) 2013-2018 Wind River Systems, Inc.
+#
+#
+#
+#
+#
+
+# WRS extension
+
+
+from osc_lib import utils
+from openstackclient.i18n import _
+
+import logging
+LOG = logging.getLogger(__name__)
+
+DEFAULT_API_VERSION = '2'
+API_VERSION_OPTION = 'telemetry_api_version'
+API_NAME = "telemetry"
+API_VERSIONS = {
+ "2": "ceilometerclient.v2.client.Client",
+}
+
+
+def make_client(instance):
+ """Returns an ceilometer service client"""
+ ceilometer_client = utils.get_client_class(
+ API_NAME,
+ instance._api_version[API_NAME],
+ API_VERSIONS)
+ LOG.debug('Instantiating ceilometer client: %s', ceilometer_client)
+
+ # Remember interface only if interface is set
+ kwargs = utils.build_kwargs_dict('endpoint_type', instance.interface)
+
+ client = ceilometer_client(
+ session=instance.session,
+ region_name=instance.region_name,
+ **kwargs
+ )
+
+ return client
+
+
+def build_option_parser(parser):
+ """Hook to add global options"""
+ parser.add_argument(
+ '--os-telemetry-api-version',
+ metavar='<telemetry-api-version>',
+ default=utils.env('TELEMETRY_API_VERSION'),
+ help=_('Ceilometer API version, default=%s (Env: TELEMETRY_API_VERSION)') %
+ DEFAULT_API_VERSION,
+ )
+ return parser
diff --git a/openstackclient/telemetry/v2/__init__.py b/openstackclient/telemetry/v2/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/openstackclient/telemetry/v2/metertype.py b/openstackclient/telemetry/v2/metertype.py
new file mode 100644
index 0000000..5472123
--- /dev/null
+++ b/openstackclient/telemetry/v2/metertype.py
@@ -0,0 +1,67 @@
+# Copyright 2012-2018 OpenStack Foundation
+#
+# 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.
+#
+# Copyright (c) 2013-2018 Wind River Systems, Inc.
+#
+#
+#
+#
+#
+# Copyright (c) 2013-2018 Wind River Systems, Inc.
+#
+#
+#
+#
+#
+# WRS extension
+
+from osc_lib.command import command
+from osc_lib import utils
+
+from openstackclient.i18n import _
+
+
+class ListMetertype(command.Lister):
+ """List the user's meter types."""
+
+ def get_parser(self, prog_name):
+ parser = super(ListMetertype, self).get_parser(prog_name)
+ parser.add_argument(
+ "-q", "--query",
+ metavar="<QUERY>",
+ help=_("key[op]data_type::value; list. data_type is optional, "
+ "but if supplied must be string, integer, float, or boolean.")
+ )
+ parser.add_argument(
+ "-l", "--limit",
+ metavar="<NUMBER>",
+ help=_("Maximum number of meters to return.")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ ceilometer_client = self.app.client_manager.telemetry
+
+ columns = (
+ "Name",
+ "Type",
+ "Unit",
+ )
+
+ metertypes = ceilometer_client.metertypes.list()
+
+ return (columns,
+ (utils.get_item_properties(
+ s, columns,
+ ) for s in metertypes))
diff --git a/openstackclient/telemetry/v2/pipeline.py b/openstackclient/telemetry/v2/pipeline.py
new file mode 100644
index 0000000..cbe077a
--- /dev/null
+++ b/openstackclient/telemetry/v2/pipeline.py
@@ -0,0 +1,146 @@
+# Copyright 2012-2018 OpenStack Foundation
+#
+# 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.
+#
+# Copyright (c) 2013-2018 Wind River Systems, Inc.
+#
+#
+#
+#
+#
+
+# WRS extension
+
+from osc_lib.command import command
+from osc_lib import utils
+import six
+
+from openstackclient.i18n import _
+
+from oslo_utils import strutils
+from ceilometerclient import exc
+from ceilometerclient.common import utils as ceilometer_utils
+
+
+class ListPipeline(command.Lister):
+ """List the pipelines ."""
+
+ def get_parser(self, prog_name):
+ parser = super(ListPipeline, self).get_parser(prog_name)
+ parser.add_argument(
+ "-q", "--query",
+ metavar="<QUERY>",
+ help=_("key[op]value; list.")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ ceilometer_client = self.app.client_manager.telemetry
+
+ columns = (
+ "Name",
+ "Enabled",
+ "Location",
+ "Max Bytes",
+ "Backup Count",
+ "Compress",
+ )
+
+ pipelines = ceilometer_client.pipelines.list()
+
+ return (columns,
+ (utils.get_item_properties(
+ s, columns,
+ ) for s in pipelines))
+
+
+class ShowPipeline(command.ShowOne):
+ """Show details of a given pipeline."""
+
+ def get_parser(self, prog_name):
+ parser = super(ShowPipeline, self).get_parser(prog_name)
+ parser.add_argument(
+ "-n", "--name",
+ metavar="<PIPELINE_NAME>",
+ help=_("Name of the pipeline to show.")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ ceilometer_client = self.app.client_manager.telemetry
+ pipelines = ceilometer_client.pipelines.get(parsed_args.name)
+ data = pipelines._info.copy()
+ return zip(*sorted(six.iteritems(data)))
+
+
+def _show_pipeline(pipeline):
+ fields = ['name', 'enabled', 'location', 'max_bytes',
+ 'backup_count', 'compress']
+ data = dict([(f, getattr(pipeline, f, '')) for f in fields])
+ ceilometer_utils.print_dict(data, wrap=72)
+
+
+class UpdatePipeline(command.Command):
+ """Update output values for an existing csv pipeline"""
+
+ def get_parser(self, prog_name):
+ parser = super(UpdatePipeline, self).get_parser(prog_name)
+ parser.add_argument(
+ "-n", "--name",
+ required=True,
+ metavar="<PIPELINE_NAME>",
+ help=_("Name of the pipeline to update.")
+ )
+ parser.add_argument(
+ "--enabled",
+ type=strutils.bool_from_string,
+ metavar="{True|False}",
+ help=_("True if enabling this pipeline")
+ )
+ parser.add_argument(
+ "--location",
+ metavar="<LOCATION>",
+ help=_("Full Path of the output file.")
+ )
+ parser.add_argument(
+ "--backup_count",
+ type=int,
+ metavar="<BACKUP_COUNT>",
+ help=_("Number of backup files to keep.")
+ )
+ parser.add_argument(
+ "--max_bytes",
+ type=int,
+ metavar="<MAX_BYTES>",
+ help=_("Maximum size of the file in bytes.")
+ )
+ parser.add_argument(
+ "--compress",
+ type=strutils.bool_from_string,
+ metavar="{True|False}",
+ help=_("True if compressing backups.")
+ )
+ return parser
+
+ def take_action(self, parsed_args):
+ """Update output values for an existing csv pipeline."""
+ ceilometer_client = self.app.client_manager.telemetry
+
+ fields = dict(filter(lambda x: not (x[1] is None), vars(parsed_args).items()))
+ fields = ceilometer_utils.key_with_slash_to_nested_dict(fields)
+ fields.pop('name')
+ try:
+ pipeline = ceilometer_client.pipelines.update(parsed_args.name, **fields)
+ except exc.HTTPNotFound:
+ raise exc.CommandError('Pipeline not found: %s' % parsed_args.name)
+ _show_pipeline(pipeline)
diff --git a/requirements.txt b/requirements.txt
index 24e4672..56a5705 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,3 +15,4 @@ python-glanceclient>=2.7.0 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0
python-novaclient>=9.0.0 # Apache-2.0
python-cinderclient>=3.0.0 # Apache-2.0
+python-ceilometerclient>=2.9.0 # Apache-2.0
diff --git a/setup.cfg b/setup.cfg
index 11f7261..1b8e006 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -37,6 +37,7 @@ openstack.cli.base =
network = openstackclient.network.client
object_store = openstackclient.object.client
volume = openstackclient.volume.client
+ telemetry = openstackclient.telemetry.client
openstack.common =
availability_zone_list = openstackclient.common.availability_zone:ListAvailabilityZone
configuration_show = openstackclient.common.configuration:ShowConfiguration
@@ -632,6 +633,11 @@ openstack.volume.v3 =
volume_transfer_request_delete = openstackclient.volume.v2.volume_transfer_request:DeleteTransferRequest
volume_transfer_request_list = openstackclient.volume.v2.volume_transfer_request:ListTransferRequest
volume_transfer_request_show = openstackclient.volume.v2.volume_transfer_request:ShowTransferRequest
+openstack.telemetry.v2 =
+ telemetry_metertype_list = openstackclient.telemetry.v2.metertype:ListMetertype
+ telemetry_pipeline_list = openstackclient.telemetry.v2.pipeline:ListPipeline
+ telemetry_pipeline_show = openstackclient.telemetry.v2.pipeline:ShowPipeline
+ telemetry_pipeline_update = openstackclient.telemetry.v2.pipeline:UpdatePipeline
[pbr]
autodoc_tree_index_modules = True
--
1.8.3.1