コード例 #1
0
    def test_delete_from_fs(self):
        delete_fs = import_flow._DeleteFromFS(self.task.task_id, self.task_type)

        data = "test"

        store = glance_store.get_store_from_scheme("file")
        path = glance_store.store_add_to_backend(
            mock.sentinel.image_id, data, mock.sentinel.image_size, store, context=None
        )[0]

        path_wo_scheme = path.split("file://")[1]
        self.assertTrue(os.path.exists(path_wo_scheme))
        delete_fs.execute(path)
        self.assertFalse(os.path.exists(path_wo_scheme))
コード例 #2
0
ファイル: test_import.py プロジェクト: wilkmar/glance
    def test_delete_from_fs(self):
        delete_fs = import_flow._DeleteFromFS(self.task.task_id,
                                              self.task_type)

        data = [b"test"]

        store = glance_store.get_store_from_scheme('file')
        path = glance_store.store_add_to_backend(mock.sentinel.image_id, data,
                                                 mock.sentinel.image_size,
                                                 store, context=None)[0]

        path_wo_scheme = path.split("file://")[1]
        self.assertTrue(os.path.exists(path_wo_scheme))
        delete_fs.execute(path)
        self.assertFalse(os.path.exists(path_wo_scheme))
コード例 #3
0
ファイル: images.py プロジェクト: amoid/glance
    def get_store_or_400(self, request, scheme):
        """
        Grabs the storage backend for the supplied store name
        or raises an HTTPBadRequest (400) response

        :param request: The WSGI/Webob Request object
        :param scheme: The backend store scheme

        :raises HTTPNotFound if store does not exist
        """
        try:
            return store.get_store_from_scheme(scheme)
        except exception.UnknownScheme:
            msg = "Store for scheme %s not found" % scheme
            LOG.debug(msg)
            raise HTTPBadRequest(explanation=msg, request=request, content_type="text/plain")