[Kimchi-devel] [PATCH 2/2] Update current code to report target_uri while creating a Task
Aline Manera
alinefm at linux.vnet.ibm.com
Wed Sep 3 03:07:28 UTC 2014
It will be useful to list Task by target_uri
Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 6 ++++--
src/kimchi/model/debugreports.py | 3 ++-
src/kimchi/model/host.py | 3 ++-
src/kimchi/model/storagepools.py | 4 ++--
tests/test_rest.py | 12 +++++++++---
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 05e3fa4..b94c3fe 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -859,7 +859,8 @@ class MockModel(object):
raise NotFoundError("KCHDISTRO0001E", {'name': name})
def _gen_debugreport_file(self, ident):
- return self.add_task('', self._create_log, ident)
+ return self.add_task('/debugreports/%s' % ident, self._create_log,
+ ident)
def _create_log(self, cb, name):
path = config.get_debugreports_path()
@@ -962,7 +963,8 @@ class MockModel(object):
return self._mock_swupdate.getUpdate(pkg_name)
def host_swupdate(self, args=None):
- task_id = self.add_task('', self._mock_swupdate.doUpdate, None)
+ task_id = self.add_task('/host/swupdate', self._mock_swupdate.doUpdate,
+ None)
return self.task_lookup(task_id)
def repositories_get_list(self):
diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
index fb72df4..fbc0463 100644
--- a/src/kimchi/model/debugreports.py
+++ b/src/kimchi/model/debugreports.py
@@ -62,7 +62,8 @@ class DebugReportsModel(object):
gen_cmd = self.get_system_report_tool()
if gen_cmd is not None:
- return add_task('', gen_cmd, self.objstore, name)
+ return add_task('/debugreports/%s' % name, gen_cmd, self.objstore,
+ name)
raise OperationFailed("KCHDR0002E")
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 553ad7c..933a142 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -114,7 +114,8 @@ class HostModel(object):
raise OperationFailed('KCHPKGUPD0001E')
kimchi_log.debug('Host is going to be updated.')
- taskid = add_task('', swupdate.doUpdate, self.objstore, None)
+ taskid = add_task('/host/swupdate', swupdate.doUpdate, self.objstore,
+ None)
return self.task.lookup(taskid)
def shutdown(self, args=None):
diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py
index 44cb3c2..49b2f6a 100644
--- a/src/kimchi/model/storagepools.py
+++ b/src/kimchi/model/storagepools.py
@@ -167,8 +167,8 @@ class StoragePoolsModel(object):
params['path'] = self.scanner.scan_dir_prepare(params['name'])
scan_params['pool_path'] = params['path']
- task_id = add_task('', self.scanner.start_scan, self.objstore,
- scan_params)
+ task_id = add_task('/storagepools/%s' % ISO_POOL_NAME,
+ self.scanner.start_scan, self.objstore, scan_params)
# Record scanning-task/storagepool mapping for future querying
try:
with self.objstore as session:
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 8af333f..2e6c54f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1513,9 +1513,15 @@ class RestTests(unittest.TestCase):
time.sleep(1)
def test_tasks(self):
- id1 = model.add_task('', self._async_op)
- id2 = model.add_task('', self._except_op)
- id3 = model.add_task('', self._intermid_op)
+ id1 = model.add_task('/tasks', self._async_op)
+ id2 = model.add_task('/tasks', self._except_op)
+ id3 = model.add_task('/tasks', self._intermid_op)
+
+ target_uri = urllib2.quote('/tasks', safe="")
+ filter_data = 'status=running&target_uri=%s' % target_uri
+ tasks = json.loads(self.request('/tasks?%s' % filter_data).read())
+ self.assertEquals(3, len(tasks))
+
tasks = json.loads(self.request('/tasks').read())
tasks_ids = [int(t['id']) for t in tasks]
self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
--
1.9.3
More information about the Kimchi-devel
mailing list