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://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')
def get_image_service(context, image_href): """Get the proper image_service and id for the given image_href. The image_href param can be an href of the form http://myglanceserver:9292/images/42, or just an int such as 42. If the image_href is an int, then the default image service is returned. :param image_href: image ref/id for an image :returns: a tuple of the form (image_service, image_id) """ # check if this is not a uri if '/' not in str(image_href): return (get_default_image_service(), image_href) else: (glance_client, image_id) = glance._get_glance_client(context, image_href) image_service = nova.image.glance.GlanceImageService(glance_client) return (image_service, image_id)
def test_glance_client_image_id(self): fixture = self._make_fixture(name='test image') image_id = self.service.create(self.context, fixture)['id'] client, same_id = glance._get_glance_client(self.context, image_id) self.assertEquals(same_id, image_id)