deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/8] git commit: Python client: update instance after action
Date Tue, 21 Aug 2012 11:41:45 GMT
Python client: update instance after action

Previously, the instance's XML representation wasn't being updated upon
completing an action:

    >>> i = client.instances()
    >>> i.actions()
    ['start', 'destroy', 'run', 'create_image']
    >>> i.start()
    True
    >>> i.actions()
    ['start', 'destroy', 'run', 'create_image']

The last call shows "start" as an available action even though the
instance is already running.

This fix updates the instance's internal representation when an action
is finished successfully.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>


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

Branch: refs/heads/master
Commit: bc5d15ba91d10c999859d374937bcf8e80a8795d
Parents: 4362ee1
Author: Tomas Sedovic <tomas@sedovic.cz>
Authored: Wed Aug 8 16:19:51 2012 +0200
Committer: Tomas Sedovic <tomas@sedovic.cz>
Committed: Tue Aug 21 12:06:56 2012 +0200

----------------------------------------------------------------------
 clients/python/deltacloud.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/bc5d15ba/clients/python/deltacloud.py
----------------------------------------------------------------------
diff --git a/clients/python/deltacloud.py b/clients/python/deltacloud.py
index 708c84b..cf091ef 100644
--- a/clients/python/deltacloud.py
+++ b/clients/python/deltacloud.py
@@ -152,7 +152,11 @@ class Instance(Deltacloud):
         url = action.xpathEval('@href')[0].content
         method = action.xpathEval('@method')[0].content
         response, body = self.deltacloud.client.do_request(url, method)
-        return response['status'][0] == '2'  # HTTP 2xx codes mean success
+        if not response['status'][0] == '2':  # HTTP 2xx codes mean success
+            return False
+        if body:
+            self.instance = body.xpathEval('instance')[0]
+        return True
 
 
 class Image(Deltacloud):


Mime
View raw message