[Ovirt-devel] [PATCH] Redirecting all logs to /var/log/ovirt.log

Perry N. Myers pmyers at redhat.com
Mon Jul 14 19:29:35 UTC 2008


Darryl L. Pierce wrote:
> From: Darryl Pierce <dpierce at redhat.com>
> 
> This incorporates feedback and ensures that any function call that fails 
> shows the [FAILED] output in the console, while still ensuring data is 
> captured to the /var/log/ovirt.log file.
> 
> 
> Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
> ---
>  ovirt-managed-node/src/scripts/ovirt           |   21 ++++++++++++---------
>  ovirt-managed-node/src/scripts/ovirt-awake     |    2 +-
>  ovirt-managed-node/src/scripts/ovirt-early     |   11 +++++++++--
>  ovirt-managed-node/src/scripts/ovirt-functions |    5 ++++-
>  ovirt-managed-node/src/scripts/ovirt-post      |   14 ++++++++------
>  5 files changed, 34 insertions(+), 19 deletions(-)
> 
> diff --git a/ovirt-managed-node/src/scripts/ovirt b/ovirt-managed-node/src/scripts/ovirt
> index 92a0e40..7a5ba80 100755
> --- a/ovirt-managed-node/src/scripts/ovirt
> +++ b/ovirt-managed-node/src/scripts/ovirt
> @@ -11,15 +11,14 @@
>  . /etc/init.d/ovirt-functions
>  
>  start() {
> -    echo -n $"Starting ovirt: "
> -
>      find_srv ipa tcp
>      krb5_conf=/etc/krb5.conf
>      if [ ! -s $krb5_conf ]; then
>          rm -f $krb5_conf
>          # FIXME this is IPA specific
> -        wget -q http://$SRV_HOST:$SRV_PORT/ipa/config/krb5.ini -O $krb5_conf \
> -            || die "Failed to get $krb5_conf"
> +        wget -q \
> +            http://$SRV_HOST:$SRV_PORT/ipa/config/krb5.ini -O $krb5_conf \
> +            || echo "Failed to get $krb5_conf" && return 1
>      fi
>      IPA_HOST=$SRV_HOST
>      IPA_PORT=$SRV_PORT
> @@ -34,16 +33,20 @@ start() {
>          sed -e "s/@COLLECTD_SERVER@/$SRV_HOST/" \
>              -e "s/@COLLECTD_PORT@/$SRV_PORT/" $collectd_conf.in \
>              > $collectd_conf \
> -            || die "Failed to write $collectd_conf"
> +            || echo "Failed to write $collectd_conf" && return 1
>      fi
> -
> -    success
> -    echo
>  }
>  
>  case "$1" in
>      start)
> -        start
> +        echo -n $"Starting ovirt: "
> +
> +        {
> +            start
> +        } >> $OVIRT_LOGFILE 2>&1
> +
> +        test $? == 0 && success || failure
> +        echo
>          ;;
>      *)
>          echo "Usage: ovirt {start}"
> diff --git a/ovirt-managed-node/src/scripts/ovirt-awake b/ovirt-managed-node/src/scripts/ovirt-awake
> index 4e43d45..38d405e 100755
> --- a/ovirt-managed-node/src/scripts/ovirt-awake
> +++ b/ovirt-managed-node/src/scripts/ovirt-awake
> @@ -66,7 +66,7 @@ start () {
>              if [ -n $KEYTAB ]; then
>                  echo "Retrieving keytab: '$KEYTAB'"
>  
> -                wget $KEYTAB --output-document=$KEYTAB_FILE
> +                wget -q $KEYTAB --output-document=$KEYTAB_FILE
>              else
>                  echo "No keytab to retrieve"
>              fi
> diff --git a/ovirt-managed-node/src/scripts/ovirt-early b/ovirt-managed-node/src/scripts/ovirt-early
> index 4116847..6c7aaa3 100755
> --- a/ovirt-managed-node/src/scripts/ovirt-early
> +++ b/ovirt-managed-node/src/scripts/ovirt-early
> @@ -27,7 +27,7 @@ configure_from_network() {
>                  find_srv ovirt tcp
>                  printf .
>                  if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
> -                    wget --quiet -O - "http://$SRV_HOST:$SRV_PORT/ovirt/cfgdb/$(hostname)" \
> +                    wget -q -O - "http://$SRV_HOST:$SRV_PORT/ovirt/cfgdb/$(hostname)" \
>                          | augtool > /dev/null 2>&1
>                      if [ $? -eq 0 ]; then
>                          printf "remote config applied."
> @@ -96,7 +96,14 @@ start() {
>  
>  case "$1" in
>      start)
> -        start
> +        echo -n $"Starting ovirt-early: "
> +
> +        {
> +            start
> +        } >> $OVIRT_LOGFILE 2>&1
> +
> +        test $? == 0 && success || failure
> +        echo
>          ;;
>      *)
>          echo "Usage: ovirt-early {start}"
> diff --git a/ovirt-managed-node/src/scripts/ovirt-functions b/ovirt-managed-node/src/scripts/ovirt-functions
> index 9974533..5b530f7 100644
> --- a/ovirt-managed-node/src/scripts/ovirt-functions
> +++ b/ovirt-managed-node/src/scripts/ovirt-functions
> @@ -1,6 +1,9 @@
>  # -*-Shell-script-*-
>  
> -find_srv() {
> +OVIRT_LOGFILE=/var/log/ovirt.log
> +
> +find_srv()
> +{
>      local dnsreply
>      dnsreply=$(dig +short -t srv _$1._$2.$(dnsdomainname))
>      if [ $? -eq 0 ]; then
> diff --git a/ovirt-managed-node/src/scripts/ovirt-post b/ovirt-managed-node/src/scripts/ovirt-post
> index 3bb0f6d..f113b28 100755
> --- a/ovirt-managed-node/src/scripts/ovirt-post
> +++ b/ovirt-managed-node/src/scripts/ovirt-post
> @@ -11,8 +11,6 @@
>  . /etc/init.d/ovirt-functions
>  
>  start() {
> -    echo -n $"Starting ovirt-post: "
> -
>      find_srv identify tcp
>      UUID=`hal-get-property --udi \
>          /org/freedesktop/Hal/devices/computer --key system.hardware.uuid`
> @@ -22,14 +20,18 @@ start() {
>      else
>          ovirt-identify-node -s $SRV_HOST -p $SRV_PORT -u $UUID
>      fi
> -
> -    success
> -    echo
>  }
>  
>  case "$1" in
>      start)
> -        start
> +        echo -n $"Starting ovirt-post: "
> +
> +        {
> +            start
> +        } >> $OVIRT_LOGFILE 2>&1
> +
> +        test $? -eq 0 &&  success || failure
> +        echo
>          ;;
>      *)
>          echo "Usage: ovirt-post {start}"

ACK, this looks ok as long as it's been tested :)

As Jeff notes in another message, we should also add some logger commands 
to log important things to syslog (so that we can eventually get those 
over to an rsyslog server).  But this patch is good as is, we can add in 
logger stuff in another patch later.

Perry

-- 
|=-        Red Hat, Engineering, Emerging Technologies, Boston        -=|
|=-                     Email: pmyers at redhat.com                      -=|
|=-         Office: +1 412 474 3552   Mobile: +1 703 362 9622         -=|
|=- GnuPG: E65E4F3D 88F9 F1C9 C2F3 1303 01FE 817C C5D2 8B91 E65E 4F3D -=|




More information about the ovirt-devel mailing list