[ovs-dev] [patch v2] ovn: ovn-ctl support to start ovn db servers in backup mode

Ben Pfaff blp at ovn.org
Tue Oct 4 18:36:39 UTC 2016


This never got a review, does it still nee done or is it superseded by
your current 4-patch series?

On Thu, Sep 01, 2016 at 05:14:42PM +0530, bschanmu at redhat.com wrote:
> From: Babu Shanmugam <bschanmu at redhat.com>
> 
> This patch adds support to start_ovsdb() function in ovn-ctl to start the
> ovn db servers in backup mode. This can be done in the following ways
> 1. Use parameters --ovn-nb-sync-from-addr and --ovn-sb-sync-from-addr to
>    set the addresses of the active server.
> 2. Create files $etcdir/ovnnb-active.conf and $etcdir/ovnsb-active.conf
>    with the tcp url of the active servers.
> 
> If --ovn-nb-sync-from-addr and --ovn-sb-sync-from-addr is used, it will
> overwrite the contents in the $etcdir/*.conf and use that server as the
> active server.
> 
> Additional functions to promote a backup server to active and demote
> active server to backup mode are also added in this patch
> 
> Signed-off-by: Babu Shanmugam <bschanmu at redhat.com>
> ---
>  ovn/utilities/ovn-ctl | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 77 insertions(+)
> 
> diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
> index a4a9817..c1f955b 100755
> --- a/ovn/utilities/ovn-ctl
> +++ b/ovn/utilities/ovn-ctl
> @@ -26,6 +26,8 @@ for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
>  done
>  
>  
> +ovnnb_active_conf_file="$etcdir/ovnnb-active.conf"
> +ovnsb_active_conf_file="$etcdir/ovnsb-active.conf"
>  ## ----- ##
>  ## start ##
>  ## ----- ##
> @@ -45,6 +47,44 @@ stop_ovsdb () {
>      fi
>  }
>  
> +demote_ovnnb() {
> +    if test ! -z "$DB_NB_SYNC_FROM_ADDR"; then
> +        echo "tcp:$DB_NB_SYNC_FROM_ADDR:$DB_NB_SYNC_FROM_PORT" > $ovnnb_active_conf_file
> +    fi
> +
> +    if test -e $ovnnb_active_conf_file; then
> +        ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/set-active-ovsdb-server `cat $ovnnb_active_conf_file`
> +        ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/connect-active-ovsdb-server
> +    else
> +        echo >&2 "$0: active server details not set"
> +        exit 1
> +    fi
> +}
> +
> +demote_ovnsb() {
> +    if test ! -z "$DB_SB_SYNC_FROM_ADDR"; then
> +        echo "tcp:$DB_SB_SYNC_FROM_ADDR:$DB_SB_SYNC_FROM_PORT" > $ovnsb_active_conf_file
> +    fi
> +
> +    if test -e $ovnsb_active_conf_file; then
> +        ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/set-active-ovsdb-server `cat $ovnsb_active_conf_file`
> +        ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/connect-active-ovsdb-server
> +    else
> +        echo >&2 "$0: active server details not set"
> +        exit 1
> +    fi
> +}
> +
> +promote_ovnnb() {
> +    rm -f $ovnnb_active_conf_file
> +    ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/disconnect-active-ovsdb-server
> +}
> +
> +promote_ovnsb() {
> +    rm -f $ovnsb_active_conf_file
> +    ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/disconnect-active-ovsdb-server
> +}
> +
>  start_ovsdb () {
>      # Check and eventually start ovsdb-server for Northbound DB
>      if ! pidfile_is_running $DB_NB_PID; then
> @@ -54,6 +94,14 @@ start_ovsdb () {
>  
>          set "$@" --detach $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT:$DB_NB_ADDR --pidfile=$DB_NB_PID --unixctl=ovnnb_db.ctl
>  
> +        if test ! -z "$DB_NB_SYNC_FROM_ADDR"; then
> +            echo "tcp:$DB_NB_SYNC_FROM_ADDR:$DB_NB_SYNC_FROM_PORT" > $ovnnb_active_conf_file
> +        fi
> +
> +        if test -e $ovnnb_active_conf_file; then
> +            set "$@" --sync-from=`cat $ovnnb_active_conf_file`
> +        fi
> +
>          $@ $DB_NB_FILE
>      fi
>  
> @@ -64,6 +112,15 @@ start_ovsdb () {
>          set ovsdb-server
>  
>          set "$@" --detach $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT:$DB_SB_ADDR --pidfile=$DB_SB_PID --unixctl=ovnsb_db.ctl
> +
> +        if test ! -z "$DB_SB_SYNC_FROM_ADDR"; then
> +            echo "tcp:$DB_SB_SYNC_FROM_ADDR:$DB_SB_SYNC_FROM_PORT" > $ovnsb_active_conf_file
> +        fi
> +
> +        if test -e $ovnsb_active_conf_file; then
> +            set "$@" --sync-from=`cat $ovnsb_active_conf_file`
> +        fi
> +
>          $@ $DB_SB_FILE
>      fi
>  }
> @@ -176,12 +233,16 @@ set_defaults () {
>      DB_NB_FILE=$dbdir/ovnnb_db.db
>      DB_NB_ADDR=0.0.0.0
>      DB_NB_PORT=6641
> +    DB_NB_SYNC_FROM_ADDR=
> +    DB_NB_SYNC_FROM_PORT=6641
>  
>      DB_SB_SOCK=$rundir/ovnsb_db.sock
>      DB_SB_PID=$rundir/ovnsb_db.pid
>      DB_SB_FILE=$dbdir/ovnsb_db.db
>      DB_SB_ADDR=0.0.0.0
>      DB_SB_PORT=6642
> +    DB_SB_SYNC_FROM_ADDR=
> +    DB_SB_SYNC_FROM_PORT=6642
>  
>      DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
>      DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
> @@ -272,6 +333,10 @@ File location options:
>    --db-sb-port=PORT    OVN Southbound db ptcp port (default: $DB_SB_PORT)
>    --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVN_NB_LOGFILE)
>    --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVN_SB_LOGFILE)
> +  --db-nb-sync-from-addr=ADDR OVN Northbound active db tcp address (default: $DB_NB_SYNC_FROM_ADDR)
> +  --db-nb-sync-from-port=PORT OVN Northdbound active db tcp port (default: $DB_NB_SYNC_FROM_PORT)
> +  --db-sb-sync-from-addr=ADDR OVN Southbound active db tcp address (default: $DB_SB_SYNC_FROM_ADDR)
> +  --db-sb-sync-from-port=ADDR OVN Southbound active db tcp port (default: $DB_SB_SYNC_FROM_PORT)
>  
>  Default directories with "configure" option and environment variable override:
>    logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
> @@ -377,6 +442,18 @@ case $command in
>      status_controller_vtep)
>          daemon_status ovn-controller-vtep || exit 1
>          ;;
> +    promote_ovnnb)
> +        promote_ovnnb
> +        ;;
> +    promote_ovnsb)
> +        promote_ovnsb
> +        ;;
> +    demote_ovnnb)
> +        demote_ovnnb
> +        ;;
> +    demote_ovnsb)
> +        demote_ovnsb
> +        ;;
>      help)
>          usage
>          ;;
> -- 
> 1.9.1
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list