From: RYAN D. MOATS <rmo...@us.ibm.com> Allows for auto detection and reconnect if the ovn-remote needs to change. ovn-controller test case updated to include testing this code
Signed-off-by: RYAN D. MOATS <rmo...@us.ibm.com> --- ovn/controller/ovn-controller.c | 13 +++++++++++++ tests/ovn-controller.at | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index e52b731..09139bb 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -342,6 +342,19 @@ main(int argc, char *argv[]) if (should_service_stop()) { exiting = true; } + /* Check OVN SB database. */ + char *new_ovnsb_remote = get_ovnsb_remote(ovs_idl_loop.idl); + if (strcmp(ovnsb_remote, new_ovnsb_remote)) { + free (ovnsb_remote); + ovnsb_remote = new_ovnsb_remote; + ovsdb_idl_destroy(ovnsb_idl_loop.idl); + ovnsb_idl_loop.idl = ovsdb_idl_create(ovnsb_remote, + &sbrec_idl_class, true, + true); + ovsdb_idl_get_initial_snapshot(ovnsb_idl_loop.idl); + } else { + free (new_ovnsb_remote); + } } /* It's time to exit. Clean up the databases. */ diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 971ea1e..f9b2941 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -107,6 +107,21 @@ check_patches \ 'br-int patch-quux-to-baz patch-baz-to-quux' \ 'br-int patch-baz-to-quux patch-quux-to-baz' +# Create an empty database, serve it and switch to it +# and verify that the OVS patch ports disappear +# then put it back and verify that they reappear +ovsdb-tool create $ovs_base/ovn-sb/ovn-sb1.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema +as ovn-sb ovsdb-server --detach --pidfile=$ovs_base/ovn-sb/ovsdb-server-2.pid --remote=punix:$ovs_base/ovn-sb/ovn-sb1.sock $ovs_base/ovn-sb/ovn-sb1.db +ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb1.sock +sleep 1 +check_patches +ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock +sleep 1 +check_patches \ + 'br-int patch-quux-to-baz patch-baz-to-quux' \ + 'br-int patch-baz-to-quux patch-quux-to-baz' + + # Change the logical patch ports to VIFs and verify that the OVS patch # ports disappear. AT_CHECK([ovn-sbctl \ @@ -125,6 +140,7 @@ OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) OVS_APP_EXIT_AND_WAIT([ovsdb-server]) as ovn-sb +kill `cat $ovs_base/ovn-sb/ovsdb-server-2.pid` OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP -- 1.7.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev