~ubuntu-branches/ubuntu/raring/glance/raring-proposed

« back to all changes in this revision

Viewing changes to glance/db/sqlalchemy/migrate_repo/versions/015_quote_swift_credentials.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 10:09:59 UTC
  • mfrom: (1.1.47)
  • Revision ID: package-import@ubuntu.com-20121123100959-a3mt0ziwvee17rkf
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/patches/*: Refreshed for opening of Grizzly.

[ Chuck Short ]
* debian/glance-client.install: Dropped
* New upstream version
* debian/rules: FTBFS if there are missing binaries
* debian/glance-registry.install: Add glance-replicator
* debian/patches/disable-swift-tests.patch: Dropped.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
    images_table = sqlalchemy.Table('images', meta, autoload=True)
52
52
 
53
 
    images = images_table.select(images_table.c.location.startswith('swift')).\
54
 
             execute()
 
53
    images = images_table.select(images_table.c.location.startswith('swift'))\
 
54
                         .execute()
55
55
 
56
56
    for image in images:
57
57
        fixed_uri = fix_uri_credentials(image['location'], to_quoted)
58
 
        images_table.update().\
59
 
            where(images_table.c.id == image['id']).\
60
 
            values(location=fixed_uri).execute()
 
58
        images_table.update()\
 
59
                    .where(images_table.c.id == image['id'])\
 
60
                    .values(location=fixed_uri).execute()
61
61
 
62
62
 
63
63
def fix_uri_credentials(uri, to_quoted):
104
104
    # swift://user:pass@http://authurl.com/v1/container/obj
105
105
    # are immediately rejected.
106
106
    if uri.count('://') != 1:
107
 
        reason = _(
108
 
                "URI cannot contain more than one occurrence of a scheme."
109
 
                "If you have specified a URI like "
110
 
                "swift://user:pass@http://authurl.com/v1/container/obj"
111
 
                ", you need to change it to use the swift+http:// scheme, "
112
 
                "like so: "
113
 
                "swift+http://user:pass@authurl.com/v1/container/obj"
114
 
                )
 
107
        reason = _("URI cannot contain more than one occurrence of a scheme."
 
108
                   "If you have specified a URI like "
 
109
                   "swift://user:pass@http://authurl.com/v1/container/obj"
 
110
                   ", you need to change it to use the swift+http:// scheme, "
 
111
                   "like so: "
 
112
                   "swift+http://user:pass@authurl.com/v1/container/obj")
115
113
 
116
114
        LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
117
115
        raise exception.BadStoreUri(message=reason)