drop instance meter

Change-Id: I11bf2196624d5100f89b6c5eae70e289f9cc360b
This commit is contained in:
gord chung 2016-11-22 21:28:06 +00:00
parent 0c4ff9f912
commit a91253a810
6 changed files with 64 additions and 109 deletions

View File

@ -1,33 +0,0 @@
#
# Copyright 2012 eNovance <licensing@enovance.com>
# Copyright 2012 Red Hat, Inc
#
# 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 ceilometer.compute import pollsters
from ceilometer.compute.pollsters import util
from ceilometer import sample
class InstancePollster(pollsters.BaseComputePollster):
def get_samples(self, manager, cache, resources):
for instance in resources:
yield util.make_sample_from_instance(
self.conf,
instance,
name='instance',
type=sample.TYPE_GAUGE,
unit='instance',
volume=1,
)

View File

@ -35,7 +35,6 @@ resources:
- resource_type: instance
metrics:
- 'instance'
- 'memory'
- 'memory.usage'
- 'memory.resident'

View File

@ -71,6 +71,58 @@ class TestCPUPollster(base.TestPollsterBase):
self.assertEqual(10 ** 6, samples[0].volume)
self.assertEqual(0, len(cache))
# the following apply to all instance resource pollsters but are tested
# here alone.
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_metadata(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = cpu.CPUPollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(1, len(samples))
self.assertEqual(1, samples[0].resource_metadata['vcpus'])
self.assertEqual(512, samples[0].resource_metadata['memory_mb'])
self.assertEqual(20, samples[0].resource_metadata['disk_gb'])
self.assertEqual(20, samples[0].resource_metadata['root_gb'])
self.assertEqual(0, samples[0].resource_metadata['ephemeral_gb'])
self.assertEqual('active', samples[0].resource_metadata['status'])
self.assertEqual('active', samples[0].resource_metadata['state'])
self.assertIsNone(samples[0].resource_metadata['task_state'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_reserved_metadata_with_keys(self):
self.CONF.set_override('reserved_metadata_keys', ['fqdn'])
mgr = manager.AgentManager(0, self.CONF)
pollster = cpu.CPUPollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual({'fqdn': 'vm_fqdn',
'stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128'},
samples[0].resource_metadata['user_metadata'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_reserved_metadata_with_namespace(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = cpu.CPUPollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual({'stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128'},
samples[0].resource_metadata['user_metadata'])
self.CONF.set_override('reserved_metadata_namespace', [])
mgr = manager.AgentManager(0, self.CONF)
pollster = cpu.CPUPollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertNotIn('user_metadata', samples[0].resource_metadata)
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_flavor_name_as_metadata_instance_type(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = cpu.CPUPollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(1, len(samples))
self.assertEqual('m1.small',
samples[0].resource_metadata['instance_type'])
class TestCPUUtilPollster(base.TestPollsterBase):

View File

@ -1,74 +0,0 @@
#
# Copyright 2012 eNovance <licensing@enovance.com>
# Copyright 2012 Red Hat, Inc
#
# 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.
import mock
from ceilometer.agent import manager
from ceilometer.compute.pollsters import instance as pollsters_instance
from ceilometer.tests.unit.compute.pollsters import base
class TestInstancePollster(base.TestPollsterBase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_samples_instance(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = pollsters_instance.InstancePollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(1, len(samples))
self.assertEqual('instance', samples[0].name)
self.assertEqual(1, samples[0].resource_metadata['vcpus'])
self.assertEqual(512, samples[0].resource_metadata['memory_mb'])
self.assertEqual(20, samples[0].resource_metadata['disk_gb'])
self.assertEqual(20, samples[0].resource_metadata['root_gb'])
self.assertEqual(0, samples[0].resource_metadata['ephemeral_gb'])
self.assertEqual('active', samples[0].resource_metadata['status'])
self.assertEqual('active', samples[0].resource_metadata['state'])
self.assertIsNone(samples[0].resource_metadata['task_state'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_reserved_metadata_with_keys(self):
self.CONF.set_override('reserved_metadata_keys', ['fqdn'])
mgr = manager.AgentManager(0, self.CONF)
pollster = pollsters_instance.InstancePollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual({'fqdn': 'vm_fqdn',
'stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128'},
samples[0].resource_metadata['user_metadata'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_reserved_metadata_with_namespace(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = pollsters_instance.InstancePollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual({'stack': '2cadc4b4-8789-123c-b4eg-edd2f0a9c128'},
samples[0].resource_metadata['user_metadata'])
self.CONF.set_override('reserved_metadata_namespace', [])
mgr = manager.AgentManager(0, self.CONF)
pollster = pollsters_instance.InstancePollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertNotIn('user_metadata', samples[0].resource_metadata)
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_flavor_name_as_metadata_instance_type(self):
mgr = manager.AgentManager(0, self.CONF)
pollster = pollsters_instance.InstancePollster(self.CONF)
samples = list(pollster.get_samples(mgr, {}, [self.instance]))
self.assertEqual(1, len(samples))
self.assertEqual('m1.small',
samples[0].resource_metadata['instance_type'])

View File

@ -529,7 +529,7 @@ class DispatcherWorkflowTest(base.BaseTestCase,
'display_name': 'myinstance',
},
metric_names=[
'instance', 'disk.root.size', 'disk.ephemeral.size',
'disk.root.size', 'disk.ephemeral.size',
'memory', 'vcpus', 'memory.usage', 'memory.resident',
'memory.bandwidth.total', 'memory.bandwidth.local',
'cpu', 'cpu.delta', 'cpu_util', 'vcpus', 'disk.read.requests',

View File

@ -0,0 +1,11 @@
---
prelude: >
Samples are required to measure some aspect of a resource. Samples not
measuring anything will be dropped.
upgrade:
- The `instance` meter no longer will be generated. For equivalent
functionality, perform the exact same query on any compute meter such as
`cpu`, `disk.read.requests`, `memory.usage`, `network.incoming.bytes`,
etc...
deprecations:
- The `instance` meter no longer will be generated.