From ade948dd77139390dc03f62564b0050df3ef54f3 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Fri, 10 Feb 2012 16:51:54 +0800 Subject: [PATCH] Backslash continuations (nova.api.openstack) Fixes bug #925286 Backslash continuations removal for package nova.api.openstack Change-Id: I204b6d53bea224859e23771d5f4c96c1aff6fd03 --- nova/api/openstack/__init__.py | 2 +- nova/api/openstack/auth.py | 14 +++++++++----- nova/api/openstack/compute/__init__.py | 7 +++---- .../openstack/compute/contrib/certificates.py | 4 ++-- .../openstack/compute/contrib/console_output.py | 4 ++-- .../openstack/compute/contrib/createserverext.py | 4 ++-- .../openstack/compute/contrib/deferred_delete.py | 4 ++-- .../openstack/compute/contrib/extended_status.py | 4 ++-- .../openstack/compute/contrib/flavorextradata.py | 4 ++-- .../compute/contrib/flavorextraspecs.py | 4 ++-- .../compute/contrib/floating_ip_pools.py | 4 ++-- .../openstack/compute/contrib/scheduler_hints.py | 4 ++-- .../compute/contrib/server_action_list.py | 4 ++-- .../compute/contrib/server_diagnostics.py | 4 ++-- .../compute/contrib/simple_tenant_usage.py | 12 ++++++------ .../compute/contrib/virtual_interfaces.py | 4 ++-- .../compute/contrib/virtual_storage_arrays.py | 16 ++++++++-------- nova/api/openstack/compute/images.py | 4 ++-- nova/api/openstack/compute/limits.py | 5 +++-- nova/api/openstack/compute/servers.py | 12 ++++++------ nova/api/openstack/compute/views/limits.py | 8 ++++---- nova/api/openstack/wsgi.py | 4 ++-- 22 files changed, 68 insertions(+), 64 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 31e6f48fa5b6..82e958a5972d 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -68,7 +68,7 @@ class ProjectMapper(APIMapper): p_collection = parent_resource['collection_name'] p_member = parent_resource['member_name'] kwargs['path_prefix'] = '{project_id}/%s/:%s_id' % (p_collection, - p_member) + p_member) routes.Mapper.resource(self, member_name, collection_name, **kwargs) diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index c404c72af7b0..c59d2a315fd3 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -173,15 +173,19 @@ class AuthMiddleware(base_wsgi.Middleware): if user and token: res = webob.Response() res.headers['X-Auth-Token'] = token['token_hash'] - res.headers['X-Server-Management-Url'] = \ - token['server_management_url'] + _x_server_url = 'X-Server-Management-Url' + _server_url = 'server_management_url' + res.headers[_x_server_url] = token[_server_url] if token['storage_url']: - res.headers['X-Storage-Url'] = token['storage_url'] + _x_storage_url = 'X-Storage-Url' + _storage_url = 'storage_url' + res.headers[_x_storage_url] = token[_storage_url] if token['cdn_management_url']: - res.headers['X-CDN-Management-Url'] = \ - token['cdn_management_url'] + _x_cdn_url = 'X-CDN-Management-Url' + _cdn_url = 'cdn_management_url' + res.headers[_x_cdn_url] = token[_cdn_url] res.content_type = 'text/plain' res.status = '204' diff --git a/nova/api/openstack/compute/__init__.py b/nova/api/openstack/compute/__init__.py index 2c6a3ce39820..9e9bb9003a54 100644 --- a/nova/api/openstack/compute/__init__.py +++ b/nova/api/openstack/compute/__init__.py @@ -38,10 +38,9 @@ from nova.openstack.common import cfg LOG = logging.getLogger(__name__) -allow_instance_snapshots_opt = \ - cfg.BoolOpt('allow_instance_snapshots', - default=True, - help='Permit instance snapshot operations.') +allow_instance_snapshots_opt = cfg.BoolOpt('allow_instance_snapshots', + default=True, + help='Permit instance snapshot operations.') FLAGS = flags.FLAGS FLAGS.register_opt(allow_instance_snapshots_opt) diff --git a/nova/api/openstack/compute/contrib/certificates.py b/nova/api/openstack/compute/contrib/certificates.py index 11e1480a27ab..41843e32ee35 100644 --- a/nova/api/openstack/compute/contrib/certificates.py +++ b/nova/api/openstack/compute/contrib/certificates.py @@ -97,8 +97,8 @@ class Certificates(extensions.ExtensionDescriptor): name = "Certificates" alias = "os-certificates" - namespace = \ - "http://docs.openstack.org/compute/ext/certificates/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "certificates/api/v1.1") updated = "2012-01-19T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/console_output.py b/nova/api/openstack/compute/contrib/console_output.py index 6fc7fcbf014a..1eb86a092f90 100644 --- a/nova/api/openstack/compute/contrib/console_output.py +++ b/nova/api/openstack/compute/contrib/console_output.py @@ -65,8 +65,8 @@ class Console_output(extensions.ExtensionDescriptor): name = "Console_output" alias = "os-console-output" - namespace = "http://docs.openstack.org/compute/ext/" \ - "os-console-output/api/v2" + namespace = ("http://docs.openstack.org/compute/ext/" + "os-console-output/api/v2") updated = "2011-12-08T00:00:00+00:00" def get_controller_extensions(self): diff --git a/nova/api/openstack/compute/contrib/createserverext.py b/nova/api/openstack/compute/contrib/createserverext.py index de4ba8dd09b0..c5e26a349078 100644 --- a/nova/api/openstack/compute/contrib/createserverext.py +++ b/nova/api/openstack/compute/contrib/createserverext.py @@ -49,8 +49,8 @@ class Createserverext(extensions.ExtensionDescriptor): name = "Createserverext" alias = "os-create-server-ext" - namespace = "http://docs.openstack.org/compute/ext/" \ - "createserverext/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "createserverext/api/v1.1") updated = "2011-07-19T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/deferred_delete.py b/nova/api/openstack/compute/contrib/deferred_delete.py index 7752871dea5b..16c305973c2d 100644 --- a/nova/api/openstack/compute/contrib/deferred_delete.py +++ b/nova/api/openstack/compute/contrib/deferred_delete.py @@ -66,8 +66,8 @@ class Deferred_delete(extensions.ExtensionDescriptor): name = "DeferredDelete" alias = "os-deferred-delete" - namespace = "http://docs.openstack.org/compute/ext/" \ - "deferred-delete/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "deferred-delete/api/v1.1") updated = "2011-09-01T00:00:00+00:00" def get_controller_extensions(self): diff --git a/nova/api/openstack/compute/contrib/extended_status.py b/nova/api/openstack/compute/contrib/extended_status.py index 88a5f12a4ef1..de532adad6a1 100644 --- a/nova/api/openstack/compute/contrib/extended_status.py +++ b/nova/api/openstack/compute/contrib/extended_status.py @@ -89,8 +89,8 @@ class Extended_status(extensions.ExtensionDescriptor): name = "ExtendedStatus" alias = "OS-EXT-STS" - namespace = "http://docs.openstack.org/compute/ext/" \ - "extended_status/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "extended_status/api/v1.1") updated = "2011-11-03T00:00:00+00:00" def get_controller_extensions(self): diff --git a/nova/api/openstack/compute/contrib/flavorextradata.py b/nova/api/openstack/compute/contrib/flavorextradata.py index 5c86bef90018..c4676c61819b 100644 --- a/nova/api/openstack/compute/contrib/flavorextradata.py +++ b/nova/api/openstack/compute/contrib/flavorextradata.py @@ -98,8 +98,8 @@ class Flavorextradata(extensions.ExtensionDescriptor): name = "FlavorExtraData" alias = "OS-FLV-EXT-DATA" - namespace = "http://docs.openstack.org/compute/ext/" \ - "flavor_extra_data/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "flavor_extra_data/api/v1.1") updated = "2011-09-14T00:00:00+00:00" def get_controller_extensions(self): diff --git a/nova/api/openstack/compute/contrib/flavorextraspecs.py b/nova/api/openstack/compute/contrib/flavorextraspecs.py index faf023659f7d..1712e30b9277 100644 --- a/nova/api/openstack/compute/contrib/flavorextraspecs.py +++ b/nova/api/openstack/compute/contrib/flavorextraspecs.py @@ -119,8 +119,8 @@ class Flavorextraspecs(extensions.ExtensionDescriptor): name = "FlavorExtraSpecs" alias = "os-flavor-extra-specs" - namespace = "http://docs.openstack.org/compute/ext/" \ - "flavor_extra_specs/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "flavor_extra_specs/api/v1.1") updated = "2011-06-23T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/floating_ip_pools.py b/nova/api/openstack/compute/contrib/floating_ip_pools.py index 39348db6eb14..9080f086ee30 100644 --- a/nova/api/openstack/compute/contrib/floating_ip_pools.py +++ b/nova/api/openstack/compute/contrib/floating_ip_pools.py @@ -80,8 +80,8 @@ class Floating_ip_pools(extensions.ExtensionDescriptor): name = "Floating_ip_pools" alias = "os-floating-ip-pools" - namespace = \ - "http://docs.openstack.org/compute/ext/floating_ip_pools/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "floating_ip_pools/api/v1.1") updated = "2012-01-04T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/scheduler_hints.py b/nova/api/openstack/compute/contrib/scheduler_hints.py index d5c9a25de0ab..9e0b3ea3a0c5 100644 --- a/nova/api/openstack/compute/contrib/scheduler_hints.py +++ b/nova/api/openstack/compute/contrib/scheduler_hints.py @@ -55,8 +55,8 @@ class Scheduler_hints(extensions.ExtensionDescriptor): name = "SchedulerHints" alias = "os-scheduler-hints" - namespace = "http://docs.openstack.org/compute/ext/" \ - "scheduler-hints/api/v2" + namespace = ("http://docs.openstack.org/compute/ext/" + "scheduler-hints/api/v2") updated = "2011-07-19T00:00:00+00:00" def get_controller_extensions(self): diff --git a/nova/api/openstack/compute/contrib/server_action_list.py b/nova/api/openstack/compute/contrib/server_action_list.py index 24d3595d472b..55c167442df4 100644 --- a/nova/api/openstack/compute/contrib/server_action_list.py +++ b/nova/api/openstack/compute/contrib/server_action_list.py @@ -65,8 +65,8 @@ class Server_action_list(extensions.ExtensionDescriptor): name = "ServerActionList" alias = "os-server-action-list" - namespace = "http://docs.openstack.org/compute/ext/" \ - "server-actions-list/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "server-actions-list/api/v1.1") updated = "2011-12-21T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/server_diagnostics.py b/nova/api/openstack/compute/contrib/server_diagnostics.py index c03cd2d47000..eddb7429deac 100644 --- a/nova/api/openstack/compute/contrib/server_diagnostics.py +++ b/nova/api/openstack/compute/contrib/server_diagnostics.py @@ -54,8 +54,8 @@ class Server_diagnostics(extensions.ExtensionDescriptor): name = "ServerDiagnostics" alias = "os-server-diagnostics" - namespace = "http://docs.openstack.org/compute/ext/" \ - "server-diagnostics/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "server-diagnostics/api/v1.1") updated = "2011-12-21T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/simple_tenant_usage.py b/nova/api/openstack/compute/contrib/simple_tenant_usage.py index eb32e9f08bb0..fd1a95949b58 100644 --- a/nova/api/openstack/compute/contrib/simple_tenant_usage.py +++ b/nova/api/openstack/compute/contrib/simple_tenant_usage.py @@ -97,8 +97,8 @@ class SimpleTenantUsageController(object): # instance is still running, so charge them up to current time stop = period_stop dt = stop - start - seconds = dt.days * 3600 * 24 + dt.seconds\ - + dt.microseconds / 100000.0 + seconds = (dt.days * 3600 * 24 + dt.seconds + + dt.microseconds / 100000.0) return seconds / 3600.0 else: @@ -178,8 +178,8 @@ class SimpleTenantUsageController(object): summary = rval[info['tenant_id']] summary['total_local_gb_usage'] += info['local_gb'] * info['hours'] summary['total_vcpus_usage'] += info['vcpus'] * info['hours'] - summary['total_memory_mb_usage'] += info['memory_mb']\ - * info['hours'] + summary['total_memory_mb_usage'] += (info['memory_mb'] * + info['hours']) summary['total_hours'] += info['hours'] if detailed: @@ -249,8 +249,8 @@ class Simple_tenant_usage(extensions.ExtensionDescriptor): name = "SimpleTenantUsage" alias = "os-simple-tenant-usage" - namespace = "http://docs.openstack.org/compute/ext/" \ - "os-simple-tenant-usage/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "os-simple-tenant-usage/api/v1.1") updated = "2011-08-19T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/virtual_interfaces.py b/nova/api/openstack/compute/contrib/virtual_interfaces.py index eee90ca7d153..87754499a312 100644 --- a/nova/api/openstack/compute/contrib/virtual_interfaces.py +++ b/nova/api/openstack/compute/contrib/virtual_interfaces.py @@ -81,8 +81,8 @@ class Virtual_interfaces(extensions.ExtensionDescriptor): name = "VirtualInterfaces" alias = "virtual_interfaces" - namespace = "http://docs.openstack.org/compute/ext/" \ - "virtual_interfaces/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "virtual_interfaces/api/v1.1") updated = "2011-08-17T00:00:00+00:00" def get_resources(self): diff --git a/nova/api/openstack/compute/contrib/virtual_storage_arrays.py b/nova/api/openstack/compute/contrib/virtual_storage_arrays.py index 34e181cc792a..ff275f911493 100644 --- a/nova/api/openstack/compute/contrib/virtual_storage_arrays.py +++ b/nova/api/openstack/compute/contrib/virtual_storage_arrays.py @@ -182,13 +182,13 @@ class VsaController(object): LOG.audit(_("Create VSA %(display_name)s of type %(vc_type)s"), locals(), context=context) + _vsa_placement = vsa.get('placement', {}) args = dict(display_name=display_name, - display_description=vsa.get('displayDescription'), - instance_type=instance_type, - storage=vsa.get('storage'), - shared=vsa.get('shared'), - availability_zone=vsa.get('placement', {}).\ - get('AvailabilityZone')) + display_description=vsa.get('displayDescription'), + instance_type=instance_type, + storage=vsa.get('storage'), + shared=vsa.get('shared'), + availability_zone=_vsa_placement.get('AvailabilityZone')) vsa = self.vsa_api.create(context, **args) @@ -294,7 +294,7 @@ class VsaVolumeDriveController(volumes.VolumeController): own_vsa_id = self.volume_api.get_volume_metadata_value(volume_ref, self.direction) if own_vsa_id != vsa_id: - LOG.error(_("%(obj)s with ID %(id)s belongs to VSA %(own_vsa_id)s"\ + LOG.error(_("%(obj)s with ID %(id)s belongs to VSA %(own_vsa_id)s" " and not to VSA %(vsa_id)s."), locals()) raise exception.Invalid() @@ -307,7 +307,7 @@ class VsaVolumeDriveController(volumes.VolumeController): search_opts={'metadata': {self.direction: str(vsa_id)}}) limited_list = common.limited(vols, req) - res = [self._translation(context, vol, vsa_id, details) \ + res = [self._translation(context, vol, vsa_id, details) for vol in limited_list] return {self.objects: res} diff --git a/nova/api/openstack/compute/images.py b/nova/api/openstack/compute/images.py index 51d833e1fbc6..296aacb4bfe8 100644 --- a/nova/api/openstack/compute/images.py +++ b/nova/api/openstack/compute/images.py @@ -101,8 +101,8 @@ class Controller(wsgi.Controller): """ super(Controller, self).__init__(**kwargs) - self._image_service = image_service or \ - nova.image.get_default_image_service() + self._image_service = (image_service or + nova.image.get_default_image_service()) def _get_filters(self, req): """ diff --git a/nova/api/openstack/compute/limits.py b/nova/api/openstack/compute/limits.py index cc78b3006444..a20b75bc9ac3 100644 --- a/nova/api/openstack/compute/limits.py +++ b/nova/api/openstack/compute/limits.py @@ -137,8 +137,9 @@ class Limit(object): self.water_level = 0 self.capacity = self.unit self.request_value = float(self.capacity) / float(self.value) - self.error_message = _("Only %(value)s %(verb)s request(s) can be "\ - "made to %(uri)s every %(unit_string)s." % self.__dict__) + self.error_message = _("Only %(value)s %(verb)s request(s) can be " + "made to %(uri)s every %(unit_string)s." % + self.__dict__) def __call__(self, verb, url): """ diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 26ed42f202ee..7a0141a01261 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -558,8 +558,8 @@ class Controller(wsgi.Controller): # at the boot time for id, ip in networks: if id == network_uuid: - expl = _("Duplicate networks (%s) are not allowed")\ - % network_uuid + expl = (_("Duplicate networks (%s) are not allowed") % + network_uuid) raise exc.HTTPBadRequest(explanation=expl) networks.append((network_uuid, address)) @@ -705,8 +705,8 @@ class Controller(wsgi.Controller): scheduler_hints = server_dict.get('scheduler_hints', {}) try: - inst_type = \ - instance_types.get_instance_type_by_flavor_id(flavor_id) + _get_inst_type = instance_types.get_instance_type_by_flavor_id + inst_type = _get_inst_type(flavor_id) (instances, resv_id) = self.compute_api.create(context, inst_type, @@ -747,8 +747,8 @@ class Controller(wsgi.Controller): except exception.SecurityGroupNotFound as error: raise exc.HTTPBadRequest(explanation=unicode(error)) except rpc_common.RemoteError as err: - msg = "%(err_type)s: %(err_msg)s" % \ - {'err_type': err.exc_type, 'err_msg': err.value} + msg = "%(err_type)s: %(err_msg)s" % {'err_type': err.exc_type, + 'err_msg': err.value} raise exc.HTTPBadRequest(explanation=msg) # Let the caller deal with unhandled exceptions. diff --git a/nova/api/openstack/compute/views/limits.py b/nova/api/openstack/compute/views/limits.py index cff6781be8b5..f55f451d4ffb 100644 --- a/nova/api/openstack/compute/views/limits.py +++ b/nova/api/openstack/compute/views/limits.py @@ -66,8 +66,8 @@ class ViewBuilder(object): # check for existing key for limit in limits: - if limit["uri"] == rate_limit["URI"] and \ - limit["regex"] == rate_limit["regex"]: + if (limit["uri"] == rate_limit["URI"] and + limit["regex"] == rate_limit["regex"]): _rate_limit_key = limit break @@ -85,8 +85,8 @@ class ViewBuilder(object): return limits def _build_rate_limit(self, rate_limit): - next_avail = \ - datetime.datetime.utcfromtimestamp(rate_limit["resetTime"]) + _get_utc = datetime.datetime.utcfromtimestamp + next_avail = _get_utc(rate_limit["resetTime"]) return { "verb": rate_limit["verb"], "value": rate_limit["value"], diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index c887701a7727..ad45284c7d03 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -79,8 +79,8 @@ class Request(webob.Request): if not content_type: content_type = self.accept.best_match(SUPPORTED_CONTENT_TYPES) - self.environ['nova.best_content_type'] = content_type or \ - 'application/json' + self.environ['nova.best_content_type'] = (content_type or + 'application/json') return self.environ['nova.best_content_type']