From 04b29c3421cd63f193e1b7e1b5f9625df543376c Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Thu, 1 Oct 2015 15:09:55 -0700 Subject: [PATCH] ovn-ctl, ovs-ctl: Move common code to ovs-lib. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- ovn/utilities/ovn-ctl | 6 ------ utilities/ovs-ctl.in | 12 ++---------- utilities/ovs-lib.in | 10 ++++++++++ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl index 89c774e69..9f1602195 100755 --- a/ovn/utilities/ovn-ctl +++ b/ovn/utilities/ovn-ctl @@ -30,12 +30,6 @@ done ## start ## ## ----- ## -create_db () { - DB_FILE=$1 - DB_SCHEMA=$2 - action "Creating empty database $DB_FILE" ovsdb-tool create "$DB_FILE" "$DB_SCHEMA" -} - check_ovn_dbs () { if test ! -e "$DB_NB_FILE"; then create_db "$DB_NB_FILE" "$DB_NB_SCHEMA" diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index bca8c5623..322e42005 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -76,20 +76,12 @@ ovs_vsctl () { ovs-vsctl --no-wait "$@" } -ovsdb_tool () { - ovsdb-tool -vconsole:off "$@" -} - -create_db () { - action "Creating empty database $DB_FILE" ovsdb_tool create "$DB_FILE" "$DB_SCHEMA" -} - upgrade_db () { schemaver=`ovsdb_tool schema-version "$DB_SCHEMA"` if test ! -e "$DB_FILE"; then log_warning_msg "$DB_FILE does not exist" install -d -m 755 -o root -g root `dirname $DB_FILE` - create_db + create_db "$DB_FILE" "$DB_SCHEMA" elif test X"`ovsdb_tool needs-conversion "$DB_FILE" "$DB_SCHEMA"`" != Xno; then # Back up the old version. version=`ovsdb_tool db-version "$DB_FILE"` @@ -118,7 +110,7 @@ upgrade_db () { else log_warning_msg "Schema conversion failed, using empty database instead" rm -f "$DB_FILE" - create_db + create_db "$DB_FILE" "$DB_SCHEMA" fi fi } diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in index 7cde6e426..ef3150ad2 100644 --- a/utilities/ovs-lib.in +++ b/utilities/ovs-lib.in @@ -325,3 +325,13 @@ move_ip_routes () { echo "ip route add $route dev $dst" done } + +ovsdb_tool () { + ovsdb-tool -vconsole:off "$@" +} + +create_db () { + DB_FILE="$1" + DB_SCHEMA="$2" + action "Creating empty database $DB_FILE" ovsdb_tool create "$DB_FILE" "$DB_SCHEMA" +} -- 2.20.1