WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Added task.session field.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Added task.session field.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 Jan 2007 07:05:25 -0800
Delivery-date: Wed, 31 Jan 2007 08:14:53 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1170173356 0
# Node ID 300c47bec138704d4753675f293b76ebb702da82
# Parent  0803bdfdd9c566ff14c9b88759ce5dd46d334aa8
Added task.session field.

Fix session.get_by_uuid and get_uuid, and remove session.get_all.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 docs/xen-api/xenapi-datamodel.tex        |   33 +++++++++++++++++++++++++++++++
 tools/python/xen/xend/XendAPI.py         |   21 +++++++++++++++----
 tools/python/xen/xend/XendTask.py        |    7 ++++--
 tools/python/xen/xend/XendTaskManager.py |    6 ++---
 4 files changed, 58 insertions(+), 9 deletions(-)

diff -r 0803bdfdd9c5 -r 300c47bec138 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 15:57:58 2007 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Jan 30 16:09:16 2007 +0000
@@ -495,6 +495,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt name/label} & string & a human-readable 
name \\
 $\mathit{RO}_\mathit{run}$ &  {\tt name/description} & string & a notes field 
containg human-readable description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status} & task\_status\_type & current 
status of the task \\
+$\mathit{RO}_\mathit{run}$ &  {\tt session} & session ref & the session that 
created the task \\
 $\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. \\
 $\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. \\
 $\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. \\
@@ -684,6 +685,38 @@ Get the status field of the given task.
  \noindent {\bf Return Type:} 
 {\tt 
 task\_status\_type
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_session}
+
+{\bf Overview:} 
+Get the session field of the given task.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (session ref) get_session (session_id s, task ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt task ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+session ref
 }
 
 
diff -r 0803bdfdd9c5 -r 300c47bec138 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Jan 30 15:57:58 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Tue Jan 30 16:09:16 2007 +0000
@@ -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 = []
@@ -571,6 +579,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()
@@ -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 -r 0803bdfdd9c5 -r 300c47bec138 tools/python/xen/xend/XendTask.py
--- a/tools/python/xen/xend/XendTask.py Tue Jan 30 15:57:58 2007 +0000
+++ b/tools/python/xen/xend/XendTask.py Tue Jan 30 16:09:16 2007 +0000
@@ -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
@@ -81,6 +81,8 @@ class XendTask(threading.Thread):
         self.func_name = func_name 
         self.func = func
         self.args = args
+
+        self.session = session
 
     def set_status(self, new_status):
         self.status_lock.acquire()
@@ -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 -r 0803bdfdd9c5 -r 300c47bec138 tools/python/xen/xend/XendTaskManager.py
--- a/tools/python/xen/xend/XendTaskManager.py  Tue Jan 30 15:57:58 2007 +0000
+++ b/tools/python/xen/xend/XendTaskManager.py  Tue Jan 30 16:09:16 2007 +0000
@@ -32,7 +32,7 @@ tasks = {}
 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, r
     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()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Added task.session field., Xen patchbot-unstable <=