Remove Ceilometer collector and transformer

As announced during the Queens cycle, all ceilometer-collector
related code has been removed.

Change-Id: I03f9a89ae4bc970fbc421dd6964be95cdacfe758
Task: 6293
Story: 2001503
This commit is contained in:
Luka Peschke 2018-02-28 16:53:31 +01:00 committed by Martin CAMEY
parent acf1978421
commit dd64aaa3d5
14 changed files with 10 additions and 924 deletions

View File

@ -36,7 +36,7 @@ class CollectorInfos(wtypes.Base):
@classmethod
def sample(cls):
sample = cls(name='ceilometer',
sample = cls(name='gnocchi',
enabled=True)
return sample
@ -60,7 +60,7 @@ class ServiceToCollectorMapping(wtypes.Base):
@classmethod
def sample(cls):
sample = cls(service='compute',
collector='ceilometer')
collector='gnocchi')
return sample
@ -79,6 +79,6 @@ class ServiceToCollectorMappingCollection(wtypes.Base):
@classmethod
def sample(cls):
mapping = ServiceToCollectorMapping(service='compute',
collector='ceilometer')
collector='gnocchi')
sample = cls(mappings=[mapping])
return sample

View File

@ -1,518 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Objectif Libre
#
# 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.
#
# @author: Stéphane Albert
#
import decimal
from ceilometerclient import client as cclient
from keystoneauth1 import loading as ks_loading
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import units
from cloudkitty import collector
from cloudkitty import utils as ck_utils
LOG = logging.getLogger(__name__)
CEILOMETER_COLLECTOR_OPTS = 'ceilometer_collector'
ceilometer_collector_opts = ks_loading.get_auth_common_conf_options()
cfg.CONF.register_opts(ceilometer_collector_opts, CEILOMETER_COLLECTOR_OPTS)
ks_loading.register_session_conf_options(
cfg.CONF,
CEILOMETER_COLLECTOR_OPTS)
ks_loading.register_auth_conf_options(
cfg.CONF,
CEILOMETER_COLLECTOR_OPTS)
CONF = cfg.CONF
METRICS_CONF = ck_utils.get_metrics_conf(CONF.collect.metrics_conf)
class ResourceNotFound(Exception):
"""Raised when the resource doesn't exist."""
def __init__(self, resource_type, resource_id):
super(ResourceNotFound, self).__init__(
"No such resource: %s, type: %s" % (resource_id, resource_type))
self.resource_id = resource_id
self.resource_type = resource_type
class CeilometerResourceCacher(object):
def __init__(self):
self._resource_cache = {}
def add_resource_detail(self, resource_type, resource_id, resource_data):
if resource_type not in self._resource_cache:
self._resource_cache[resource_type] = {}
self._resource_cache[resource_type][resource_id] = resource_data
return self._resource_cache[resource_type][resource_id]
def has_resource_detail(self, resource_type, resource_id):
if resource_type in self._resource_cache:
if resource_id in self._resource_cache[resource_type]:
return True
return False
def get_resource_detail(self, resource_type, resource_id):
try:
resource = self._resource_cache[resource_type][resource_id]
return resource
except KeyError:
raise ResourceNotFound(resource_type, resource_id)
class CeilometerCollector(collector.BaseCollector):
collector_name = 'ceilometer'
dependencies = ('CeilometerTransformer',
'CloudKittyFormatTransformer')
units_mappings = {
'compute': 'instance',
'image': 'MiB',
'volume': 'GiB',
'network.bw.out': 'MB',
'network.bw.in': 'MB',
'network.floating': 'ip',
'radosgw.usage': 'GiB'
}
def __init__(self, transformers, **kwargs):
super(CeilometerCollector, self).__init__(transformers, **kwargs)
self.t_ceilometer = self.transformers['CeilometerTransformer']
self.t_cloudkitty = self.transformers['CloudKittyFormatTransformer']
self._cacher = CeilometerResourceCacher()
self.auth = ks_loading.load_auth_from_conf_options(
CONF,
CEILOMETER_COLLECTOR_OPTS)
self.session = ks_loading.load_session_from_conf_options(
CONF,
CEILOMETER_COLLECTOR_OPTS,
auth=self.auth)
self._conn = cclient.get_client(
'2',
session=self.session)
@classmethod
def get_metadata(cls, resource_name, transformers):
info = super(CeilometerCollector, cls).get_metadata(resource_name,
transformers)
try:
info["metadata"].extend(transformers['CeilometerTransformer']
.get_metadata(resource_name))
try:
tmp = METRICS_CONF['metrics_units'][resource_name]
info['unit'] = list(tmp.values())[0]['unit']
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
info['unit'] = cls.units_mappings[resource_name]
except KeyError:
pass
return info
def gen_filter(self, op='eq', **kwargs):
"""Generate ceilometer filter from kwargs."""
q_filter = []
for kwarg in kwargs:
q_filter.append({'field': kwarg, 'op': op, 'value': kwargs[kwarg]})
return q_filter
def prepend_filter(self, prepend, **kwargs):
"""Filter composer."""
q_filter = {}
for kwarg in kwargs:
q_filter[prepend + kwarg] = kwargs[kwarg]
return q_filter
def user_metadata_filter(self, op='eq', **kwargs):
"""Create user_metadata filter from kwargs."""
user_filter = {}
for kwarg in kwargs:
field = kwarg
# Auto replace of . to _ to match ceilometer behaviour
if '.' in field:
field = field.replace('.', '_')
user_filter[field] = kwargs[kwarg]
user_filter = self.prepend_filter('user_metadata.', **user_filter)
return self.metadata_filter(op, **user_filter)
def metadata_filter(self, op='eq', **kwargs):
"""Create metadata filter from kwargs."""
meta_filter = self.prepend_filter('metadata.', **kwargs)
return self.gen_filter(op, **meta_filter)
def resources_stats(self,
meter,
start,
end=None,
project_id=None,
q_filter=None):
"""Resources statistics during the timespan."""
start_iso = ck_utils.ts2iso(start)
req_filter = self.gen_filter(op='ge', timestamp=start_iso)
if project_id:
req_filter.extend(self.gen_filter(project=project_id))
if end:
end_iso = ck_utils.ts2iso(end)
req_filter.extend(self.gen_filter(op='le', timestamp=end_iso))
if isinstance(q_filter, list):
req_filter.extend(q_filter)
elif q_filter:
req_filter.append(q_filter)
resources_stats = self._conn.statistics.list(meter_name=meter,
period=0, q=req_filter,
groupby=['resource_id'])
return resources_stats
def active_resources(self,
meter,
start,
end=None,
project_id=None,
q_filter=None):
"""Resources that were active during the timespan."""
resources_stats = self.resources_stats(meter,
start,
end,
project_id,
q_filter)
return [resource.groupby['resource_id']
for resource in resources_stats]
def get_compute(self, start, end=None, project_id=None, q_filter=None):
active_instance_ids = self.active_resources('cpu', start, end,
project_id, q_filter)
compute_data = []
for instance_id in active_instance_ids:
if not self._cacher.has_resource_detail('compute', instance_id):
raw_resource = self._conn.resources.get(instance_id)
instance = self.t_ceilometer.strip_resource_data('compute',
raw_resource)
self._cacher.add_resource_detail('compute',
instance_id,
instance)
instance = self._cacher.get_resource_detail('compute',
instance_id)
try:
met = list(METRICS_CONF['metrics_units']['compute'].values())
compute_data.append(self.t_cloudkitty.format_item(
instance,
met[0]['unit'],
1,
))
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
compute_data.append(self.t_cloudkitty.format_item(
instance,
self.units_mappings['compute'],
1,
))
if not compute_data:
raise collector.NoDataCollected(self.collector_name, 'compute')
return self.t_cloudkitty.format_service('compute', compute_data)
def get_image(self, start, end=None, project_id=None, q_filter=None):
active_image_stats = self.resources_stats('image.size',
start,
end,
project_id,
q_filter)
image_data = []
for image_stats in active_image_stats:
image_id = image_stats.groupby['resource_id']
if not self._cacher.has_resource_detail('image', image_id):
raw_resource = self._conn.resources.get(image_id)
image = self.t_ceilometer.strip_resource_data('image',
raw_resource)
self._cacher.add_resource_detail('image',
image_id,
image)
image = self._cacher.get_resource_detail('image',
image_id)
# Unit conversion
try:
conv_data = METRICS_CONF['metrics_units']['image']
image_size_mb = ck_utils.convert_unit(
decimal.Decimal(image_stats.max),
conv_data['image.size'].get('factor', 1),
conv_data['image.size'].get('offset', 0),
)
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated hardcoded method.')
image_size_mb = decimal.Decimal(image_stats.max) / units.Mi
try:
met = list(METRICS_CONF['metrics_units']['image'].values())
image_data.append(self.t_cloudkitty.format_item(
image,
met[0]['unit'],
image_size_mb,
))
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
image_data.append(self.t_cloudkitty.format_item(
image,
self.units_mappings['image'],
image_size_mb,
))
if not image_data:
raise collector.NoDataCollected(self.collector_name, 'image')
return self.t_cloudkitty.format_service('image', image_data)
def get_volume(self, start, end=None, project_id=None, q_filter=None):
active_volume_stats = self.resources_stats('volume.size',
start,
end,
project_id,
q_filter)
volume_data = []
for volume_stats in active_volume_stats:
volume_id = volume_stats.groupby['resource_id']
if not self._cacher.has_resource_detail('volume',
volume_id):
raw_resource = self._conn.resources.get(volume_id)
volume = self.t_ceilometer.strip_resource_data('volume',
raw_resource)
self._cacher.add_resource_detail('volume',
volume_id,
volume)
volume = self._cacher.get_resource_detail('volume',
volume_id)
# Unit conversion
try:
conv_data = METRICS_CONF['metrics_units']['volume']
volume_stats.max = ck_utils.convert_unit(
decimal.Decimal(volume_stats.max),
conv_data['volume.size'].get('factor', 1),
conv_data['volume.size'].get('offset', 0),
)
volume_data.append(self.t_cloudkitty.format_item(
volume,
conv_data['volume.size']['unit'],
volume_stats.max,
))
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
volume_data.append(self.t_cloudkitty.format_item(
volume,
self.units_mappings['volume'],
volume_stats.max,
))
if not volume_data:
raise collector.NoDataCollected(self.collector_name, 'volume')
return self.t_cloudkitty.format_service('volume', volume_data)
def _get_network_bw(self,
direction,
start,
end=None,
project_id=None,
q_filter=None):
if direction == 'in':
resource_type = 'network.incoming.bytes'
else:
direction = 'out'
resource_type = 'network.outgoing.bytes'
active_tap_stats = self.resources_stats(resource_type,
start,
end,
project_id,
q_filter)
bw_data = []
for tap_stat in active_tap_stats:
tap_id = tap_stat.groupby['resource_id']
if not self._cacher.has_resource_detail('network.tap',
tap_id):
raw_resource = self._conn.resources.get(tap_id)
tap = self.t_ceilometer.strip_resource_data(
'network.tap',
raw_resource)
self._cacher.add_resource_detail('network.tap',
tap_id,
tap)
tap = self._cacher.get_resource_detail('network.tap',
tap_id)
# Unit conversion
try:
conv = METRICS_CONF['metrics_units']['network.bw.' + direction]
tap_bw_mb = ck_utils.convert_unit(
decimal.Decimal(tap_stat.max),
conv[resource_type].get('factor', 1),
conv[resource_type].get('offset', 0),
)
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated hardcoded method.')
tap_bw_mb = decimal.Decimal(tap_stat.max) / units.M
try:
met = METRICS_CONF['metrics_units']['network.bw.' + direction]
bw_data.append(self.t_cloudkitty.format_item(
tap,
list(met.values())[0]['unit'],
tap_bw_mb,
))
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
bw_data.append(self.t_cloudkitty.format_item(
tap,
self.units_mappings['network.bw.' + direction],
tap_bw_mb,
))
ck_res_name = 'network.bw.{}'.format(direction)
if not bw_data:
raise collector.NoDataCollected(self.collector_name,
ck_res_name)
return self.t_cloudkitty.format_service(ck_res_name,
bw_data)
def get_network_bw_out(self,
start,
end=None,
project_id=None,
q_filter=None):
return self._get_network_bw('out', start, end, project_id, q_filter)
def get_network_bw_in(self,
start,
end=None,
project_id=None,
q_filter=None):
return self._get_network_bw('in', start, end, project_id, q_filter)
def get_network_floating(self,
start,
end=None,
project_id=None,
q_filter=None):
active_floating_ids = self.active_resources('ip.floating',
start,
end,
project_id,
q_filter)
floating_data = []
for floating_id in active_floating_ids:
if not self._cacher.has_resource_detail('network.floating',
floating_id):
raw_resource = self._conn.resources.get(floating_id)
floating = self.t_ceilometer.strip_resource_data(
'network.floating',
raw_resource)
self._cacher.add_resource_detail('network.floating',
floating_id,
floating)
floating = self._cacher.get_resource_detail('network.floating',
floating_id)
try:
metric = METRICS_CONF['metrics_units']['network.floating']
floating_data.append(self.t_cloudkitty.format_item(
floating,
list(metric.values())[0]['unit'],
1,
))
# NOTE(mc): deprecated except part kept for backward compatibility.
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated oslo config method.')
floating_data.append(self.t_cloudkitty.format_item(
floating,
self.units_mappings['network.floating'],
1,
))
if not floating_data:
raise collector.NoDataCollected(self.collector_name,
'network.floating')
return self.t_cloudkitty.format_service('network.floating',
floating_data)
def get_radosgw_usage(self,
start,
end=None,
project_id=None,
q_filter=None):
active_rgw_stats = self.resources_stats('radosgw.objects.size', start,
end, project_id, q_filter)
rgw_data = []
for rgw_stats in active_rgw_stats:
rgw_id = rgw_stats.groupby['resource_id']
if not self._cacher.has_resource_detail('radosgw.usage', rgw_id):
raw_resource = self._conn.resources.get(rgw_id)
rgw = self.t_ceilometer.strip_resource_data('radosgw.usage',
raw_resource)
self._cacher.add_resource_detail('radosgw.usage', rgw_id, rgw)
rgw = self._cacher.get_resource_detail('radosgw.usage', rgw_id)
# Unit conversion
try:
conv_data = METRICS_CONF['metrics_units']['radosgw.usage']
rgw_size = ck_utils.convert_unit(
decimal.Decimal(rgw_stats.max),
conv_data['radosgw.object.size'].get('factor', 1),
conv_data['radosgw.object.size'].get('offset', 0),
)
rgw_data.append(
self.t_cloudkitty.format_item(
rgw,
conv_data['rados.objects.size']['unit'],
rgw_size,
)
)
except KeyError:
LOG.warning('Error when trying to use yaml metrology conf.')
LOG.warning('Fallback on the deprecated hardcoded method.')
rgw_size = decimal.Decimal(rgw_stats.max) / units.Gi
rgw_data.append(
self.t_cloudkitty.format_item(
rgw,
self.units_mappings['radosgw.usage'],
rgw_size,
)
)
if not rgw_data:
raise collector.NoDataCollected(self.collector_name,
'radosgw.usage')
return self.t_cloudkitty.format_service('radosgw.usage', rgw_data)

View File

@ -17,7 +17,6 @@ import copy
import itertools
import cloudkitty.api.app
import cloudkitty.collector.ceilometer
import cloudkitty.collector.gnocchi
import cloudkitty.collector.monasca
import cloudkitty.config
@ -36,8 +35,6 @@ _opts = [
cloudkitty.api.app.api_opts,))),
('collect', list(itertools.chain(
cloudkitty.utils.collect_opts))),
('ceilometer_collector', list(itertools.chain(
cloudkitty.collector.ceilometer.ceilometer_collector_opts))),
('collector_monasca', list(itertools.chain(
cloudkitty.collector.monasca.collector_monasca_opts))),
('gnocchi_collector', list(itertools.chain(

View File

@ -153,10 +153,6 @@ class APIWorker(BaseWorker):
class Worker(BaseWorker):
def __init__(self, collector, storage, tenant_id=None):
self._collector = collector
if getattr(self._collector, 'collector_name') == 'ceilometer':
LOG.warning('Ceilometer collector is deprecated and will be '
'removed during R cycle. This collector only works '
'with versions prior to Ocata')
self._storage = storage
self._period = METRICS_CONF['period']
self._wait_time = METRICS_CONF['wait_periods'] * self._period

View File

@ -1,158 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Objectif Libre
#
# 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.
#
# @author: Stéphane Albert
#
import copy
from cloudkitty import tests
from cloudkitty.tests import transformers as t_transformers
from cloudkitty.transformer import ceilometer
CEIL_COMPUTE = {
'availability_zone': 'nova',
'display_name': 'test',
'instance_type': 'm1.nano',
'image.id': 'c8ae2e38-316d-11e6-b19a-dbee663ddaee',
'memory_mb': 64,
'user_metadata.meta1': 'test1',
'vcpus': '1'}
TRANS_COMPUTE = {
'instance_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
'availability_zone': 'nova',
'metadata': {
'meta1': 'test1'},
'name': 'test',
'flavor': 'm1.nano',
'image_id': 'c8ae2e38-316d-11e6-b19a-dbee663ddaee',
'memory': 64,
'vcpus': '1'}
CEIL_VOLUME = {
'availability_zone': 'az1',
'volume_id': '17992d58-316f-11e6-9528-1379eed8ebe4',
'display_name': 'vol1',
'size': 10}
TRANS_VOLUME = {
'volume_id': '17992d58-316f-11e6-9528-1379eed8ebe4',
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
'availability_zone': 'az1',
'name': 'vol1',
'size': 10}
CEIL_IMAGE = {
'status': 'active',
'name': 'Cirros',
'deleted': 'False',
'disk_format': 'ami',
'id': 'c4a0d12e-88ff-43e1-b182-f95dfe75e40c',
'protected': 'False',
'container_format': 'ami',
'is_public': 'False',
'size': '25165824'}
TRANS_IMAGE = {
'image_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
'container_format': 'ami',
'deleted': 'False',
'disk_format': 'ami',
'is_public': 'False',
'name': 'Cirros',
'protected': 'False',
'size': '25165824',
'status': 'active'}
CEIL_NETWORK_TAP = {
'instance_host': 'dev',
'mac': 'fa:16:3e:90:4b:6f',
'host': '5b85dd1e7796f87bae6fea6dcb608cf907446eaa715de90d77dadb7b',
'vnic_name': 'tap704159b2-8b',
'instance_id': '685243d6-34f1-4a39-8446-87b018ada8d9'}
TRANS_NETWORK_TAP = {
'instance_host': 'dev',
'mac': 'fa:16:3e:90:4b:6f',
'host': '5b85dd1e7796f87bae6fea6dcb608cf907446eaa715de90d77dadb7b',
'vnic_name': 'tap704159b2-8b',
'instance_id': '685243d6-34f1-4a39-8446-87b018ada8d9',
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'interface_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df'}
CEIL_NETWORK_FLOATING = {
'status': 'ACTIVE',
'router_id': 'a46530af-c5ba-4ba2-aa59-e2de4393151d',
'floating_network_id': '823daec0-b000-446b-9539-20f7463775c3',
'fixed_ip_address': '10.0.0.6',
'floating_ip_address': '172.24.4.9',
'port_id': '65005c79-2ab0-46d4-8ab8-f3044ec47418'}
TRANS_NETWORK_FLOATING = {
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
'floatingip_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
'status': 'ACTIVE',
'router_id': 'a46530af-c5ba-4ba2-aa59-e2de4393151d',
'floating_network_id': '823daec0-b000-446b-9539-20f7463775c3',
'fixed_ip_address': '10.0.0.6',
'floating_ip_address': '172.24.4.9',
'port_id': '65005c79-2ab0-46d4-8ab8-f3044ec47418'}
class CeilometerTransformerTest(tests.TestCase):
def generate_ceilometer_resource(self, data):
resource = t_transformers.ClassWithAttr({
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
'resource_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
'user_id': '576808d8-3169-11e6-992b-5f931fc671df'})
resource.metadata = copy.deepcopy(data)
return resource
def test_strip_ceilometer_compute(self):
resource = self.generate_ceilometer_resource(CEIL_COMPUTE)
t_test = ceilometer.CeilometerTransformer()
result = t_test.strip_resource_data('compute', resource)
self.assertEqual(TRANS_COMPUTE, result)
def test_strip_ceilometer_volume(self):
resource = self.generate_ceilometer_resource(CEIL_VOLUME)
t_test = ceilometer.CeilometerTransformer()
result = t_test.strip_resource_data('volume', resource)
self.assertEqual(TRANS_VOLUME, result)
def test_strip_ceilometer_image(self):
resource = self.generate_ceilometer_resource(CEIL_IMAGE)
t_test = ceilometer.CeilometerTransformer()
result = t_test.strip_resource_data('image', resource)
self.assertEqual(TRANS_IMAGE, result)
def test_strip_ceilometer_network_tap(self):
resource = self.generate_ceilometer_resource(CEIL_NETWORK_TAP)
t_test = ceilometer.CeilometerTransformer()
result = t_test.strip_resource_data('network_tap', resource)
self.assertEqual(TRANS_NETWORK_TAP, result)
def test_strip_ceilometer_network_floating(self):
resource = self.generate_ceilometer_resource(CEIL_NETWORK_FLOATING)
t_test = ceilometer.CeilometerTransformer()
result = t_test.strip_resource_data('network_floating', resource)
self.assertEqual(TRANS_NETWORK_FLOATING, result)

View File

@ -1,138 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Objectif Libre
#
# 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.
#
# @author: Stéphane Albert
#
from cloudkitty import transformer
class CeilometerTransformer(transformer.BaseTransformer):
compute_map = {
'name': ['display_name'],
'flavor': ['flavor.name', 'instance_type'],
'vcpus': ['vcpus'],
'memory': ['memory_mb'],
'image_id': ['image.id', 'image_meta.base_image_ref'],
'availability_zone': [
'availability_zone',
'OS-EXT-AZ.availability_zone'],
}
volume_map = {
'volume_id': ['volume_id'],
'name': ['display_name'],
'availability_zone': ['availability_zone'],
'size': ['size'],
}
image_map = {
'container_format': ['container_format'],
'deleted': ['deleted'],
'disk_format': ['disk_format'],
'is_public': ['is_public'],
'name': ['name'],
'protected': ['protected'],
'size': ['size'],
'status': ['status'],
}
network_tap_map = {
'instance_host': ['instance_host'],
'mac': ['mac'],
'host': ['host'],
'vnic_name': ['vnic_name'],
'instance_id': ['instance_id'],
}
network_floating_map = {
'status': ['status'],
'router_id': ['router_id'],
'floating_network_id': ['floating_network_id'],
'fixed_ip_address': ['fixed_ip_address'],
'floating_ip_address': ['floating_ip_address'],
'port_id': ['port_id'],
}
radosgw_usage_map = {}
metadata_item = 'metadata'
def _strip_compute(self, data):
res_data = self.generic_strip('compute', data)
res_data['instance_id'] = data.resource_id
res_data['project_id'] = data.project_id
res_data['user_id'] = data.user_id
res_data['metadata'] = {}
for field in data.metadata:
if field.startswith('user_metadata'):
res_data['metadata'][field[14:]] = data.metadata[field]
return res_data
def _strip_volume(self, data):
res_data = self.generic_strip('volume', data)
res_data['user_id'] = data.user_id
res_data['project_id'] = data.project_id
return res_data
def _strip_image(self, data):
res_data = self.generic_strip('image', data)
res_data['image_id'] = data.resource_id
res_data['project_id'] = data.project_id
res_data['user_id'] = data.user_id
return res_data
def _strip_network_tap(self, data):
res_data = self.generic_strip('network_tap', data)
res_data['user_id'] = data.user_id
res_data['project_id'] = data.project_id
res_data['interface_id'] = data.resource_id
return res_data
def _strip_network_floating(self, data):
res_data = self.generic_strip('network_floating', data)
res_data['user_id'] = data.user_id
res_data['project_id'] = data.project_id
res_data['floatingip_id'] = data.resource_id
return res_data
def _strip_radosgw_usage(self, data):
res_data = self.generic_strip('radosgw_usage_size', data)
res_data['radosgw_id'] = data.resource_id
res_data['user_id'] = data.user_id
res_data['project_id'] = data.project_id
return res_data
def get_metadata(self, res_type):
"""Return list of metadata available after transformation for given
resource type.
"""
class FakeData(dict):
"""FakeData object."""
def __getattr__(self, name, default=None):
try:
return super(FakeData, self).__getattr__(self, name)
except AttributeError:
return default or name
# list of metadata is built by applying the generic strip_resource_data
# function to a fake data object
fkdt = FakeData()
setattr(fkdt, self.metadata_item, FakeData())
res_data = self.strip_resource_data(res_type, fkdt)
return res_data.keys()

View File

@ -1,85 +0,0 @@
#!/usr/bin/env bash
show_state()
{
echo ''
echo 'Show ceilometer state:'
echo "GET http://localhost:8889/v1/collector/ceilometer/state"
curl "http://localhost:8889/v1/collector/ceilometer/state"
echo ''
echo "GET http://localhost:8889/v1/collector/state/ceilometer"
curl "http://localhost:8889/v1/collector/state/ceilometer"
echo ''
}
set_state()
{
echo ''
echo 'Set ceilometer state:'
echo "PUT http://localhost:8889/v1/collector/ceilometer/state"
curl "http://localhost:8889/v1/collector/ceilometer/state" \
-X PUT -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"enabled": true}'
echo ''
echo "PUT http://localhost:8889/v1/collector/state/ceilometer"
curl "http://localhost:8889/v1/collector/state/ceilometer" \
-X PUT -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"enabled": false}'
echo ''
}
list_mappings()
{
echo ''
echo 'Get compute mapping:'
echo "GET http://localhost:8889/v1/collector/mappings/compute"
curl "http://localhost:8889/v1/collector/mappings/compute"
echo ''
echo 'List ceilometer mappings:'
echo "GET http://localhost:8889/v1/collector/ceilometer/mappings"
curl "http://localhost:8889/v1/collector/ceilometer/mappings"
echo ''
}
set_mappings()
{
echo ''
echo 'Set compute to ceilometer mapping:'
echo "POST http://localhost:8889/v1/collector/ceilometer/mappings/compute"
curl "http://localhost:8889/v1/collector/ceilometer/mappings/compute" \
-X POST -H "Content-Type: application/json" -H "Accept: application/json" \
-d ''
echo ''
echo 'Set volume to ceilometer mapping:'
echo "POST http://localhost:8889/v1/collector/mappings?collector=ceilometer&service=volume"
curl "http://localhost:8889/v1/collector/mappings?collector=ceilometer&service=volume" \
-X POST -H "Content-Type: application/json" -H "Accept: application/json" \
-d ''
echo ''
}
del_mappings()
{
echo ''
echo 'Deleting compute to ceilometer mapping:'
echo "DELETE http://localhost:8889/v1/collector/ceilometer/mappings/compute"
curl "http://localhost:8889/v1/collector/ceilometer/mappings/compute" \
-X DELETE -H "Content-Type: application/json" -H "Accept: application/json" \
-d ''
test $? && echo 'OK'
echo 'Deleting volume to ceilometer mapping:'
echo "DELETE http://localhost:8889/v1/collector/mappings?collector=ceilometer&service=volume"
curl "http://localhost:8889/v1/collector/mappings?collector=ceilometer&service=volume" \
-X DELETE -H "Content-Type: application/json" -H "Accept: application/json" \
-d ''
test $? && echo 'OK'
}
show_state
set_state
list_mappings
set_mappings
list_mappings
del_mappings
list_mappings

View File

@ -41,7 +41,7 @@ CLOUDKITTY_PRICING_PASSWORD=${CLOUDKITTY_PRICING_PASSWORD:-$ADMIN_PASSWORD}
CLOUDKITTY_PRICING_TENANT=${CLOUDKITTY_PRICING_TENANT:-"demo"}
# Set CloudKitty collect info
CLOUDKITTY_COLLECTOR=${CLOUDKITTY_COLLECTOR:-ceilometer}
CLOUDKITTY_COLLECTOR=${CLOUDKITTY_COLLECTOR:-gnocchi}
CLOUDKITTY_SERVICES=${CLOUDKITTY_SERVICES:-compute}
CLOUDKITTY_METRICS_CONF=metrics.yml

View File

@ -45,13 +45,6 @@ Field
A field is referring to a metadata field of a resource. For example on an
instance object (**compute**), you can use the flavor to define specific rules.
With Ceilometer as the collector, the following fields are available for each
service:
* Compute: flavor, vcpus, memory (MB), image_id, availability_zone
* Volume: name, volume_type, availability_zone
* Image: disk_format, container_format, is_public, availability_zone
With Gnocchi as collector, the following fields are available for each service:
* Compute: flavor_id, vcpus, image_id, memory (MB)

View File

@ -166,9 +166,8 @@ gnocchi backend, add the following entry:
[storage_gnocchi]
auth_section = ks_auth
Three collectors are available: Ceilometer (deprecated, see the Telemetry
documentation), Gnocchi and Monasca. The Monasca collector collects metrics
published by the Ceilometer agent to Monasca using Ceilosca_.
Two collectors are available: Gnocchi and Monasca. The Monasca collector
collects metrics published by the Ceilometer agent to Monasca using Ceilosca_.
The collect information, is separated from the Cloudkitty configuration file,
in a yaml one.

View File

@ -0,0 +1,4 @@
---
deprecations:
- |
The ceilometer collector and transformer have been removed.

View File

@ -5,7 +5,6 @@ pbr>=1.6 # Apache-2.0
alembic>=0.8.0 # MIT
eventlet!=0.18.3,>=0.18.2 # MIT
keystonemiddleware!=4.1.0,>=4.0.0 # Apache-2.0
python-ceilometerclient>=2.2.1 # Apache-2.0
gnocchiclient>=2.5.0 # Apache-2.0
python-monascaclient>=1.7.0 # Apache-2.0
python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0

View File

@ -4,7 +4,6 @@
pbr<2.0,>=1.6
eventlet>=0.17.4
keystonemiddleware>=2.0.0
python-ceilometerclient>=1.0.13
python-keystoneclient>=1.6.0
PasteDeploy>=1.5.0
pecan>=1.0.0

View File

@ -46,7 +46,6 @@ oslo.config.opts.defaults =
cloudkitty.collector.backends =
fake = cloudkitty.collector.fake:CSVCollector
ceilometer = cloudkitty.collector.ceilometer:CeilometerCollector
gnocchi = cloudkitty.collector.gnocchi:GnocchiCollector
monasca = cloudkitty.collector.monasca:MonascaCollector
meta = cloudkitty.collector.meta:MetaCollector
@ -57,7 +56,6 @@ cloudkitty.tenant.fetchers =
cloudkitty.transformers =
CloudKittyFormatTransformer = cloudkitty.transformer.format:CloudKittyFormatTransformer
CeilometerTransformer = cloudkitty.transformer.ceilometer:CeilometerTransformer
GnocchiTransformer = cloudkitty.transformer.gnocchi:GnocchiTransformer
cloudkitty.rating.processors =