Expose started state of coordinator to external

Users (others projects like Ceilometer) may need to check if the
coordinator has been started or not, but tooz didn't expose an external
interface. This change expose an is_started property that Ceilometer don't
need maintain the state itself any more.

Change-Id: I1a177cf3efd63593667751c6b53bcc536fb0670f
This commit is contained in:
liu-sheng 2015-07-14 14:18:09 +08:00
parent 77bb9f8a92
commit 7ab084a06b
2 changed files with 10 additions and 0 deletions

View File

@ -172,6 +172,10 @@ class CoordinationDriver(object):
"""
raise tooz.NotImplemented
@property
def is_started(self):
return self._started
def start(self):
"""Start the service engine.

View File

@ -720,6 +720,12 @@ class TestAPI(testscenarios.TestWithScenarios,
self.assertTrue(lock2.acquire(blocking=True))
self.assertTrue(lock2.release())
def test_get_started_status(self):
self.assertTrue(self._coord.is_started)
self._coord.stop()
self.assertFalse(self._coord.is_started)
self._coord.start()
@staticmethod
def _get_random_uuid():
return str(uuid.uuid4()).encode('ascii')