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
# License for the specific language governing permissions and limitations
# 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
@ -68,7 +68,7 @@ class InstanceScheduled(ComputeNotificationBase):
class ComputeInstanceNotificationBase(ComputeNotificationBase):
"""Convert compute.instance.* notifications into Counters
"""Convert compute.instance.* notifications into Samples
"""
event_types = ['compute.instance.*']

View File

@ -65,7 +65,7 @@ class DeletedInstanceStatsGatherer(object):
samples = self.mgr.map(self._get_samples_from_plugin,
cache=cache,
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
results = []
for slist in samples:
@ -158,15 +158,15 @@ def notify(context, message):
context, instance_ref, None, None)
# 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.
instance = Instance(context, instance_ref)
counters = gatherer(instance)
payload['samples'] = [{'name': c.name,
'type': c.type,
'unit': c.unit,
'volume': c.volume}
for c in counters]
samples = gatherer(instance)
payload['samples'] = [{'name': s.name,
'type': s.type,
'unit': s.unit,
'volume': s.volume}
for s in samples]
publisher_id = notifier_api.publisher_id('compute', None)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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