~nskaggs/juju-ci-tools/add-assess-terms

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -eux


usage() {
    echo "usage: $0 ADDRESS"
    echo "  ADDRESS: The IP or DNS address the windows test machine."
    echo "  --juju-home: The location of cloud-city and staging-juju-rsa."
    exit 1
}

INSTALL_JUJU="false"
while [[ "${1-}" != "" && $1 =~ ^-.*  ]]; do
    case $1 in
        --juju-home)
            shift
            JUJU_HOME=$(cd $1; pwd)
            ;;
        --help)
            usage
            ;;
    esac
    shift
done


test $# -eq 1 || usage

HOST="$1"
: ${SCRIPTS=$(readlink -f $(dirname $0))}
export PATH="$SCRIPTS:$PATH"

SSH_OPTIONS="-i $JUJU_HOME/staging-juju-rsa \
    -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"

retry_ssh() {
    for attempt in $(seq 3); do
        $@
        if [[ $? != "255" ]]; then
            # SSH didn't fail.
            break
        fi
        echo "SSH attempt $attempt failed."
    done
}

set -x
installer=$(
    $SCRIPTS/jujuci.py get build-win-client 'juju-setup-*.exe' ./)
echo "Downloaded $installer"
retry_ssh scp $SSH_OPTIONS \
    $SCRIPTS/deploy_stack.py $SCRIPTS/jujupy.py $SCRIPTS/jujuconfig.py \
    $SCRIPTS/substrate.py $SCRIPTS/utility.py $installer \
    Administrator@$HOST:/cygdrive/c/Users/Administrator/ci/
if [ $? -ne 0 ]; then
    exit 1
fi

set +e
retry_ssh ssh $SSH_OPTIONS Administrator@$HOST <<EOT
/cygdrive/c/Users/Administrator/ci/$installer /verysilent
juju version
juju destroy-environment --force -y test-win-client
python \\Users\\Administrator\\ci\\deploy_stack.py test-win-client
EOT
EXIT_STATUS=$?
exit $EXIT_STATUS