Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Support for listing members
Browse files Browse the repository at this point in the history
  • Loading branch information
dims committed Mar 30, 2017
1 parent ec4180e commit 4aa5968
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions etcd3gw/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ def status(self):
return self.post(self.get_url("/maintenance/status"),
json={})

def members(self):
"""Lists all the members in the cluster.
:return: json response
"""
result = self.post(self.get_url("/cluster/member/list"),
json={})
return result['members']

def lease(self, ttl=DEFAULT_TIMEOUT):
"""Create a Lease object given a timeout
Expand Down
3 changes: 3 additions & 0 deletions etcd3gw/examples/etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def main():
result = client.status()
print("cluster id : %r" % result['header']['cluster_id'])

result = client.members()
print("first member info : %r" % result[0])

print('>>>> Lease')
lease = client.lease()
print("Lease id : %r" % lease.id)
Expand Down
8 changes: 8 additions & 0 deletions etcd3gw/tests/test_etcd3gw.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def test_client_status(self):
self.assertIn('header', response)
self.assertIn('cluster_id', response['header'])

@unittest.skipUnless(
_is_etcd3_running(), "etcd3 is not available")
def test_client_members(self):
response = self.client.members()
self.assertTrue(len(response) > 0)
self.assertIn('clientURLs', response[0])
self.assertIn('peerURLs', response[0])

@unittest.skipUnless(
_is_etcd3_running(), "etcd3 is not available")
def test_client_with_keys_and_values(self):
Expand Down

0 comments on commit 4aa5968

Please sign in to comment.