[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add remove and list support. Also make all class methods "safe".



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 1a27091a1e7a5d6b73bf6bbf2d687fc6acc21412
# Parent  54af576824313c4eff97de59691dc4f825f88fd1
Add remove and list support.  Also make all class methods "safe".
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 54af57682431 -r 1a27091a1e7a 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Fri Sep  9 17:03:34 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Fri Sep  9 17:34:40 2005
@@ -88,40 +88,81 @@
         else:
             raise TypeError
 
+    def _remove(self, key):
+        path = "%s/%s" % (self.path, key)
+        return xshandle().rm(path)
+
+    def remove(self, *args):
+        if len(args) == 0:
+            raise TypeError
+        for key in args:
+            self._remove(key)
+
+    def _list(self, key):
+        path = "%s/%s" % (self.path, key)
+        return map(lambda x: key + "/" + x, xshandle().ls(path))
+
+    def list(self, *args):
+        if len(args) == 0:
+            raise TypeError
+        ret = []
+        for key in args:
+            ret.extend(self._list(key))
+        return ret
+
+
     def Read(cls, path, *args):
-        t = cls(path)
-        v = t.read(*args)
-        t.commit()
-        return v
-
-    Read = classmethod(Read)
-
-    def Write(cls, path, *args, **opts):
-        t = cls(path)
-        t.write(*args, **opts)
-        t.commit()
-
-    Write = classmethod(Write)
-
-    def SafeRead(cls, path, *args):
         while True:
             try:
-                return cls.Read(path, *args)
+                t = cls(path)
+                v = t.read(*args)
+                t.commit()
+                return v
             except RuntimeError, ex:
                 if ex.args[0] == errno.ETIMEDOUT:
                     pass
                 raise
 
-    SafeRead = classmethod(SafeRead)
+    Read = classmethod(Read)
 
-    def SafeWrite(cls, path, *args, **opts):
+    def Write(cls, path, *args, **opts):
         while True:
             try:
-                cls.Write(path, *args, **opts)
+                t = cls(path)
+                t.write(*args, **opts)
+                t.commit()
                 return
             except RuntimeError, ex:
                 if ex.args[0] == errno.ETIMEDOUT:
                     pass
                 raise
 
-    SafeWrite = classmethod(SafeWrite)
+    Write = classmethod(Write)
+
+    def Remove(cls, *args):
+        while True:
+            try:
+                t = cls(path)
+                t.remove(*args)
+                t.commit()
+                return
+            except RuntimeError, ex:
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                raise
+
+    Remove = classmethod(Remove)
+
+    def List(cls, path, *args):
+        while True:
+            try:
+                t = cls(path)
+                v = t.list(*args)
+                t.commit()
+                return v
+            except RuntimeError, ex:
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                raise
+
+    List = classmethod(List)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.