예제 #1
0
 def setUp(self):
     """Establish a clean test environment"""
     super(TestRegistryDb, self).setUp()
     conf = test_utils.TestConfigOpts(CONF)
     self.adm_context = rcontext.RequestContext(is_admin=True)
     self.context = rcontext.RequestContext(is_admin=False)
     db_api.configure_db(conf)
     self.destroy_fixtures()
     self.create_fixtures()
예제 #2
0
파일: test_db.py 프로젝트: russellb/glance
 def setUp(self):
     """Establish a clean test environment"""
     self.stubs = stubout.StubOutForTesting()
     stubs.stub_out_registry_and_store_server(self.stubs)
     stubs.stub_out_filesystem_backend()
     conf = test_utils.TestConfigOpts(CONF)
     self.adm_context = rcontext.RequestContext(is_admin=True)
     self.context = rcontext.RequestContext(is_admin=False)
     db_api.configure_db(conf)
     self.destroy_fixtures()
     self.create_fixtures()
예제 #3
0
    def _delete(self, image_id, location):
        try:
            logger.debug(_("Deleting %(location)s") % locals())
            store.delete_from_backend(location)
        except (store.UnsupportedBackend, exception.NotFound):
            msg = _("Failed to delete image from store (%(uri)s).") % locals()
            logger.error(msg)

        ctx = context.RequestContext(is_admin=True, show_deleted=True)
        db_api.image_update(ctx, image_id, {'status': 'deleted'})
예제 #4
0
    def queue_image(self, image_id):
        ctx = context.RequestContext(is_admin=True, show_deleted=True)
        try:
            image_meta = registry.get_image_metadata(ctx, image_id)
            if image_meta['status'] != 'active':
                logger.warn(_("Image '%s' is not active. Not queueing."),
                            image_id)
                return False

        except exception.NotFound:
            logger.warn(_("No metadata found for image '%s'"), image_id)
            return False

        logger.debug(_("Queueing image '%s'"), image_id)
        self.cache.queue_image(image_id)
        return True
예제 #5
0
    def fetch_image_into_cache(self, image_id):
        ctx = context.RequestContext(is_admin=True, show_deleted=True)

        try:
            image_meta = registry.get_image_metadata(ctx, image_id)
            if image_meta['status'] != 'active':
                logger.warn(_("Image '%s' is not active. Not caching."),
                            image_id)
                return False

        except exception.NotFound:
            logger.warn(_("No metadata found for image '%s'"), image_id)
            return False

        image_data, image_size = get_from_backend(image_meta['location'])
        logger.debug(_("Caching image '%s'"), image_id)
        self.cache.cache_image_iter(image_id, image_data)
        return True