Remove the gnocchi transformer
This is part of a global effort to clean up CloudKitty's unmaintained codebase. Change-Id: Id2878bc9885132306333a7c675f3ac029a27a580 Story: 2004400 Task: 28580
This commit is contained in:
parent
838ec237e4
commit
6eb90404e4
@ -1,116 +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
|
|
||||||
import testtools
|
|
||||||
|
|
||||||
from cloudkitty import tests
|
|
||||||
from cloudkitty.tests.utils import is_functional_test
|
|
||||||
from cloudkitty.transformer import gnocchi
|
|
||||||
|
|
||||||
|
|
||||||
GNOCCHI_COMPUTE = {
|
|
||||||
'id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'display_name': 'test',
|
|
||||||
'flavor_id': '6aa7b1ce-317c-11e6-92d2-835668472674',
|
|
||||||
'image_ref': 'http://fakeglance/c8ae2e38-316d-11e6-b19a-dbee663ddaee',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
TRANS_COMPUTE = {
|
|
||||||
'instance_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
|
|
||||||
'resource_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'name': 'test',
|
|
||||||
'flavor_id': '6aa7b1ce-317c-11e6-92d2-835668472674',
|
|
||||||
'image_id': 'c8ae2e38-316d-11e6-b19a-dbee663ddaee',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
GNOCCHI_IMAGE = {
|
|
||||||
'id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'container_format': 'bare',
|
|
||||||
'disk_format': 'raw',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
TRANS_IMAGE = {
|
|
||||||
'resource_id': '2f58a438-3169-11e6-b36c-bfe1fa3241fe',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'container_format': 'bare',
|
|
||||||
'disk_format': 'raw',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
GNOCCHI_VOLUME = {
|
|
||||||
'id': '17992d58-316f-11e6-9528-1379eed8ebe4',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'display_name': 'vol1',
|
|
||||||
'volume_type': 'lvmdriver-1',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
TRANS_VOLUME = {
|
|
||||||
'resource_id': '17992d58-316f-11e6-9528-1379eed8ebe4',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'name': 'vol1',
|
|
||||||
'volume_type': 'lvmdriver-1',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
GNOCCHI_NETWORK = {
|
|
||||||
'id': '02f8e84e-317d-11e6-ad23-af0423cd2a97',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'name': 'network1',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
TRANS_NETWORK = {
|
|
||||||
'resource_id': '02f8e84e-317d-11e6-ad23-af0423cd2a97',
|
|
||||||
'project_id': '4480c638-3169-11e6-91de-a3bd3a7d3afb',
|
|
||||||
'user_id': '576808d8-3169-11e6-992b-5f931fc671df',
|
|
||||||
'name': 'network1',
|
|
||||||
'metrics': {}}
|
|
||||||
|
|
||||||
|
|
||||||
@testtools.skipIf(is_functional_test(), 'Not a functional test')
|
|
||||||
class GnocchiTransformerTest(tests.TestCase):
|
|
||||||
def test_strip_gnocchi_compute(self):
|
|
||||||
resource = copy.deepcopy(GNOCCHI_COMPUTE)
|
|
||||||
t_test = gnocchi.GnocchiTransformer()
|
|
||||||
result = t_test.strip_resource_data('compute', resource)
|
|
||||||
self.assertEqual(TRANS_COMPUTE, result)
|
|
||||||
|
|
||||||
def test_strip_gnocchi_image(self):
|
|
||||||
resource = copy.deepcopy(GNOCCHI_IMAGE)
|
|
||||||
t_test = gnocchi.GnocchiTransformer()
|
|
||||||
result = t_test.strip_resource_data('image', resource)
|
|
||||||
self.assertEqual(TRANS_IMAGE, result)
|
|
||||||
|
|
||||||
def test_strip_gnocchi_volume(self):
|
|
||||||
resource = copy.deepcopy(GNOCCHI_VOLUME)
|
|
||||||
t_test = gnocchi.GnocchiTransformer()
|
|
||||||
result = t_test.strip_resource_data('volume', resource)
|
|
||||||
self.assertEqual(TRANS_VOLUME, result)
|
|
||||||
|
|
||||||
def test_strip_gnocchi_network(self):
|
|
||||||
resource = copy.deepcopy(GNOCCHI_NETWORK)
|
|
||||||
t_test = gnocchi.GnocchiTransformer()
|
|
||||||
result = t_test.strip_resource_data('network', resource)
|
|
||||||
self.assertEqual(TRANS_NETWORK, result)
|
|
@ -1,82 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2015 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.
|
|
||||||
#
|
|
||||||
from cloudkitty import transformer
|
|
||||||
|
|
||||||
|
|
||||||
class GnocchiTransformer(transformer.BaseTransformer):
|
|
||||||
compute_map = {
|
|
||||||
'instance_id': ['id'],
|
|
||||||
'name': ['display_name'],
|
|
||||||
'flavor_id': ['flavor_id'],
|
|
||||||
'image_id': lambda x, y: x.get_image_id(y),
|
|
||||||
}
|
|
||||||
image_map = {
|
|
||||||
'container_format': ['container_format'],
|
|
||||||
'disk_format': ['disk_format'],
|
|
||||||
}
|
|
||||||
volume_map = {
|
|
||||||
'name': ['display_name'],
|
|
||||||
'volume_type': ['volume_type'],
|
|
||||||
}
|
|
||||||
network_map = {
|
|
||||||
'name': ['name'],
|
|
||||||
}
|
|
||||||
|
|
||||||
def _generic_strip(self, data):
|
|
||||||
res_data = {
|
|
||||||
'resource_id': data['id'],
|
|
||||||
'project_id': data['project_id'],
|
|
||||||
'user_id': data['user_id'],
|
|
||||||
'metrics': data['metrics']}
|
|
||||||
return res_data
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_image_id(data):
|
|
||||||
image_ref = data.get('image_ref', None)
|
|
||||||
return image_ref.rpartition('/')[-1] if image_ref else None
|
|
||||||
|
|
||||||
def strip_resource_data(self, res_type, res_data):
|
|
||||||
result = self._generic_strip(res_data)
|
|
||||||
stripped_data = super(GnocchiTransformer, self).strip_resource_data(
|
|
||||||
res_type,
|
|
||||||
res_data)
|
|
||||||
result.update(stripped_data)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_metadata(self, res_type):
|
|
||||||
"""Return list of metadata available after transformation for
|
|
||||||
|
|
||||||
given resource type.
|
|
||||||
"""
|
|
||||||
|
|
||||||
class FakeData(dict):
|
|
||||||
"""FakeData object."""
|
|
||||||
|
|
||||||
def __getitem__(self, item):
|
|
||||||
try:
|
|
||||||
return super(FakeData, self).__getitem__(item)
|
|
||||||
except KeyError:
|
|
||||||
return item
|
|
||||||
|
|
||||||
def get(self, item, default=None):
|
|
||||||
return super(FakeData, self).get(item, item)
|
|
||||||
|
|
||||||
# list of metadata is built by applying the generic strip_resource_data
|
|
||||||
# function to a fake data object
|
|
||||||
|
|
||||||
fkdt = FakeData()
|
|
||||||
res_data = self.strip_resource_data(res_type, fkdt)
|
|
||||||
return res_data.keys()
|
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
The gnocchi transformer has been removed from CloudKitty's codebase.
|
@ -59,7 +59,6 @@ cloudkitty.fetchers =
|
|||||||
|
|
||||||
cloudkitty.transformers =
|
cloudkitty.transformers =
|
||||||
CloudKittyFormatTransformer = cloudkitty.transformer.format:CloudKittyFormatTransformer
|
CloudKittyFormatTransformer = cloudkitty.transformer.format:CloudKittyFormatTransformer
|
||||||
GnocchiTransformer = cloudkitty.transformer.gnocchi:GnocchiTransformer
|
|
||||||
|
|
||||||
cloudkitty.rating.processors =
|
cloudkitty.rating.processors =
|
||||||
noop = cloudkitty.rating.noop:Noop
|
noop = cloudkitty.rating.noop:Noop
|
||||||
|
Loading…
Reference in New Issue
Block a user