From ac507843970dd097bca7f7cc7b9871302ca32140 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Thu, 2 Aug 2012 10:32:58 +1000 Subject: [PATCH] URLs to glance need to be absolute. Otherwise the apache SSL frontend that many users deploy will get confused and return a HTTP error. Change-Id: Ie8ae560810a5e5419e4d4aacae17e1e301ed4126 --- bin/glance-replicator | 12 ++++++------ glance/tests/unit/test_glance_replicator.py | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/glance-replicator b/bin/glance-replicator index c030bc16d6..574acf4739 100755 --- a/bin/glance-replicator +++ b/bin/glance-replicator @@ -85,7 +85,7 @@ class ImageService(object): if self.auth_token: headers.setdefault('x-auth-token', self.auth_token) - logging.debug(_('Request: %(method)s http://%(server)s:%(port)s/' + logging.debug(_('Request: %(method)s http://%(server)s:%(port)s' '%(url)s with headers %(headers)s') % {'method': method, 'server': self.conn.host, @@ -122,7 +122,7 @@ class ImageService(object): params = {'is_public': None} while True: - url = 'v1/images/detail' + url = '/v1/images/detail' query = urllib.urlencode(params) if query: url += '?%s' % query @@ -143,7 +143,7 @@ class ImageService(object): Returns: a httplib Response object where the body is the image. """ - url = 'v1/images/%s' % image_uuid + url = '/v1/images/%s' % image_uuid return self._http_request('GET', url, {}, '') @staticmethod @@ -171,7 +171,7 @@ class ImageService(object): Returns: image metadata as a dictionary """ - url = 'v1/images/%s' % image_uuid + url = '/v1/images/%s' % image_uuid response = self._http_request('HEAD', url, {}, '', ignore_result_body=True) return self._header_list_to_dict(response.getheaders()) @@ -203,7 +203,7 @@ class ImageService(object): Returns: a tuple of (http response headers, http response body) """ - url = 'v1/images' + url = '/v1/images' headers = self._dict_to_headers(image_meta) headers['Content-Type'] = 'application/octet-stream' headers['Content-Length'] = int(image_meta['size']) @@ -223,7 +223,7 @@ class ImageService(object): Returns: a tuple of (http response headers, http response body) """ - url = 'v1/images/%s' % image_meta['id'] + url = '/v1/images/%s' % image_meta['id'] headers = self._dict_to_headers(image_meta) headers['Content-Type'] = 'application/octet-stream' diff --git a/glance/tests/unit/test_glance_replicator.py b/glance/tests/unit/test_glance_replicator.py index 7cc071c151..a78cdba6e8 100644 --- a/glance/tests/unit/test_glance_replicator.py +++ b/glance/tests/unit/test_glance_replicator.py @@ -85,6 +85,9 @@ class FakeHTTPConnection(object): def prime_request(self, method, url, in_body, in_headers, out_body, out_headers): + if not url.startswith('/'): + url = '/' + url + hkeys = in_headers.keys() hkeys.sort() hashable = (method, url, in_body, ' '.join(hkeys))