diff options
| -rwxr-xr-x | leap-deploy-node.sh | 44 | ||||
| -rwxr-xr-x | leap-platform-test | 149 | ||||
| -rwxr-xr-x | leap-reset-deploy-all.sh | 30 | 
3 files changed, 149 insertions, 74 deletions
| diff --git a/leap-deploy-node.sh b/leap-deploy-node.sh deleted file mode 100755 index 039f635..0000000 --- a/leap-deploy-node.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -. /etc/leap/platform-test.cfg - -vm=$1 - -LOG="$LOGDIR/deploy-$vm.log" -ERRLOG="$LOGDIR/deploy-$vm-`date +"%F-%H%M%S"`-error.log" - -cd $PROVIDERDIR - - -# remove colors until #1751 is fixed -RMCOLORS='s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' - -# we need to deploy with verbose level 2, and filter out unwanted stuff -# until puppet errors show up in verbose level 0 +1 (#1750) -FILTER_CLI='= read|= loading|= no change|   - executing| = executing| = applying| = ran git| = checking| = synching| = skipping file_path|   - cd .*; rsync -a|   - hiera| = created hiera/|   - cd /root/|   - rolling backexecuting|   - files/ca/client_ca.crt|\[bin,puppet\] ->' -FILTER_PUPPET='] notice: |] No change to hostname|] Puppet apply complete|] warning: Dynamic lookup|] warning: Scope\(Class' -FILTER_ALL="($FILTER_CLI|$FILTER_PUPPET)" - - -echo "Deploying \"$vm\" on `date`"|tee -a $LOG - -leap $OPTS -v 2 deploy $vm 2>&1 |  sed -r "$RMCOLORS" | tee -a $LOG | egrep -v "$FILTER_ALL" > $ERRLOG - - -if [ $? -eq 0 ] -then -  msg="From: $MAIL_FROM\nTo: $MAIL_TO\nSubject: Deploy to \"$vm\" had errors !\n\n`cat $ERRLOG`" -  echo "Deploy to \"$vm\" on `date` had errors." | tee -a $LOG -  echo -  cat $ERRLOG  -   -  if [ "$MAIL_TO" != '' ]; then -    echo "Sending this mail to $MAIL_TO:" -    printf "$msg" | sendmail -t -  fi - -else -  echo "Deploy to $vm on `date` went fine."| tee -a $LOG -fi - -echo diff --git a/leap-platform-test b/leap-platform-test new file mode 100755 index 0000000..83b7153 --- /dev/null +++ b/leap-platform-test @@ -0,0 +1,149 @@ +#!/bin/bash + +usage() +{ +cat << EOF + +usage: $0 [options] command [arguments...] + +This script runs the leap platform deploy tests + +OPTIONS + +  -c|--config file      specify config file    +  -a|--all              run command on all nodes +  -h|--help             show help + +COMMANDS +  deploy       <node>   deploy node +  reset_deploy <node>   reset and deploy node + +EOF +} + +compile () { +  leap $OPTS clean +  leap $OPTS compile +} + + +deploy() { +  vm=$1 +  LOG="$LOGDIR/deploy-$vm.log" +  ERRLOG="$LOGDIR/deploy-$vm-`date +"%F-%H%M%S"`-error.log" + +  # remove colors until #1751 is fixed +  RMCOLORS='s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' + +  # we need to deploy with verbose level 2, and filter out unwanted stuff +  # until puppet errors show up in verbose level 0 +1 (#1750) +  FILTER_CLI='= read|= loading|= no change|   - executing| = executing| = applying| = ran git| = checking| = synching| = skipping file_path|   - cd .*; rsync -a|   - hiera| = created hiera/|   - cd /root/|   - rolling backexecuting|   - files/ca/client_ca.crt|\[bin,puppet\] ->' +  FILTER_PUPPET='] notice: |] No change to hostname|] Puppet apply complete|] warning: Dynamic lookup|] warning: Scope\(Class' +  FILTER_ALL="($FILTER_CLI|$FILTER_PUPPET)" + + +  echo "Deploying \"$vm\" on `date`"|tee -a $LOG + +  leap $OPTS -v 2 deploy $vm 2>&1 |  sed -r "$RMCOLORS" | tee -a $LOG | egrep -v "$FILTER_ALL" > $ERRLOG + + +  if [ $? -eq 0 ] +  then +    msg="From: $MAIL_FROM\nTo: $MAIL_TO\nSubject: Deploy to \"$vm\" had errors !\n\n`cat $ERRLOG`" +    echo "Deploy to \"$vm\" on `date` had errors." | tee -a $LOG +    echo +    cat $ERRLOG  +     +    if [ "$MAIL_TO" != '' ]; then +      echo "Sending this mail to $MAIL_TO:" +      printf "$msg" | sendmail -t +    fi + +  else +    echo "Deploy to $vm on `date` went fine."| tee -a $LOG +  fi +}  + +reset_deploy() { + +  compile + +  echo "Starting deploy_nodes for nodes $@ as background tasks on `date`" + +  for i in $@ +  do +    leap $OPTS local reset $i +    # only sleep one time +    if $need_to_sleep ; then +      echo "Waiting $SLEEP secs for VM to come up..." +      sleep $SLEEP +      need_to_sleep=false +    fi +    echo $i +    deploy $i & +  done +} + + +config="" +all=false + +if ! options=$(getopt -o ac:h -l all,config:,help -- "$@") +then  +  # something went wrong, getopt will put out an error message for us +  usage +  exit 1 +fi   + +eval set -- "$options" + +while [ $# -gt 0 ] +do +  case $1 in +    -h|--help)     usage; exit 1;; +    -c|--config)   config=$2; shift ;; +    -a|--all)      all=true;; +    -v|--verbose)  VERBOSE=1 ;; +    (--) shift; break;; +    (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; +    (*) break;; +  esac +  shift +done + + +cmd=$1 +shift +nodelist=$@ + +echo "config:   $config" +echo "cmd:      $cmd" +echo "nodelist: $nodelist" +echo "all:      $all" +#echo "remaining:    $@" + +if [ -z $config ] +then +  usage +  echo "Please provide a config file" +  exit 1 +fi + +source $config +cd  $ROOTDIR/$PROVIDER + +if ! $all ; then +  nodes=$nodelist +else +  nodes=$NODES +fi + +echo +echo "Starting $0 on `date`" + +case $cmd in  +  deploy)       deploy "$nodes";; +  reset_deploy) reset_deploy "$nodes";; +esac + + diff --git a/leap-reset-deploy-all.sh b/leap-reset-deploy-all.sh deleted file mode 100755 index 43e3e34..0000000 --- a/leap-reset-deploy-all.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -reset_nodes () { -  leap clean -  leap compile -  leap local reset -} - -deploy_nodes () { -  for i in $NODES -  do -    $PLATFORM_TEST_BIN/leap-deploy-node.sh $i &  -  done -} - -. /etc/leap/platform-test.cfg - -cd  $ROOTDIR/$PROVIDER - -echo -echo "Starting $0 on `date`" - - -echo "Starting reset_nodes on `date`" -reset_nodes -sleep 20 - -echo "Starting deploy_nodes as background tasks on `date`" -deploy_nodes - | 
