On Fri, Aug 19, 2016 at 9:32 AM, Numan Siddique <nusid...@redhat.com> wrote:
> This command will be useful to query if the ovsdb-server > instance is active or backup. > > Signed-off-by: Numan Siddique <nusid...@redhat.com> > --- > ovsdb/ovsdb-server.1.in | 4 ++++ > ovsdb/ovsdb-server.c | 17 +++++++++++++++++ > tests/ovsdb-server.at | 19 +++++++++++++++++++ > 3 files changed, 40 insertions(+) > > > v1 -> v2 > ------- > * Added the test case > * Updated the document > > > diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in > index d1ba83b..723fb76 100644 > --- a/ovsdb/ovsdb-server.1.in > +++ b/ovsdb/ovsdb-server.1.in > @@ -205,6 +205,10 @@ again (with \fBovsdb\-server/add\-db\fR). > Outputs a list of the currently configured databases added either through > the command line or through the \fBovsdb\-server/add\-db\fR command. > . > +.IP "\fBovsdb\-server/is\-backup\-server" > +Outputs true if \fBovsdb\-server\fR is currently synchronizing > +its databases from the active server. > +. > .IP "\fBovsdb\-server/set\-active\-ovsdb\-server \fIserver" > Sets the active \fIserver\fR from which \fBovsdb\-server\fR connects > through > \fBovsdb\-server/connect\-active\-ovsdb\-server\fR. > diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c > index e08c341..283ec1b 100644 > --- a/ovsdb/ovsdb-server.c > +++ b/ovsdb/ovsdb-server.c > @@ -81,6 +81,7 @@ static unixctl_cb_func ovsdb_server_set_active_ovsdb_ > server; > static unixctl_cb_func ovsdb_server_get_active_ovsdb_server; > static unixctl_cb_func ovsdb_server_connect_active_ovsdb_server; > static unixctl_cb_func ovsdb_server_disconnect_active_ovsdb_server; > +static unixctl_cb_func ovsdb_server_is_backup_server; > static unixctl_cb_func ovsdb_server_set_sync_excluded_tables; > static unixctl_cb_func ovsdb_server_get_sync_excluded_tables; > > @@ -361,6 +362,9 @@ main(int argc, char *argv[]) > unixctl_command_register("ovsdb-server/disconnect-active-ovsdb-server", > "", > 0, 0, ovsdb_server_disconnect_ > active_ovsdb_server, > NULL); > + unixctl_command_register("ovsdb-server/is-backup-server", "", > + 0, 0, ovsdb_server_is_backup_server, > + NULL); > unixctl_command_register("ovsdb-server/set-sync-excluded-tables", "", > 0, 1, ovsdb_server_set_sync_excluded_tables, > NULL); > @@ -1104,6 +1108,19 @@ ovsdb_server_disconnect_active_ovsdb_server(struct > unixctl_conn *conn, > } > > static void > +ovsdb_server_is_backup_server(struct unixctl_conn *conn, > + int argc OVS_UNUSED, > + const char *argv[] OVS_UNUSED, > + void *arg_ OVS_UNUSED) > +{ > + struct ds s; > + ds_init(&s); > + ds_put_format(&s, "%s\n", is_backup_server ? "true": "false"); > + unixctl_command_reply(conn, ds_cstr(&s)); > + ds_destroy(&s); > +} > + > +static void > ovsdb_server_set_sync_excluded_tables(struct unixctl_conn *conn, > int argc OVS_UNUSED, > const char *argv[], > diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at > index 0436de8..2f0d175 100644 > --- a/tests/ovsdb-server.at > +++ b/tests/ovsdb-server.at > @@ -1105,6 +1105,25 @@ AT_CHECK([ovs-appctl -t ovsdb-server > ovsdb-server/get-active-ovsdb-server], > ]) > AT_CLEANUP > > +#ovsdb-server/is-backup-server command > +AT_SETUP([ovsdb-server/is-backup-server]) > +AT_KEYWORDS([ovsdb server replication is-backup]) > +ordinal_schema > schema > +AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) > +on_exit 'kill `cat *.pid`' > +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp: > 127.0.0.1:9999 db]) > + > +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/is-backup-server], > + [0], [true > +]) > + > +ovs-appctl -t ovsdb-server ovsdb-server/disconnect-active-ovsdb-server > + > +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/is-backup-server], > + [0], [false > +]) > +AT_CLEANUP > + > #ovsdb-server/get-sync-excluded-tables command > AT_SETUP([ovsdb-server/get-sync-excluded-tables]) > AT_KEYWORDS([ovsdb server replication get-excluded-tables]) > -- > 2.7.4 > I don't think this patch is required any more. The information is available from appctl command ovsdb-server/sync-status. > > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev