We use ovs-ctl from startup scripts to start, stop, restart,
force-reload-kmod OVS daemons. ovs-ctl gives quite a descriptive
o/p while running the above commands. But the o/p goes to stdout.
Sometimes, this output is quite useful to debug issues.

With this patch, we store the o/p of ovs-ctl when called from
startup scripts in /var/log/openvswitch/ovs-ctl.log

Signed-off-by: Gurucharan Shetty <[email protected]>
---
 debian/openvswitch-switch.init   |    2 +-
 rhel/etc_init.d_openvswitch      |   16 ++++++++++------
 xenserver/etc_init.d_openvswitch |   16 ++++++++++------
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init
index 3df711f..7cc64de 100755
--- a/debian/openvswitch-switch.init
+++ b/debian/openvswitch-switch.init
@@ -39,7 +39,7 @@ network_interfaces () {
 
 ovs_ctl () {
     set /usr/share/openvswitch/scripts/ovs-ctl "$@"
-    "$@"
+    "$@" 2>&1 | tee -a /var/log/openvswitch/ovs-ctl.log
 }
 
 load_kmod () {
diff --git a/rhel/etc_init.d_openvswitch b/rhel/etc_init.d_openvswitch
index a25e624..9450736 100755
--- a/rhel/etc_init.d_openvswitch
+++ b/rhel/etc_init.d_openvswitch
@@ -30,8 +30,13 @@
 . /usr/share/openvswitch/scripts/ovs-lib || exit 1
 test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch
 
+ovs_ctl () {
+    set /usr/share/openvswitch/scripts/ovs-ctl "$@"
+    "$@" 2>&1 | tee -a /var/log/openvswitch/ovs-ctl.log
+}
+
 start () {
-    set $ovs_ctl ${1-start}
+    set ovs_ctl ${1-start}
     set "$@" --system-id=random
     if test X"$FORCE_COREFILES" != X; then
        set "$@" --force-corefiles="$FORCE_COREFILES"
@@ -48,13 +53,13 @@ start () {
     set "$@" $OVS_CTL_OPTS
     "$@"
 
-    $ovs_ctl --protocol=gre enable-protocol
+    ovs_ctl --protocol=gre enable-protocol
 
     touch /var/lock/subsys/openvswitch
 }
 
 stop () {
-    $ovs_ctl stop
+    ovs_ctl stop
     rm -f /var/lock/subsys/openvswitch
 }
 
@@ -67,7 +72,6 @@ restart () {
     fi
 }
 
-ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl
 case $1 in
     start)
         start
@@ -83,10 +87,10 @@ case $1 in
         # Nothing to do.
         ;;
     status)
-        $ovs_ctl status
+        ovs_ctl status
         ;;
     version)
-        $ovs_ctl version
+        ovs_ctl version
         ;;
     force-reload-kmod)
         start force-reload-kmod
diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch
index 534451b..a45afa9 100755
--- a/xenserver/etc_init.d_openvswitch
+++ b/xenserver/etc_init.d_openvswitch
@@ -43,6 +43,11 @@ case `cat /etc/xensource/network.conf` in
         ;;
 esac
 
+ovs_ctl () {
+    set /usr/share/openvswitch/scripts/ovs-ctl "$@"
+    "$@" 2>&1 | tee -a /var/log/openvswitch/ovs-ctl.log
+}
+
 start_ovs_xapi_sync () {
     if daemon_is_running ovs-xapi-sync; then
        log_success_msg "ovs-xapi-sync is already running"
@@ -54,7 +59,7 @@ start_ovs_xapi_sync () {
 }
 
 start () {
-    set $ovs_ctl ${1-start}
+    set ovs_ctl ${1-start}
     set "$@" --system-id="$INSTALLATION_UUID"
     set "$@" --system-type="$PRODUCT_BRAND"
     set "$@" --system-version="$PRODUCT_VERSION-$BUILD_NUMBER"
@@ -81,7 +86,7 @@ start () {
 
     start_ovs_xapi_sync
 
-    $ovs_ctl --protocol=gre enable-protocol
+    ovs_ctl --protocol=gre enable-protocol
 
     touch /var/lock/subsys/openvswitch
 }
@@ -102,7 +107,7 @@ force_reload_kmod () {
 }
 
 stop () {
-    $ovs_ctl stop
+    ovs_ctl stop
     stop_daemon ovs-xapi-sync
     rm -f /var/lock/subsys/openvswitch
 }
@@ -117,7 +122,6 @@ restart () {
     fi
 }
 
-ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl
 case $1 in
     start)
         start
@@ -137,10 +141,10 @@ case $1 in
         fi
         ;;
     status)
-        $ovs_ctl status && daemon_status ovs-xapi-sync
+        ovs_ctl status && daemon_status ovs-xapi-sync
         ;;
     version)
-        $ovs_ctl version
+        ovs_ctl version
         ;;
     force-reload-kmod)
         force_reload_kmod
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to