~james-page/ubuntu-openstack-ci/drop-tox-from-slave-config

« back to all changes in this revision

Viewing changes to operate/deprecated/926-juju-delete-enviro-files-all.sh

  • Committer: Ryan Beisner
  • Date: 2018-12-13 22:12:48 UTC
  • mfrom: (402.2.9 uosci-func-test-update)
  • Revision ID: ryan.beisner@canonical.com-20181213221248-by9gaj688y9911cw
[1chb1n, r=thedac] Make functional test naming generic and deprecate unused legacy bits

The functional tests may run amulet or zaza based on each
repo's tox definitions.

Leave symlink shims in for legacy amulet jobs until the
corresponding jobs are all updated to point to the new
generic runner file.

Remove several unused legacy amulet helpers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash -e
2
 
echo $0
3
 
 
4
 
# DANGEROUS!!  delete juju environment jenv files from master and all slaves!
5
 
# Manually delete the .juju/environments/*jenv files for sticky situations
6
 
7
 
 
8
 
jenv_dir="/var/lib/jenkins/.juju/environments"
9
 
 
10
 
param=$1
11
 
 
12
 
if [ -z "$param" ]; then
13
 
  echo "Manually deletes juju environment files!"
14
 
  echo "Potentially dangerous, so you must confirm with YES."
15
 
  echo "Usage:  (this script).sh YES"
16
 
fi
17
 
 
18
 
if [ "$param" == "YES" ]; then
19
 
  # Get jenkins units
20
 
  units=$(juju status --format=yaml | egrep "osci[-]?(slave|lab|task)?/[0-9]{1,10}:" \
21
 
    | cut -d ":" -f 1 | sed 's/^ *//')
22
 
 
23
 
  if [ -z "$units" ]; then
24
 
    echo "No units found.  Check default juju environment?"
25
 
    exit 1
26
 
  fi
27
 
 
28
 
  for unit in $units; do
29
 
    jenv_files=$(juju ssh $unit "sudo ls ${jenv_dir}")
30
 
    if [ -n "$jenv_files" ]; then
31
 
      echo "Found files in ${jenv_dir}, deleting them!"
32
 
        for this_file in $jenv_files; do
33
 
          fn=$(echo "${jenv_dir}/${this_file}" | tr -d '\r')
34
 
          echo "Deleting ${fn} on ${unit}!"
35
 
          juju ssh $unit "sudo ls ${jenv_dir} -alh && sudo rm -v ${fn} && uname -a"
36
 
        done
37
 
    else
38
 
      echo "${unit} juju environment appears to be all clear, deleting nothing."
39
 
    fi
40
 
  done
41
 
fi
42