def get_storage_driver(storage_url=None): if not storage_url: storage_url = cfg.CONF.storage_url if not cfg.CONF.storage_driver: return STOR_REG._load_driver(storage_url) return importutils.import_object(cfg.CONF.storage_driver, storage_url)
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)
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)
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)
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)