Adding swarm id_attribute to match docker output

Swarm id is returned in a attribute with the key ID. The swarm model was using the default behaviour and looking for Id.
Signed-off-by: Steve Clark <steve@cobe.io>
This commit is contained in:
Steve Clark 2017-09-18 11:35:53 +01:00 committed by Joffrey F
parent ba66b09e2b
commit 1d77ef9e53
2 changed files with 3 additions and 0 deletions

View File

@ -9,6 +9,8 @@ class Swarm(Model):
The server's Swarm state. This a singleton that must be reloaded to get
the current state of the Swarm.
"""
id_attribute = 'ID'
def __init__(self, *args, **kwargs):
super(Swarm, self).__init__(*args, **kwargs)
if self.client:

View File

@ -22,6 +22,7 @@ class SwarmTest(unittest.TestCase):
assert client.swarm.attrs['Spec']['Raft']['SnapshotInterval'] == 5000
client.swarm.update(snapshot_interval=10000)
assert client.swarm.attrs['Spec']['Raft']['SnapshotInterval'] == 10000
assert client.swarm.id
assert client.swarm.leave(force=True)
with self.assertRaises(docker.errors.APIError) as cm:
client.swarm.reload()