From: Rob Hoes Date: Wed, 27 Jun 2012 15:14:21 +0000 (+0100) Subject: xenserver: Improve efficiency of code by using get_all_records_where() X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dc6839d2dd4e672742114a2664f5130c3235f3d;p=openvswitch xenserver: Improve efficiency of code by using get_all_records_where() Replace the get_record() for network references which caused as many slave-to-master calls as there are Network records plus one. The get_all_records_where() call gets exactly what is needed with a single call. Signed-off-by: Rob Hoes Acked-by: Dominic Curran Signed-off-by: Ben Pfaff --- diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index 5083bbd1..cb35e7a3 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -82,10 +82,9 @@ def get_network_by_bridge(br_name): " XAPI session could not be initialized" % br_name) return None - for n in session.xenapi.network.get_all(): - rec = session.xenapi.network.get_record(n) - if rec['bridge'] == br_name: - return rec + recs = session.xenapi.network.get_all_records_where('field "bridge"="%s"' % br_name) + if len(recs) > 0: + return recs.values()[0] return None