예제 #1
0
        if not self._check_path():
            return None
        path = self._container_path(uuid)
        if os.path.exists(path):
            shutil.rmtree(path)
        os.mkdir(path)
        url = 'leveldb://%s' % path
        cont = StorageContainer(uuid, LevelDBDriver(url))
        self._containers[uuid] = cont
        return cont

    def delete_container(self, uuid):
        if uuid in self._containers:
            cont = self._containers[uuid]
            cont.close()
            del self._containers[uuid]
        if not self._check_path():
            return None
        path = self._container_path(uuid)
        if os.path.exists(path):
            shutil.rmtree(path)
            return True
        return False

    def close(self):
        del self._db
        self._db = None


STOR_REG.register('leveldb', LevelDBDriver)
예제 #2
0
파일: memory.py 프로젝트: vindeka/gate
            return None
        if uuid not in self._containers:
            return None
        return self._containers[uuid]

    def create_container(self, uuid):
        if not hasattr(self, '_containers'):
            LOG.error('Cannot call create_container when driver is in container mode.')
            return None
        cont = StorageContainer(uuid, MemoryDriver(None, True))
        self._containers[uuid] = cont
        return cont

    def delete_container(self, uuid):
        if not hasattr(self, '_containers'):
            LOG.error('Cannot call delete_container when driver is in container mode.')
            return None
        if uuid in self._containers:
            del self._containers[uuid]
            return True
        return False

    def close(self):
        self._storage = None
        self._index = None
        if not hasattr(self, '_containers'):
            self._containers = None


STOR_REG.register('memory', MemoryDriver)
예제 #3
0
파일: level.py 프로젝트: vindeka/gate
    def create_container(self, uuid):
        if not self._check_path():
            return None
        path = self._container_path(uuid)
        if os.path.exists(path):
            shutil.rmtree(path)
        os.mkdir(path)
        url = 'leveldb://%s' % path
        cont = StorageContainer(uuid, LevelDBDriver(url))
        self._containers[uuid] = cont
        return cont

    def delete_container(self, uuid):
        if uuid in self._containers:
            cont = self._containers[uuid]
            cont.close()
            del self._containers[uuid]
        if not self._check_path():
            return None
        path = self._container_path(uuid)
        if os.path.exists(path):
            shutil.rmtree(path)
            return True
        return False

    def close(self):
        del self._db
        self._db = None

STOR_REG.register('leveldb', LevelDBDriver)
예제 #4
0
    def create_container(self, uuid):
        if not hasattr(self, '_containers'):
            LOG.error(
                'Cannot call create_container when driver is in container mode.'
            )
            return None
        cont = StorageContainer(uuid, MemoryDriver(None, True))
        self._containers[uuid] = cont
        return cont

    def delete_container(self, uuid):
        if not hasattr(self, '_containers'):
            LOG.error(
                'Cannot call delete_container when driver is in container mode.'
            )
            return None
        if uuid in self._containers:
            del self._containers[uuid]
            return True
        return False

    def close(self):
        self._storage = None
        self._index = None
        if not hasattr(self, '_containers'):
            self._containers = None


STOR_REG.register('memory', MemoryDriver)