summaryrefslogtreecommitdiff
path: root/ovn/utilities
diff options
context:
space:
mode:
authorGurucharan Shetty <shettyg@nicira.com>2015-10-01 15:09:56 -0700
committerGurucharan Shetty <gshetty@nicira.com>2015-10-02 10:39:40 -0700
commit2db1b5d8c9b6bd8dbafa078c5ad3704dc8c3ecf1 (patch)
treeba464b42639f802a53360438b7fa0cc877cf0dd8 /ovn/utilities
parent04b29c3421cd63f193e1b7e1b5f9625df543376c (diff)
downloadopenvswitch-2db1b5d8c9b6bd8dbafa078c5ad3704dc8c3ecf1.tar.gz
ovn-ctl: Ability to upgrade databases.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ovn/utilities')
-rwxr-xr-xovn/utilities/ovn-ctl37
1 files changed, 17 insertions, 20 deletions
diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
index 9f1602195..3e2ccf9a6 100755
--- a/ovn/utilities/ovn-ctl
+++ b/ovn/utilities/ovn-ctl
@@ -30,31 +30,28 @@ done
## start ##
## ----- ##
-check_ovn_dbs () {
- if test ! -e "$DB_NB_FILE"; then
- create_db "$DB_NB_FILE" "$DB_NB_SCHEMA"
- fi
-
- if test ! -e "$DB_SB_FILE"; then
- create_db "$DB_SB_FILE" "$DB_SB_SCHEMA"
- fi
-
- running_ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs | grep OVN | wc -l)
- if [ "$running_ovn_dbs" != "2" ] ; then
- ovs-appctl -t ovsdb-server ovsdb-server/add-db $DB_NB_FILE
- ovs-appctl -t ovsdb-server ovsdb-server/add-db $DB_SB_FILE
- running_ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs | grep OVN | wc -l)
- if [ "$running_ovn_dbs" != "2" ] ; then
- echo >&2 "$0: Failed to add OVN dbs to ovsdb-server"
- exit 1
- fi
- fi
+upgrade_ovn_dbs () {
+ ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs 2>/dev/null)
+ for db in $ovn_dbs; do
+ case $db in
+ OVN*)
+ action "Removing $db from ovsdb-server" \
+ ovs-appctl -t ovsdb-server ovsdb-server/remove-db $db
+ ;;
+ esac
+ done
+ upgrade_db "$DB_NB_FILE" "$DB_NB_SCHEMA"
+ upgrade_db "$DB_SB_FILE" "$DB_SB_SCHEMA"
+ for db in $DB_NB_FILE $DB_SB_FILE; do
+ action "Adding $db to ovsdb-server" \
+ ovs-appctl -t ovsdb-server ovsdb-server/add-db $db || exit 1
+ done
}
start_northd () {
# We expect ovn-northd to be co-located with ovsdb-server handling both the
# OVN_Northbound and OVN_Southbound dbs.
- check_ovn_dbs
+ upgrade_ovn_dbs
set ovn-northd
set "$@" -vconsole:emer -vsyslog:err -vfile:info