From 51c8a8e55cc43ef5774c42ce38c962cb2526acfb Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 8 Jan 2013 17:47:18 +0100 Subject: [PATCH] Update pep8 to 1.3.3 This is needed to update openstack.common Change-Id: I8410f978f38b3893b71239f97f785086ca5faffe Signed-off-by: Julien Danjou --- ceilometer/api/__init__.py | 2 +- ceilometer/api/controllers/v2.py | 7 ++-- ceilometer/api/v1/blueprint.py | 21 +++++----- ceilometer/central/manager.py | 4 +- ceilometer/collector/meter.py | 2 +- ceilometer/collector/service.py | 8 ++-- ceilometer/compute/instance.py | 7 ++-- ceilometer/compute/manager.py | 7 ++-- ceilometer/compute/notifications.py | 25 +++++------ ceilometer/compute/nova_notifier.py | 4 +- ceilometer/compute/pollsters.py | 12 +++--- ceilometer/compute/virt/libvirt/inspector.py | 9 ++-- ceilometer/extension_manager.py | 6 +-- ceilometer/image/glance.py | 36 ++++++++-------- ceilometer/network/floatingip.py | 2 +- ceilometer/nova_client.py | 4 +- ceilometer/objectstore/swift.py | 4 +- ceilometer/objectstore/swift_middleware.py | 5 ++- ceilometer/openstack/common/iniparser.py | 2 +- ceilometer/openstack/common/log.py | 4 +- ceilometer/policy.py | 2 +- ceilometer/publish.py | 4 +- ceilometer/service.py | 4 +- ceilometer/storage/__init__.py | 2 +- ceilometer/storage/impl_mongodb.py | 25 ++++++----- ceilometer/storage/impl_sqlalchemy.py | 4 +- .../versions/003_set_utf8_charset.py | 4 +- ceilometer/storage/sqlalchemy/migration.py | 4 +- ceilometer/storage/sqlalchemy/models.py | 18 ++++---- ceilometer/storage/sqlalchemy/session.py | 12 +++--- ceilometer/tests/api.py | 14 +++---- ceilometer/volume/notifications.py | 3 +- setup.py | 2 +- .../v1/test_compute_duration_by_resource.py | 12 +++--- tests/api/v1/test_list_events.py | 23 +++++------ tests/api/v1/test_list_meters.py | 15 +++---- tests/api/v1/test_list_projects.py | 10 ++--- tests/api/v1/test_list_resources.py | 16 ++++---- tests/api/v1/test_list_users.py | 4 +- tests/api/v1/test_max_project_volume.py | 2 +- tests/api/v1/test_max_resource_volume.py | 2 +- tests/api/v1/test_sum_project_volume.py | 2 +- tests/api/v1/test_sum_resource_volume.py | 2 +- tests/api/v2/test_acl.py | 18 ++++---- .../v2/test_compute_duration_by_resource.py | 6 +-- tests/api/v2/test_date_range.py | 8 ++-- tests/api/v2/test_list_events.py | 4 +- tests/api/v2/test_list_meters.py | 15 +++---- tests/api/v2/test_list_projects.py | 8 ++-- tests/api/v2/test_list_resources.py | 18 ++++---- tests/api/v2/test_list_users.py | 11 +++-- tests/api/v2/test_max_project_volume.py | 2 +- tests/api/v2/test_max_resource_volume.py | 2 +- tests/api/v2/test_sum_project_volume.py | 2 +- tests/api/v2/test_sum_resource_volume.py | 2 +- tests/collector/test_manager.py | 8 ++-- tests/collector/test_meter.py | 2 +- tests/compute/test_instance.py | 41 +++++++++---------- tests/compute/test_manager.py | 8 ++-- tests/compute/test_notifications.py | 33 ++++++++------- tests/compute/test_nova_notifier.py | 10 ++--- tests/compute/test_pollsters.py | 40 +++++++++--------- tests/compute/virt/libvirt/test_inspector.py | 2 +- tests/image/test_glance.py | 2 +- tests/objectstore/test_swift_middleware.py | 6 ++- tests/storage/test_impl_mongodb.py | 31 +++++++------- tests/storage/test_impl_sqlalchemy.py | 38 ++++++++--------- tests/test_publish.py | 5 +-- tools/test-requires | 1 - tools/test-requires-folsom | 1 - tox.ini | 2 +- 71 files changed, 331 insertions(+), 352 deletions(-) diff --git a/ceilometer/api/__init__.py b/ceilometer/api/__init__.py index 2b5193448..dd50d8707 100644 --- a/ceilometer/api/__init__.py +++ b/ceilometer/api/__init__.py @@ -32,5 +32,5 @@ API_SERVICE_OPTS = [ default=8777, help='The port for the ceilometer API server', ), - ] +] cfg.CONF.register_opts(API_SERVICE_OPTS) diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index a78c18b57..1153c5d36 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -284,7 +284,7 @@ class MeterController(RestController): _custom_actions = { 'duration': ['GET'], - } + } def __init__(self, meter_id): request.context['meter_id'] = meter_id @@ -304,7 +304,7 @@ class MeterController(RestController): resource=request.context.get('resource_id'), meter=self._id, source=request.context.get('source_id'), - ) + ) return [Event(**e) for e in request.storage_conn.get_raw_events(f) ] @@ -445,7 +445,8 @@ class ResourcesController(RestController): project=request.context.get('project_id'), start_timestamp=start_timestamp, end_timestamp=end_timestamp, - )] + ) + ] return resources diff --git a/ceilometer/api/v1/blueprint.py b/ceilometer/api/v1/blueprint.py index 503c67a32..8ca9a8c42 100644 --- a/ceilometer/api/v1/blueprint.py +++ b/ceilometer/api/v1/blueprint.py @@ -105,7 +105,7 @@ def request_wants_html(): def _get_metaquery(args): return dict((k, v) for (k, v) in args.iteritems() - if k.startswith('metadata.')) + if k.startswith('metadata.')) def check_authorized_project(project): @@ -204,7 +204,7 @@ def _list_resources(source=None, user=None, project=None): start_timestamp=q_ts['start_timestamp'], end_timestamp=q_ts['end_timestamp'], metaquery=_get_metaquery(rq.args), - ) + ) return flask.jsonify(resources=list(resources)) @@ -371,14 +371,15 @@ def _list_events(meter, """Return a list of raw metering events. """ q_ts = _get_query_timestamps(flask.request.args) - f = storage.EventFilter(user=user, - project=project, - source=source, - meter=meter, - resource=resource, - start=q_ts['start_timestamp'], - end=q_ts['end_timestamp'], - metaquery=_get_metaquery(flask.request.args), + f = storage.EventFilter( + user=user, + project=project, + source=source, + meter=meter, + resource=resource, + start=q_ts['start_timestamp'], + end=q_ts['end_timestamp'], + metaquery=_get_metaquery(flask.request.args), ) events = list(flask.request.storage_conn.get_raw_events(f)) jsonified = flask.jsonify(events=events) diff --git a/ceilometer/central/manager.py b/ceilometer/central/manager.py index ca5b90c9e..861ea18e8 100644 --- a/ceilometer/central/manager.py +++ b/ceilometer/central/manager.py @@ -26,7 +26,7 @@ OPTS = [ default=[], help='list of central pollsters to disable', ), - ] +] cfg.CONF.register_opts(OPTS) @@ -42,7 +42,7 @@ class AgentManager(object): self.ext_manager = extension_manager.ActivatedExtensionManager( namespace=PLUGIN_NAMESPACE, disabled_names=cfg.CONF.disabled_central_pollsters, - ) + ) @staticmethod def publish_counters_from_one_pollster(ext, manager, context): diff --git a/ceilometer/collector/meter.py b/ceilometer/collector/meter.py index c40ba1788..da9d7edec 100644 --- a/ceilometer/collector/meter.py +++ b/ceilometer/collector/meter.py @@ -33,7 +33,7 @@ METER_OPTS = [ default='openstack', help='Source for counters emited on this instance', ), - ] +] def register_opts(config): diff --git a/ceilometer/collector/service.py b/ceilometer/collector/service.py index 924c15319..458408613 100644 --- a/ceilometer/collector/service.py +++ b/ceilometer/collector/service.py @@ -35,7 +35,7 @@ OPTS = [ default=[], help='list of listener plugins to disable', ), - ] +] cfg.CONF.register_opts(OPTS) @@ -59,7 +59,7 @@ class CollectorService(service.PeriodicService): self.ext_manager = extension_manager.ActivatedExtensionManager( namespace=self.COLLECTOR_NAMESPACE, disabled_names=cfg.CONF.disabled_notification_listeners, - ) + ) if not list(self.ext_manager): LOG.warning('Failed to load any notification handlers for %s', @@ -73,7 +73,7 @@ class CollectorService(service.PeriodicService): cfg.CONF.metering_topic, rpc_dispatcher.RpcDispatcher([self]), 'ceilometer.collector.' + cfg.CONF.metering_topic, - ) + ) def _setup_subscription(self, ext, *args, **kwds): handler = ext.obj @@ -90,7 +90,7 @@ class CollectorService(service.PeriodicService): topic=topic, exchange_name=exchange_topic.exchange, callback=self.process_notification, - ) + ) def process_notification(self, notification): """Make a notification processed by an handler.""" diff --git a/ceilometer/compute/instance.py b/ceilometer/compute/instance.py index 9eb946470..728ccc854 100644 --- a/ceilometer/compute/instance.py +++ b/ceilometer/compute/instance.py @@ -33,8 +33,7 @@ INSTANCE_PROPERTIES = [ 'ephemeral_gb', 'memory_mb', 'root_gb', - 'vcpus', - ] + 'vcpus'] def get_metadata_from_object(instance): @@ -48,8 +47,8 @@ def get_metadata_from_object(instance): # Image properties 'image_ref': (instance.image['id'] if instance.image else None), 'image_ref_url': (instance.image['links'][0]['href'] - if instance.image else None), - } + if instance.image else None), + } for name in INSTANCE_PROPERTIES: metadata[name] = getattr(instance, name, u'') diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index 098f7cb27..e44610d82 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -33,9 +33,8 @@ OPTS = [ ), cfg.StrOpt('hypervisor_inspector', default='libvirt', - help='Inspector to use for inspecting the hypervisor layer', - ), - ] + help='Inspector to use for inspecting the hypervisor layer'), +] cfg.CONF.register_opts(OPTS) @@ -63,7 +62,7 @@ class AgentManager(object): self.ext_manager = extension_manager.ActivatedExtensionManager( namespace=PLUGIN_NAMESPACE, disabled_names=cfg.CONF.disabled_compute_pollsters, - ) + ) self._inspector = get_hypervisor_inspector() return diff --git a/ceilometer/compute/notifications.py b/ceilometer/compute/notifications.py index c651b40c3..d3ba61e1a 100644 --- a/ceilometer/compute/notifications.py +++ b/ceilometer/compute/notifications.py @@ -50,8 +50,7 @@ class _Base(plugin.NotificationBase): 'compute.instance.exists', 'compute.instance.delete.start', 'compute.instance.finish_resize.end', - 'compute.instance.resize.revert.end', - ] + 'compute.instance.resize.revert.end'] @staticmethod def get_exchange_topics(conf): @@ -80,7 +79,7 @@ class Instance(_Base): resource_metadata=self.notification_to_metadata( message), ), - ] + ] class Memory(_Base): @@ -96,9 +95,8 @@ class Memory(_Base): resource_id=message['payload']['instance_id'], timestamp=message['timestamp'], resource_metadata=self.notification_to_metadata( - message), - ), - ] + message)), + ] class VCpus(_Base): @@ -114,9 +112,8 @@ class VCpus(_Base): resource_id=message['payload']['instance_id'], timestamp=message['timestamp'], resource_metadata=self.notification_to_metadata( - message), - ), - ] + message)), + ] class RootDiskSize(_Base): @@ -132,9 +129,8 @@ class RootDiskSize(_Base): resource_id=message['payload']['instance_id'], timestamp=message['timestamp'], resource_metadata=self.notification_to_metadata( - message), - ), - ] + message)), + ] class EphemeralDiskSize(_Base): @@ -150,9 +146,8 @@ class EphemeralDiskSize(_Base): resource_id=message['payload']['instance_id'], timestamp=message['timestamp'], resource_metadata=self.notification_to_metadata( - message), - ), - ] + message)), + ] class InstanceFlavor(_Base): diff --git a/ceilometer/compute/nova_notifier.py b/ceilometer/compute/nova_notifier.py index 3f43cb4b7..c650d9cd1 100644 --- a/ceilometer/compute/nova_notifier.py +++ b/ceilometer/compute/nova_notifier.py @@ -60,4 +60,6 @@ def notify(context, message): instance_id = message['payload']['instance_id'] LOG.debug('polling final stats for %r', instance_id) _agent_manager.poll_instance(context, - instance_info_source.instance_get_by_uuid(context, instance_id)) + instance_info_source.instance_get_by_uuid( + context, + instance_id)) diff --git a/ceilometer/compute/pollsters.py b/ceilometer/compute/pollsters.py index 158363af6..ffd29a733 100644 --- a/ceilometer/compute/pollsters.py +++ b/ceilometer/compute/pollsters.py @@ -46,7 +46,7 @@ def make_counter_from_instance(instance, name, type, unit, volume): resource_id=instance.id, timestamp=timeutils.isotime(), resource_metadata=compute_instance.get_metadata_from_object(instance), - ) + ) class InstancePollster(plugin.ComputePollster): @@ -56,15 +56,13 @@ class InstancePollster(plugin.ComputePollster): name='instance', type=counter.TYPE_GAUGE, unit='instance', - volume=1, - ) + volume=1) yield make_counter_from_instance(instance, name='instance:%s' % instance.flavor['name'], type=counter.TYPE_GAUGE, unit='instance', - volume=1, - ) + volume=1) class DiskIOPollster(plugin.ComputePollster): @@ -194,8 +192,8 @@ class NetPollster(plugin.ComputePollster): metadata = copy.copy(vnic_data) resource_metadata = dict(zip(metadata._fields, metadata)) resource_metadata['instance_id'] = instance.id - resource_metadata['instance_type'] = instance.flavor['id'] if \ - instance.flavor else None, + resource_metadata['instance_type'] = \ + instance.flavor['id'] if instance.flavor else None, return counter.Counter( name=name, diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 23ffa97de..ece82c42e 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -36,7 +36,7 @@ libvirt_opts = [ default='', help='Override the default libvirt URI ' '(which is dependent on libvirt_type)'), - ] +] CONF = cfg.CONF CONF.register_opts(libvirt_opts) @@ -126,9 +126,10 @@ class LibvirtInspector(virt_inspector.Inspector): def inspect_disks(self, instance_name): domain = self._lookup_by_name(instance_name) tree = etree.fromstring(domain.XMLDesc(0)) - for device in filter(bool, - [target.get("dev") - for target in tree.findall('devices/disk/target')]): + for device in filter( + bool, + [target.get("dev") + for target in tree.findall('devices/disk/target')]): disk = virt_inspector.Disk(device=device) block_stats = domain.blockStats(device) stats = virt_inspector.DiskStats(read_requests=block_stats[0], diff --git a/ceilometer/extension_manager.py b/ceilometer/extension_manager.py index bc95aae38..a55b45f34 100644 --- a/ceilometer/extension_manager.py +++ b/ceilometer/extension_manager.py @@ -38,14 +38,14 @@ def should_use_extension(namespace, ext, disabled_names): LOG.debug( '%s extension %r disabled through configuration setting', namespace, ext.name, - ) + ) return False if not ext.obj.is_enabled(): LOG.debug( '%s extension %r reported that it is disabled', namespace, ext.name, - ) + ) return False LOG.debug('using %s extension %r', namespace, ext.name) return True @@ -68,4 +68,4 @@ class ActivatedExtensionManager(enabled.EnabledExtensionManager): invoke_on_load=invoke_on_load, invoke_args=invoke_args, invoke_kwds=invoke_kwds, - ) + ) diff --git a/ceilometer/image/glance.py b/ceilometer/image/glance.py index f1aa5c2c8..743d6598e 100644 --- a/ceilometer/image/glance.py +++ b/ceilometer/image/glance.py @@ -61,24 +61,24 @@ class _Base(plugin.PollsterBase): @staticmethod def extract_image_metadata(image): return dict((k, getattr(image, k)) - for k in [ - "status", - "is_public", - "name", - "deleted", - "container_format", - "created_at", - "disk_format", - "updated_at", - "properties", - "min_disk", - "protected", - "checksum", - "deleted_at", - "min_ram", - "size", - ] - ) + for k in + [ + "status", + "is_public", + "name", + "deleted", + "container_format", + "created_at", + "disk_format", + "updated_at", + "properties", + "min_disk", + "protected", + "checksum", + "deleted_at", + "min_ram", + "size", + ]) class ImagePollster(_Base): diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index 8b148d6d7..11df99de6 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -47,4 +47,4 @@ class FloatingIPPollster(plugin.CentralPollster): 'host': ip.host, 'pool': ip.pool, 'auto_assigned': ip.auto_assigned - }) + }) diff --git a/ceilometer/nova_client.py b/ceilometer/nova_client.py index 77359db5e..fd21e923b 100644 --- a/ceilometer/nova_client.py +++ b/ceilometer/nova_client.py @@ -61,8 +61,8 @@ class Client(object): """Returns list of instances on particular host""" search_opts = {'host': hostname, 'all_tenants': True} return self._with_flavor(self.nova_client.servers.list( - detailed=True, - search_opts=search_opts)) + detailed=True, + search_opts=search_opts)) @logged def floating_ip_get_all(self): diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index f0bff7f3d..3be29ec79 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -36,8 +36,8 @@ LOG = log.getLogger(__name__) OPTS = [ cfg.StrOpt('reseller_prefix', default='AUTH_', - help="Swift reseller prefix. Must be on par with "\ - "reseller_prefix in proxy-server.conf."), + help="Swift reseller prefix. Must be on par with " + "reseller_prefix in proxy-server.conf."), ] cfg.CONF.register_opts(OPTS) diff --git a/ceilometer/objectstore/swift_middleware.py b/ceilometer/objectstore/swift_middleware.py index 3b88b8ffe..4d044a991 100644 --- a/ceilometer/objectstore/swift_middleware.py +++ b/ceilometer/objectstore/swift_middleware.py @@ -104,7 +104,8 @@ class CeilometerMiddleware(object): "version": version, "container": container, "object": obj, - }), + }, + ), cfg.CONF.metering_topic, cfg.CONF.metering_secret, cfg.CONF.counter_source) @@ -126,7 +127,7 @@ class CeilometerMiddleware(object): "version": version, "container": container, "object": obj, - }), + }), cfg.CONF.metering_topic, cfg.CONF.metering_secret, cfg.CONF.counter_source) diff --git a/ceilometer/openstack/common/iniparser.py b/ceilometer/openstack/common/iniparser.py index 241284449..9bf399f0c 100644 --- a/ceilometer/openstack/common/iniparser.py +++ b/ceilometer/openstack/common/iniparser.py @@ -54,7 +54,7 @@ class BaseParser(object): value = value.strip() if ((value and value[0] == value[-1]) and - (value[0] == "\"" or value[0] == "'")): + (value[0] == "\"" or value[0] == "'")): value = value[1:-1] return key.strip(), [value] diff --git a/ceilometer/openstack/common/log.py b/ceilometer/openstack/common/log.py index 5f45f2cb1..ea8d28331 100644 --- a/ceilometer/openstack/common/log.py +++ b/ceilometer/openstack/common/log.py @@ -258,7 +258,7 @@ class JSONFormatter(logging.Formatter): class PublishErrorsHandler(logging.Handler): def emit(self, record): if ('ceilometer.openstack.common.notifier.log_notifier' in - CONF.notification_driver): + CONF.notification_driver): return notifier.api.notify(None, 'error.publisher', 'error_notification', @@ -418,7 +418,7 @@ class LegacyFormatter(logging.Formatter): self._fmt = CONF.logging_default_format_string if (record.levelno == logging.DEBUG and - CONF.logging_debug_format_suffix): + CONF.logging_debug_format_suffix): self._fmt += " " + CONF.logging_debug_format_suffix # Cache this on the record, Logger will respect our formated copy diff --git a/ceilometer/policy.py b/ceilometer/policy.py index 8613d9ee5..e468be253 100644 --- a/ceilometer/policy.py +++ b/ceilometer/policy.py @@ -31,7 +31,7 @@ OPTS = [ cfg.StrOpt('policy_default_rule', default='default', help='Rule checked when requested rule is not found'), - ] +] cfg.CONF.register_opts(OPTS) diff --git a/ceilometer/publish.py b/ceilometer/publish.py index 0f51d02e5..24aab9a68 100644 --- a/ceilometer/publish.py +++ b/ceilometer/publish.py @@ -33,7 +33,7 @@ PUBLISH_OPTS = [ cfg.StrOpt('control_exchange', default='ceilometer', help='AMQP exchange to connect to if using RabbitMQ or Qpid'), - ] +] def register_opts(config): @@ -59,7 +59,7 @@ def publish_counter(context, counter, topic, secret, source): secret, source), }, - } + } LOG.debug('PUBLISH: %s', str(msg)) rpc.cast(context, topic, msg) rpc.cast(context, topic + '.' + counter.name, msg) diff --git a/ceilometer/service.py b/ceilometer/service.py index 58343ac22..609faecd6 100644 --- a/ceilometer/service.py +++ b/ceilometer/service.py @@ -66,8 +66,8 @@ class PeriodicService(rpc_service.Service): super(PeriodicService, self).start() admin_context = context.RequestContext('admin', 'admin', is_admin=True) self.tg.add_timer(cfg.CONF.periodic_interval, - self.manager.periodic_tasks, - context=admin_context) + self.manager.periodic_tasks, + context=admin_context) def _sanitize_cmd_line(argv): diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index 331540988..7bffed681 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -36,7 +36,7 @@ STORAGE_OPTS = [ default='mongodb://localhost:27017/ceilometer', help='Database connection string', ), - ] +] cfg.CONF.register_opts(STORAGE_OPTS) diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 9a872b50c..f795e69a8 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -193,17 +193,16 @@ class Connection(base.Connection): # including both. for primary in ['user_id', 'project_id']: self.db.resource.ensure_index([ - (primary, pymongo.ASCENDING), - ('source', pymongo.ASCENDING), - ], name='resource_idx') + (primary, pymongo.ASCENDING), + ('source', pymongo.ASCENDING), + ], name='resource_idx') self.db.meter.ensure_index([ - ('resource_id', pymongo.ASCENDING), - (primary, pymongo.ASCENDING), - ('counter_name', pymongo.ASCENDING), - ('timestamp', pymongo.ASCENDING), - ('source', pymongo.ASCENDING), - ], name='meter_idx') - return + ('resource_id', pymongo.ASCENDING), + (primary, pymongo.ASCENDING), + ('counter_name', pymongo.ASCENDING), + ('timestamp', pymongo.ASCENDING), + ('source', pymongo.ASCENDING), + ], name='meter_idx') def upgrade(self, version=None): pass @@ -249,14 +248,14 @@ class Connection(base.Connection): }, }, upsert=True, - ) + ) self.db.project.update( {'_id': data['project_id']}, {'$addToSet': {'source': data['source'], }, }, upsert=True, - ) + ) # Record the updated resource metadata received_timestamp = datetime.datetime.utcnow() @@ -278,7 +277,7 @@ class Connection(base.Connection): }, }, upsert=True, - ) + ) # Record the raw data for the event. Use a copy so we do not # modify a data structure owned by our caller (the driver adds diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py index 99d8dbd94..93187a767 100644 --- a/ceilometer/storage/impl_sqlalchemy.py +++ b/ceilometer/storage/impl_sqlalchemy.py @@ -252,7 +252,7 @@ class Connection(base.Connection): if project is not None: query = query.filter(Resource.project_id == project) query = query.options( - sqlalchemy_session.sqlalchemy.orm.joinedload('meters')) + sqlalchemy_session.sqlalchemy.orm.joinedload('meters')) if metaquery is not None: raise NotImplementedError('metaquery not implemented') @@ -298,7 +298,7 @@ class Connection(base.Connection): if project is not None: query = query.filter(Resource.project_id == project) query = query.options( - sqlalchemy_session.sqlalchemy.orm.joinedload('meters')) + sqlalchemy_session.sqlalchemy.orm.joinedload('meters')) if len(metaquery) > 0: raise NotImplementedError('metaquery not implemented') diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/003_set_utf8_charset.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/003_set_utf8_charset.py index 135eda030..347ef51f9 100644 --- a/ceilometer/storage/sqlalchemy/migrate_repo/versions/003_set_utf8_charset.py +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/003_set_utf8_charset.py @@ -21,7 +21,7 @@ def upgrade(migrate_engine): if migrate_engine.name == "mysql": tables = ['meter', 'user', 'resource', 'project', 'source', - 'sourceassoc'] + 'sourceassoc'] sql = "SET foreign_key_checks = 0;" for table in tables: @@ -36,7 +36,7 @@ def downgrade(migrate_engine): # Operations to reverse the above upgrade go here. if migrate_engine.name == "mysql": tables = ['meter', 'user', 'resource', 'project', 'source', - 'sourceassoc'] + 'sourceassoc'] sql = "SET foreign_key_checks = 0;" for table in tables: diff --git a/ceilometer/storage/sqlalchemy/migration.py b/ceilometer/storage/sqlalchemy/migration.py index abcd921b9..61c398c3b 100644 --- a/ceilometer/storage/sqlalchemy/migration.py +++ b/ceilometer/storage/sqlalchemy/migration.py @@ -46,8 +46,8 @@ def patched_with_engine(f, *a, **kw): # TODO(jkoelker) When migrate 0.7.3 is released and nova depends # on that version or higher, this can be removed MIN_PKG_VERSION = dist_version.StrictVersion('0.7.3') -if (not hasattr(migrate, '__version__') or - dist_version.StrictVersion(migrate.__version__) < MIN_PKG_VERSION): +if (not hasattr(migrate, '__version__') + or dist_version.StrictVersion(migrate.__version__) < MIN_PKG_VERSION): migrate_util.with_engine = patched_with_engine diff --git a/ceilometer/storage/sqlalchemy/models.py b/ceilometer/storage/sqlalchemy/models.py index c1de1a448..c6eba7e77 100644 --- a/ceilometer/storage/sqlalchemy/models.py +++ b/ceilometer/storage/sqlalchemy/models.py @@ -33,7 +33,7 @@ sql_opts = [ cfg.StrOpt('mysql_engine', default='InnoDB', help='MySQL engine') - ] +] cfg.CONF.register_opts(sql_opts) @@ -78,12 +78,16 @@ Base = declarative_base(cls=CeilometerBase) sourceassoc = Table('sourceassoc', Base.metadata, - Column('meter_id', Integer, ForeignKey("meter.id")), - Column('project_id', String(255), ForeignKey("project.id")), - Column('resource_id', String(255), ForeignKey("resource.id")), - Column('user_id', String(255), ForeignKey("user.id")), - Column('source_id', String(255), ForeignKey("source.id")) -) + Column('meter_id', Integer, + ForeignKey("meter.id")), + Column('project_id', String(255), + ForeignKey("project.id")), + Column('resource_id', String(255), + ForeignKey("resource.id")), + Column('user_id', String(255), + ForeignKey("user.id")), + Column('source_id', String(255), + ForeignKey("source.id"))) class Source(Base): diff --git a/ceilometer/storage/sqlalchemy/session.py b/ceilometer/storage/sqlalchemy/session.py index 3b66f1feb..ad955367a 100644 --- a/ceilometer/storage/sqlalchemy/session.py +++ b/ceilometer/storage/sqlalchemy/session.py @@ -41,8 +41,8 @@ sql_opts = [ help='Verbosity of SQL debugging information. 0=None, ' '100=Everything'), cfg.BoolOpt('sql_connection_trace', - default=False, - help='Add python stack traces to SQL as comment strings'), + default=False, + help='Add python stack traces to SQL as comment strings'), cfg.BoolOpt('sqlite_synchronous', default=True, help='If passed, use synchronous mode for sqlite'), @@ -56,7 +56,7 @@ sql_opts = [ cfg.IntOpt('sql_retry_interval', default=10, help='interval between retries of opening a sql connection'), - ] +] cfg.CONF.register_opts(sql_opts) @@ -121,7 +121,7 @@ def get_engine(): global _ENGINE if _ENGINE is None: connection_dict = sqlalchemy.engine.url.make_url( - cfg.CONF.database_connection) + cfg.CONF.database_connection) engine_args = { "pool_recycle": cfg.CONF.sql_idle_timeout, @@ -178,8 +178,8 @@ def get_engine(): _ENGINE.connect() break except OperationalError, e: - if (remaining != 'infinite' and remaining == 0) or \ - not is_db_connection_error(e.args[0]): + if (remaining != 'infinite' and remaining == 0) \ + or not is_db_connection_error(e.args[0]): raise return _ENGINE diff --git a/ceilometer/tests/api.py b/ceilometer/tests/api.py index 4422c2e4c..376d4c5a4 100644 --- a/ceilometer/tests/api.py +++ b/ceilometer/tests/api.py @@ -103,7 +103,7 @@ class FunctionalTest(unittest.TestCase): 'modules': ['ceilometer.api'], 'static_root': '%s/public' % root_dir, 'template_path': '%s/ceilometer/api/templates' % root_dir, - }, + }, 'logging': { 'loggers': { @@ -112,22 +112,22 @@ class FunctionalTest(unittest.TestCase): 'ceilometer': {'level': 'DEBUG', 'handlers': ['console'], }, - }, + }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'simple' - } - }, + } + }, 'formatters': { 'simple': { 'format': ('%(asctime)s %(levelname)-5.5s [%(name)s]' '[%(threadName)s] %(message)s') - } - }, + } }, - } + }, + } self.mox = mox.Mox() self.stubs = stubout.StubOutForTesting() diff --git a/ceilometer/volume/notifications.py b/ceilometer/volume/notifications.py index f02155d59..c893e0a50 100644 --- a/ceilometer/volume/notifications.py +++ b/ceilometer/volume/notifications.py @@ -61,8 +61,7 @@ class _Base(plugin.NotificationBase): def get_event_types(): return ['volume.exists', 'volume.create.end', - 'volume.delete.start', - ] + 'volume.delete.start'] class Volume(_Base): diff --git a/setup.py b/setup.py index 7a79cb96b..d2c41ef46 100755 --- a/setup.py +++ b/setup.py @@ -136,4 +136,4 @@ setuptools.setup( [paste.filter_factory] swift=ceilometer.objectstore.swift_middleware:filter_factory """), - ) +) diff --git a/tests/api/v1/test_compute_duration_by_resource.py b/tests/api/v1/test_compute_duration_by_resource.py index e2b399e06..020bb3380 100644 --- a/tests/api/v1/test_compute_duration_by_resource.py +++ b/tests/api/v1/test_compute_duration_by_resource.py @@ -36,17 +36,17 @@ class TestComputeDurationByResource(tests_api.TestBase): # Create events relative to the range and pretend # that the intervening events exist. - self.early1 = datetime.datetime(2012, 8, 27, 7, 0) + self.early1 = datetime.datetime(2012, 8, 27, 7, 0) self.early2 = datetime.datetime(2012, 8, 27, 17, 0) self.start = datetime.datetime(2012, 8, 28, 0, 0) - self.middle1 = datetime.datetime(2012, 8, 28, 8, 0) + self.middle1 = datetime.datetime(2012, 8, 28, 8, 0) self.middle2 = datetime.datetime(2012, 8, 28, 18, 0) self.end = datetime.datetime(2012, 8, 28, 23, 59) - self.late1 = datetime.datetime(2012, 8, 29, 9, 0) + self.late1 = datetime.datetime(2012, 8, 29, 9, 0) self.late2 = datetime.datetime(2012, 8, 29, 19, 0) def _set_interval(self, start, end): @@ -62,7 +62,7 @@ class TestComputeDurationByResource(tests_api.TestBase): start_timestamp=self.start.isoformat(), end_timestamp=self.end.isoformat(), search_offset=10, # this value doesn't matter, db call is mocked - ) + ) def test_before_range(self): self._set_interval(self.early1, self.early2) @@ -118,7 +118,7 @@ class TestComputeDurationByResource(tests_api.TestBase): '/resources/resource-id/meters/instance:m1.tiny/duration', start_timestamp=self.late1.isoformat(), search_offset=10, # this value doesn't matter, db call is mocked - ) + ) self._assert_times_match(data['start_timestamp'], self.late1) self._assert_times_match(data['end_timestamp'], self.late2) @@ -130,6 +130,6 @@ class TestComputeDurationByResource(tests_api.TestBase): '/resources/resource-id/meters/instance:m1.tiny/duration', end_timestamp=self.early2.isoformat(), search_offset=10, # this value doesn't matter, db call is mocked - ) + ) self._assert_times_match(data['start_timestamp'], self.early1) self._assert_times_match(data['end_timestamp'], self.early2) diff --git a/tests/api/v1/test_list_events.py b/tests/api/v1/test_list_events.py index 42d73ff12..f0fe11c23 100644 --- a/tests/api/v1/test_list_events.py +++ b/tests/api/v1/test_list_events.py @@ -46,8 +46,7 @@ class TestListEvents(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - } + 'tag': 'self.counter'} ), counter.Counter( 'instance', @@ -59,8 +58,7 @@ class TestListEvents(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - } + 'tag': 'self.counter'} ), counter.Counter( 'instance', @@ -72,8 +70,7 @@ class TestListEvents(tests_api.TestBase): 'resource-id-alternate', timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter2', - } + 'tag': 'self.counter2'} ), ]: msg = meter.meter_message_from_counter(cnt, @@ -116,14 +113,14 @@ class TestListEvents(tests_api.TestBase): def test_by_resource_non_admin(self): data = self.get('/resources/resource-id-alternate/meters/instance', - headers={"X-Roles": "Member", - "X-Tenant-Id": "project2"}) + headers={"X-Roles": "Member", + "X-Tenant-Id": "project2"}) self.assertEquals(1, len(data['events'])) def test_by_resource_some_tenant(self): data = self.get('/resources/resource-id/meters/instance', - headers={"X-Roles": "Member", - "X-Tenant-Id": "project2"}) + headers={"X-Roles": "Member", + "X-Tenant-Id": "project2"}) self.assertEquals(0, len(data['events'])) def test_empty_source(self): @@ -168,7 +165,7 @@ class TestListEvents(tests_api.TestBase): def test_by_user_with_timestamps(self): data = self.get('/users/user-id/meters/instance', start_timestamp=datetime.datetime(2012, 7, 2, 10, 41), - end_timestamp=datetime.datetime(2012, 7, 2, 10, 42)) + end_timestamp=datetime.datetime(2012, 7, 2, 10, 42)) self.assertEquals(1, len(data['events'])) def test_metaquery1(self): @@ -203,6 +200,6 @@ class TestListEvents(tests_api.TestBase): def test_metaquery3_with_project(self): q = '/sources/source1/meters/instance' data = self.get('%s?metadata.display_name=test-server' % q, - headers={"X-Roles": "Member", - "X-Tenant-Id": "project2"}) + headers={"X-Roles": "Member", + "X-Tenant-Id": "project2"}) self.assertEquals(1, len(data['events'])) diff --git a/tests/api/v1/test_list_meters.py b/tests/api/v1/test_list_meters.py index eb453501a..e9c43aec8 100644 --- a/tests/api/v1/test_list_meters.py +++ b/tests/api/v1/test_list_meters.py @@ -54,8 +54,7 @@ class TestListMeters(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - }), + 'tag': 'self.counter'}), counter.Counter( 'meter.test', 'cumulative', @@ -66,8 +65,7 @@ class TestListMeters(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 11, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - }), + 'tag': 'self.counter'}), counter.Counter( 'meter.mine', 'gauge', @@ -78,8 +76,7 @@ class TestListMeters(tests_api.TestBase): 'resource-id2', timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', - 'tag': 'two.counter', - }), + 'tag': 'two.counter'}), counter.Counter( 'meter.test', 'cumulative', @@ -90,8 +87,7 @@ class TestListMeters(tests_api.TestBase): 'resource-id3', timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', - 'tag': 'three.counter', - }), + 'tag': 'three.counter'}), counter.Counter( 'meter.mine', 'gauge', @@ -102,8 +98,7 @@ class TestListMeters(tests_api.TestBase): 'resource-id4', timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', - 'tag': 'four.counter', - })]: + 'tag': 'four.counter'})]: msg = meter.meter_message_from_counter(cnt, cfg.CONF.metering_secret, 'test_list_resources') diff --git a/tests/api/v1/test_list_projects.py b/tests/api/v1/test_list_projects.py index 96c5fc98f..c806f740f 100644 --- a/tests/api/v1/test_list_projects.py +++ b/tests/api/v1/test_list_projects.py @@ -52,9 +52,8 @@ class TestListProjects(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - } - ) + 'tag': 'self.counter'} + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_projects', @@ -71,9 +70,8 @@ class TestListProjects(tests_api.TestBase): 'resource-id-alternate', timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter2', - } - ) + 'tag': 'self.counter2'} + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'test_list_users', diff --git a/tests/api/v1/test_list_resources.py b/tests/api/v1/test_list_resources.py index a4cbabcfc..0aa64d85c 100644 --- a/tests/api/v1/test_list_resources.py +++ b/tests/api/v1/test_list_resources.py @@ -54,8 +54,8 @@ class TestListResources(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - }), + 'tag': 'self.counter'}, + ), counter.Counter( 'instance', 'cumulative', @@ -66,8 +66,8 @@ class TestListResources(tests_api.TestBase): 'resource-id-alternate', timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter2', - }), + 'tag': 'self.counter2'}, + ), counter.Counter( 'instance', 'cumulative', @@ -78,8 +78,8 @@ class TestListResources(tests_api.TestBase): 'resource-id2', timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter3', - }), + 'tag': 'self.counter3'}, + ), counter.Counter( 'instance', 'cumulative', @@ -90,8 +90,8 @@ class TestListResources(tests_api.TestBase): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter4', - })]: + 'tag': 'self.counter4'} + )]: msg = meter.meter_message_from_counter(cnt, cfg.CONF.metering_secret, 'test_list_resources') diff --git a/tests/api/v1/test_list_users.py b/tests/api/v1/test_list_users.py index b01889f61..7c88a9689 100644 --- a/tests/api/v1/test_list_users.py +++ b/tests/api/v1/test_list_users.py @@ -55,7 +55,7 @@ class TestListUsers(tests_api.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_users', @@ -74,7 +74,7 @@ class TestListUsers(tests_api.TestBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', diff --git a/tests/api/v1/test_max_project_volume.py b/tests/api/v1/test_max_project_volume.py index 7592b8465..c20a97699 100644 --- a/tests/api/v1/test_max_project_volume.py +++ b/tests/api/v1/test_max_project_volume.py @@ -49,7 +49,7 @@ class TestMaxProjectVolume(tests_api.TestBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v1/test_max_resource_volume.py b/tests/api/v1/test_max_resource_volume.py index 382a61648..0264f396e 100644 --- a/tests/api/v1/test_max_resource_volume.py +++ b/tests/api/v1/test_max_resource_volume.py @@ -48,7 +48,7 @@ class TestMaxResourceVolume(tests_api.TestBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v1/test_sum_project_volume.py b/tests/api/v1/test_sum_project_volume.py index 556750aba..deb74db3a 100644 --- a/tests/api/v1/test_sum_project_volume.py +++ b/tests/api/v1/test_sum_project_volume.py @@ -49,7 +49,7 @@ class TestSumProjectVolume(tests_api.TestBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v1/test_sum_resource_volume.py b/tests/api/v1/test_sum_resource_volume.py index 7832e8938..21c3795ea 100644 --- a/tests/api/v1/test_sum_resource_volume.py +++ b/tests/api/v1/test_sum_resource_volume.py @@ -49,7 +49,7 @@ class TestSumResourceVolume(tests_api.TestBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v2/test_acl.py b/tests/api/v2/test_acl.py index 842b4d606..e08ed565b 100644 --- a/tests/api/v2/test_acl.py +++ b/tests/api/v2/test_acl.py @@ -51,10 +51,11 @@ class TestAPIACL(FunctionalTest): response = self.get_json('/sources', expect_errors=True, headers={ - "X-Roles": "Member", - "X-Tenant-Name": "admin", - "X-Tenant-Id": "bc23a9d531064583ace8f67dad60f6bb", - }) + "X-Roles": "Member", + "X-Tenant-Name": "admin", + "X-Tenant-Id": + "bc23a9d531064583ace8f67dad60f6bb", + }) self.assertEqual(response.status_int, 401) # FIXME(dhellmann): This test is not properly looking at the tenant @@ -76,8 +77,9 @@ class TestAPIACL(FunctionalTest): response = self.get_json('/sources', expect_errors=True, headers={ - "X-Roles": "admin", - "X-Tenant-Name": "admin", - "X-Tenant-Id": "bc23a9d531064583ace8f67dad60f6bb", - }) + "X-Roles": "admin", + "X-Tenant-Name": "admin", + "X-Tenant-Id": + "bc23a9d531064583ace8f67dad60f6bb", + }) self.assertEqual(response.status_int, 200) diff --git a/tests/api/v2/test_compute_duration_by_resource.py b/tests/api/v2/test_compute_duration_by_resource.py index fdd43f3ad..243499129 100644 --- a/tests/api/v2/test_compute_duration_by_resource.py +++ b/tests/api/v2/test_compute_duration_by_resource.py @@ -36,17 +36,17 @@ class TestComputeDurationByResource(FunctionalTest): # Create events relative to the range and pretend # that the intervening events exist. - self.early1 = datetime.datetime(2012, 8, 27, 7, 0) + self.early1 = datetime.datetime(2012, 8, 27, 7, 0) self.early2 = datetime.datetime(2012, 8, 27, 17, 0) self.start = datetime.datetime(2012, 8, 28, 0, 0) - self.middle1 = datetime.datetime(2012, 8, 28, 8, 0) + self.middle1 = datetime.datetime(2012, 8, 28, 8, 0) self.middle2 = datetime.datetime(2012, 8, 28, 18, 0) self.end = datetime.datetime(2012, 8, 28, 23, 59) - self.late1 = datetime.datetime(2012, 8, 29, 9, 0) + self.late1 = datetime.datetime(2012, 8, 29, 9, 0) self.late2 = datetime.datetime(2012, 8, 29, 19, 0) def _stub_interval_func(self, func): diff --git a/tests/api/v2/test_date_range.py b/tests/api/v2/test_date_range.py index af66cb7f9..076577f91 100644 --- a/tests/api/v2/test_date_range.py +++ b/tests/api/v2/test_date_range.py @@ -46,7 +46,7 @@ class DateRangeTest(unittest.TestCase): 'query_start': datetime.datetime(2012, 9, 20, 12, 13, 14), 'query_end': None, 'search_offset': 0, - } + } assert result == expected @@ -59,7 +59,7 @@ class DateRangeTest(unittest.TestCase): 'query_end': datetime.datetime(2012, 9, 20, 12, 13, 14), 'query_start': None, 'search_offset': 0, - } + } assert result == expected @@ -68,13 +68,13 @@ class DateRangeTest(unittest.TestCase): end=datetime.datetime(2012, 9, 20, 13, 24, 25), start=datetime.datetime(2012, 9, 20, 12, 13, 14), search_offset=20, - ).to_dict() + ).to_dict() expected = { 'query_end': datetime.datetime(2012, 9, 20, 13, 44, 25), 'query_start': datetime.datetime(2012, 9, 20, 11, 53, 14), 'end_timestamp': datetime.datetime(2012, 9, 20, 13, 24, 25), 'start_timestamp': datetime.datetime(2012, 9, 20, 12, 13, 14), 'search_offset': 20, - } + } assert result == expected diff --git a/tests/api/v2/test_list_events.py b/tests/api/v2/test_list_events.py index 0b3baa8cc..cf5b9ec39 100644 --- a/tests/api/v2/test_list_events.py +++ b/tests/api/v2/test_list_events.py @@ -48,7 +48,7 @@ class TestListEvents(FunctionalTest): 'ignored_dict': {'key': 'value'}, 'ignored_list': ['not-returned'], } - ) + ) msg = meter.meter_message_from_counter(self.counter1, cfg.CONF.metering_secret, 'test_source', @@ -67,7 +67,7 @@ class TestListEvents(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(self.counter2, cfg.CONF.metering_secret, 'source2', diff --git a/tests/api/v2/test_list_meters.py b/tests/api/v2/test_list_meters.py index 820f96350..18bcf1d9c 100644 --- a/tests/api/v2/test_list_meters.py +++ b/tests/api/v2/test_list_meters.py @@ -53,8 +53,7 @@ class TestListMeters(FunctionalTest): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - }), + 'tag': 'self.counter'}), counter.Counter( 'meter.test', 'cumulative', @@ -65,8 +64,7 @@ class TestListMeters(FunctionalTest): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 11, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - }), + 'tag': 'self.counter'}), counter.Counter( 'meter.mine', 'gauge', @@ -77,8 +75,7 @@ class TestListMeters(FunctionalTest): 'resource-id2', timestamp=datetime.datetime(2012, 7, 2, 10, 41), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter2', - }), + 'tag': 'self.counter2'}), counter.Counter( 'meter.test', 'cumulative', @@ -89,8 +86,7 @@ class TestListMeters(FunctionalTest): 'resource-id3', timestamp=datetime.datetime(2012, 7, 2, 10, 42), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter3', - }), + 'tag': 'self.counter3'}), counter.Counter( 'meter.mine', 'gauge', @@ -101,8 +97,7 @@ class TestListMeters(FunctionalTest): 'resource-id4', timestamp=datetime.datetime(2012, 7, 2, 10, 43), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter4', - })]: + 'tag': 'self.counter4'})]: msg = meter.meter_message_from_counter(cnt, cfg.CONF.metering_secret, 'test_source') diff --git a/tests/api/v2/test_list_projects.py b/tests/api/v2/test_list_projects.py index df8c54497..7a48dd151 100644 --- a/tests/api/v2/test_list_projects.py +++ b/tests/api/v2/test_list_projects.py @@ -50,7 +50,7 @@ class TestListProjects(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_source', @@ -69,7 +69,7 @@ class TestListProjects(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'test_source', @@ -92,7 +92,7 @@ class TestListProjects(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_source', @@ -111,7 +111,7 @@ class TestListProjects(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', diff --git a/tests/api/v2/test_list_resources.py b/tests/api/v2/test_list_resources.py index d2feaa36b..bf7e895fc 100644 --- a/tests/api/v2/test_list_resources.py +++ b/tests/api/v2/test_list_resources.py @@ -51,7 +51,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test', @@ -70,7 +70,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'test', @@ -93,7 +93,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_resources', @@ -112,7 +112,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', @@ -136,7 +136,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_resources', @@ -155,7 +155,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', @@ -179,7 +179,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_resources', @@ -198,7 +198,7 @@ class TestListResources(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', @@ -224,7 +224,7 @@ class TestListResources(FunctionalTest): 'ignored_dict': {'key': 'value'}, 'ignored_list': ['not-returned'], } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test', diff --git a/tests/api/v2/test_list_users.py b/tests/api/v2/test_list_users.py index 96d988102..8a27dafaa 100644 --- a/tests/api/v2/test_list_users.py +++ b/tests/api/v2/test_list_users.py @@ -50,9 +50,8 @@ class TestListUsers(FunctionalTest): 'resource-id', timestamp=datetime.datetime(2012, 7, 2, 10, 40), resource_metadata={'display_name': 'test-server', - 'tag': 'self.counter', - } - ) + 'tag': 'self.counter'} + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_users', @@ -71,7 +70,7 @@ class TestListUsers(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'test_list_users', @@ -94,7 +93,7 @@ class TestListUsers(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) msg = meter.meter_message_from_counter(counter1, cfg.CONF.metering_secret, 'test_list_users', @@ -113,7 +112,7 @@ class TestListUsers(FunctionalTest): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) msg2 = meter.meter_message_from_counter(counter2, cfg.CONF.metering_secret, 'not-test', diff --git a/tests/api/v2/test_max_project_volume.py b/tests/api/v2/test_max_project_volume.py index 1d48bd910..e0adc4f58 100644 --- a/tests/api/v2/test_max_project_volume.py +++ b/tests/api/v2/test_max_project_volume.py @@ -51,7 +51,7 @@ class TestMaxProjectVolume(FunctionalTest): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v2/test_max_resource_volume.py b/tests/api/v2/test_max_resource_volume.py index 6c1827a62..b002fc69b 100644 --- a/tests/api/v2/test_max_resource_volume.py +++ b/tests/api/v2/test_max_resource_volume.py @@ -50,7 +50,7 @@ class TestMaxResourceVolume(FunctionalTest): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v2/test_sum_project_volume.py b/tests/api/v2/test_sum_project_volume.py index afac21a54..ea7ec3b30 100644 --- a/tests/api/v2/test_sum_project_volume.py +++ b/tests/api/v2/test_sum_project_volume.py @@ -50,7 +50,7 @@ class TestSumProjectVolume(FunctionalTest): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/api/v2/test_sum_resource_volume.py b/tests/api/v2/test_sum_resource_volume.py index 4fb690e7e..6b624cb42 100644 --- a/tests/api/v2/test_sum_resource_volume.py +++ b/tests/api/v2/test_sum_resource_volume.py @@ -50,7 +50,7 @@ class TestSumResourceVolume(FunctionalTest): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/collector/test_manager.py b/tests/collector/test_manager.py index 65a0c6642..3fab2c289 100644 --- a/tests/collector/test_manager.py +++ b/tests/collector/test_manager.py @@ -80,7 +80,7 @@ TEST_NOTICE = { u'priority': u'INFO', u'publisher_id': u'compute.vagrant-precise', u'timestamp': u'2012-05-08 20:23:48.028195', - } +} class TestCollectorService(tests_base.TestCase): @@ -107,7 +107,7 @@ class TestCollectorService(tests_base.TestCase): msg['message_signature'] = meter.compute_signature( msg, cfg.CONF.metering_secret, - ) + ) self.srv.storage_conn = self.mox.CreateMock(base.Connection) self.srv.storage_conn.record_metering_data(msg) @@ -146,7 +146,7 @@ class TestCollectorService(tests_base.TestCase): msg['message_signature'] = meter.compute_signature( msg, cfg.CONF.metering_secret, - ) + ) expected = {} expected.update(msg) @@ -168,7 +168,7 @@ class TestCollectorService(tests_base.TestCase): msg['message_signature'] = meter.compute_signature( msg, cfg.CONF.metering_secret, - ) + ) expected = {} expected.update(msg) diff --git a/tests/collector/test_meter.py b/tests/collector/test_meter.py index f9c40c571..2831e5f4e 100644 --- a/tests/collector/test_meter.py +++ b/tests/collector/test_meter.py @@ -145,7 +145,7 @@ TEST_NOTICE = { u'priority': u'INFO', u'publisher_id': u'compute.vagrant-precise', u'timestamp': u'2012-05-08 20:23:48.028195', - } +} def test_meter_message_from_counter_signed(): diff --git a/tests/compute/test_instance.py b/tests/compute/test_instance.py index e0e598985..d8e4b8027 100644 --- a/tests/compute/test_instance.py +++ b/tests/compute/test_instance.py @@ -50,25 +50,24 @@ class TestLocationMetadata(unittest.TestCase): # Mimics an instance returned from nova api call self.INSTANCE_PROPERTIES = {'name': 'display name', - 'OS-EXT-SRV-ATTR:instance_name': 'instance-000001', - 'reservation_id': 'reservation id', - 'architecture': 'x86_64', - 'availability_zone': 'zone1', - 'kernel_id': 'kernel id', - 'os_type': 'linux', - 'ramdisk_id': 'ramdisk id', - 'disk_gb': 10, - 'ephemeral_gb': 7, - 'memory_mb': 2048, - 'root_gb': 3, - 'vcpus': 1, - 'image': {'id': 1, - 'links': [{"rel": "bookmark", - 'href': 2}], - }, - 'flavor': {'id': 1}, - 'hostId': '1234-5678', - } + 'OS-EXT-SRV-ATTR:instance_name': + 'instance-000001', + 'reservation_id': 'reservation id', + 'architecture': 'x86_64', + 'availability_zone': 'zone1', + 'kernel_id': 'kernel id', + 'os_type': 'linux', + 'ramdisk_id': 'ramdisk id', + 'disk_gb': 10, + 'ephemeral_gb': 7, + 'memory_mb': 2048, + 'root_gb': 3, + 'vcpus': 1, + 'image': {'id': 1, + 'links': [{"rel": "bookmark", + 'href': 2}]}, + 'flavor': {'id': 1}, + 'hostId': '1234-5678'} self.instance = FauxInstance(**self.INSTANCE_PROPERTIES) self.instance.host = 'made-up-hostname' @@ -101,5 +100,5 @@ class TestLocationMetadata(unittest.TestCase): self.INSTANCE_PROPERTIES['image'] = '' self.instance = FauxInstance(**self.INSTANCE_PROPERTIES) md = instance.get_metadata_from_object(self.instance) - assert md['image_ref'] == None - assert md['image_ref_url'] == None + self.assertEqual(md['image_ref'], None) + self.assertEqual(md['image_ref_url'], None) diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 05a5848d5..7b07084f8 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -51,9 +51,8 @@ class TestRunTasks(base.TestCase): project_id='test', resource_id='test_run_tasks', timestamp=datetime.datetime.utcnow().isoformat(), - resource_metadata={'name': 'Pollster', - }, - ) + resource_metadata={'name': 'Pollster'}, + ) def get_counters(self, manager, instance): self.counters.append((manager, instance)) @@ -98,5 +97,4 @@ class TestRunTasks(base.TestCase): assert list(actual[0]) == [self.Pollster.test_data, cfg.CONF.metering_topic, cfg.CONF.metering_secret, - cfg.CONF.counter_source, - ] + cfg.CONF.counter_source] diff --git a/tests/compute/test_notifications.py b/tests/compute/test_notifications.py index 692bf452a..0254e517b 100644 --- a/tests/compute/test_notifications.py +++ b/tests/compute/test_notifications.py @@ -71,7 +71,7 @@ INSTANCE_CREATE_END = { u'priority': u'INFO', u'publisher_id': u'compute.vagrant-precise', u'timestamp': u'2012-05-08 20:23:48.028195', - } +} INSTANCE_DELETE_START = { u'_context_auth_token': u'3d8b13de1b7d499587dfc69b77dc09c2', @@ -115,7 +115,7 @@ INSTANCE_DELETE_START = { u'priority': u'INFO', u'publisher_id': u'compute.vagrant-precise', u'timestamp': u'2012-05-08 20:24:14.824743', - } +} INSTANCE_EXISTS = { u'_context_auth_token': None, @@ -162,7 +162,7 @@ INSTANCE_EXISTS = { u'priority': u'INFO', u'publisher_id': u'compute.vagrant-precise', u'timestamp': u'2012-05-08 16:03:44.122481', - } +} INSTANCE_FINISH_RESIZE_END = { u'_context_roles': [u'admin'], @@ -208,7 +208,7 @@ INSTANCE_FINISH_RESIZE_END = { u'host': u'ip-10-147-132-184.ec2.internal', u'display_name': u's1', u'image_ref_url': u'http://10.147.132.184:9292/images/' - 'a130b9d9-e00e-436e-9782-836ccef06e8a', + 'a130b9d9-e00e-436e-9782-836ccef06e8a', u'root_gb': 20, u'tenant_id': u'cea4b25edb484e5392727181b7721d29', u'created_at': u'2013-01-04T11:21:48.000000', @@ -216,17 +216,16 @@ INSTANCE_FINISH_RESIZE_END = { u'instance_type': u'm1.small', u'vcpus': 1, u'image_meta': {u'kernel_id': - u'571478e0-d5e7-4c2e-95a5-2bc79443c28a', + u'571478e0-d5e7-4c2e-95a5-2bc79443c28a', u'ramdisk_id': - u'5f23128e-5525-46d8-bc66-9c30cd87141a', + u'5f23128e-5525-46d8-bc66-9c30cd87141a', u'base_image_ref': - u'a130b9d9-e00e-436e-9782-836ccef06e8a' - }, + u'a130b9d9-e00e-436e-9782-836ccef06e8a'}, u'architecture': None, u'os_type': None }, u'priority': u'INFO' - } +} INSTANCE_RESIZE_REVERT_END = { u'_context_roles': [u'admin'], @@ -266,7 +265,7 @@ INSTANCE_RESIZE_REVERT_END = { u'host': u'ip-10-147-132-184.ec2.internal', u'display_name': u's1', u'image_ref_url': u'http://10.147.132.184:9292/images/' - 'a130b9d9-e00e-436e-9782-836ccef06e8a', + 'a130b9d9-e00e-436e-9782-836ccef06e8a', u'root_gb': 0, u'tenant_id': u'cea4b25edb484e5392727181b7721d29', u'created_at': u'2013-01-04T11:21:48.000000', @@ -274,23 +273,23 @@ INSTANCE_RESIZE_REVERT_END = { u'instance_type': u'm1.tiny', u'vcpus': 1, u'image_meta': {u'kernel_id': - u'571478e0-d5e7-4c2e-95a5-2bc79443c28a', + u'571478e0-d5e7-4c2e-95a5-2bc79443c28a', u'ramdisk_id': - u'5f23128e-5525-46d8-bc66-9c30cd87141a', + u'5f23128e-5525-46d8-bc66-9c30cd87141a', u'base_image_ref': - u'a130b9d9-e00e-436e-9782-836ccef06e8a' - }, + u'a130b9d9-e00e-436e-9782-836ccef06e8a'}, u'architecture': None, u'os_type': None }, u'priority': u'INFO' - } +} class TestNotifications(unittest.TestCase): def test_process_notification(self): info = notifications.Instance.process_notification( - INSTANCE_CREATE_END)[0] + INSTANCE_CREATE_END + )[0] for name, actual, expected in [ ('counter_name', info.name, 'instance'), @@ -306,7 +305,7 @@ class TestNotifications(unittest.TestCase): INSTANCE_CREATE_END['payload']['instance_type_id']), ('host', info.resource_metadata['host'], INSTANCE_CREATE_END['publisher_id']), - ]: + ]: yield compare, name, actual, expected @staticmethod diff --git a/tests/compute/test_nova_notifier.py b/tests/compute/test_nova_notifier.py index 81e65e879..f1372f7e2 100644 --- a/tests/compute/test_nova_notifier.py +++ b/tests/compute/test_nova_notifier.py @@ -67,7 +67,7 @@ class TestNovaNotifier(base.TestCase): timestamp=datetime.datetime.utcnow().isoformat(), resource_metadata={'name': 'Pollster', }, - ) + ) def get_counters(self, manager, instance): self.counters.append((manager, instance)) @@ -111,7 +111,7 @@ class TestNovaNotifier(base.TestCase): "vcpus": 1, "host": "fakehost", "availability_zone": - "1e3ce043029547f1a61c1996d1a531a4", + "1e3ce043029547f1a61c1996d1a531a4", "created_at": '2012-05-08 20:23:41', "os_type": "linux", "kernel_id": "kernelid", @@ -140,7 +140,7 @@ class TestNovaNotifier(base.TestCase): None, self.Pollster(), ), - ]) + ]) nova_notifier.initialize_manager(agent_manager) def tearDown(self): @@ -157,9 +157,9 @@ class TestNovaNotifier(base.TestCase): # call this method directly, but not safe to mock it # because mock.patch() fails to find the original. self.stubs.Set(db, 'instance_get_by_uuid', - self.fake_db_instance_get) + self.fake_db_instance_get) self.compute.terminate_instance(self.context, - instance=self.instance) + instance=self.instance) else: # Under Grizzly, Nova has moved to no-db access on the # compute node. The compute manager uses RPC to talk to diff --git a/tests/compute/test_pollsters.py b/tests/compute/test_pollsters.py index b28331caa..50a3a037f 100644 --- a/tests/compute/test_pollsters.py +++ b/tests/compute/test_pollsters.py @@ -69,11 +69,11 @@ class TestDiskIOPollster(TestPollsterBase): def test_get_counters(self): disks = [ - (virt_inspector.Disk(device='vda'), - virt_inspector.DiskStats(read_bytes=1L, read_requests=2L, - write_bytes=3L, write_requests=4L, - errors=-1L)) - ] + (virt_inspector.Disk(device='vda'), + virt_inspector.DiskStats(read_bytes=1L, read_requests=2L, + write_bytes=3L, write_requests=4L, + errors=-1L)) + ] self.inspector.inspect_disks(self.instance.name).AndReturn(disks) self.mox.ReplayAll() @@ -100,22 +100,24 @@ class TestNetPollster(TestPollsterBase): super(TestNetPollster, self).setUp() def test_get_counters(self): - vnic0 = virt_inspector.Interface(name='vnet0', - fref='fa163e71ec6e', - mac='fa:16:3e:71:ec:6d', - parameters=dict(ip='10.0.0.2', - projmask='255.255.255.0', - projnet='proj1', - dhcp_server='10.0.0.1')) + vnic0 = virt_inspector.Interface( + name='vnet0', + fref='fa163e71ec6e', + mac='fa:16:3e:71:ec:6d', + parameters=dict(ip='10.0.0.2', + projmask='255.255.255.0', + projnet='proj1', + dhcp_server='10.0.0.1')) stats0 = virt_inspector.InterfaceStats(rx_bytes=1L, rx_packets=2L, tx_bytes=3L, tx_packets=4L) - vnic1 = virt_inspector.Interface(name='vnet1', - fref='fa163e71ec6f', - mac='fa:16:3e:71:ec:6e', - parameters=dict(ip='192.168.0.3', - projmask='255.255.255.0', - projnet='proj2', - dhcp_server='10.0.0.2')) + vnic1 = virt_inspector.Interface( + name='vnet1', + fref='fa163e71ec6f', + mac='fa:16:3e:71:ec:6e', + parameters=dict(ip='192.168.0.3', + projmask='255.255.255.0', + projnet='proj2', + dhcp_server='10.0.0.2')) stats1 = virt_inspector.InterfaceStats(rx_bytes=5L, rx_packets=6L, tx_bytes=7L, tx_packets=8L) vnics = [(vnic0, stats0), (vnic1, stats1)] diff --git a/tests/compute/virt/libvirt/test_inspector.py b/tests/compute/virt/libvirt/test_inspector.py index 2b2c94b68..1be2ad026 100644 --- a/tests/compute/virt/libvirt/test_inspector.py +++ b/tests/compute/virt/libvirt/test_inspector.py @@ -37,7 +37,7 @@ class TestLibvirtInspection(test_base.TestCase): self.inspector.connection.getCapabilities() self.domain = self.mox.CreateMockAnything() self.inspector.connection.lookupByName(self.instance_name).AndReturn( - self.domain) + self.domain) def test_inspect_cpus(self): self.domain.info().AndReturn((0L, 0L, 0L, 2L, 999999L)) diff --git a/tests/image/test_glance.py b/tests/image/test_glance.py index 6132244a9..704ac2417 100644 --- a/tests/image/test_glance.py +++ b/tests/image/test_glance.py @@ -110,4 +110,4 @@ class TestImagePollster(base.TestCase): for image in IMAGE_LIST: self.assert_( any(map(lambda counter: counter.volume == image.size, - counters))) + counters))) diff --git a/tests/objectstore/test_swift_middleware.py b/tests/objectstore/test_swift_middleware.py index 7436e4174..ee0510a1a 100644 --- a/tests/objectstore/test_swift_middleware.py +++ b/tests/objectstore/test_swift_middleware.py @@ -30,8 +30,10 @@ class FakeApp(object): self.body = body def __call__(self, env, start_response): - start_response('200 OK', [('Content-Type', 'text/plain'), - ('Content-Length', str(sum(map(len, self.body))))]) + start_response('200 OK', [ + ('Content-Type', 'text/plain'), + ('Content-Length', str(sum(map(len, self.body)))) + ]) while env['wsgi.input'].read(5): pass return self.body diff --git a/tests/storage/test_impl_mongodb.py b/tests/storage/test_impl_mongodb.py index 71967fb97..37ae93723 100644 --- a/tests/storage/test_impl_mongodb.py +++ b/tests/storage/test_impl_mongodb.py @@ -82,7 +82,7 @@ class MongoDBEngineTestBase(unittest.TestCase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) self.msg = meter.meter_message_from_counter(self.counter, 'not-so-secret', 'test-1') @@ -100,7 +100,7 @@ class MongoDBEngineTestBase(unittest.TestCase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) self.msg2 = meter.meter_message_from_counter(self.counter2, 'not-so-secret', 'test-2') @@ -118,7 +118,7 @@ class MongoDBEngineTestBase(unittest.TestCase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter3', } - ) + ) self.msg3 = meter.meter_message_from_counter(self.counter3, 'not-so-secret', 'test-3') @@ -137,7 +137,7 @@ class MongoDBEngineTestBase(unittest.TestCase): resource_metadata={'display_name': 'test-server', 'tag': 'counter-%s' % i, } - ) + ) msg = meter.meter_message_from_counter(c, 'not-so-secret', 'test') self.conn.record_metering_data(msg) @@ -264,8 +264,7 @@ class ResourceTest(MongoDBEngineTestBase): start_ts = datetime.datetime(2012, 7, 2, 10, 42) end_ts = datetime.datetime(2012, 7, 2, 10, 43) resources = list(self.conn.get_resources(start_timestamp=start_ts, - end_timestamp=end_ts) - ) + end_timestamp=end_ts)) resource_ids = [r['resource_id'] for r in resources] expected = set(['resource-id-2']) assert set(resource_ids) == expected @@ -334,7 +333,7 @@ class MeterTest(MongoDBEngineTestBase): f = storage.EventFilter( user='user-id', start=datetime.datetime(2012, 7, 2, 10, 41), - ) + ) results = list(self.conn.get_raw_events(f)) length = len(results) assert length == 1 @@ -344,7 +343,7 @@ class MeterTest(MongoDBEngineTestBase): f = storage.EventFilter( user='user-id', end=datetime.datetime(2012, 7, 2, 10, 41), - ) + ) results = list(self.conn.get_raw_events(f)) length = len(results) assert length == 1 @@ -354,7 +353,7 @@ class MeterTest(MongoDBEngineTestBase): f = storage.EventFilter( start=datetime.datetime(2012, 7, 2, 10, 42), end=datetime.datetime(2012, 7, 2, 10, 43), - ) + ) results = list(self.conn.get_raw_events(f)) length = len(results) assert length == 1 @@ -364,7 +363,7 @@ class MeterTest(MongoDBEngineTestBase): f = storage.EventFilter( user='user-id', meter='no-such-meter', - ) + ) results = list(self.conn.get_raw_events(f)) assert not results @@ -372,7 +371,7 @@ class MeterTest(MongoDBEngineTestBase): f = storage.EventFilter( user='user-id', meter='instance', - ) + ) results = list(self.conn.get_raw_events(f)) assert results @@ -393,7 +392,7 @@ class SumTest(MongoDBEngineTestBase): f = storage.EventFilter( user='user-id', meter='instance', - ) + ) results = list(self.conn.get_volume_sum(f)) assert results counts = dict((r['resource_id'], r['value']) @@ -407,7 +406,7 @@ class SumTest(MongoDBEngineTestBase): f = storage.EventFilter( project='project-id', meter='instance', - ) + ) results = list(self.conn.get_volume_sum(f)) assert results counts = dict((r['resource_id'], r['value']) @@ -422,7 +421,7 @@ class SumTest(MongoDBEngineTestBase): user='user-id', meter='instance', resource='resource-id', - ) + ) results = list(self.conn.get_volume_sum(f)) assert results counts = dict((r['resource_id'], r['value']) @@ -457,7 +456,7 @@ class TestGetEventInterval(MongoDBEngineTestBase): meter='instance', start=self.start, end=self.end, - ) + ) def _make_events(self, *timestamps): for t in timestamps: @@ -472,7 +471,7 @@ class TestGetEventInterval(MongoDBEngineTestBase): timestamp=t, resource_metadata={'display_name': 'test-server', } - ) + ) msg = meter.meter_message_from_counter(counter=c, secret='not-so-secret', source='test', diff --git a/tests/storage/test_impl_sqlalchemy.py b/tests/storage/test_impl_sqlalchemy.py index 36d881be8..e4cbdd5ef 100644 --- a/tests/storage/test_impl_sqlalchemy.py +++ b/tests/storage/test_impl_sqlalchemy.py @@ -106,7 +106,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter', } - ) + ) self.msg1 = meter.meter_message_from_counter(self.counter, cfg.CONF.metering_secret, 'test-1', @@ -125,7 +125,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter2', } - ) + ) self.msg2 = meter.meter_message_from_counter(self.counter2, cfg.CONF.metering_secret, 'test-2', @@ -144,7 +144,7 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): resource_metadata={'display_name': 'test-server', 'tag': 'self.counter3', } - ) + ) self.msg3 = meter.meter_message_from_counter(self.counter3, cfg.CONF.metering_secret, 'test-3', @@ -162,9 +162,8 @@ class SQLAlchemyEngineTestBase(SQLAlchemyEngineSubBase): 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, - } - ) + 'tag': 'counter-%s' % i}, + ) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, 'test') self.conn.record_metering_data(msg) @@ -230,8 +229,8 @@ class ResourceTest(SQLAlchemyEngineTestBase): def test_new_resource_meter(self): resource = self.session.query(Resource).filter_by(id='resource-id').\ - filter(Meter.counter_name == 'instance').\ - filter(Meter.counter_type == 'cumulative').first() + filter(Meter.counter_name == 'instance').\ + filter(Meter.counter_type == 'cumulative').first() assert len(set(resource.meters)) == 1 foo = map(lambda x: [x.counter_name, x.counter_type], resource.meters) assert ['instance', 'cumulative'] in foo @@ -278,8 +277,7 @@ class ResourceTest(SQLAlchemyEngineTestBase): start_ts = datetime.datetime(2012, 7, 2, 10, 42) end_ts = datetime.datetime(2012, 7, 2, 10, 43) resources = list(self.conn.get_resources(start_timestamp=start_ts, - end_timestamp=end_ts) - ) + end_timestamp=end_ts)) resource_ids = [r['resource_id'] for r in resources] assert set(resource_ids) == set(['resource-id-2']) @@ -396,7 +394,7 @@ class MeterTest(SQLAlchemyEngineTestBase): f = storage.EventFilter( user='user-id', start=datetime.datetime(2012, 7, 2, 10, 41), - ) + ) results = list(self.conn.get_raw_events(f)) assert len(results) == 1 assert results[0]['timestamp'] == datetime.datetime(2012, 7, 2, 10, 41) @@ -405,7 +403,7 @@ class MeterTest(SQLAlchemyEngineTestBase): f = storage.EventFilter( user='user-id', end=datetime.datetime(2012, 7, 2, 10, 41), - ) + ) results = list(self.conn.get_raw_events(f)) length = len(results) assert length == 1 @@ -415,7 +413,7 @@ class MeterTest(SQLAlchemyEngineTestBase): f = storage.EventFilter( start=datetime.datetime(2012, 7, 2, 10, 42), end=datetime.datetime(2012, 7, 2, 10, 43), - ) + ) results = list(self.conn.get_raw_events(f)) length = len(results) assert length == 1 @@ -463,7 +461,7 @@ class TestGetEventInterval(SQLAlchemyEngineTestBase): meter='instance', start=self.start, end=self.end, - ) + ) def _make_events(self, *timestamps): for t in timestamps: @@ -478,7 +476,7 @@ class TestGetEventInterval(SQLAlchemyEngineTestBase): timestamp=t, resource_metadata={'display_name': 'test-server', } - ) + ) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, 'test') self.conn.record_metering_data(msg) @@ -542,7 +540,7 @@ class SumTest(SQLAlchemyEngineTestBase): f = storage.EventFilter( user='user-id', meter='instance', - ) + ) results = list(self.conn.get_volume_sum(f)) counts = dict((r['resource_id'], r['value']) for r in results) @@ -555,7 +553,7 @@ class SumTest(SQLAlchemyEngineTestBase): f = storage.EventFilter( project='project-id', meter='instance', - ) + ) results = list(self.conn.get_volume_sum(f)) assert results counts = dict((r['resource_id'], r['value']) @@ -570,7 +568,7 @@ class SumTest(SQLAlchemyEngineTestBase): user='user-id', meter='instance', resource='resource-id', - ) + ) results = list(self.conn.get_volume_sum(f)) assert results counts = dict((r['resource_id'], r['value']) @@ -598,7 +596,7 @@ class MaxProjectTest(SQLAlchemyEngineSubBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, @@ -677,7 +675,7 @@ class MaxResourceTest(SQLAlchemyEngineSubBase): resource_metadata={'display_name': 'test-volume', 'tag': 'self.counter', } - ) + ) self.counters.append(c) msg = meter.meter_message_from_counter(c, cfg.CONF.metering_secret, diff --git a/tests/test_publish.py b/tests/test_publish.py index a72196b65..8de261315 100644 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -38,9 +38,8 @@ class TestPublish(base.TestCase): project_id='test', resource_id='test_run_tasks', timestamp=datetime.datetime.utcnow().isoformat(), - resource_metadata={'name': 'TestPublish', - }, - ) + resource_metadata={'name': 'TestPublish'}, + ) def faux_notify(self, context, topic, msg): self.notifications.append((topic, msg)) diff --git a/tools/test-requires b/tools/test-requires index cb596c03b..dbdff0057 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,6 +1,5 @@ nose coverage -pep8>=1.0 mock mox Babel>=0.9.6 diff --git a/tools/test-requires-folsom b/tools/test-requires-folsom index 55ec57825..e698c1881 100644 --- a/tools/test-requires-folsom +++ b/tools/test-requires-folsom @@ -1,7 +1,6 @@ http://tarballs.openstack.org/nova/nova-stable-folsom.tar.gz nose coverage -pep8>=1.0 mock mox # NOTE(dhellmann): Ming is necessary to provide the Mongo-in-memory diff --git a/tox.ini b/tox.ini index 34a7d81fb..571b83f87 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ setenv=CEILOMETER_TEST_LIVE=1 commands = {toxinidir}/run_tests.sh --no-path-adjustment --with-coverage --cover-erase --cover-package=ceilometer --cover-inclusive [] [testenv:pep8] -deps = pep8==1.1 +deps = pep8==1.3.3 commands = pep8 --repeat --show-source ceilometer setup.py bin/ceilometer-agent-central bin/ceilometer-agent-compute bin/ceilometer-collector bin/ceilometer-api tests [testenv:venv]