[ovs-dev] [PATCH 1/1] xenserver: Reduce number of xapi DB calls in plugin
Dominic Curran
gigamuffin at gmail.com
Mon Dec 5 14:43:12 UTC 2011
From: Rob Hoes <rob.hoes at citrix.com>
When there are lots of PIFs in a XenServer/XCP pool, for example when
there are many VLANs configured on the pool, operations such as
PIF.get_all and loops over all PIFs which include database operations,
are very inefficient when executed on a pool slave, and should be
avoided as much as possible. This patch reduces the number of database
calls in the update function of the openvswitch-cfg-update xapi plugin.
Signed-off-by: Rob Hoes <rob.hoes at citrix.com>
Acked-by: Dominic Curran <Dominic.curran at citrix.com>
---
.../etc_xapi.d_plugins_openvswitch-cfg-update | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
index cc97c2d..a9a10e8 100755
--- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
+++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
@@ -86,8 +86,7 @@ def update(session, args):
bton = {}
- for n in session.xenapi.network.get_all():
- rec = session.xenapi.network.get_record(n)
+ for rec in session.xenapi.network.get_all_records().values():
try:
bton[rec['bridge']] = rec
except KeyError:
@@ -100,10 +99,9 @@ def update(session, args):
host_mgmt_device = None
pool_mgmt_macs = {}
if new_controller:
- for n in session.xenapi.PIF.get_all():
- rec = session.xenapi.PIF.get_record(n)
- if rec.get('management', False):
- pool_mgmt_macs[rec.get('MAC')] = rec.get('device')
+ recs = session.xenapi.PIF.get_all_records_where('field "management"="true"')
+ for rec in recs:
+ pool_mgmt_macs[rec.get('MAC')] = rec.get('device')
dib_changed = False
fail_mode_changed = False
--
1.7.5.4
More information about the dev
mailing list