xend: Implement get_by_name_label for class XendNetwork
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 4 Dec 2007 10:41:55 +0000 (10:41 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 4 Dec 2007 10:41:55 +0000 (10:41 +0000)
Although XenAPI c-bindings support this operation on Network class,
there is no implementation in xend.  This patch provides one.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
tools/python/xen/xend/XendNetwork.py

index 1858fbfbb0d881c4be777293510ab3ce25a29bfe..d04584d3adf2d5d2c4c334aeb7d52a7e2ff81a54 100644 (file)
@@ -65,7 +65,7 @@ class XendNetwork(XendBase):
         return XendBase.getMethods() + methods
 
     def getFuncs(self):
-        funcs = ['create']
+        funcs = ['create', 'get_by_name_label']
         return XendBase.getFuncs() + funcs
 
     getClass    = classmethod(getClass)
@@ -133,9 +133,15 @@ class XendNetwork(XendBase):
 
         return uuid
 
-    create_phy  = classmethod(create_phy)
-    recreate    = classmethod(recreate)
-    create      = classmethod(create)
+    def get_by_name_label(cls, name):
+        return [inst.get_uuid()
+                 for inst in XendAPIStore.get_all(cls.getClass())
+                 if inst.get_name_label() == name]
+    
+    create_phy        = classmethod(create_phy)
+    recreate          = classmethod(recreate)
+    create            = classmethod(create)
+    get_by_name_label = classmethod(get_by_name_label)
         
     def __init__(self, record, uuid):       
         XendBase.__init__(self, uuid, record)