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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
#!/usr/bin/env bash
# Release public tools.
#
# Publish to Canonistack, HP, AWS, and Azure.
# This script requires that the user has credentials to upload the tools
# to Canonistack, HP Cloud, AWS, and Azure
set -e
SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd )
usage() {
echo "usage: $0 PURPOSE DIST_DIRECTORY"
echo " PURPOSE: 'RELEASE' or 'TESTING'"
echo " RELEASE installs tools/ at the top of juju-dist/tools."
echo " TESTING installs tools/ at juju-dist/testing/tools."
echo " DIST_DIRECTORY: The directory to the assembled tools."
echo " This is the juju-dist dir created by assemble-public-tools.bash."
exit 1
}
check_deps() {
echo "Phase 0: Checking requirements."
has_deps=1
which swift || has_deps=0
which s3cmd || has_deps=0
test -f $JUJU_DIR/canonistacktoolsrc || has_deps=0
test -f $JUJU_DIR/hptoolsrc || has_deps=0
test -f $JUJU_DIR/s3cfg || has_deps=0
test -f $JUJU_DIR/azuretoolsrc || has_deps=0
if [[ $has_deps == 0 ]]; then
echo "Install python-swiftclient, and s3cmd"
echo "Your $JUJU_DIR dir must contain rc files to publish:"
echo " canonistacktoolsrc, hptoolsrc, s3cfg, azuretoolsrc"
exit 2
fi
}
publish_to_canonistack() {
[[ $JT_IGNORE_CANONISTACK == '1' ]] && return 0
echo "Phase 1: Publish to canonistack."
source $JUJU_DIR/canonistacktoolsrc
cd $JUJU_DIST/tools/releases/
${SCRIPT_DIR}/swift-sync.bash tools/releases/ *.tgz
cd $JUJU_DIST/tools/streams/v1
${SCRIPT_DIR}/swift-sync.bash tools/streams/v1/ {index,com}*
# This needed to allow old deployments upgrade.
cd ${JUJU_DIST}/tools
${SCRIPT_DIR}/swift-sync.bash tools/ juju-1.16*.tgz
}
testing_to_canonistack() {
[[ $JT_IGNORE_CANONISTACK == '1' ]] && return 0
echo "Phase 1: Testing to canonistack."
source $JUJU_DIR/canonistacktoolsrc
cd $JUJU_DIST/tools/releases/
${SCRIPT_DIR}/swift-sync.bash testing/tools/releases/ *.tgz
cd $JUJU_DIST/tools/streams/v1
${SCRIPT_DIR}/swift-sync.bash testing/tools/streams/v1/ {index,com}*
}
publish_to_hp() {
[[ $JT_IGNORE_HP == '1' ]] && return 0
echo "Phase 2: Publish to HP Cloud."
source $JUJU_DIR/hptoolsrc
cd $JUJU_DIST/tools/releases/
${SCRIPT_DIR}/swift-sync.bash tools/releases/ *.tgz
cd $JUJU_DIST/tools/streams/v1
${SCRIPT_DIR}/swift-sync.bash tools/streams/v1/ {index,com}*
# Support old tools location so that deployments can upgrade to new tools.
cd ${JUJU_DIST}/tools
${SCRIPT_DIR}/swift-sync.bash tools/ juju-1.16*.tgz
}
testing_to_hp() {
# sync-tools cannot place the tools in a testing location, so swift is
# used.
[[ $JT_IGNORE_HP == '1' ]] && return 0
echo "Phase 2: Testing to HP Cloud."
source $JUJU_DIR/hptoolsrc
cd $JUJU_DIST/tools/releases/
${SCRIPT_DIR}/swift-sync.bash testing/tools/releases/ *.tgz
cd $JUJU_DIST/tools/streams/v1
${SCRIPT_DIR}/swift-sync.bash testing/tools/streams/v1/ {index,com}*
}
publish_to_aws() {
[[ $JT_IGNORE_AWS == '1' ]] && return 0
echo "Phase 3: Publish to AWS."
s3cmd -c $JUJU_DIR/s3cfg sync --exclude '*mirror*' \
${JUJU_DIST}/tools s3://juju-dist/
}
testing_to_aws() {
# this is the same as the publishing command except that the
# destination is juju-dist/testing/
[[ $JT_IGNORE_AWS == '1' ]] && return 0
echo "Phase 3: Testing to AWS."
s3cmd -c $JUJU_DIR/s3cfg sync --exclude '*mirror*' \
${JUJU_DIST}/tools s3://juju-dist/testing/
}
shim_creds() {
# The azure library uses different vars than was defined for gwacl.
export AZURE_STORAGE_ACCOUNT=${AZURE_STORAGE_ACCOUNT:-$AZURE_ACCOUNT}
AZURE_STORAGE_ACCESS_KEY=${AZURE_STORAGE_ACCESS_KEY:-$AZURE_JUJU_TOOLS_KEY}
export AZURE_STORAGE_ACCOUNT AZURE_STORAGE_ACCESS_KEY
}
publish_to_azure() {
[[ $JT_IGNORE_AZURE == '1' ]] && return 0
echo "Phase 4: Publish to Azure."
source $JUJU_DIR/azuretoolsrc
shim_creds
${SCRIPT_DIR}/azure_publish_tools.py publish release ${JUJU_DIST}
}
testing_to_azure() {
# This command is like the publish command expcept tht -container is
# different.
[[ $JT_IGNORE_AZURE == '1' ]] && return 0
echo "Phase 4: Testing to Azure."
source $JUJU_DIR/azuretoolsrc
shim_creds
${SCRIPT_DIR}/azure_publish_tools.py publish testing ${JUJU_DIST}
}
publish_to_streams() {
[[ -f $JUJU_DIR/streamsrc ]] || return 0
[[ $JT_IGNORE_STREAMS == '1' ]] && return 0
echo "Phase 5: Published to streams.canonical.com."
source $JUJU_DIR/streamsrc
rsync -avzh $JUJU_DIST/ $STREAMS_OFFICIAL_DEST
}
testing_to_streams() {
[[ -f $JUJU_DIR/streamsrc ]] || return 0
[[ $JT_IGNORE_STREAMS == '1' ]] && return 0
echo "Phase 5: Testing to streams.canonical.com."
source $JUJU_DIR/streamsrc
rsync -avzh $JUJU_DIST/ $STREAMS_TESTING_DEST
}
# The location of environments.yaml and rc files.
JUJU_DIR=${JUJU_HOME:-$HOME/.juju}
test $# -eq 2 || usage
PURPOSE=$1
if [[ $PURPOSE != "RELEASE" && $PURPOSE != "TESTING" ]]; then
usage
fi
JUJU_DIST=$(cd $2; pwd)
if [[ ! -d $JUJU_DIST/tools/releases && ! -d $JUJU_DIST/tools/streams ]]; then
usage
fi
check_deps
if [[ $PURPOSE == "RELEASE" ]]; then
publish_to_streams
publish_to_canonistack
publish_to_hp
publish_to_aws
publish_to_azure
echo "Release data published to all CPCs."
else
testing_to_streams
testing_to_canonistack
testing_to_hp
testing_to_aws
testing_to_azure
echo "Testing data published to all CPCs."
fi
|