forked from cloudfoundry/diego-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-deployment-manifest
executable file
·240 lines (211 loc) · 6.95 KB
/
generate-deployment-manifest
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
set -e
manifest_generation=$(dirname $0)/../manifest-generation
usage() {
>&2 cat <<EOF
SYNOPSIS:
Generate a manifest for a Diego deployment to accompany an existing cf-release deployment.
USAGE:
$0 <MANDATORY ARGUMENTS> [OPTIONAL ARGUMENTS]
MANDATORY ARGUMENTS:
-c <cf-path> Path to CF manifest file.
-i <iaas-path> Path to IaaS-settings stub file.
-p <property-path> Path to property-overrides stub file.
OPTIONAL ARGUMENTS:
-n <count-path> Path to instance-count-overrides stub file.
-v <versions-path> Path to release-versions stub file.
-s <sql-db-path> Path to SQL stub file.
-x Opt out of deploying etcd with the database vms (requires sql)
-b Opt into using capi-release for bridge components.
-d <voldriver-path> Path to voldriver stub file.
-N <cf-networking-path> Path to CF Networking stub file
-B Opt out of deprecated CC bridge components.
-R Opt into using local route-emitter configuration for cells.
-Q Opt into using sql locket service (EXPERIMENTAL).
-G Opt into using grootfs release (EXPERIMENTAL).
-L Opt into using garden-linux-release for cells. (DEPRECATED)
EXAMPLE:
$0 \\
-c ../cf-release/bosh-lite/deployments/cf.yml \\
-i manifest-generation/bosh-lite-stubs/iaas-settings.yml \\
-p manifest-generation/bosh-lite-stubs/property-overrides.yml \\
-n manifest-generation/bosh-lite-stubs/instance-count-overrides.yml \\
-v manifest-generation/bosh-lite-stubs/release-versions.yml \\
-s manifest-generation/bosh-lite-stubs/postgres/diego-sql.yml \\
-x \\
-d manifest-generation/bosh-lite-stubs/experimental/voldriver/drivers.yml \\
-b \\
-R
EOF
exit 1
}
base_releases="${manifest_generation}/base-releases.yml"
garden_properties=""
bridge_properties=""
local_route_emitter_properties=""
bridge_jobs=""
while getopts "c:i:p:n:k:v:s:d:N:QkrbgxLBRG" opt; do
case $opt in
c)
cf_deployment_manifest=$OPTARG
;;
i)
iaas_settings=$OPTARG
;;
p)
property_overrides=$OPTARG
;;
n)
instance_counts=$OPTARG
;;
g)
>&2 echo "DEPRECATED -g flag: garden-runc is now the default backend and -g is not needed."
dash_g_provided="true"
;;
b)
bridge_properties="${manifest_generation}/capi-bridge-properties.yml";
;;
v)
release_versions=$OPTARG
;;
s)
sql_settings=$OPTARG
;;
k)
>&2 echo "DEPRECATED -k flag: Persistent disk configuration moved to IaaS-settings stub."
;;
r)
;;
d)
voldriver_settings=$OPTARG
;;
N)
cf_networking_settings=$OPTARG
;;
L)
>&2 echo "DEPRECATED -L flag: Support for garden-linux is being deprecated. Please migrate to garden-runc."
garden_properties="${manifest_generation}/garden-linux-properties.yml";
;;
x)
bbs_properties="${manifest_generation}/bbs-overrides-no-etcd.yml"
;;
B)
bridge_jobs="${manifest_generation}/disable-deprecated-bridge-jobs.yml";
;;
R)
local_route_emitter_properties="${manifest_generation}/enable-local-route-emitters.yml";
;;
Q)
sql_lock_overrides="${manifest_generation}/enable-sql-lock.yml"
;;
G)
grootfs_properties="${manifest_generation}/enable-grootfs.yml"
;;
*)
echo "Unknown arguments"
usage
;;
esac
done
if [ "${dash_g_provided}x" != "x" ]; then
if [ "${garden_properties}x" != "x" ]; then
>&2 echo "ERROR: Only one of -g or -L may be specified."
>&2 echo
usage
fi
fi
if [ -z ${cf_deployment_manifest} ]; then
>&2 echo "ERROR: CF manifest file is missing"
argument_error=true
else
if [ ! -f "${cf_deployment_manifest}" ]; then
>&2 echo "ERROR: CF manifest '${cf_deployment_manifest}' is not a regular file"
argument_error=true
fi
fi
if [ -z ${iaas_settings} ]; then
>&2 echo "ERROR: IaaS-settings stub file is missing"
argument_error=true
else
if [ ! -f "${iaas_settings}" ]; then
>&2 echo "ERROR: IaaS Setting stub '${iaas_settings}' is not a regular file"
argument_error=true
fi
fi
if [ -z ${property_overrides} ]; then
>&2 echo "ERROR: Property-overrides stub file is missing"
argument_error=true
else
if [ ! -f "${property_overrides}" ]; then
>&2 echo "ERROR: Property-overrides stub '${property_overrides}' is not a regular file"
argument_error=true
fi
fi
if [[ -z "${sql_settings}" ]]; then
>&2 echo "ERROR: SQL Setting stub is missing"
argument_error=true
fi
if [[ ! -z "${sql_settings}" && ! -f "${sql_settings}" ]]; then
>&2 echo "ERROR: SQL Setting stub '${sql_settings}' is not a regular file"
argument_error=true
fi
if [[ ! -z "${sql_lock_overrides}" && ! -f "${sql_lock_overrides}" ]]; then
>&2 echo "ERROR: SQL Setting stub '${sql_lock_overrides}' is not a regular file"
argument_error=true
fi
if [[ ! -z "${voldriver_settings}" && ! -f "${voldriver_settings}" ]]; then
>&2 echo "ERROR: Voldriver Setting stub '${voldriver_settings}' is not a regular file"
argument_error=true
fi
if [[ ! -z "${cf_networking_settings}" && ! -f "${cf_networking_settings}" ]]; then
>&2 echo "ERROR: CF Networking Setting stub '${cf_networking_settings}' is not a regular file"
argument_error=true
fi
if [[ ! -z "${cf_networking_settings}" && "${garden_properties}x" != "x" ]]; then
>&2 echo "ERROR: CF Networking Setting stub '${cf_networking_settings}' is set but Garden-Runc not selected"
argument_error=true
fi
if [[ ! -z "${instance_counts}" && ! -f "${instance_counts}" ]]; then
>&2 echo "ERROR: Instance-count-overrides stub '${instance_counts}' is not a regular file"
argument_error=true
fi
if [[ ! -z "${release_versions}" && ! -f "${release_versions}" ]]; then
>&2 echo "ERROR: Release-versions stub '${release_versions}' is not a regular file"
argument_error=true
fi
if [ ! -z $argument_error ]; then
echo
usage
fi
tmpdir=$(mktemp -d /tmp/diego-manifest.XXXXX)
spiff merge \
${manifest_generation}/config-from-cf.yml \
${manifest_generation}/config-from-cf-internal.yml \
${cf_deployment_manifest} \
> ${tmpdir}/config-from-cf.yml
spiff merge \
${cf_networking_settings} \
${tmpdir}/config-from-cf.yml \
> ${tmpdir}/cf-networking-merged.yml
spiff merge \
${manifest_generation}/diego.yml \
${garden_properties} \
${grootfs_properties} \
${release_versions} \
${bbs_properties} \
${bridge_jobs} \
${bridge_properties} \
${local_route_emitter_properties} \
${property_overrides} \
${instance_counts} \
${sql_settings} \
${voldriver_settings} \
${sql_lock_overrides} \
${tmpdir}/cf-networking-merged.yml \
${iaas_settings} \
${tmpdir}/config-from-cf.yml \
> ${tmpdir}/diego.yml
spiff merge \
${manifest_generation}/misc-templates/bosh.yml \
${tmpdir}/diego.yml
rm -r $tmpdir