From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
After move AsyncTask to memory, the call to add a new task has changed.
This patch updates all add_task() calls to address the new way.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
mockmodel.py | 5 +++--
model/storagepools.py | 5 +++--
model/storagevolumes.py | 7 ++++---
model/vmhostdevs.py | 12 ++++++------
model/vms.py | 12 ++++++------
model/vmsnapshots.py | 4 ++--
tests/test_model.py | 15 +++++++--------
tests/test_rest.py | 11 ++++-------
8 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/mockmodel.py b/mockmodel.py
index cd06ee3..eed2e7f 100644
--- a/mockmodel.py
+++ b/mockmodel.py
@@ -28,9 +28,10 @@ from collections import defaultdict
from lxml import objectify
from lxml.builder import E
+from wok.asynctask import add_task
from wok.exception import NotFoundError, OperationFailed
from wok.objectstore import ObjectStore
-from wok.utils import add_task, convert_data_size
+from wok.utils import convert_data_size
from wok.xmlutils.utils import xml_item_update
from wok.plugins.kimchi import imageinfo
@@ -418,7 +419,7 @@ class MockModel(Model):
params = {'vm_name': vm_name, 'name': name}
taskid = add_task(u'/plugins/kimchi/vms/%s/snapshots/%s' %
(vm_name, name), self._vmsnapshots_create_task,
- self.objstore, params)
+ params)
return self.task_lookup(taskid)
def _vmsnapshots_create_task(self, cb, params):
diff --git a/model/storagepools.py b/model/storagepools.py
index a2dbaec..95e3858 100644
--- a/model/storagepools.py
+++ b/model/storagepools.py
@@ -21,9 +21,10 @@ import libvirt
import lxml.etree as ET
from lxml.builder import E
+from wok.asynctask import add_task
from wok.exception import InvalidOperation, MissingParameter
from wok.exception import NotFoundError, OperationFailed
-from wok.utils import add_task, run_command, wok_log
+from wok.utils import run_command, wok_log
from wok.xmlutils.utils import xpath_get_text
from wok.plugins.kimchi.config import config, get_kimchi_version, kimchiPaths
@@ -253,7 +254,7 @@ class StoragePoolsModel(object):
params['path'] = self.scanner.scan_dir_prepare(params['name'])
scan_params['pool_path'] = params['path']
task_id = add_task('/plugins/kimchi/storagepools/%s' % ISO_POOL_NAME,
- self.scanner.start_scan, self.objstore, scan_params)
+ self.scanner.start_scan, scan_params)
# Record scanning-task/storagepool mapping for future querying
try:
with self.objstore as session:
diff --git a/model/storagevolumes.py b/model/storagevolumes.py
index 7b2272b..958af3e 100644
--- a/model/storagevolumes.py
+++ b/model/storagevolumes.py
@@ -28,9 +28,10 @@ import time
import urllib2
from lxml.builder import E
+from wok.asynctask import add_task
from wok.exception import InvalidOperation, InvalidParameter, IsoFormatError
from wok.exception import MissingParameter, NotFoundError, OperationFailed
-from wok.utils import add_task, get_unique_file_name
+from wok.utils import get_unique_file_name
from wok.utils import probe_file_permission_as_user, wok_log
from wok.xmlutils.utils import xpath_get_text
from wok.model.tasks import TaskModel
@@ -124,7 +125,7 @@ class StorageVolumesModel(object):
params['pool'] = pool_name
targeturi = '/plugins/kimchi/storagepools/%s/storagevolumes/%s' \
% (pool_name, name)
- taskid = add_task(targeturi, create_func, self.objstore, params)
+ taskid = add_task(targeturi, create_func, params)
return self.task.lookup(taskid)
def _create_volume_with_capacity(self, cb, params):
@@ -442,7 +443,7 @@ class StorageVolumeModel(object):
'new_name': new_name}
target_uri = u'/plugins/kimchi/storagepools/%s/storagevolumes/%s/clone'
taskid = add_task(target_uri % (pool, new_name), self._clone_task,
- self.objstore, params)
+ params)
return self.task.lookup(taskid)
def _clone_task(self, cb, params):
diff --git a/model/vmhostdevs.py b/model/vmhostdevs.py
index ef39de3..c92decd 100644
--- a/model/vmhostdevs.py
+++ b/model/vmhostdevs.py
@@ -26,12 +26,13 @@ from lxml import etree, objectify
from lxml.builder import E, ElementMaker
from operator import itemgetter
+from wok.asynctask import add_task
from wok.exception import InvalidOperation, InvalidParameter, NotFoundError
from wok.exception import OperationFailed
from wok.message import WokMessage
from wok.model.tasks import TaskModel
from wok.rollbackcontext import RollbackContext
-from wok.utils import add_task, run_command, wok_log
+from wok.utils import run_command, wok_log
from wok.plugins.kimchi.model.config import CapabilitiesModel
from wok.plugins.kimchi.model.host import DeviceModel, DevicesModel
@@ -94,7 +95,7 @@ class VMHostDevsModel(object):
if dev_info['device_type'] == 'pci':
taskid = add_task(u'/plugins/kimchi/vms/%s/hostdevs/' %
VMModel.get_vm(vmid, self.conn).name(),
- self._attach_pci_device, self.objstore,
+ self._attach_pci_device,
{'vmid': vmid, 'dev_info': dev_info,
'lock': threading.RLock()})
return self.task.lookup(taskid)
@@ -113,8 +114,8 @@ class VMHostDevsModel(object):
taskid = add_task(u'/plugins/kimchi/vms/%s/hostdevs/' %
VMModel.get_vm(vmid, self.conn).name(),
'_attach_%s_device' % dev_info['device_type'],
- self.objstore, {'vmid': vmid, 'dev_info':
dev_info,
- 'lock': threading.RLock()})
+ {'vmid': vmid, 'dev_info': dev_info,
+ 'lock': threading.RLock()})
return self.task.lookup(taskid)
@@ -604,8 +605,7 @@ class VMHostDevModel(object):
'lock': threading.RLock()}
task_uri = u'/plugins/kimchi/vms/%s/hostdevs/%s' % \
(VMModel.get_vm(vmid, self.conn).name(), dev_name)
- taskid = add_task(task_uri, self._detach_device, self.objstore,
- task_params)
+ taskid = add_task(task_uri, self._detach_device, task_params)
return self.task.lookup(taskid)
def _event_devices(self, conn, dom, alias, opaque):
diff --git a/model/vms.py b/model/vms.py
index 3380278..518378f 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -34,12 +34,13 @@ from lxml import etree, objectify
from lxml.builder import E
from xml.etree import ElementTree
+from wok.asynctask import add_task
from wok.config import config
from wok.exception import InvalidOperation, InvalidParameter
from wok.exception import NotFoundError, OperationFailed
from wok.model.tasks import TaskModel
from wok.rollbackcontext import RollbackContext
-from wok.utils import add_task, convert_data_size
+from wok.utils import convert_data_size
from wok.utils import import_class, run_setfacl_set_attr, run_command, wok_log
from wok.xmlutils.utils import dictize, xpath_get_text, xml_item_insert
from wok.xmlutils.utils import xml_item_remove, xml_item_update
@@ -145,7 +146,7 @@ class VMsModel(object):
"title": params.get("title", ""),
"description": params.get("description",
"")}
taskid = add_task(u'/plugins/kimchi/vms/%s' % name, self._create_task,
- self.objstore, data)
+ data)
return self.task.lookup(taskid)
@@ -350,8 +351,8 @@ class VMModel(object):
# create a task with the actual clone function
taskid = add_task(u'/plugins/kimchi/vms/%s/clone' % new_name,
- self._clone_task, self.objstore,
- {'name': name, 'new_name': new_name})
+ self._clone_task, {'name': name,
+ 'new_name': new_name})
return self.task.lookup(taskid)
@@ -1899,8 +1900,7 @@ class VMModel(object):
'remote_host': remote_host,
'user': user}
task_id = add_task('/plugins/kimchi/vms/%s/migrate' % name,
- self._migrate_task,
- self.objstore, params)
+ self._migrate_task, params)
return self.task.lookup(task_id)
diff --git a/model/vmsnapshots.py b/model/vmsnapshots.py
index 6f2483c..520623e 100644
--- a/model/vmsnapshots.py
+++ b/model/vmsnapshots.py
@@ -23,8 +23,8 @@ import time
from lxml import objectify
from lxml.builder import E
+from wok.asynctask import add_task
from wok.exception import InvalidOperation, NotFoundError, OperationFailed
-from wok.utils import add_task
from wok.xmlutils.utils import xpath_get_text
from wok.model.tasks import TaskModel
@@ -75,7 +75,7 @@ class VMSnapshotsModel(object):
task_params = {'vm_name': vm_name, 'name': name}
taskid = add_task(u'/plugins/kimchi/vms/%s/snapshots/%s' % (vm_name,
- name), self._create_task, self.objstore, task_params)
+ name), self._create_task, task_params)
return self.task.lookup(taskid)
def _create_task(self, cb, params):
diff --git a/tests/test_model.py b/tests/test_model.py
index e77d4fd..0a5d343 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -36,12 +36,13 @@ from mock import call, mock_open, patch
import tests.utils as utils
import wok.objectstore
+from wok.asynctask import add_task
from wok.basemodel import Singleton
from wok.config import config
from wok.exception import InvalidOperation
from wok.exception import InvalidParameter, NotFoundError, OperationFailed
from wok.rollbackcontext import RollbackContext
-from wok.utils import add_task, convert_data_size, get_task_id
+from wok.utils import convert_data_size, get_task_id
from wok.xmlutils.utils import xpath_get_text
from wok.plugins.gingerbase import netinfo
@@ -1401,15 +1402,14 @@ class ModelTests(unittest.TestCase):
inst = model.Model('test:///default',
objstore_loc=self.tmp_store)
- taskid = add_task('', quick_op, inst.objstore, 'Hello')
+ taskid = add_task('', quick_op, 'Hello')
inst.task_wait(taskid)
self.assertEquals(get_task_id(), taskid)
self.assertEquals('finished',
inst.task_lookup(taskid)['status'])
self.assertEquals('Hello', inst.task_lookup(taskid)['message'])
- taskid = add_task('', long_op, inst.objstore,
- {'delay': 3, 'result': False,
- 'message': 'It was not meant to be'})
+ taskid = add_task('', long_op, {'delay': 3, 'result':
False,
+ 'message': 'It was not meant to
be'})
self.assertEquals(get_task_id(), taskid)
self.assertEquals('running', inst.task_lookup(taskid)['status'])
self.assertEquals('OK', inst.task_lookup(taskid)['message'])
@@ -1417,14 +1417,13 @@ class ModelTests(unittest.TestCase):
self.assertEquals('failed', inst.task_lookup(taskid)['status'])
self.assertEquals('It was not meant to be',
inst.task_lookup(taskid)['message'])
- taskid = add_task('', abnormal_op, inst.objstore, {})
+ taskid = add_task('', abnormal_op, {})
inst.task_wait(taskid)
self.assertEquals('Exception raised',
inst.task_lookup(taskid)['message'])
self.assertEquals('failed', inst.task_lookup(taskid)['status'])
- taskid = add_task('', continuous_ops, inst.objstore,
- {'result': True})
+ taskid = add_task('', continuous_ops, {'result': True})
self.assertEquals('running', inst.task_lookup(taskid)['status'])
inst.task_wait(taskid, timeout=10)
self.assertEquals('finished',
inst.task_lookup(taskid)['status'])
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 80596c2..483e5ff 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -30,8 +30,8 @@ from functools import partial
from tests.utils import get_free_port, patch_auth, request
from tests.utils import run_server, wait_task
+from wok.asynctask import add_task
from wok.rollbackcontext import RollbackContext
-from wok.utils import add_task
from wok.plugins.kimchi import mockmodel
from wok.plugins.kimchi.osinfo import get_template_default
@@ -1305,12 +1305,9 @@ class RestTests(unittest.TestCase):
)
def test_tasks(self):
- id1 = add_task('/plugins/kimchi/tasks/1', self._async_op,
- model.objstore)
- id2 = add_task('/plugins/kimchi/tasks/2', self._except_op,
- model.objstore)
- id3 = add_task('/plugins/kimchi/tasks/3', self._intermid_op,
- model.objstore)
+ id1 = add_task('/plugins/kimchi/tasks/1', self._async_op)
+ id2 = add_task('/plugins/kimchi/tasks/2', self._except_op)
+ id3 = add_task('/plugins/kimchi/tasks/3', self._intermid_op)
target_uri = urllib2.quote('^/plugins/kimchi/tasks/*',
safe="")
filter_data = 'status=running&target_uri=%s' % target_uri
--
2.7.4