Provide the meters unit's in /meters

* change pollsters and notification handlers to report units
 * modify db storage to store units in counters

Change-Id: Ibd7e52623b84d26ca7bbc9f260c20fdf1d61a4bc
Implements: blueprint provide-meter-units
This commit is contained in:
guillaume pernot 2012-12-19 20:44:26 +01:00
parent 092aad40bd
commit c0379cefd9
45 changed files with 234 additions and 61 deletions

View File

@ -40,6 +40,10 @@ cfg.CONF.register_cli_opts([
help='counter type (gauge, delta, cumulative)',
default='gauge',
required=True),
cfg.StrOpt('counter-unit',
short='U',
help='counter unit',
default=None),
cfg.IntOpt('counter-volume',
short='l',
help='counter volume value',
@ -77,6 +81,7 @@ root_logger.setLevel(logging.DEBUG)
publish.publish_counter(context.get_admin_context(),
counter.Counter(name=cfg.CONF.counter_name,
type=cfg.CONF.counter_type,
unit=cfg.CONF.counter_unit,
volume=cfg.CONF.counter_volume,
user_id=cfg.CONF.counter_user,
project_id=cfg.CONF.counter_project,

View File

@ -252,6 +252,7 @@ class Event(Base):
source = text
counter_name = text
counter_type = text
counter_unit = text
counter_volume = float
user_id = text
project_id = text

View File

@ -88,6 +88,7 @@ def meter_message_from_counter(counter, secret, source):
msg = {'source': source,
'counter_name': counter.name,
'counter_type': counter.type,
'counter_unit': counter.unit,
'counter_volume': counter.volume,
'user_id': counter.user_id,
'project_id': counter.project_id,

View File

@ -71,6 +71,7 @@ class Instance(_Base):
return [
counter.Counter(name='instance',
type=counter.TYPE_GAUGE,
unit='instance',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -88,6 +89,7 @@ class Memory(_Base):
return [
counter.Counter(name='memory',
type=counter.TYPE_GAUGE,
unit='B',
volume=message['payload']['memory_mb'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -105,6 +107,7 @@ class VCpus(_Base):
return [
counter.Counter(name='vcpus',
type=counter.TYPE_GAUGE,
unit='vcpu',
volume=message['payload']['vcpus'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -122,6 +125,7 @@ class RootDiskSize(_Base):
return [
counter.Counter(name='disk.root.size',
type=counter.TYPE_GAUGE,
unit='B',
volume=message['payload']['root_gb'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -139,6 +143,7 @@ class EphemeralDiskSize(_Base):
return [
counter.Counter(name='disk.ephemeral.size',
type=counter.TYPE_GAUGE,
unit='B',
volume=message['payload']['ephemeral_gb'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -160,6 +165,7 @@ class InstanceFlavor(_Base):
counter.Counter(
name='instance:%s' % instance_type,
type=counter.TYPE_GAUGE,
unit='instance',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],

View File

@ -35,10 +35,11 @@ def _instance_name(instance):
return getattr(instance, 'OS-EXT-SRV-ATTR:instance_name', None)
def make_counter_from_instance(instance, name, type, volume):
def make_counter_from_instance(instance, name, type, unit, volume):
return counter.Counter(
name=name,
type=type,
unit=unit,
volume=volume,
user_id=instance.user_id,
project_id=instance.tenant_id,
@ -54,12 +55,14 @@ class InstancePollster(plugin.ComputePollster):
yield make_counter_from_instance(instance,
name='instance',
type=counter.TYPE_GAUGE,
unit='instance',
volume=1,
)
yield make_counter_from_instance(instance,
name='instance:%s' %
instance.flavor['name'],
type=counter.TYPE_GAUGE,
unit='instance',
volume=1,
)
@ -96,21 +99,25 @@ class DiskIOPollster(plugin.ComputePollster):
yield make_counter_from_instance(instance,
name='disk.read.requests',
type=counter.TYPE_CUMULATIVE,
unit='request',
volume=r_requests,
)
yield make_counter_from_instance(instance,
name='disk.read.bytes',
type=counter.TYPE_CUMULATIVE,
unit='B',
volume=r_bytes,
)
yield make_counter_from_instance(instance,
name='disk.write.requests',
type=counter.TYPE_CUMULATIVE,
unit='request',
volume=w_requests,
)
yield make_counter_from_instance(instance,
name='disk.write.bytes',
type=counter.TYPE_CUMULATIVE,
unit='B',
volume=w_bytes,
)
except Exception as err:
@ -160,11 +167,13 @@ class CPUPollster(plugin.ComputePollster):
yield make_counter_from_instance(instance,
name='cpu_util',
type=counter.TYPE_GAUGE,
unit='%',
volume=cpu_util,
)
yield make_counter_from_instance(instance,
name='cpu',
type=counter.TYPE_CUMULATIVE,
unit='ns',
volume=cpu_info.time,
)
except Exception as err:
@ -181,7 +190,7 @@ class NetPollster(plugin.ComputePollster):
"write-bytes=%d"])
@staticmethod
def make_vnic_counter(instance, name, type, volume, vnic_data):
def make_vnic_counter(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
@ -191,6 +200,7 @@ class NetPollster(plugin.ComputePollster):
return counter.Counter(
name=name,
type=type,
unit=unit,
volume=volume,
user_id=instance.user_id,
project_id=instance.tenant_id,
@ -209,24 +219,28 @@ class NetPollster(plugin.ComputePollster):
yield self.make_vnic_counter(instance,
name='network.incoming.bytes',
type=counter.TYPE_CUMULATIVE,
unit='B',
volume=info.rx_bytes,
vnic_data=vnic,
)
yield self.make_vnic_counter(instance,
name='network.outgoing.bytes',
type=counter.TYPE_CUMULATIVE,
unit='B',
volume=info.tx_bytes,
vnic_data=vnic,
)
yield self.make_vnic_counter(instance,
name='network.incoming.packets',
type=counter.TYPE_CUMULATIVE,
unit='packet',
volume=info.rx_packets,
vnic_data=vnic,
)
yield self.make_vnic_counter(instance,
name='network.outgoing.packets',
type=counter.TYPE_CUMULATIVE,
unit='packet',
volume=info.tx_packets,
vnic_data=vnic,
)

View File

@ -31,6 +31,7 @@ import collections
# - cumulative: the value is incremented and never reset to 0
# - delta: the value is reset to 0 each time it is sent
# - gauge: the value is an absolute value and is not a counter
# Unit: the unit of the counter
# Volume: the counter value
# User ID: the user ID
# Project ID: the project ID
@ -41,6 +42,7 @@ Counter = collections.namedtuple('Counter',
' '.join([
'name',
'type',
'unit',
'volume',
'user_id',
'project_id',

View File

@ -88,6 +88,7 @@ class ImagePollster(_Base):
yield counter.Counter(
name='image',
type=counter.TYPE_GAUGE,
unit='image',
volume=1,
user_id=None,
project_id=image.owner,
@ -104,6 +105,7 @@ class ImageSizePollster(_Base):
yield counter.Counter(
name='image.size',
type=counter.TYPE_GAUGE,
unit='B',
volume=image.size,
user_id=None,
project_id=image.owner,

View File

@ -90,6 +90,7 @@ class ImageCRUD(ImageCRUDBase):
counter.Counter(
name=message['event_type'],
type=counter.TYPE_DELTA,
unit='event',
volume=1,
resource_id=message['payload']['id'],
user_id=None,
@ -108,6 +109,7 @@ class Image(ImageCRUDBase):
counter.Counter(
name='image',
type=counter.TYPE_GAUGE,
unit='image',
volume=1,
resource_id=message['payload']['id'],
user_id=None,
@ -126,6 +128,7 @@ class ImageSize(ImageCRUDBase):
counter.Counter(
name='image.size',
type=counter.TYPE_GAUGE,
unit='B',
volume=message['payload']['size'],
resource_id=message['payload']['id'],
user_id=None,
@ -153,6 +156,7 @@ class ImageDownload(ImageBase):
counter.Counter(
name='image.download',
type=counter.TYPE_DELTA,
unit='B',
volume=message['payload']['bytes_sent'],
resource_id=message['payload']['image_id'],
user_id=message['payload']['receiver_user_id'],
@ -181,6 +185,7 @@ class ImageServe(ImageBase):
counter.Counter(
name='image.serve',
type=counter.TYPE_DELTA,
unit='B',
volume=message['payload']['bytes_sent'],
resource_id=message['payload']['image_id'],
user_id=None,

View File

@ -35,6 +35,7 @@ class FloatingIPPollster(plugin.CentralPollster):
yield counter.Counter(
name='ip.floating',
type=counter.TYPE_GAUGE,
unit='ip',
volume=1,
user_id=None,
project_id=ip.project_id,

View File

@ -75,6 +75,7 @@ class NetworkNotificationBase(plugin.NotificationBase):
yield counter.Counter(name=counter_name,
type=counter.TYPE_GAUGE,
unit=self.resource_name,
volume=1,
user_id=message['_context_user_id'],
project_id=message['payload']['tenant_id'],
@ -88,6 +89,7 @@ class NetworkNotificationBase(plugin.NotificationBase):
yield counter.Counter(name=counter_name
+ "." + event_type_split[1],
type=counter.TYPE_DELTA,
unit=self.resource_name,
volume=1,
user_id=message['_context_user_id'],
project_id=message['payload']['tenant_id'],

View File

@ -58,6 +58,7 @@ class _Base(plugin.PollsterBase):
name='storage.objects',
type=counter.TYPE_GAUGE,
volume=int(account['x-account-object-count']),
unit='object',
user_id=None,
project_id=tenant,
resource_id=tenant,
@ -68,6 +69,7 @@ class _Base(plugin.PollsterBase):
name='storage.objects.size',
type=counter.TYPE_GAUGE,
volume=int(account['x-account-bytes-used']),
unit='B',
user_id=None,
project_id=tenant,
resource_id=tenant,
@ -78,6 +80,7 @@ class _Base(plugin.PollsterBase):
name='storage.objects.containers',
type=counter.TYPE_GAUGE,
volume=int(account['x-account-container-count']),
unit='container',
user_id=None,
project_id=tenant,
resource_id=tenant,

View File

@ -92,6 +92,7 @@ class CeilometerMiddleware(object):
counter.Counter(
name='storage.objects.incoming.bytes',
type='delta',
unit='B',
volume=bytes_received,
user_id=env.get('HTTP_X_USER_ID'),
project_id=env.get('HTTP_X_TENANT_ID'),
@ -113,6 +114,7 @@ class CeilometerMiddleware(object):
counter.Counter(
name='storage.objects.outgoing.bytes',
type='delta',
unit='B',
volume=bytes_sent,
user_id=env.get('HTTP_X_USER_ID'),
project_id=env.get('HTTP_X_TENANT_ID'),

View File

@ -109,6 +109,7 @@ class Connection(object):
{ 'name': name of the meter,
'type': type of the meter (guage, counter),
'unit': unit of the meter,
'resource_id': UUID of the resource,
'project_id': UUID of project owning the resource,
'user_id': UUID of user owning the resource,

View File

@ -55,7 +55,8 @@ class MongoDBStorage(base.StorageEngine):
timestamp: datetime of last update
user_id: uuid
project_id: uuid
meter: [ array of {counter_name: string, counter_type: string} ]
meter: [ array of {counter_name: string, counter_type: string,
counter_unit: string} ]
}
"""
@ -272,6 +273,7 @@ class Connection(base.Connection):
},
'$addToSet': {'meter': {'counter_name': data['counter_name'],
'counter_type': data['counter_type'],
'counter_unit': data['counter_unit'],
},
},
},
@ -364,6 +366,7 @@ class Connection(base.Connection):
{ 'name': name of the meter,
'type': type of the meter (guage, counter),
'unit': unit of the meter,
'resource_id': UUID of the resource,
'project_id': UUID of project owning the resource,
'user_id': UUID of user owning the resource,
@ -391,6 +394,7 @@ class Connection(base.Connection):
m = {}
m['name'] = r_meter['counter_name']
m['type'] = r_meter['counter_type']
m['unit'] = r_meter['counter_unit']
m['resource_id'] = r['_id']
m['project_id'] = r['project_id']
m['user_id'] = r['user_id']

View File

@ -50,6 +50,7 @@ class SQLAlchemyStorage(base.StorageEngine):
resource_id: resource uuid (->resource.id)
resource_metadata: metadata dictionaries
counter_type: counter type
counter_unit: counter unit
counter_volume: counter volume
timestamp: datetime
message_signature: message signature
@ -184,6 +185,7 @@ class Connection(base.Connection):
# Record the raw data for the event.
meter = Meter(counter_type=data['counter_type'],
counter_unit=data['counter_unit'],
counter_name=data['counter_name'], resource=resource)
self.session.add(meter)
if not filter(lambda x: x.id == source.id, meter.sources):
@ -274,6 +276,7 @@ class Connection(base.Connection):
{ 'name': name of the meter,
'type': type of the meter (guage, counter),
'unit': unit of the meter,
'resource_id': UUID of the resource,
'project_id': UUID of project owning the resource,
'user_id': UUID of user owning the resource,
@ -311,6 +314,7 @@ class Connection(base.Connection):
m['user_id'] = resource.user_id
m['name'] = meter.counter_name
m['type'] = meter.counter_type
m['unit'] = meter.counter_unit
yield m
def get_raw_events(self, event_filter):

View File

@ -55,7 +55,8 @@ class TestDBStorage(base.StorageEngine):
timestamp: datetime of last update
user_id: uuid
project_id: uuid
meter: [ array of {counter_name: string, counter_type: string} ]
meter: [ array of {counter_name: string, counter_type: string,
counter_unit: string} ]
}
"""

View File

@ -0,0 +1,33 @@
# -*- encoding: utf-8 -*-
#
# Author: Guillaume Pernot <gpernot@praksys.org>
#
# 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 sqlalchemy import *
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
meter = Table('meter', meta, autoload=True)
unit = Column('counter_unit', String(255))
meter.create_column(unit)
def downgrade(migrate_engine):
meta.bind = migrate_engine
meter = Table('meter', meta, autoload=True)
unit = Column('counter_unit', String(255))
meter.drop_column(unit)

View File

@ -103,6 +103,7 @@ class Meter(Base):
resource_id = Column(String(255), ForeignKey('resource.id'))
resource_metadata = Column(JSONEncodedDict)
counter_type = Column(String(255))
counter_unit = Column(String(255))
counter_volume = Column(Integer)
timestamp = Column(DateTime, default=timeutils.utcnow)
message_signature = Column(String)

View File

@ -71,6 +71,7 @@ class Volume(_Base):
return [
counter.Counter(name='volume',
type=counter.TYPE_GAUGE,
unit='volume',
volume=1,
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],
@ -88,6 +89,7 @@ class VolumeSize(_Base):
return [
counter.Counter(name='volume.size',
type=counter.TYPE_GAUGE,
unit='B',
volume=message['payload']['size'],
user_id=message['payload']['user_id'],
project_id=message['payload']['tenant_id'],

View File

@ -34,90 +34,100 @@ Gauge Discrete items (floating IPs, image uploads) and fluctuating values
Delta Changing over time (bandwidth)
========== ==============================================================================
Units should use common abbreviatons:
============ ======== ============== =====
Dimension Unit Abbreviations Note
============ ======== ============== =====
None N/A Dimension-less variable
Volume byte B
Time seconds s
Information units should be expressed in bits ('b') or bytes ('B').
Here are the meter types by components that are currently implemented:
Compute (Nova)
==============
======================== ========== ======= ======== =======================================================
Name Type Volume Resource Note
======================== ========== ======= ======== =======================================================
instance Gauge 1 inst ID Duration of instance
instance:<type> Gauge 1 inst ID Duration of instance <type> (openstack types)
memory Gauge MB inst ID Volume of RAM in MB
cpu Cumulative ns inst ID CPU time used
vcpus Gauge vcpu inst ID Number of VCPUs
disk.root.size Gauge GB inst ID Size of root disk in GB
disk.ephemeral.size Gauge GB inst ID Size of ephemeral disk in GB
disk.io.requests Cumulative request inst ID Number of disk io requests
disk.io.bytes Cumulative bytes inst ID Volume of disk io in bytes
network.incoming.bytes Cumulative bytes iface ID number of incoming bytes on the network
network.outgoing.bytes Cumulative bytes iface ID number of outgoing bytes on the network
network.incoming.packets Cumulative packets iface ID number of incoming packets
network.outgoing.packets Cumulative packets iface ID number of outgoing packets
======================== ========== ======= ======== =======================================================
======================== ========== ======== ======== =======================================================
Name Type Unit Resource Note
======================== ========== ======== ======== =======================================================
instance Gauge inst ID Duration of instance
instance:<type> Gauge inst ID Duration of instance <type> (openstack types)
memory Gauge B inst ID Volume of RAM in MB
cpu Cumulative ns inst ID CPU time used
vcpus Gauge vcpu inst ID Number of VCPUs
disk.root.size Gauge B inst ID Size of root disk in GB
disk.ephemeral.size Gauge B inst ID Size of ephemeral disk in GB
disk.io.requests Cumulative requests inst ID Number of disk io requests
disk.io.bytes Cumulative B inst ID Volume of disk io in bytes
network.incoming.bytes Cumulative B iface ID number of incoming bytes on the network
network.outgoing.bytes Cumulative B iface ID number of outgoing bytes on the network
network.incoming.packets Cumulative packets iface ID number of incoming packets
network.outgoing.packets Cumulative packets iface ID number of outgoing packets
======================== ========== ======== ======== =======================================================
Network (Quantum)
=================
======================== ========== ======= ======== =======================================================
Name Type Volume Resource Note
======================== ========== ======= ======== =======================================================
network Gauge 1 netw ID Duration of network
network.create Delta request netw ID Creation requests for this network
network.update Delta request netw ID Update requests for this network
subnet Gauge 1 subnt ID Duration of subnet
subnet.create Delta request subnt ID Creation requests for this subnet
subnet.update Delta request subnt ID Update requests for this subnet
port Gauge 1 port ID Duration of port
port.create Delta request port ID Creation requests for this port
port.update Delta request port ID Update requests for this port
router Gauge 1 rtr ID Duration of router
router.create Delta request rtr ID Creation requests for this router
router.update Delta request rtr ID Update requests for this router
ip.floating Gauge 1 ip ID Duration of floating ip
ip.floating.create Delta 1 ip ID Creation requests for this floating ip
ip.floating.update Delta 1 ip ID Update requests for this floating ip
======================== ========== ======= ======== =======================================================
======================== ========== ======== ======== ======================================================
Name Type Unit Resource Note
======================== ========== ======== ======== ======================================================
network Gauge network netw ID Duration of network
network.create Delta network netw ID Creation requests for this network
network.update Delta network netw ID Update requests for this network
subnet Gauge subnet subnt ID Duration of subnet
subnet.create Delta subnet subnt ID Creation requests for this subnet
subnet.update Delta subnet subnt ID Update requests for this subnet
port Gauge port port ID Duration of port
port.create Delta port port ID Creation requests for this port
port.update Delta port port ID Update requests for this port
router Gauge router rtr ID Duration of router
router.create Delta router rtr ID Creation requests for this router
router.update Delta router rtr ID Update requests for this router
ip.floating Gauge ip ip ID Duration of floating ip
ip.floating.create Delta ip ip ID Creation requests for this floating ip
ip.floating.update Delta ip ip ID Update requests for this floating ip
======================== ========== ======== ======== ======================================================
Image (Glance)
==============
======================== ========== ======= ======== =======================================================
Name Type Volume Resource Note
Name Type Unit Resource Note
======================== ========== ======= ======== =======================================================
image Gauge 1 image ID Image polling -> it (still) exists
image.size Gauge bytes image ID Uploaded image size
image.update Delta reqs image ID Number of update on the image
image.upload Delta reqs image ID Number of upload of the image
image.delete Delta reqs image ID Number of delete on the image
image.download Delta bytes image ID Image is downloaded
image.serve Delta bytes image ID Image is served out
image Gauge image image ID Image polling -> it (still) exists
image.size Gauge B image ID Uploaded image size
image.update Delta image image ID Number of update on the image
image.upload Delta image image ID Number of upload of the image
image.delete Delta image image ID Number of delete on the image
image.download Delta B image ID Image is downloaded
image.serve Delta B image ID Image is served out
======================== ========== ======= ======== =======================================================
Volume (Cinder)
===============
======================== ========== ======= ======== =======================================================
Name Type Volume Resource Note
Name Type Unit Resource Note
======================== ========== ======= ======== =======================================================
volume Gauge 1 vol ID Duration of volune
volume.size Gauge GB vol ID Size of volume
volume Gauge volume vol ID Duration of volune
volume.size Gauge GiB vol ID Size of volume
======================== ========== ======= ======== =======================================================
Object Storage (Swift)
======================
========================== ========== ========== ======== ==================================================
========================== ========== ========== ======== ==============================================
Name Type Volume Resource Note
========================== ========== ========== ======== ==================================================
========================== ========== ========== ======== ==============================================
storage.objects Gauge objects store ID Number of objects
storage.objects.size Gauge bytes store ID Total size of stored objects
storage.objects.size Gauge B store ID Total size of stored objects
storage.objects.containers Gauge containers store ID Number of containers
storage.objects.incoming.bytes Delta bytes store ID Number of incoming bytes
storage.objects.outgoing.bytes Delta bytes store ID Number of outgoing bytes
============================== ========== ========== ======== ==================================================
storage.objects.incoming.bytes Delta B store ID Number of incoming bytes
storage.objects.outgoing.bytes Delta B store ID Number of outgoing bytes
============================== ========== ========== ======== ==============================================
Dynamically retrieving the Meters via ceilometer client
=======================================================

View File

@ -39,6 +39,7 @@ class TestListEvents(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project1',
@ -51,6 +52,7 @@ class TestListEvents(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
2,
'user-id',
'project1',
@ -63,6 +65,7 @@ class TestListEvents(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project2',

View File

@ -47,6 +47,7 @@ class TestListMeters(tests_api.TestBase):
counter.Counter(
'meter.test',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -58,6 +59,7 @@ class TestListMeters(tests_api.TestBase):
counter.Counter(
'meter.test',
'cumulative',
'',
3,
'user-id',
'project-id',
@ -69,6 +71,7 @@ class TestListMeters(tests_api.TestBase):
counter.Counter(
'meter.mine',
'gauge',
'',
1,
'user-id',
'project-id',
@ -80,6 +83,7 @@ class TestListMeters(tests_api.TestBase):
counter.Counter(
'meter.test',
'cumulative',
'',
1,
'user-id2',
'project-id2',
@ -91,6 +95,7 @@ class TestListMeters(tests_api.TestBase):
counter.Counter(
'meter.mine',
'gauge',
'',
1,
'user-id4',
'project-id2',

View File

@ -45,6 +45,7 @@ class TestListProjects(tests_api.TestBase):
counter1 = counter.Counter(
'instance',
'cumulative',
'instance',
1,
'user-id',
'project-id',
@ -63,6 +64,7 @@ class TestListProjects(tests_api.TestBase):
counter2 = counter.Counter(
'instance',
'cumulative',
'instance',
1,
'user-id2',
'project-id2',

View File

@ -47,6 +47,7 @@ class TestListResources(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -58,6 +59,7 @@ class TestListResources(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -69,6 +71,7 @@ class TestListResources(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id2',
@ -80,6 +83,7 @@ class TestListResources(tests_api.TestBase):
counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',

View File

@ -46,6 +46,7 @@ class TestListUsers(tests_api.TestBase):
counter1 = counter.Counter(
'instance',
'cumulative',
'instance',
1,
'user-id',
'project-id',
@ -64,6 +65,7 @@ class TestListUsers(tests_api.TestBase):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id',

View File

@ -40,6 +40,7 @@ class TestMaxProjectVolume(tests_api.TestBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -39,6 +39,7 @@ class TestMaxResourceVolume(tests_api.TestBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -40,6 +40,7 @@ class TestSumProjectVolume(tests_api.TestBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -40,6 +40,7 @@ class TestSumResourceVolume(tests_api.TestBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -37,6 +37,7 @@ class TestListEvents(FunctionalTest):
self.counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project1',
@ -57,6 +58,7 @@ class TestListEvents(FunctionalTest):
self.counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project2',

View File

@ -46,6 +46,7 @@ class TestListMeters(FunctionalTest):
counter.Counter(
'meter.test',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -57,6 +58,7 @@ class TestListMeters(FunctionalTest):
counter.Counter(
'meter.test',
'cumulative',
'',
3,
'user-id',
'project-id',
@ -68,6 +70,7 @@ class TestListMeters(FunctionalTest):
counter.Counter(
'meter.mine',
'gauge',
'',
1,
'user-id',
'project-id',
@ -79,6 +82,7 @@ class TestListMeters(FunctionalTest):
counter.Counter(
'meter.test',
'cumulative',
'',
1,
'user-id2',
'project-id2',
@ -90,6 +94,7 @@ class TestListMeters(FunctionalTest):
counter.Counter(
'meter.mine',
'gauge',
'',
1,
'user-id4',
'project-id2',

View File

@ -41,6 +41,7 @@ class TestListProjects(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -59,6 +60,7 @@ class TestListProjects(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id2',
@ -81,6 +83,7 @@ class TestListProjects(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -99,6 +102,7 @@ class TestListProjects(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id2',

View File

@ -42,6 +42,7 @@ class TestListResources(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -60,6 +61,7 @@ class TestListResources(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -82,6 +84,7 @@ class TestListResources(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -100,6 +103,7 @@ class TestListResources(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id',
@ -123,6 +127,7 @@ class TestListResources(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -141,6 +146,7 @@ class TestListResources(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id',
@ -164,6 +170,7 @@ class TestListResources(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -182,6 +189,7 @@ class TestListResources(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id2',
@ -205,6 +213,7 @@ class TestListResources(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',

View File

@ -43,6 +43,7 @@ class TestListUsers(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -61,6 +62,7 @@ class TestListUsers(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id',
@ -83,6 +85,7 @@ class TestListUsers(FunctionalTest):
counter1 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id',
'project-id',
@ -101,6 +104,7 @@ class TestListUsers(FunctionalTest):
counter2 = counter.Counter(
'instance',
'cumulative',
'',
1,
'user-id2',
'project-id',

View File

@ -42,6 +42,7 @@ class TestMaxProjectVolume(FunctionalTest):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -41,6 +41,7 @@ class TestMaxResourceVolume(FunctionalTest):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -41,6 +41,7 @@ class TestSumProjectVolume(FunctionalTest):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -41,6 +41,7 @@ class TestSumResourceVolume(FunctionalTest):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -101,6 +101,7 @@ def test_verify_signature_nested():
TEST_COUNTER = counter.Counter(name='name',
type='typ',
unit='',
volume=1,
user_id='user',
project_id='project',
@ -160,6 +161,7 @@ def test_meter_message_from_counter_field():
'src')
name_map = {'name': 'counter_name',
'type': 'counter_type',
'unit': 'counter_unit',
'volume': 'counter_volume',
}
for f in TEST_COUNTER._fields:

View File

@ -45,6 +45,7 @@ class TestRunTasks(base.TestCase):
test_data = counter.Counter(
name='test',
type=counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='test',
project_id='test',

View File

@ -59,6 +59,7 @@ class TestNovaNotifier(base.TestCase):
test_data = counter.Counter(
name='test',
type=counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='test',
project_id='test',

View File

@ -73,6 +73,7 @@ class MongoDBEngineTestBase(unittest.TestCase):
self.counter = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
'',
1,
'user-id',
'project-id',
@ -90,6 +91,7 @@ class MongoDBEngineTestBase(unittest.TestCase):
self.counter2 = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
'',
1,
'user-id',
'project-id',
@ -107,6 +109,7 @@ class MongoDBEngineTestBase(unittest.TestCase):
self.counter3 = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
'',
1,
'user-id-alternate',
'project-id',
@ -125,6 +128,7 @@ class MongoDBEngineTestBase(unittest.TestCase):
c = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
'',
1,
'user-id-%s' % i,
'project-id-%s' % i,
@ -217,6 +221,7 @@ class ResourceTest(MongoDBEngineTestBase):
assert 'meter' in resource
assert resource['meter'] == [{'counter_name': 'instance',
'counter_type': 'cumulative',
'counter_unit': '',
}]
def test_new_resource_metadata(self):
@ -235,6 +240,7 @@ class ResourceTest(MongoDBEngineTestBase):
assert 'metadata' in resource
assert resource['meter'] == [{'counter_name': 'instance',
'counter_type': 'cumulative',
'counter_unit': '',
}]
break
else:
@ -458,6 +464,7 @@ class TestGetEventInterval(MongoDBEngineTestBase):
c = counter.Counter(
name='instance',
type=counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='user-id',
project_id='project-id',

View File

@ -97,6 +97,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase):
self.counter = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='user-id',
project_id='project-id',
@ -115,6 +116,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase):
self.counter2 = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='user-id',
project_id='project-id',
@ -133,6 +135,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase):
self.counter3 = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='user-id-alternate',
project_id='project-id',
@ -152,10 +155,11 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase):
c = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
1,
'user-id-%s' % i,
'project-id-%s' % i,
'resource-id-%s' % i,
unit='',
volume=1,
user_id='user-id-%s' % i,
project_id='project-id-%s' % i,
resource_id='resource-id-%s' % i,
timestamp=datetime.datetime(2012, 7, 2, 10, 40 + i),
resource_metadata={'display_name': 'test-server',
'tag': 'counter-%s' % i,
@ -466,6 +470,7 @@ class TestGetEventInterval(SQLAlchemyEngineTestBase):
c = counter.Counter(
'instance',
counter.TYPE_CUMULATIVE,
'',
1,
'11',
'1',
@ -584,6 +589,7 @@ class MaxProjectTest(SQLAlchemyEngineSubBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',
@ -662,6 +668,7 @@ class MaxResourceTest(SQLAlchemyEngineSubBase):
c = counter.Counter(
'volume.size',
'gauge',
'GiB',
5 + i,
'user-id',
'project1',

View File

@ -32,6 +32,7 @@ class TestPublish(base.TestCase):
test_data = counter.Counter(
name='test',
type=counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='test',
project_id='test',

View File

@ -60,6 +60,11 @@ def main():
default='gauge',
help='counter type',
)
parser.add_argument(
'--unit',
default=None,
help='counter unit',
)
parser.add_argument(
'--project',
help='project id of owner',
@ -115,6 +120,7 @@ def main():
while timestamp <= end:
c = counter.Counter(name=args.counter,
type=args.type,
unit=args.unit,
volume=args.volume,
user_id=args.user,
project_id=args.project,