debuggers.hg
changeset 13764:300c47bec138
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>
Fix session.get_by_uuid and get_uuid, and remove session.get_all.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Tue Jan 30 16:09:16 2007 +0000 (2007-01-30) |
parents | 0803bdfdd9c5 |
children | bd69e83b65ea |
files | docs/xen-api/xenapi-datamodel.tex tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendTask.py tools/python/xen/xend/XendTaskManager.py |
line diff
1.1 --- a/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 15:57:58 2007 +0000 1.2 +++ b/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 16:09:16 2007 +0000 1.3 @@ -495,6 +495,7 @@ Quals & Field & Type & Description \\ 1.4 $\mathit{RO}_\mathit{run}$ & {\tt name/label} & string & a human-readable name \\ 1.5 $\mathit{RO}_\mathit{run}$ & {\tt name/description} & string & a notes field containg human-readable description \\ 1.6 $\mathit{RO}_\mathit{run}$ & {\tt status} & task\_status\_type & current status of the task \\ 1.7 +$\mathit{RO}_\mathit{run}$ & {\tt session} & session ref & the session that created the task \\ 1.8 $\mathit{RO}_\mathit{run}$ & {\tt progress} & int & if the task is still pending, this field contains the estimated percentage complete (0-100). If task has completed (successfully or unsuccessfully) this should be 100. \\ 1.9 $\mathit{RO}_\mathit{run}$ & {\tt type} & string & if the task has completed successfully, this field contains the type of the encoded result (i.e. name of the class whose reference is in the result field). Undefined otherwise. \\ 1.10 $\mathit{RO}_\mathit{run}$ & {\tt result} & string & if the task has completed successfully, this field contains the result value (either Void or an object reference). Undefined otherwise. \\ 1.11 @@ -691,6 +692,38 @@ value of the field 1.12 \vspace{0.3cm} 1.13 \vspace{0.3cm} 1.14 \vspace{0.3cm} 1.15 +\subsubsection{RPC name:~get\_session} 1.16 + 1.17 +{\bf Overview:} 1.18 +Get the session field of the given task. 1.19 + 1.20 + \noindent {\bf Signature:} 1.21 +\begin{verbatim} (session ref) get_session (session_id s, task ref self)\end{verbatim} 1.22 + 1.23 + 1.24 +\noindent{\bf Arguments:} 1.25 + 1.26 + 1.27 +\vspace{0.3cm} 1.28 +\begin{tabular}{|c|c|p{7cm}|} 1.29 + \hline 1.30 +{\bf type} & {\bf name} & {\bf description} \\ \hline 1.31 +{\tt task ref } & self & reference to the object \\ \hline 1.32 + 1.33 +\end{tabular} 1.34 + 1.35 +\vspace{0.3cm} 1.36 + 1.37 + \noindent {\bf Return Type:} 1.38 +{\tt 1.39 +session ref 1.40 +} 1.41 + 1.42 + 1.43 +value of the field 1.44 +\vspace{0.3cm} 1.45 +\vspace{0.3cm} 1.46 +\vspace{0.3cm} 1.47 \subsubsection{RPC name:~get\_progress} 1.48 1.49 {\bf Overview:}
2.1 --- a/tools/python/xen/xend/XendAPI.py Tue Jan 30 15:57:58 2007 +0000 2.2 +++ b/tools/python/xen/xend/XendAPI.py Tue Jan 30 16:09:16 2007 +0000 2.3 @@ -396,6 +396,9 @@ class XendAPI(object): 2.4 # all get_by_uuid() methods. 2.5 2.6 for api_cls in classes.keys(): 2.7 + if api_cls == 'session': 2.8 + continue 2.9 + 2.10 get_by_uuid = '%s_get_by_uuid' % api_cls 2.11 get_uuid = '%s_get_uuid' % api_cls 2.12 def _get_by_uuid(_1, _2, ref): 2.13 @@ -501,9 +504,13 @@ class XendAPI(object): 2.14 'this_host': XendNode.instance().uuid, 2.15 'this_user': auth_manager().get_user(session)} 2.16 return xen_api_success(record) 2.17 - def session_get_all(self): 2.18 - return xen_api_error(XEND_ERROR_UNSUPPORTED) 2.19 - 2.20 + 2.21 + def session_get_uuid(self, session): 2.22 + return xen_api_success(session) 2.23 + 2.24 + def session_get_by_uuid(self, session): 2.25 + return xen_api_success(session) 2.26 + 2.27 # attributes (ro) 2.28 def session_get_this_host(self, session): 2.29 return xen_api_success(XendNode.instance().uuid) 2.30 @@ -530,6 +537,7 @@ class XendAPI(object): 2.31 'error_code', 2.32 'error_info', 2.33 'allowed_operations', 2.34 + 'session' 2.35 ] 2.36 2.37 task_attr_rw = [] 2.38 @@ -572,6 +580,10 @@ class XendAPI(object): 2.39 def task_get_allowed_operations(self, session, task_ref): 2.40 return xen_api_success({}) 2.41 2.42 + def task_get_session(self, session, task_ref): 2.43 + task = XendTaskManager.get_task(task_ref) 2.44 + return xen_api_success(task.session) 2.45 + 2.46 def task_get_all(self, session): 2.47 tasks = XendTaskManager.get_all_tasks() 2.48 return xen_api_success(tasks) 2.49 @@ -2057,7 +2069,8 @@ class XendAPIAsyncProxy: 2.50 task_uuid = XendTaskManager.create_task(method, args, 2.51 synchronous_method_name, 2.52 return_type, 2.53 - synchronous_method_name) 2.54 + synchronous_method_name, 2.55 + session) 2.56 return xen_api_success(task_uuid) 2.57 2.58 #
3.1 --- a/tools/python/xen/xend/XendTask.py Tue Jan 30 15:57:58 2007 +0000 3.2 +++ b/tools/python/xen/xend/XendTask.py Tue Jan 30 16:09:16 2007 +0000 3.3 @@ -45,8 +45,8 @@ class XendTask(threading.Thread): 3.4 task_progress = {} 3.5 task_progress_lock = threading.Lock() 3.6 3.7 - def __init__(self, uuid, func, args, func_name, return_type = None, 3.8 - label = None, desc = None): 3.9 + def __init__(self, uuid, func, args, func_name, return_type, label, desc, 3.10 + session): 3.11 """ 3.12 @param uuid: UUID of the task 3.13 @type uuid: string 3.14 @@ -82,6 +82,8 @@ class XendTask(threading.Thread): 3.15 self.func = func 3.16 self.args = args 3.17 3.18 + self.session = session 3.19 + 3.20 def set_status(self, new_status): 3.21 self.status_lock.acquire() 3.22 try: 3.23 @@ -145,6 +147,7 @@ class XendTask(threading.Thread): 3.24 'error_code': self.error_code, 3.25 'error_info': self.error_info, 3.26 'allowed_operations': {}, 3.27 + 'session': self.session, 3.28 } 3.29 3.30 def get_progress(self):
4.1 --- a/tools/python/xen/xend/XendTaskManager.py Tue Jan 30 15:57:58 2007 +0000 4.2 +++ b/tools/python/xen/xend/XendTaskManager.py Tue Jan 30 16:09:16 2007 +0000 4.3 @@ -32,7 +32,7 @@ import threading 4.4 tasks = {} 4.5 tasks_lock = threading.Lock() 4.6 4.7 -def create_task(func, args, func_name, return_type = None, label = ''): 4.8 +def create_task(func, args, func_name, return_type, label, session): 4.9 """Creates a new Task and registers it with the XendTaskManager. 4.10 4.11 @param func: callable object XMLRPC method 4.12 @@ -48,8 +48,8 @@ def create_task(func, args, func_name, r 4.13 task_uuid = uuid.createString() 4.14 try: 4.15 tasks_lock.acquire() 4.16 - task = XendTask(task_uuid, func, args, func_name, 4.17 - return_type = return_type, label = label) 4.18 + task = XendTask(task_uuid, func, args, func_name, return_type, label, 4.19 + '', session) 4.20 tasks[task_uuid] = task 4.21 finally: 4.22 tasks_lock.release()