[Kimchi-devel] [PATCH 1/2] Expose target_uri on Task resource

Aline Manera alinefm at linux.vnet.ibm.com
Thu Sep 4 01:07:44 UTC 2014


The target_uri is used to identify which resource the Task is associated to.
It will be useful to update UI accordingly when a Task is running.
So if a user A starts a Task it will be shown to user B as a task in
progress.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 docs/API.md                 | 1 +
 src/kimchi/control/tasks.py | 4 +---
 tests/test_rest.py          | 2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/docs/API.md b/docs/API.md
index 298441f..0c4a641 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -584,6 +584,7 @@ server.
         * finished: The task has finished successfully
         * failed: The task failed
     * message: Human-readable details about the Task status
+    * target_uri: Resource URI related to the Task
 * **POST**: *See Task Actions*
 
 **Actions (POST):**
diff --git a/src/kimchi/control/tasks.py b/src/kimchi/control/tasks.py
index d88637e..4870dbd 100644
--- a/src/kimchi/control/tasks.py
+++ b/src/kimchi/control/tasks.py
@@ -34,6 +34,4 @@ class Task(Resource):
 
     @property
     def data(self):
-        return {'id': self.ident,
-                'status': self.info['status'],
-                'message': self.info['message']}
+        return self.info
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 9e14b6d..8af333f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1521,6 +1521,8 @@ class RestTests(unittest.TestCase):
         self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
         self._wait_task(id2)
         foo2 = json.loads(self.request('/tasks/%s' % id2).read())
+        keys = ['id', 'status', 'message', 'target_uri']
+        self.assertEquals(sorted(keys), sorted(foo2.keys()))
         self.assertEquals('failed', foo2['status'])
         self._wait_task(id3)
         foo3 = json.loads(self.request('/tasks/%s' % id3).read())
-- 
1.9.3




More information about the Kimchi-devel mailing list