Skip to content
Browse files

Remove Swift location/password from messages.

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...
1 parent efd7e75 commit 37d4d96bf88c2bf3e7e9511b5e321cf4bed364b7 @dprince dprince committed Jan 12, 2013
Showing with 8 additions and 9 deletions.
  1. +8 −9 glance/store/swift.py
View
17 glance/store/swift.py
@@ -109,7 +109,7 @@ def parse_uri(self, uri):
"like so: "
"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()
pieces = urlparse.urlparse(uri)
@@ -139,8 +139,7 @@ def parse_uri(self, uri):
# the account and user. Combine them into a single username of
# account:user
if len(cred_parts) == 1:
- reason = (_("Badly formed credentials '%(creds)s' in Swift "
- "URI") % locals())
+ reason = (_("Badly formed credentials in Swift URI."))
logger.error(reason)
raise exception.BadStoreUri()
elif len(cred_parts) == 3:
@@ -161,7 +160,7 @@ def parse_uri(self, uri):
path_parts.insert(0, netloc)
self.authurl = '/'.join(path_parts)
except IndexError:
- reason = _("Badly formed Swift URI: %s") % uri
+ reason = _("Badly formed Swift URI.")
logger.error(reason)
raise exception.BadStoreUri()
@@ -265,8 +264,8 @@ def get(self, location):
except swift_client.ClientException, e:
if e.http_status == httplib.NOT_FOUND:
uri = location.get_store_uri()
- raise exception.NotFound(_("Swift could not find image at "
- "uri %(uri)s") % locals())
+ msg = _("Swift could not find image at URI.")
+ raise exception.NotFound(msg)
else:
raise
@@ -464,7 +463,7 @@ def add(self, image_id, image_file, image_size):
except swift_client.ClientException, e:
if e.http_status == httplib.CONFLICT:
raise exception.Duplicate(_("Swift already has an image at "
- "location %s") % location.get_uri())
+ "this location."))
msg = (_("Failed to add object to Swift.\n"
"Got error from Swift: %(e)s") % locals())
logger.error(msg)
@@ -513,8 +512,8 @@ def delete(self, location):
except swift_client.ClientException, e:
if e.http_status == httplib.NOT_FOUND:
uri = location.get_store_uri()
- raise exception.NotFound(_("Swift could not find image at "
- "uri %(uri)s") % locals())
+ msg = _("Swift could not find image at URI.")
+ raise exception.NotFound(msg)
else:
raise

0 comments on commit 37d4d96

Please sign in to comment.
Something went wrong with that request. Please try again.