diff --git a/nova/image/glance.py b/nova/image/glance.py index a5f9e6865f0c..97a60cb78fc2 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -111,13 +111,13 @@ def get_glance_client(context, image_href): else: try: - (image_id, host, port) = _parse_image_ref(image_href) + (image_id, glance_host, glance_port) = _parse_image_ref(image_href) + glance_client = _create_glance_client(context, + glance_host, + glance_port) except ValueError: raise exception.InvalidImageRef(image_href=image_href) - glance_client = _create_glance_client(context, - glance_host, - glance_port) return (glance_client, image_id) diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index bc5969a4516b..8fa136aad853 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -578,6 +578,7 @@ class TestGlanceImageService(test.TestCase): def test_glance_client_image_ref(self): fixture = self._make_fixture(name='test image') image_id = self.service.create(self.context, fixture)['id'] - image_url = 'http://foo/%s' % image_id + image_url = 'http://something-less-likely/%s' % image_id client, same_id = glance.get_glance_client(self.context, image_url) self.assertEquals(same_id, image_id) + self.assertEquals(client.host, 'something-less-likely')