return actual action object

Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/0c1808fb
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0c1808fb
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0c1808fb

Branch: refs/heads/trunk
Commit: 0c1808fbd2e488b6cf822487eafdef0d2641c0bb
Parents: 939f065
Author: Mario Loria <ma...@arroyonetworks.com>
Authored: Thu Oct 13 14:47:37 2016 -0400
Committer: Anthony Shaw <anthonys...@apache.org>
Committed: Fri Oct 14 19:44:40 2016 +1100

----------------------------------------------------------------------
 libcloud/container/drivers/rancher.py | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/0c1808fb/libcloud/container/drivers/rancher.py
----------------------------------------------------------------------
diff --git a/libcloud/container/drivers/rancher.py 
b/libcloud/container/drivers/rancher.py
index 745332d..5a213e4 100644
--- a/libcloud/container/drivers/rancher.py
+++ b/libcloud/container/drivers/rancher.py
@@ -577,11 +577,9 @@ class RancherContainerDriver(ContainerDriver):
         """
         result = self.connection.request('%s/containers/%s?action=start' %
                                          (self.baseuri, container.id),
-                                         method='POST')
-        if result.status in VALID_RESPONSE_CODES:
-            return self.get_container(container.id)
-        else:
-            raise RancherException(result.status, 'failed to start container')
+                                         method='POST').object
+
+        return self._to_container(result)
 
     def stop_container(self, container):
         """
@@ -595,11 +593,9 @@ class RancherContainerDriver(ContainerDriver):
         """
         result = self.connection.request('%s/containers/%s?action=stop' %
                                          (self.baseuri, container.id),
-                                         method='POST')
-        if result.status in VALID_RESPONSE_CODES:
-            return self.get_container(container.id)
-        else:
-            raise RancherException(result.status, 'failed to stop container')
+                                         method='POST').object
+
+        return self._to_container(result)
 
     def ex_search_containers(self, search_params):
         """
@@ -632,11 +628,9 @@ class RancherContainerDriver(ContainerDriver):
         :rtype: ``bool``
         """
         result = self.connection.request('%s/containers/%s' % (self.baseuri,
-                                         container.id), method='DELETE')
-        if result.status in VALID_RESPONSE_CODES:
-            return self.get_container(container.id)
-        else:
-            raise RancherException(result.status, 'failed to stop container')
+                                         container.id), method='DELETE').object
+
+        return self._to_container(result)
 
     def _gen_image(self, imageuuid):
         """

Reply via email to