From 1dc6839d2dd4e672742114a2664f5130c3235f3d Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Wed, 27 Jun 2012 16:14:21 +0100 Subject: [PATCH] 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 --- xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index 5083bbd16..cb35e7a30 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 -- 2.43.0