diff options
author | drebs <drebs@leap.se> | 2012-12-05 17:04:46 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2012-12-05 17:04:46 -0200 |
commit | 1815c078a9bb4c016b354429f7618da664344236 (patch) | |
tree | c303c7faee20484884b0f7a557d284a7b56729d7 /src/leap/soledad | |
parent | a237e151cc83edc9d3cd2b3ee0df854e7d4b6204 (diff) |
OpenStack backend initialization.
Diffstat (limited to 'src/leap/soledad')
-rw-r--r-- | src/leap/soledad/openstack.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/leap/soledad/openstack.py b/src/leap/soledad/openstack.py index af04465d..07ed071d 100644 --- a/src/leap/soledad/openstack.py +++ b/src/leap/soledad/openstack.py @@ -18,6 +18,7 @@ class OpenStackDatabase(CommonBackend): self._connection = swiftclient.Connection(self._auth_url, self._user, self._auth_key) self._get_auth() + self._ensure_u1db_data() #------------------------------------------------------------------------- # implemented methods from Database @@ -185,11 +186,29 @@ class OpenStackDatabase(CommonBackend): # OpenStack specific methods #------------------------------------------------------------------------- - def _is_initialized(self, c): - raise NotImplementedError(self._is_initialized) + def _ensure_u1db_data(self): + """ + Guarantee that u1db data exists in store. + """ + if self._is_initialized(): + return + self._initialize() - def _initialize(self, c): - raise NotImplementedError(self._initialize) + def _is_initialized(self): + """ + Verify if u1db data exists in store. + """ + if not self._get_doc('u1db_data'): + return False + return True + + def _initialize(self): + """ + Create u1db data object in store. + """ + content = { 'transaction_log' = [], + 'sync_log' = [] } + doc = self.create_doc('u1db_data', content) def _get_auth(self): self._url, self._auth_token = self._connection.get_auth() |