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.

Change-Id: I458de58563343347d5c976fe1ad084cc7e3280eb
  • Loading branch information
dprince committed Jan 29, 2013
1 parent 1c01cf1 commit e962731
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions glance/store/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def parse_uri(self, uri):
", you need to change it to use the "
"swift+http:// scheme, like so: "
"swift+http://user:pass@authurl.com/v1/container/obj")
LOG.debug(_("Invalid store uri %(uri)s: %(reason)s") % locals())
LOG.debug(_("Invalid store URI: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason)

pieces = urlparse.urlparse(uri)
Expand All @@ -162,8 +162,7 @@ def parse_uri(self, uri):
if creds:
cred_parts = creds.split(':')
if len(cred_parts) != 2:
reason = (_("Badly formed credentials '%(creds)s' in Swift "
"URI") % locals())
reason = (_("Badly formed credentials in Swift URI."))
LOG.debug(reason)
raise exception.BadStoreUri()
user, key = cred_parts
Expand All @@ -181,7 +180,7 @@ def parse_uri(self, uri):
path_parts.insert(0, netloc)
self.auth_or_store_url = '/'.join(path_parts)
except IndexError:
reason = _("Badly formed Swift URI: %s") % uri
reason = _("Badly formed Swift URI.")
LOG.debug(reason)
raise exception.BadStoreUri()

Expand Down Expand Up @@ -241,8 +240,8 @@ def get(self, location, connection=None):
except swiftclient.ClientException, e:
if e.http_status == httplib.NOT_FOUND:
uri = location.get_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

Expand Down Expand Up @@ -375,8 +374,7 @@ def add(self, image_id, image_file, image_size, connection=None):
except swiftclient.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())
LOG.error(msg)
Expand Down Expand Up @@ -419,8 +417,8 @@ def delete(self, location, connection=None):
except swiftclient.ClientException, e:
if e.http_status == httplib.NOT_FOUND:
uri = location.get_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

Expand Down Expand Up @@ -578,8 +576,8 @@ def set_acls(self, location, public=False, read_tenants=None,
except swiftclient.ClientException, e:
if e.http_status == httplib.NOT_FOUND:
uri = location.get_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

Expand Down

0 comments on commit e962731

Please sign in to comment.