summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oslo_concurrency/lockutils.py16
-rw-r--r--oslo_concurrency/tests/unit/test_lockutils.py17
-rw-r--r--tox.ini2
3 files changed, 33 insertions, 2 deletions
diff --git a/oslo_concurrency/lockutils.py b/oslo_concurrency/lockutils.py
index 6b514df..b2e96a2 100644
--- a/oslo_concurrency/lockutils.py
+++ b/oslo_concurrency/lockutils.py
@@ -53,8 +53,12 @@ _opts = [
]
+def _register_opts(conf):
+ conf.register_opts(_opts, group='oslo_concurrency')
+
+
CONF = cfg.CONF
-CONF.register_opts(_opts, group='oslo_concurrency')
+_register_opts(CONF)
def set_defaults(lock_path):
@@ -65,6 +69,16 @@ def set_defaults(lock_path):
cfg.set_defaults(_opts, lock_path=lock_path)
+def get_lock_path(conf):
+ """Return the path used for external file-based locks.
+
+ :param conf: Configuration object
+ :type conf: oslo_config.cfg.ConfigOpts
+ """
+ _register_opts(conf)
+ return conf.oslo_concurrency.lock_path
+
+
class _Hourglass(object):
"""A hourglass like periodic timer."""
diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py
index 258592d..e163078 100644
--- a/oslo_concurrency/tests/unit/test_lockutils.py
+++ b/oslo_concurrency/tests/unit/test_lockutils.py
@@ -898,3 +898,20 @@ class TestLockFixture(test_base.BaseTestCase):
fixture = fixtures.LockFixture('test-lock')
self.useFixture(fixture)
self.lock = fixture.lock
+
+
+class TestGetLockPath(test_base.BaseTestCase):
+
+ def setUp(self):
+ super(TestGetLockPath, self).setUp()
+ self.conf = self.useFixture(config.Config(lockutils.CONF)).conf
+
+ def test_get_default(self):
+ lockutils.set_defaults(lock_path='/the/path')
+ self.assertEqual('/the/path', lockutils.get_lock_path(self.conf))
+
+ def test_get_override(self):
+ lockutils._register_opts(self.conf)
+ self.conf.set_override('lock_path', '/alternate/path',
+ group='oslo_concurrency')
+ self.assertEqual('/alternate/path', lockutils.get_lock_path(self.conf))
diff --git a/tox.ini b/tox.ini
index 02f3eeb..78e6203 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
minversion = 1.6
-envlist = py33,py34,py26,py27,pep8
+envlist = py34,py26,py27,pep8
# NOTE(dhellmann): We cannot set skipdist=True
# for oslo libraries because of the namespace package.
#skipsdist = True