diff mbox

[ovs-dev,3/4] ovn-ctl, ovs-ctl: Move common code to ovs-lib.

Message ID 1443737396-2585-3-git-send-email-gshetty@nicira.com
State Accepted
Headers show

Commit Message

Gurucharan Shetty Oct. 1, 2015, 10:09 p.m. UTC
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
---
 ovn/utilities/ovn-ctl |  6 ------
 utilities/ovs-ctl.in  | 12 ++----------
 utilities/ovs-lib.in  | 10 ++++++++++
 3 files changed, 12 insertions(+), 16 deletions(-)

Comments

Ben Pfaff Oct. 2, 2015, 1:07 p.m. UTC | #1
On Thu, Oct 01, 2015 at 03:09:55PM -0700, Gurucharan Shetty wrote:
> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>

Acked-by: Ben Pfaff <blp@nicira.com>
diff mbox

Patch

diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
index 89c774e..9f16021 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 bca8c56..322e420 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 7cde6e4..ef3150a 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"
+}