From 788b9d66ded6d5b8a5fe13befdcdf1aede6bbfc0 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Mon, 20 Jan 2020 13:21:06 +0100 Subject: [PATCH] Add sync function to FSBase, and implementations to fslocal and fsmongo The reason behind this change is that FSMongo needs to sync the charm to the local storage in order for libjuju to reach it. Change-Id: Ic5838fd4ab64dd2c3e2cf78c439f33363885dd14 Signed-off-by: David Garcia --- osm_common/fsbase.py | 3 +++ osm_common/fslocal.py | 3 +++ osm_common/fsmongo.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/osm_common/fsbase.py b/osm_common/fsbase.py index 208ab87..7e69613 100644 --- a/osm_common/fsbase.py +++ b/osm_common/fsbase.py @@ -82,3 +82,6 @@ class FsBase(object): def file_delete(self, storage, ignore_non_exist=False): raise FsException("Method 'file_delete' not implemented") + + def sync(self): + raise FsException("Method 'sync' not implemented") diff --git a/osm_common/fslocal.py b/osm_common/fslocal.py index 7306559..7794754 100644 --- a/osm_common/fslocal.py +++ b/osm_common/fslocal.py @@ -177,3 +177,6 @@ class FsLocal(FsBase): raise FsException("File {} does not exist".format(storage), http_code=HTTPStatus.NOT_FOUND) except (IOError, PermissionError) as e: raise FsException("File {} cannot be deleted: {}".format(f, e), http_code=HTTPStatus.INTERNAL_SERVER_ERROR) + + def sync(self): + pass # Not needed in fslocal diff --git a/osm_common/fsmongo.py b/osm_common/fsmongo.py index c558d8e..771790f 100644 --- a/osm_common/fsmongo.py +++ b/osm_common/fsmongo.py @@ -208,8 +208,6 @@ class FsMongo(FsBase): os.chmod(file_path, writing_file.metadata["permissions"]) def get_params(self): - self.__update_local_fs() - return {"fs": "mongo", "path": self.path} def fs_connect(self, config): @@ -430,3 +428,9 @@ class FsMongo(FsBase): raise FsException("File {} does not exist".format(storage), http_code=HTTPStatus.NOT_FOUND) except IOError as e: raise FsException("File {} cannot be deleted: {}".format(f, e), http_code=HTTPStatus.INTERNAL_SERVER_ERROR) + + def sync(self): + """ + Sync from FSMongo to local storage + """ + self.__update_local_fs() -- 2.25.1