diff options
author | Ewan Mellor <ewan@xensource.com> | 2007-01-30 16:09:16 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2007-01-30 16:09:16 +0000 |
commit | 77442ed1d3615d15b9cb2841e4510915d7eaee1c (patch) | |
tree | 5ba01a898040fc54a39b92468e0b0fdd67b86e87 /tools | |
parent | e9bca537abf526a0a85c843a3407088b0cab28f8 (diff) | |
download | xen-77442ed1d3615d15b9cb2841e4510915d7eaee1c.tar.gz xen-77442ed1d3615d15b9cb2841e4510915d7eaee1c.tar.bz2 xen-77442ed1d3615d15b9cb2841e4510915d7eaee1c.zip |
Added task.session field.
Fix session.get_by_uuid and get_uuid, and remove session.get_all.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/xen/xend/XendAPI.py | 21 | ||||
-rw-r--r-- | tools/python/xen/xend/XendTask.py | 7 | ||||
-rw-r--r-- | tools/python/xen/xend/XendTaskManager.py | 6 |
3 files changed, 25 insertions, 9 deletions
diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 1854f4aa19..7de21ad4d9 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -396,6 +396,9 @@ class XendAPI(object): # all get_by_uuid() methods. for api_cls in classes.keys(): + if api_cls == 'session': + continue + get_by_uuid = '%s_get_by_uuid' % api_cls get_uuid = '%s_get_uuid' % api_cls def _get_by_uuid(_1, _2, ref): @@ -501,9 +504,13 @@ class XendAPI(object): 'this_host': XendNode.instance().uuid, 'this_user': auth_manager().get_user(session)} return xen_api_success(record) - def session_get_all(self): - return xen_api_error(XEND_ERROR_UNSUPPORTED) - + + def session_get_uuid(self, session): + return xen_api_success(session) + + def session_get_by_uuid(self, session): + return xen_api_success(session) + # attributes (ro) def session_get_this_host(self, session): return xen_api_success(XendNode.instance().uuid) @@ -530,6 +537,7 @@ class XendAPI(object): 'error_code', 'error_info', 'allowed_operations', + 'session' ] task_attr_rw = [] @@ -572,6 +580,10 @@ class XendAPI(object): def task_get_allowed_operations(self, session, task_ref): return xen_api_success({}) + def task_get_session(self, session, task_ref): + task = XendTaskManager.get_task(task_ref) + return xen_api_success(task.session) + def task_get_all(self, session): tasks = XendTaskManager.get_all_tasks() return xen_api_success(tasks) @@ -2057,7 +2069,8 @@ class XendAPIAsyncProxy: task_uuid = XendTaskManager.create_task(method, args, synchronous_method_name, return_type, - synchronous_method_name) + synchronous_method_name, + session) return xen_api_success(task_uuid) # diff --git a/tools/python/xen/xend/XendTask.py b/tools/python/xen/xend/XendTask.py index 92d5fdd732..0485c39207 100644 --- a/tools/python/xen/xend/XendTask.py +++ b/tools/python/xen/xend/XendTask.py @@ -45,8 +45,8 @@ class XendTask(threading.Thread): task_progress = {} task_progress_lock = threading.Lock() - def __init__(self, uuid, func, args, func_name, return_type = None, - label = None, desc = None): + def __init__(self, uuid, func, args, func_name, return_type, label, desc, + session): """ @param uuid: UUID of the task @type uuid: string @@ -82,6 +82,8 @@ class XendTask(threading.Thread): self.func = func self.args = args + self.session = session + def set_status(self, new_status): self.status_lock.acquire() try: @@ -145,6 +147,7 @@ class XendTask(threading.Thread): 'error_code': self.error_code, 'error_info': self.error_info, 'allowed_operations': {}, + 'session': self.session, } def get_progress(self): diff --git a/tools/python/xen/xend/XendTaskManager.py b/tools/python/xen/xend/XendTaskManager.py index ee5403c24a..6282078a44 100644 --- a/tools/python/xen/xend/XendTaskManager.py +++ b/tools/python/xen/xend/XendTaskManager.py @@ -32,7 +32,7 @@ import threading tasks = {} tasks_lock = threading.Lock() -def create_task(func, args, func_name, return_type = None, label = ''): +def create_task(func, args, func_name, return_type, label, session): """Creates a new Task and registers it with the XendTaskManager. @param func: callable object XMLRPC method @@ -48,8 +48,8 @@ def create_task(func, args, func_name, return_type = None, label = ''): task_uuid = uuid.createString() try: tasks_lock.acquire() - task = XendTask(task_uuid, func, args, func_name, - return_type = return_type, label = label) + task = XendTask(task_uuid, func, args, func_name, return_type, label, + '', session) tasks[task_uuid] = task finally: tasks_lock.release() |