Federico Simoncelli has uploaded a new change for review.
Change subject: task: support task id in client request
......................................................................
task: support task id in client request
Change-Id: Ib5034e6c3466d5a663699d4f924975b7e067c768
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/BindingXMLRPC.py
M vdsm/clientIF.py
M vdsm/storage/dispatcher.py
3 files changed, 16 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/26809/1
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 76251f5..d449088 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -98,6 +98,7 @@
Create xml-rpc server over http or https.
"""
HTTP_HEADER_FLOWID = "FlowID"
+ HTTP_HEADER_TASKID = "TaskID"
threadLocal = self.cif.threadLocal
@@ -200,6 +201,7 @@
def parse_request(self):
r = basehandler.parse_request(self)
threadLocal.flowID = self.headers.get(HTTP_HEADER_FLOWID)
+ threadLocal.taskID = self.headers.get(HTTP_HEADER_TASKID)
return r
def finish(self):
@@ -207,6 +209,7 @@
threadLocal.client = None
threadLocal.server = None
threadLocal.flowID = None
+ threadLocal.taskID = None
if sys.version_info[:2] == (2, 6):
# Override BaseHTTPServer.BaseRequestHandler implementation to
@@ -246,6 +249,10 @@
fmt += " flowID [%s]"
logargs.append(self.cif.threadLocal.flowID)
+ if getattr(self.cif.threadLocal, 'taskID', None) is not None:
+ fmt += " taskID [%s]"
+ logargs.append(self.cif.threadLocal.taskID)
+
self.log.debug(fmt, *logargs)
try:
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index eac7950..21e3c71 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -99,6 +99,7 @@
self.channelListener.start()
self.threadLocal = threading.local()
self.threadLocal.client = ''
+ self.irs.setClientThreadLocal(self.threadLocal)
except:
self.log.error('failed to init clientIF, '
'shutting down storage dispatcher')
diff --git a/vdsm/storage/dispatcher.py b/vdsm/storage/dispatcher.py
index 6586492..3e2bf0a 100644
--- a/vdsm/storage/dispatcher.py
+++ b/vdsm/storage/dispatcher.py
@@ -45,10 +45,14 @@
self.storage_repository = config.get('irs', 'repository')
self._exposeFunctions(obj)
self.log.info("Starting StorageDispatcher...")
+ self._clientThreadLocal = None
@property
def ready(self):
return getattr(self._obj, 'ready', True)
+
+ def setClientThreadLocal(self, clientThreadLocal):
+ self._clientThreadLocal = clientThreadLocal
def _exposeFunctions(self, obj):
for funcName in dir(obj):
@@ -66,7 +70,10 @@
@wraps(func)
def wrapper(*args, **kwargs):
try:
- ctask = task.Task(id=None, name=name)
+ ctaskid = getattr(self._clientThreadLocal, 'taskID', None)
+ if ctaskid is not None:
+ self.log.info('using client requested taskID %s', ctaskid)
+ ctask = task.Task(id=ctaskid, name=name)
try:
response = self.STATUS_OK.copy()
result = ctask.prepare(func, *args, **kwargs)
--
To view, visit
http://gerrit.ovirt.org/26809
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5034e6c3466d5a663699d4f924975b7e067c768
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>