diff --git a/ceilometer/compute/pollsters/instance.py b/ceilometer/compute/pollsters/instance.py deleted file mode 100644 index 61279b09b2..0000000000 --- a/ceilometer/compute/pollsters/instance.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright 2012 eNovance -# 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, - ) diff --git a/ceilometer/dispatcher/data/gnocchi_resources.yaml b/ceilometer/dispatcher/data/gnocchi_resources.yaml index 9eea7ffb2c..b461b8a535 100644 --- a/ceilometer/dispatcher/data/gnocchi_resources.yaml +++ b/ceilometer/dispatcher/data/gnocchi_resources.yaml @@ -35,7 +35,6 @@ resources: - resource_type: instance metrics: - - 'instance' - 'memory' - 'memory.usage' - 'memory.resident' diff --git a/ceilometer/tests/unit/compute/pollsters/test_cpu.py b/ceilometer/tests/unit/compute/pollsters/test_cpu.py index ebd577f9a4..898e308bc4 100644 --- a/ceilometer/tests/unit/compute/pollsters/test_cpu.py +++ b/ceilometer/tests/unit/compute/pollsters/test_cpu.py @@ -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): diff --git a/ceilometer/tests/unit/compute/pollsters/test_instance.py b/ceilometer/tests/unit/compute/pollsters/test_instance.py deleted file mode 100644 index 4ccedc925c..0000000000 --- a/ceilometer/tests/unit/compute/pollsters/test_instance.py +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright 2012 eNovance -# 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']) diff --git a/ceilometer/tests/unit/dispatcher/test_gnocchi.py b/ceilometer/tests/unit/dispatcher/test_gnocchi.py index c827e71867..4284bf0804 100644 --- a/ceilometer/tests/unit/dispatcher/test_gnocchi.py +++ b/ceilometer/tests/unit/dispatcher/test_gnocchi.py @@ -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', diff --git a/releasenotes/notes/drop-instance-meter-1b657717b21a0f55.yaml b/releasenotes/notes/drop-instance-meter-1b657717b21a0f55.yaml new file mode 100644 index 0000000000..7152f27fda --- /dev/null +++ b/releasenotes/notes/drop-instance-meter-1b657717b21a0f55.yaml @@ -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.