Skip to content

Commit

Permalink
Remove Swift location/password from messages.
Browse files Browse the repository at this point in the history
Updates several exceptions and log messages in the Swift backend
so that they don't include Swift location URI's which may contain
passwords when used in Swift single tenant mode.

Fixes LP Bug #1098962 (for Essex).

Change-Id: I71c0e953cff959890d759ae07574e8b436636279
  • Loading branch information
dprince committed Jan 21, 2013
1 parent efd7e75 commit 37d4d96
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions glance/store/swift.py
Expand Up @@ -109,7 +109,7 @@ def parse_uri(self, uri):
"like so: " "like so: "
"swift+http://user:pass@authurl.com/v1/container/obj" "swift+http://user:pass@authurl.com/v1/container/obj"
) )
logger.error(_("Invalid store uri %(uri)s: %(reason)s") % locals()) logger.error(_("Invalid store URI: %(reason)s") % locals())
raise exception.BadStoreUri() raise exception.BadStoreUri()


pieces = urlparse.urlparse(uri) pieces = urlparse.urlparse(uri)
Expand Down Expand Up @@ -139,8 +139,7 @@ def parse_uri(self, uri):
# the account and user. Combine them into a single username of # the account and user. Combine them into a single username of
# account:user # account:user
if len(cred_parts) == 1: if len(cred_parts) == 1:
reason = (_("Badly formed credentials '%(creds)s' in Swift " reason = (_("Badly formed credentials in Swift URI."))
"URI") % locals())
logger.error(reason) logger.error(reason)
raise exception.BadStoreUri() raise exception.BadStoreUri()
elif len(cred_parts) == 3: elif len(cred_parts) == 3:
Expand All @@ -161,7 +160,7 @@ def parse_uri(self, uri):
path_parts.insert(0, netloc) path_parts.insert(0, netloc)
self.authurl = '/'.join(path_parts) self.authurl = '/'.join(path_parts)
except IndexError: except IndexError:
reason = _("Badly formed Swift URI: %s") % uri reason = _("Badly formed Swift URI.")
logger.error(reason) logger.error(reason)
raise exception.BadStoreUri() raise exception.BadStoreUri()


Expand Down Expand Up @@ -265,8 +264,8 @@ def get(self, location):
except swift_client.ClientException, e: except swift_client.ClientException, e:
if e.http_status == httplib.NOT_FOUND: if e.http_status == httplib.NOT_FOUND:
uri = location.get_store_uri() uri = location.get_store_uri()
raise exception.NotFound(_("Swift could not find image at " msg = _("Swift could not find image at URI.")
"uri %(uri)s") % locals()) raise exception.NotFound(msg)
else: else:
raise raise


Expand Down Expand Up @@ -464,7 +463,7 @@ def add(self, image_id, image_file, image_size):
except swift_client.ClientException, e: except swift_client.ClientException, e:
if e.http_status == httplib.CONFLICT: if e.http_status == httplib.CONFLICT:
raise exception.Duplicate(_("Swift already has an image at " raise exception.Duplicate(_("Swift already has an image at "
"location %s") % location.get_uri()) "this location."))
msg = (_("Failed to add object to Swift.\n" msg = (_("Failed to add object to Swift.\n"
"Got error from Swift: %(e)s") % locals()) "Got error from Swift: %(e)s") % locals())
logger.error(msg) logger.error(msg)
Expand Down Expand Up @@ -513,8 +512,8 @@ def delete(self, location):
except swift_client.ClientException, e: except swift_client.ClientException, e:
if e.http_status == httplib.NOT_FOUND: if e.http_status == httplib.NOT_FOUND:
uri = location.get_store_uri() uri = location.get_store_uri()
raise exception.NotFound(_("Swift could not find image at " msg = _("Swift could not find image at URI.")
"uri %(uri)s") % locals()) raise exception.NotFound(msg)
else: else:
raise raise


Expand Down

0 comments on commit 37d4d96

Please sign in to comment.