From 46528f78e5c0b7484e1735bb774ef2ad92e04593 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Wed, 13 Mar 2013 15:07:06 -0700 Subject: [PATCH] debian, rhel, xenserver: Ability to collect ovs-ctl logs. 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 --- debian/openvswitch-switch.init | 5 ----- rhel/etc_init.d_openvswitch | 11 +++++------ utilities/ovs-lib.in | 5 +++++ xenserver/etc_init.d_openvswitch | 11 +++++------ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index 3df711f9d..d84c1b671 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -37,11 +37,6 @@ network_interfaces () { [ -n "${bridges}" ] && $1 --allow=ovs ${bridges} } -ovs_ctl () { - set /usr/share/openvswitch/scripts/ovs-ctl "$@" - "$@" -} - load_kmod () { ovs_ctl load-kmod || exit $? } diff --git a/rhel/etc_init.d_openvswitch b/rhel/etc_init.d_openvswitch index a25e62402..55a13a7ed 100755 --- a/rhel/etc_init.d_openvswitch +++ b/rhel/etc_init.d_openvswitch @@ -31,7 +31,7 @@ test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch 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 +48,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 +67,6 @@ restart () { fi } -ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl case $1 in start) start @@ -83,10 +82,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/utilities/ovs-lib.in b/utilities/ovs-lib.in index b787b1ce1..d010abfe4 100644 --- a/utilities/ovs-lib.in +++ b/utilities/ovs-lib.in @@ -37,6 +37,11 @@ else dbdir='@DBDIR@' fi +ovs_ctl () { + echo "`date -u`:$@" >> "${logdir}/ovs-ctl.log" + "${datadir}/scripts/ovs-ctl" "$@" 2>&1 | tee -a "${logdir}/ovs-ctl.log" +} + VERSION='@VERSION@' DAEMON_CWD=/ diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch index 534451bac..9c0fe80b1 100755 --- a/xenserver/etc_init.d_openvswitch +++ b/xenserver/etc_init.d_openvswitch @@ -54,7 +54,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 +81,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 +102,7 @@ force_reload_kmod () { } stop () { - $ovs_ctl stop + ovs_ctl stop stop_daemon ovs-xapi-sync rm -f /var/lock/subsys/openvswitch } @@ -117,7 +117,6 @@ restart () { fi } -ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl case $1 in start) start @@ -137,10 +136,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 -- 2.43.0