def test_get_openstack_resource_by_name(self, fake_is_uuid_like): fake_manager = mock.MagicMock() fake_manager.list.return_value = ['fake_resource_data'] resource_data = utils.get_openstack_resource(fake_manager, 'fake_resource', 'fake_resource_type') self.assertEqual('fake_resource_data', resource_data)
def _get_image_data(self, context, image_ident): """Retrieves os_distro and other metadata from the Glance image. :param image_ident: image id or name of baymodel. """ try: cli = clients.OpenStackClients(context) return api_utils.get_openstack_resource(cli.glance().images, image_ident, 'images') except glanceclient.exc.NotFound: raise exception.ImageNotFound(image_id=image_ident) except glanceclient.exc.HTTPForbidden: raise exception.ImageNotAuthorized(image_id=image_ident)