You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/10/14 08:45:06 UTC
[3/3] libcloud git commit: fix state handling Closes #905
fix state handling
Closes #905
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/35eb2797
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/35eb2797
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/35eb2797
Branch: refs/heads/trunk
Commit: 35eb2797c5e5dd9cdb6f35705eb522fe4b2357f5
Parents: f108598
Author: Mario Loria <ma...@arroyonetworks.com>
Authored: Thu Oct 13 15:34:13 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Oct 14 19:44:48 2016 +1100
----------------------------------------------------------------------
libcloud/container/drivers/rancher.py | 9 ++++++---
libcloud/test/container/test_rancher.py | 3 +++
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/35eb2797/libcloud/container/drivers/rancher.py
----------------------------------------------------------------------
diff --git a/libcloud/container/drivers/rancher.py b/libcloud/container/drivers/rancher.py
index 5a213e4..eda0058 100644
--- a/libcloud/container/drivers/rancher.py
+++ b/libcloud/container/drivers/rancher.py
@@ -707,6 +707,11 @@ class RancherContainerDriver(ContainerDriver):
"""
rancher_state = data['state']
+
+ # A Removed container is purged after x amt of time.
+ # Both of these render the container dead (can't be started later)
+ terminate_condition = ["removed", "purged"]
+
if 'running' in rancher_state:
state = ContainerState.RUNNING
elif 'stopped' in rancher_state:
@@ -715,9 +720,7 @@ class RancherContainerDriver(ContainerDriver):
state = ContainerState.REBOOTING
elif 'error' in rancher_state:
state = ContainerState.ERROR
- elif 'removed' or 'purged' in rancher_state:
- # A Removed container is purged after x amt of time.
- # Both of these render the container dead (can't be started later)
+ elif any(x in rancher_state for x in terminate_condition):
state = ContainerState.TERMINATED
elif data['transitioning'] == 'yes':
# Best we can do for current actions
http://git-wip-us.apache.org/repos/asf/libcloud/blob/35eb2797/libcloud/test/container/test_rancher.py
----------------------------------------------------------------------
diff --git a/libcloud/test/container/test_rancher.py b/libcloud/test/container/test_rancher.py
index 178e298..eb23ddf 100644
--- a/libcloud/test/container/test_rancher.py
+++ b/libcloud/test/container/test_rancher.py
@@ -162,6 +162,7 @@ class RancherContainerDriverTestCase(unittest.TestCase):
started = container.start()
self.assertEqual(started.id, "1i31")
self.assertEqual(started.name, "newcontainer")
+ self.assertEqual(started.state, "pending")
self.assertEqual(started.extra['state'], "starting")
def test_stop_container(self):
@@ -169,6 +170,7 @@ class RancherContainerDriverTestCase(unittest.TestCase):
stopped = container.stop()
self.assertEqual(stopped.id, "1i31")
self.assertEqual(stopped.name, "newcontainer")
+ self.assertEqual(stopped.state, "pending")
self.assertEqual(stopped.extra['state'], "stopping")
def test_ex_search_containers(self):
@@ -180,6 +182,7 @@ class RancherContainerDriverTestCase(unittest.TestCase):
destroyed = container.destroy()
self.assertEqual(destroyed.id, "1i31")
self.assertEqual(destroyed.name, "newcontainer")
+ self.assertEqual(destroyed.state, "pending")
self.assertEqual(destroyed.extra['state'], "stopping")