mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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>
This commit is contained in:
1 parent
e9bca537ab
commit
77442ed1d3
4 files changed
+58
-9
No files matched your search
@@ -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)
|
||||
|
||||
#
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||