[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Add *.get_all_records to XenAPI, make use of this for xm list
# HG changeset patch # User Tom Wilkie <tom.wilkie@xxxxxxxxx> # Date 1176760692 -3600 # Node ID 338820b7ea4588c743df9524fc863644957886c0 # Parent 4538426ae5fd9abc6e1f160a567ce56548e62066 Add *.get_all_records to XenAPI, make use of this for xm list signed-off-by: Tom Wilkie <tom.wilkie@xxxxxxxxx> --- tools/python/xen/xend/XendAPI.py | 14 ++++++++++++-- tools/python/xen/xm/main.py | 11 ++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff -r 4538426ae5fd -r 338820b7ea45 tools/python/xen/xend/XendAPI.py --- a/tools/python/xen/xend/XendAPI.py Mon Apr 16 17:02:52 2007 -0400 +++ b/tools/python/xen/xend/XendAPI.py Mon Apr 16 22:58:12 2007 +0100 @@ -575,15 +575,25 @@ class XendAPI(object): get_by_uuid = '%s_get_by_uuid' % api_cls get_uuid = '%s_get_uuid' % api_cls + get_all_records = '%s_get_all_records' % api_cls + def _get_by_uuid(_1, _2, ref): return xen_api_success(ref) def _get_uuid(_1, _2, ref): return xen_api_success(ref) + def unpack(v): + return v['Value'] + + def _get_all_records(_api_cls): + return lambda s, session: \ + xen_api_success([unpack(getattr(cls, '%s_get_record' % _api_cls)(s, session, ref))\ + for ref in unpack(getattr(cls, '%s_get_all' % _api_cls)(s, session))]) + setattr(cls, get_by_uuid, _get_by_uuid) setattr(cls, get_uuid, _get_uuid) - + setattr(cls, get_all_records, _get_all_records(api_cls)) # Autoplugging classes # -------------------- @@ -721,7 +731,7 @@ class XendAPI(object): Base_attr_ro = ['uuid'] Base_attr_rw = [] Base_methods = [('get_record', 'Struct')] - Base_funcs = [('get_all', 'Set'), ('get_by_uuid', None)] + Base_funcs = [('get_all', 'Set'), ('get_by_uuid', None), ('get_all_records', 'Set')] # Xen API: Class Session # ---------------------------------------------------------------- diff -r 4538426ae5fd -r 338820b7ea45 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Mon Apr 16 17:02:52 2007 -0400 +++ b/tools/python/xen/xm/main.py Mon Apr 16 22:58:12 2007 +0100 @@ -741,11 +741,12 @@ def getDomains(domain_names, state, full if serverType == SERVER_XEN_API: doms_sxp = [] doms_dict = [] - dom_refs = server.xenapi.VM.get_all() - for dom_ref in dom_refs: - dom_rec = server.xenapi.VM.get_record(dom_ref) - dom_metrics_ref = server.xenapi.VM.get_metrics(dom_ref) - dom_metrics = server.xenapi.VM_metrics.get_record(dom_metrics_ref) + + dom_recs = server.xenapi.VM.get_all_records() + dom_metrics_recs = dict(map(lambda x: (x['uuid'], x), server.xenapi.VM_metrics.get_all_records())) + + for dom_rec in dom_recs: + dom_metrics = dom_metrics_recs[dom_rec['metrics']] states = ('running', 'blocked', 'paused', 'shutdown', 'crashed', 'dying') _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |