From a914d49745ea205b705ff7b07c47b7239072642b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 4 Dec 2007 10:41:55 +0000 Subject: [PATCH] xend: Implement get_by_name_label for class XendNetwork 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 --- tools/python/xen/xend/XendNetwork.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/python/xen/xend/XendNetwork.py b/tools/python/xen/xend/XendNetwork.py index 1858fbfbb0..d04584d3ad 100644 --- a/tools/python/xen/xend/XendNetwork.py +++ b/tools/python/xen/xend/XendNetwork.py @@ -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) -- 2.39.5