ovn-ctl, ovs-ctl: Move common code to ovs-lib.
authorGurucharan Shetty <shettyg@nicira.com>
Thu, 1 Oct 2015 22:09:55 +0000 (15:09 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Fri, 2 Oct 2015 17:36:57 +0000 (10:36 -0700)
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ovn/utilities/ovn-ctl
utilities/ovs-ctl.in
utilities/ovs-lib.in

index 89c774e..9f16021 100755 (executable)
@@ -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"
index bca8c56..322e420 100755 (executable)
@@ -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
 }
index 7cde6e4..ef3150a 100644 (file)
@@ -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"
+}