Skip to content

Commit

Permalink
xenserver: Improve efficiency of code by using get_all_records_where()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Dominic Curran <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
robhoes authored and blp committed Jun 27, 2012
1 parent 0d7e2fe commit 1dc6839
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1dc6839

Please sign in to comment.