#!/usr/bin/python
-# Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks
+# Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
import ovs.daemon
import ovs.db.idl
import ovs.unixctl
+import ovs.unixctl.server
vlog = ovs.vlog.Vlog("ovs-xapi-sync")
session = None
" 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
ovs.unixctl.command_register("exit", "", 0, 0, unixctl_exit, None)
ovs.unixctl.command_register("flush-cache", "", 0, 0, unixctl_flush_cache,
None)
- error, unixctl_server = ovs.unixctl.UnixctlServer.create(None)
+ error, unixctl_server = ovs.unixctl.server.UnixctlServer.create(None)
if error:
ovs.util.ovs_fatal(error, "could not create unixctl server", vlog)
iface_ids = new_iface_ids
vm_ids = new_vm_ids
+ txn.add_comment("ovs-xapi-sync: Updating records from XAPI")
txn.commit_block()
unixctl_server.close()