Change in vdsm[master]: enable task tag as list of strings

barumuga at redhat.com barumuga at redhat.com
Mon Oct 29 13:17:45 UTC 2012


Hello Ayal Baron, Timothy Asir, Saggi Mizrahi, Federico Simoncelli, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/8899

to review the following change.

Change subject: enable task tag as list of strings
......................................................................

enable task tag as list of strings

Multiple tags are stored as space-separated string and search is done
an in-string search instead of a proper set membership.  This approach
enables tag as list of strings and supports backward compatibility

Change-Id: Ib3c6f8cba17df7f545049eabe2b8f38318c5db7f
Signed-off-by: Bala.FA <barumuga at redhat.com>
---
M vdsm/storage/task.py
1 file changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/8899/1

diff --git a/vdsm/storage/task.py b/vdsm/storage/task.py
index a596494..6c79c85 100644
--- a/vdsm/storage/task.py
+++ b/vdsm/storage/task.py
@@ -49,6 +49,7 @@
 import logging
 import threading
 import types
+import ast
 
 import storage_exception as se
 import uuid
@@ -411,13 +412,22 @@
     high = "high"
 
 
+class TagList(list):
+    def __init__(self, s):
+        if s.startswith('[') and s.endswith(']'):
+            l = ast.literal_eval(s)
+        else:
+            l = s.split(' ')
+        list.__init__(self, l)
+
+
 class Task:
     # External Task info
     fields = {
         # field_name: type
         "id": str,
         "name": unicode,
-        "tag": unicode,
+        "tag": TagList,
         "store": unicode,
         "recoveryPolicy": TaskRecoveryType,
         "persistPolicy": TaskPersistType,
@@ -448,7 +458,7 @@
         self.callbackLock = threading.Lock()
         self.id = str(id)
         self.name = name
-        self.tag = tag
+        self.tag = TagList(tag)
         self.priority = priority
         self.recoveryPolicy = recovery
         self.persistPolicy = TaskPersistType.none
@@ -972,7 +982,7 @@
     def setTag(self, tag):
         if KEY_SEPERATOR in tag:
             raise ValueError("tag cannot include %s character" % KEY_SEPERATOR)
-        self.tag = unicode(tag)
+        self.tag = TagList(unicode(tag))
 
     def isDone(self):
         return self.state.isDone()
@@ -1257,7 +1267,7 @@
             "code": self.result.code,
             "message": self.result.message,
             "result": self.result.result,
-            "tag": self.tag
+            "tag": str(self.tag)
         }
 
     def getID(self):


--
To view, visit http://gerrit.ovirt.org/8899
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3c6f8cba17df7f545049eabe2b8f38318c5db7f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Bala.FA <barumuga at redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Timothy Asir <tjeyasin at redhat.com>


More information about the vdsm-patches mailing list