diff options
author | Gurucharan Shetty <shettyg@nicira.com> | 2013-06-14 11:23:25 -0700 |
---|---|---|
committer | Gurucharan Shetty <gshetty@nicira.com> | 2013-06-14 20:40:01 -0700 |
commit | ee389ff70254f7fb1531ee7b4e9434da76c0eefa (patch) | |
tree | 24c7814fd28b61a9c7a88887b7631b862dacf9f9 /xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | |
parent | 4371f019da9af2304b5e047adf2cdf2bc7c2261b (diff) |
ovs-xapi-sync: Retry getting bridge-ids in case xapi is not ready.
When there are multiple xs-network-uuids set for a bridge,
we query xapi to get the record that does not have a VLAN
associated with it. For cases when xapi does not respond,
retry again after a second.
During the times when xapi does not respond, set the value
as external_ids:bridge_id "".
Bug #17877.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Diffstat (limited to 'xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync')
-rwxr-xr-x | xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index ac56d371c..649ddbe53 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -41,6 +41,7 @@ vlog = ovs.vlog.Vlog("ovs-xapi-sync") session = None flush_cache = False exiting = False +xapi_down = False def unixctl_exit(conn, unused_argv, unused_aux): @@ -92,6 +93,7 @@ def get_network_by_bridge(br_name): # In cases like that, we should choose the bridge-id whose PIF does not have a # VLAN associated with it. def get_single_bridge_id(bridge_ids, default=None): + global xapi_down if not init_session(): vlog.warn("Failed to get single bridge id from %s because" "XAPI session could not be initialized" % bridge_ids) @@ -116,6 +118,8 @@ def get_single_bridge_id(bridge_ids, default=None): vlog.warn("Could not find XAPI entry for bridge_id %s" % bridge_id) continue + vlog.warn("Failed to get a single bridge id from Xapi.") + xapi_down = True return default # By default, the "bridge-id" external id in the Bridge table is the @@ -238,7 +242,7 @@ def update_in_band_mgmt(row): def main(): - global flush_cache + global flush_cache, xapi_down parser = argparse.ArgumentParser() parser.add_argument("database", metavar="DATABASE", @@ -285,13 +289,18 @@ def main(): break; idl.run() - if not flush_cache and seqno == idl.change_seqno: + if not xapi_down and not flush_cache and seqno == idl.change_seqno: poller = ovs.poller.Poller() unixctl_server.wait(poller) idl.wait(poller) poller.block() continue + if xapi_down: + vlog.warn("Xapi is probably down. Retry again after a second.") + time.sleep(1) + xapi_down = False + if flush_cache: vlog.info("Flushing cache as the result of unixctl.") bridges = {} @@ -317,7 +326,7 @@ def main(): bridge_id = row.external_ids.get("xs-network-uuids") if bridge_id and len(bridge_id.split(";")) > 1: bridge_ids = bridge_id.split(";") - bridge_id = get_single_bridge_id(bridge_ids, bridge_ids[0]) + bridge_id = get_single_bridge_id(bridge_ids, "") if bridge_id is not None: set_external_id(row, "bridge-id", bridge_id.split(";")[0]) |