Add a validate method to dir and memory backends

In order to allow all connections to be validated
post-creation add a new method onto the memory
backend (a no-op) and add a new method onto the
dir backend (which checks directory existence) and
raise appropriate errors when validation fails.

Change-Id: Ie476d0c33a970e543ffba21ee8b669ac02258923
This commit is contained in:
Joshua Harlow
2014-02-02 10:04:34 -08:00
parent 7ff1cde77e
commit f98f45447e
2 changed files with 16 additions and 0 deletions

View File

@@ -95,6 +95,19 @@ class Connection(base.Connection):
# to restrict the multi-process access does not work inside a process.
self._lock = backend._lock
def validate(self):
# Verify key paths exist.
paths = [
self._backend.base_path,
self._backend.lock_path,
self._flow_path,
self._task_path,
self._book_path,
]
for p in paths:
if not os.path.isdir(p):
raise RuntimeError("Missing required directory: %s" % (p))
def _read_from(self, filename):
# This is very similar to the oslo-incubator fileutils module, but
# tweaked to not depend on a global cache, as well as tweaked to not

View File

@@ -78,6 +78,9 @@ class Connection(base.Connection):
def upgrade(self):
pass
def validate(self):
pass
@property
def backend(self):
return self._backend