[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Fix xmlrpclib2's stringify to cope with floats and longs, removing the need
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Date 1167323447 0 # Node ID bfa793180cb9b44aec6d6650127b81dda36d2f4b # Parent e2392741cb9179f5dc436403a444467ce76e57e0 Fix xmlrpclib2's stringify to cope with floats and longs, removing the need for explicit type conversions in XendAPI. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/python/xen/util/xmlrpclib2.py | 8 +++++--- tools/python/xen/xend/XendAPI.py | 20 ++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff -r e2392741cb91 -r bfa793180cb9 tools/python/xen/util/xmlrpclib2.py --- a/tools/python/xen/util/xmlrpclib2.py Thu Dec 28 16:14:48 2006 +0000 +++ b/tools/python/xen/util/xmlrpclib2.py Thu Dec 28 16:30:47 2006 +0000 @@ -50,13 +50,15 @@ except ImportError: def stringify(value): - if isinstance(value, IntType) and not isinstance(value, BooleanType): + if isinstance(value, float) or \ + isinstance(value, long) or \ + (isinstance(value, int) and not isinstance(value, bool)): return str(value) - elif isinstance(value, DictType): + elif isinstance(value, dict): for k, v in value.items(): value[k] = stringify(v) return value - elif isinstance(value, (TupleType, ListType)): + elif isinstance(value, (tuple, list)): return [stringify(v) for v in value] else: return value diff -r e2392741cb91 -r bfa793180cb9 tools/python/xen/xend/XendAPI.py --- a/tools/python/xen/xend/XendAPI.py Thu Dec 28 16:14:48 2006 +0000 +++ b/tools/python/xen/xend/XendAPI.py Thu Dec 28 16:30:47 2006 +0000 @@ -1112,7 +1112,7 @@ class XendAPI: return_cfg = {} for k in cfg.keys(): if k in valid_vbd_keys: - return_cfg[k] = str(cfg[k]) + return_cfg[k] = cfg[k] return xen_api_success(return_cfg) @@ -1198,7 +1198,7 @@ class XendAPI: return_cfg = {} for k in cfg.keys(): if k in valid_vif_keys: - return_cfg[k] = str(cfg[k]) + return_cfg[k] = cfg[k] return xen_api_success(return_cfg) @@ -1490,27 +1490,23 @@ class XendAPI: # Attribute acceess - def _get_SR_func(self, _, func, conv = None): - result = getattr(XendNode.instance().get_sr(), func)() - if conv: - result = conv(result) - return xen_api_success(result) + def _get_SR_func(self, _, func): + return xen_api_success(getattr(XendNode.instance().get_sr(), func)()) def _get_SR_attr(self, _, attr): - return xen_api_success(str(getattr(XendNode.instance().get_sr(), - attr))) + return xen_api_success(getattr(XendNode.instance().get_sr(), attr)) def SR_get_VDIs(self, _, ref): return self._get_SR_func(ref, 'list_images') def SR_get_virtual_allocation(self, _, ref): - return self._get_SR_func(ref, 'virtual_allocation', str) + return self._get_SR_func(ref, 'virtual_allocation') def SR_get_physical_utilisation(self, _, ref): - return self._get_SR_func(ref, 'used_space_bytes', str) + return self._get_SR_func(ref, 'used_space_bytes') def SR_get_physical_size(self, _, ref): - return self._get_SR_func(ref, 'total_space_bytes', str) + return self._get_SR_func(ref, 'total_space_bytes') def SR_get_type(self, _, ref): return self._get_SR_attr(ref, 'type') _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |