diff options
-rw-r--r-- | tooz/drivers/etcd3gw.py | 6 | ||||
-rw-r--r-- | tooz/tests/drivers/test_etcd3gw.py | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tooz/drivers/etcd3gw.py b/tooz/drivers/etcd3gw.py index 232b3ae..97af3ed 100644 --- a/tooz/drivers/etcd3gw.py +++ b/tooz/drivers/etcd3gw.py @@ -177,6 +177,7 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): ================== ======= Name Default ================== ======= + api_version v3alpha ca_cert None cert_key None cert_cert None @@ -195,6 +196,9 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): #: Default port used if none provided (4001 or 2379 are the common ones). DEFAULT_PORT = 2379 + #: Default api version if none provided + DEFAULT_API_VERSION = "v3alpha" + GROUP_PREFIX = b"tooz/groups/" def __init__(self, member_id, parsed_url, options): @@ -207,12 +211,14 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): cert_key = options.get('cert_key') cert_cert = options.get('cert_cert') timeout = int(options.get('timeout', self.DEFAULT_TIMEOUT)) + api_version = options.get("api_version", self.DEFAULT_API_VERSION) self.client = etcd3gw.client(host=host, port=port, protocol=protocol, ca_cert=ca_cert, cert_key=cert_key, cert_cert=cert_cert, + api_path="/" + api_version + "/", timeout=timeout) self.lock_timeout = int(options.get('lock_timeout', timeout)) self.membership_timeout = int(options.get( diff --git a/tooz/tests/drivers/test_etcd3gw.py b/tooz/tests/drivers/test_etcd3gw.py index a182b77..3b8a09c 100644 --- a/tooz/tests/drivers/test_etcd3gw.py +++ b/tooz/tests/drivers/test_etcd3gw.py @@ -34,16 +34,19 @@ class TestEtcd3Gw(testcase.TestCase): 'ca_cert': None, 'cert_key': None, 'cert_cert': None, + 'api_path': ( + "/" + etcd3gw_driver.Etcd3Driver.DEFAULT_API_VERSION + "/"), 'timeout': etcd3gw_driver.Etcd3Driver.DEFAULT_TIMEOUT}, {'coord_url': ('etcd3+https://my_host:666?ca_cert=/my/ca_cert&' 'cert_key=/my/cert_key&cert_cert=/my/cert_cert&' - 'timeout=42'), + 'timeout=42&api_version=v3'), 'protocol': 'https', 'host': 'my_host', 'port': 666, 'ca_cert': '/my/ca_cert', 'cert_key': '/my/cert_key', 'cert_cert': '/my/cert_cert', + 'api_path': '/v3/', 'timeout': 42}) @ddt.unpack @mock.patch('etcd3gw.client') @@ -56,6 +59,7 @@ class TestEtcd3Gw(testcase.TestCase): ca_cert, cert_key, cert_cert, + api_path, timeout): tooz.coordination.get_coordinator(coord_url, self.FAKE_MEMBER_ID) mock_etcd3gw_client.assert_called_with(host=host, @@ -64,4 +68,5 @@ class TestEtcd3Gw(testcase.TestCase): ca_cert=ca_cert, cert_key=cert_key, cert_cert=cert_cert, + api_path=api_path, timeout=timeout) |