Change counter to sample vocable in cm.compute

This changes counter to sample vocable in ceilometer.compute code

Parts of the blueprint remove-counter

Change-Id: I69a66935254e2d769ed58c2911819549cbe0f5f0
This commit is contained in:
Mehdi Abaakouk 2013-08-20 17:10:25 +02:00
parent 2bcccd6fc8
commit 17e84e1761
8 changed files with 37 additions and 37 deletions

View File

@ -17,7 +17,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Converters for producing compute counter messages from notification events. """Converters for producing compute sample messages from notification events.
""" """
from oslo.config import cfg from oslo.config import cfg
@ -68,7 +68,7 @@ class InstanceScheduled(ComputeNotificationBase):
class ComputeInstanceNotificationBase(ComputeNotificationBase): class ComputeInstanceNotificationBase(ComputeNotificationBase):
"""Convert compute.instance.* notifications into Counters """Convert compute.instance.* notifications into Samples
""" """
event_types = ['compute.instance.*'] event_types = ['compute.instance.*']

View File

@ -65,7 +65,7 @@ class DeletedInstanceStatsGatherer(object):
samples = self.mgr.map(self._get_samples_from_plugin, samples = self.mgr.map(self._get_samples_from_plugin,
cache=cache, cache=cache,
instance=instance) instance=instance)
# counters is a list of lists, so flatten it before returning # samples is a list of lists, so flatten it before returning
# the results # the results
results = [] results = []
for slist in samples: for slist in samples:
@ -158,15 +158,15 @@ def notify(context, message):
context, instance_ref, None, None) context, instance_ref, None, None)
# Extend the payload with samples from our plugins. We only need # Extend the payload with samples from our plugins. We only need
# to send some of the data from the counter objects, since a lot # to send some of the data from the sample objects, since a lot
# of the fields are the same. # of the fields are the same.
instance = Instance(context, instance_ref) instance = Instance(context, instance_ref)
counters = gatherer(instance) samples = gatherer(instance)
payload['samples'] = [{'name': c.name, payload['samples'] = [{'name': s.name,
'type': c.type, 'type': s.type,
'unit': c.unit, 'unit': s.unit,
'volume': c.volume} 'volume': s.volume}
for c in counters] for s in samples]
publisher_id = notifier_api.publisher_id('compute', None) publisher_id = notifier_api.publisher_id('compute', None)

View File

@ -36,7 +36,7 @@ class CPUPollster(plugin.ComputePollster):
LOG.info("CPUTIME USAGE: %s %d", LOG.info("CPUTIME USAGE: %s %d",
instance.__dict__, cpu_info.time) instance.__dict__, cpu_info.time)
cpu_num = {'cpu_number': cpu_info.number} cpu_num = {'cpu_number': cpu_info.number}
yield util.make_counter_from_instance( yield util.make_sample_from_instance(
instance, instance,
name='cpu', name='cpu',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,

View File

@ -73,8 +73,8 @@ class _Base(plugin.ComputePollster):
return i_cache[instance_name] return i_cache[instance_name]
@abc.abstractmethod @abc.abstractmethod
def _get_counter(instance, c_data): def _get_sample(instance, c_data):
"""Return one Counter.""" """Return one Sample."""
def get_samples(self, manager, cache, instance): def get_samples(self, manager, cache, instance):
instance_name = util.instance_name(instance) instance_name = util.instance_name(instance)
@ -85,7 +85,7 @@ class _Base(plugin.ComputePollster):
instance_name, instance_name,
) )
try: try:
yield self._get_counter(instance, c_data) yield self._get_sample(instance, c_data)
except Exception as err: except Exception as err:
LOG.warning('Ignoring instance %s: %s', LOG.warning('Ignoring instance %s: %s',
instance_name, err) instance_name, err)
@ -95,8 +95,8 @@ class _Base(plugin.ComputePollster):
class ReadRequestsPollster(_Base): class ReadRequestsPollster(_Base):
@staticmethod @staticmethod
def _get_counter(instance, c_data): def _get_sample(instance, c_data):
return util.make_counter_from_instance( return util.make_sample_from_instance(
instance, instance,
name='disk.read.requests', name='disk.read.requests',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -108,8 +108,8 @@ class ReadRequestsPollster(_Base):
class ReadBytesPollster(_Base): class ReadBytesPollster(_Base):
@staticmethod @staticmethod
def _get_counter(instance, c_data): def _get_sample(instance, c_data):
return util.make_counter_from_instance( return util.make_sample_from_instance(
instance, instance,
name='disk.read.bytes', name='disk.read.bytes',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -121,8 +121,8 @@ class ReadBytesPollster(_Base):
class WriteRequestsPollster(_Base): class WriteRequestsPollster(_Base):
@staticmethod @staticmethod
def _get_counter(instance, c_data): def _get_sample(instance, c_data):
return util.make_counter_from_instance( return util.make_sample_from_instance(
instance, instance,
name='disk.write.requests', name='disk.write.requests',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -134,8 +134,8 @@ class WriteRequestsPollster(_Base):
class WriteBytesPollster(_Base): class WriteBytesPollster(_Base):
@staticmethod @staticmethod
def _get_counter(instance, c_data): def _get_sample(instance, c_data):
return util.make_counter_from_instance( return util.make_sample_from_instance(
instance, instance,
name='disk.write.bytes', name='disk.write.bytes',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,

View File

@ -27,7 +27,7 @@ class InstancePollster(plugin.ComputePollster):
@staticmethod @staticmethod
def get_samples(manager, cache, instance): def get_samples(manager, cache, instance):
yield util.make_counter_from_instance( yield util.make_sample_from_instance(
instance, instance,
name='instance', name='instance',
type=sample.TYPE_GAUGE, type=sample.TYPE_GAUGE,
@ -40,7 +40,7 @@ class InstanceFlavorPollster(plugin.ComputePollster):
@staticmethod @staticmethod
def get_samples(manager, cache, instance): def get_samples(manager, cache, instance):
yield util.make_counter_from_instance( yield util.make_sample_from_instance(
instance, instance,
# Use the "meter name + variable" syntax # Use the "meter name + variable" syntax
name='instance:%s' % name='instance:%s' %

View File

@ -35,7 +35,7 @@ class _Base(plugin.ComputePollster):
"write-bytes=%d"]) "write-bytes=%d"])
@staticmethod @staticmethod
def make_vnic_counter(instance, name, type, unit, volume, vnic_data): def make_vnic_sample(instance, name, type, unit, volume, vnic_data):
metadata = copy.copy(vnic_data) metadata = copy.copy(vnic_data)
resource_metadata = dict(zip(metadata._fields, metadata)) resource_metadata = dict(zip(metadata._fields, metadata))
resource_metadata['instance_id'] = instance.id resource_metadata['instance_id'] = instance.id
@ -82,7 +82,7 @@ class _Base(plugin.ComputePollster):
for vnic, info in vnics: for vnic, info in vnics:
LOG.info(self.NET_USAGE_MESSAGE, instance_name, LOG.info(self.NET_USAGE_MESSAGE, instance_name,
vnic.name, info.rx_bytes, info.tx_bytes) vnic.name, info.rx_bytes, info.tx_bytes)
yield self._get_counter(instance, vnic, info) yield self._get_sample(instance, vnic, info)
except Exception as err: except Exception as err:
LOG.warning('Ignoring instance %s: %s', LOG.warning('Ignoring instance %s: %s',
instance_name, err) instance_name, err)
@ -91,8 +91,8 @@ class _Base(plugin.ComputePollster):
class IncomingBytesPollster(_Base): class IncomingBytesPollster(_Base):
def _get_counter(self, instance, vnic, info): def _get_sample(self, instance, vnic, info):
return self.make_vnic_counter( return self.make_vnic_sample(
instance, instance,
name='network.incoming.bytes', name='network.incoming.bytes',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -104,8 +104,8 @@ class IncomingBytesPollster(_Base):
class IncomingPacketsPollster(_Base): class IncomingPacketsPollster(_Base):
def _get_counter(self, instance, vnic, info): def _get_sample(self, instance, vnic, info):
return self.make_vnic_counter( return self.make_vnic_sample(
instance, instance,
name='network.incoming.packets', name='network.incoming.packets',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -117,8 +117,8 @@ class IncomingPacketsPollster(_Base):
class OutgoingBytesPollster(_Base): class OutgoingBytesPollster(_Base):
def _get_counter(self, instance, vnic, info): def _get_sample(self, instance, vnic, info):
return self.make_vnic_counter( return self.make_vnic_sample(
instance, instance,
name='network.outgoing.bytes', name='network.outgoing.bytes',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,
@ -130,8 +130,8 @@ class OutgoingBytesPollster(_Base):
class OutgoingPacketsPollster(_Base): class OutgoingPacketsPollster(_Base):
def _get_counter(self, instance, vnic, info): def _get_sample(self, instance, vnic, info):
return self.make_vnic_counter( return self.make_vnic_sample(
instance, instance,
name='network.outgoing.packets', name='network.outgoing.packets',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,

View File

@ -96,7 +96,7 @@ def _get_metadata_from_object(instance):
return _add_reserved_user_metadata(instance, metadata) return _add_reserved_user_metadata(instance, metadata)
def make_counter_from_instance(instance, name, type, unit, volume, def make_sample_from_instance(instance, name, type, unit, volume,
additional_metadata={}): additional_metadata={}):
resource_metadata = _get_metadata_from_object(instance) resource_metadata = _get_metadata_from_object(instance)
resource_metadata.update(additional_metadata) resource_metadata.update(additional_metadata)

View File

@ -85,7 +85,7 @@ class TestNovaNotifier(base.TestCase):
def get_samples(self, manager, cache, instance): def get_samples(self, manager, cache, instance):
self.instances.append((manager, instance)) self.instances.append((manager, instance))
test_data_2 = util.make_counter_from_instance( test_data_2 = util.make_sample_from_instance(
instance, instance,
name='test2', name='test2',
type=sample.TYPE_CUMULATIVE, type=sample.TYPE_CUMULATIVE,