VOL-1101: Implement a Twisted Python shim layer to interface with any KV store
- Moved methods get, list, put, delete, reserve, renew_reservation,
release_reservation, and release_all_reservations from each of the
implementation classes to the parent KVClient.
- Did not move method _op_with_retry because it invokes different
target methods and handles different target exceptions, where
the target is Etcd or Consul.
Change-Id: I7c5c06ab5d554e17b8f7658b9b11b22cb8e492d8
diff --git a/common/kvstore/etcd_client.py b/common/kvstore/etcd_client.py
index 77451c8..a958b71 100644
--- a/common/kvstore/etcd_client.py
+++ b/common/kvstore/etcd_client.py
@@ -1,4 +1,4 @@
-# Copyright 2017-present Open Networking Foundation
+# Copyright 2018-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -40,46 +40,6 @@
self.client = Client(reactor, self.url)
@inlineCallbacks
- def get(self, key, timeout=DEFAULT_TIMEOUT):
- result = yield self._op_with_retry('GET', key, None, timeout)
- returnValue(result)
-
- @inlineCallbacks
- def list(self, key, timeout=DEFAULT_TIMEOUT):
- result = yield self._op_with_retry('LIST', key, None, timeout)
- returnValue(result)
-
- @inlineCallbacks
- def put(self, key, value, timeout=DEFAULT_TIMEOUT):
- _, err = yield self._op_with_retry('PUT', key, value, timeout)
- returnValue(err)
-
- @inlineCallbacks
- def delete(self, key, timeout=DEFAULT_TIMEOUT):
- _, err = yield self._op_with_retry('DELETE', key, None, timeout)
- returnValue(err)
-
- @inlineCallbacks
- def reserve(self, key, value, ttl, timeout=DEFAULT_TIMEOUT):
- result = yield self._op_with_retry('RESERVE', key, value, timeout, ttl=ttl)
- returnValue(result)
-
- @inlineCallbacks
- def renew_reservation(self, key, timeout=DEFAULT_TIMEOUT):
- result, err = yield self._op_with_retry('RENEW', key, None, timeout)
- returnValue(err)
-
- @inlineCallbacks
- def release_reservation(self, key, timeout=DEFAULT_TIMEOUT):
- result, err = yield self._op_with_retry('RELEASE', key, None, timeout)
- returnValue(err)
-
- @inlineCallbacks
- def release_all_reservations(self, timeout=DEFAULT_TIMEOUT):
- result, err = yield self._op_with_retry('RELEASE-ALL', None, None, timeout)
- returnValue(err)
-
- @inlineCallbacks
def watch(self, key, key_change_callback, timeout=DEFAULT_TIMEOUT):
self.key_watches[key] = key_change_callback
result = yield self._op_with_retry('WATCH', key, None, timeout, callback=self.key_changed)
@@ -137,7 +97,6 @@
callback = val
break
result = self.client.watch([KeySet(key, prefix=True)], callback)
- log.debug('watch-response', result=result)
self._clear_backoff()
break
except ConnectionRefusedError as ex: