Fix get_dev_property_by_uuid
PATCH 1/1 Fix get_dev_property_by_uuid
This patch replaces calls to get_dev_property() by calls to get_dev_property_by_uuid() in XenAPI.py and fixes the implementation of get_dev_property_by_uuid.
I am adding a test case to the xapi grouptests to verify the fixes. There's a FIXME note in the test case which should be looked at.
xen-unstable.hg/tools/python/xen/xend/XendAPI.py +13 -9
@@ -1149,23 +1149,26 @@ class XendAPI: # attributes (rw) def VBD_get_VM(self, session, vbd_ref): xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, 'VM')) + return xen_api_success(xendom.get_dev_property_by_uuid('vbd', + vbd_ref, 'VM')) def VBD_get_VDI(self, session, vbd_ref): - return xen_api_todo() + xendom = XendDomain.instance() + return xen_api_success(xendom.get_dev_property_by_uuid('vbd', + vbd_ref, 'VDI')) def VBD_get_device(self, session, vbd_ref): xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, - 'device')) + return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref, + 'device')) def VBD_get_mode(self, session, vbd_ref): xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, - 'mode')) + return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref, + 'mode')) def VBD_get_driver(self, session, vbd_ref): xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, - 'driver')) + return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref, + 'driver')) # Xen API: Class VIF # ----------------------------------------------------------------
@@ -1409,7 +1412,8 @@ class XendAPI: def VTPM_get_VM(self, session, vtpm_ref): xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vtpm', vtpm_ref, 'VM')) + return xen_api_success(xendom.get_dev_property_by_uuid('vtpm', + vtpm_ref, 'VM')) # class methods def VTPM_create(self, session, vtpm_struct):
xen-unstable.hg/tools/python/xen/xend/XendDomain.py +6 -6
@@ -640,18 +640,18 @@ class XendDomain: self.domains_lock.release() def get_dev_property_by_uuid(self, klass, dev_uuid, field): + value = None self.domains_lock.acquire() try: dom = self.get_vm_with_dev_uuid(klass, dev_uuid) - if not dom: - return None - - value = dom.get_device_property(klass, dev_uuid, field) - return value + if dom: + value = dom.get_dev_property(klass, dev_uuid, field) except ValueError, e: pass + + self.domains_lock.release() - return None + return value def is_valid_vm(self, vm_ref): return (self.get_vm_by_uuid(vm_ref) != None)
xen-unstable.hg/tools/xm-test/tests/xapi/Makefile.am +2 -1
@@ -1,6 +1,7 @@ SUBDIRS = -TESTS = 01_xapi-vm_basic.test +TESTS = 01_xapi-vm_basic.test \ + 02_xapi-vbd_basic.test XFAIL_TESTS =
xen-unstable.hg/tools/xm-test/tests/xapi/02_xapi-vbd_basic.py new file +129 -0
129 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Alastair Tse
AppliedQuoted 8 lines · Stefan Berger
This patch replaces calls to
get_dev_property()by calls toget_dev_property_by_uuid()inXenAPI.pyand fixes the implementation ofget_dev_property_by_uuid.
I am adding a test case to the xapi grouptests to verify the fixes. There's a FIXME note in the test case which should be looked at.Signed-off-by Stefan Berger <[email protected]>
Applied.
Thanks,
Alastair