summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Hoes <rob.hoes@citrix.com>2012-06-27 16:14:21 +0100
committerJustin Pettit <jpettit@nicira.com>2012-08-13 15:31:31 -0700
commitdfdc7813da6feaf33d4be359fb64c35b3a0474da (patch)
tree3bd0c91525084339fd457f75568e149791d5f268
parentd2155157b90966c6c16cf093b3fc724812f8313b (diff)
downloadopenvswitch-dfdc7813da6feaf33d4be359fb64c35b3a0474da.tar.gz
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. Bug #12848. Signed-off-by: Rob Hoes <rob.hoes@citrix.com> Acked-by: Dominic Curran <dominic.curran@citrix.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
-rwxr-xr-xxenserver/usr_share_openvswitch_scripts_ovs-xapi-sync7
1 files 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 fc2158247..09a9937b3 100755
--- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
@@ -81,10 +81,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