Merge lp:~thomir-deactivatedaccount/adt-cloud-worker/uci-nova-proxy into lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 14
Merged at revision: 14
Proposed branch: lp:~thomir-deactivatedaccount/adt-cloud-worker/uci-nova-proxy
Merge into: lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova
Diff against target: 110 lines (+34/-5)
1 file modified
uci-nova (+34/-5)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/adt-cloud-worker/uci-nova-proxy
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Joe Talbott Pending
Review via email: mp+257600@code.launchpad.net

Commit message

Add support for proxy server.

Description of the change

Support --proxy=<proxy_url> which will endup in the test environment http[s]_proxy variables.

This option should not be set to "squid.internal" until it is accessible and fully functional, otherwise adt-run won't be able to fetch sources and perform other network operations (yes, everything in the test will be proxied, except cloud-init).

Also silencing more neutron calls as a drive-by cleanup.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Re-merge approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'uci-nova'
--- uci-nova 2015-04-27 18:14:06 +0000
+++ uci-nova 2015-04-28 02:24:43 +0000
@@ -19,6 +19,8 @@
19# Name for the new server. A name will be generated if not specified.19# Name for the new server. A name will be generated if not specified.
20# -m mirror | --mirror=mirror20# -m mirror | --mirror=mirror
21# Optional ubuntu archive mirror to override the default.21# Optional ubuntu archive mirror to override the default.
22# -p proxy_url | --proxy=proxy_url
23# Optional HTTP[S] proxy url to populate testbed environment.
22# -c console-log | --console=file-name24# -c console-log | --console=file-name
23# Save the nova console-log of the server to the specified file.25# Save the nova console-log of the server to the specified file.
24#26#
@@ -59,6 +61,7 @@
59NET_ID=""61NET_ID=""
60CONSOLE=""62CONSOLE=""
61MIRROR=""63MIRROR=""
64PROXY=""
62DEBUG=""65DEBUG=""
6366
6467
@@ -78,8 +81,8 @@
78parse_args() {81parse_args() {
79 # Parse command line argument and populate environment82 # Parse command line argument and populate environment
8083
81 SHORTOPTS="f:,i:,N:,n:,m:,c:,d"84 SHORTOPTS="f:,i:,N:,n:,m:,p:,c:,d"
82 LONGOPTS="flavor:,image:,net-id:,name:,mirror:,console:,debug"85 LONGOPTS="flavor:,image:,net-id:,name:,mirror:,proxy:,console:,debug"
8386
84 TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@")87 TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@")
85 eval set -- "$TEMP"88 eval set -- "$TEMP"
@@ -101,6 +104,9 @@
101 -m|--mirror)104 -m|--mirror)
102 MIRROR=$2105 MIRROR=$2
103 shift 2;;106 shift 2;;
107 -p|--proxy)
108 PROXY=$2
109 shift 2;;
104 -c|--console)110 -c|--console)
105 CONSOLE=$2111 CONSOLE=$2
106 shift 2;;112 shift 2;;
@@ -173,6 +179,21 @@
173 --direction egress \179 --direction egress \
174 --remote-ip-prefix 91.189.88.0/21 \180 --remote-ip-prefix 91.189.88.0/21 \
175 $SRVNAME181 $SRVNAME
182
183 if [ -n "$PROXY" ]; then
184 debug "Allowing internet proxy egress traffic ..."
185 proxy_hostname=$(echo $PROXY | sed -e "s/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/")
186 if [ $(echo "$proxy_hostname" | grep -E "^[0-9]{1,3}(\.[0-9]{1,3}){3}$") ]; then
187 proxy_ip=$proxy_hostname
188 else
189 proxy_ip=$(host $proxy_hostname | cut -d' ' -f4)
190 fi
191
192 neutron security-group-rule-create \
193 --direction egress \
194 --remote-ip-prefix $proxy_ip/24 \
195 $SRVNAME
196 fi
176}197}
177198
178# create a testbed (if necessary), configure ssh, copy ssh key into it,199# create a testbed (if necessary), configure ssh, copy ssh key into it,
@@ -193,7 +214,7 @@
193214
194 # Setup testbed security with nova or neutron according to their215 # Setup testbed security with nova or neutron according to their
195 # availability in the target cloud.216 # availability in the target cloud.
196 if type neutron >/dev/null && neutron security-group-list >/dev/null; then217 if type neutron >/dev/null && neutron security-group-list >/dev/null 2>&1; then
197 debug "Setting up neutron secgroup"218 debug "Setting up neutron secgroup"
198 security_setup_neutron219 security_setup_neutron
199 else220 else
@@ -220,6 +241,12 @@
220 # from the performance perspective.241 # from the performance perspective.
221 swap_setup="fallocate -l 4G /swapfile; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile; echo \"/swapfile none swap sw 0 0\" >> /etc/fstab"242 swap_setup="fallocate -l 4G /swapfile; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile; echo \"/swapfile none swap sw 0 0\" >> /etc/fstab"
222243
244 # Testbed environment setup to be executed by cloud-init.
245 # Sets proxy-related environment variables, the local address and the
246 # configured archive_host are excluded from http[s] proxying and general
247 # http[s] proxying it set according to the user-given --proxy option.
248 environment_setup="archive_host=\`awk '/^deb .*(debian|ubuntu)/ { split(\$2, u, \"/\"); print u[3]; exit }' \"\$root/etc/apt/sources.list\"\`; echo \"no_proxy=\\\"localhost,127.0.0.1,localaddress,.localdomain.com,\${archive_host}\\\"\nhttp_proxy=\\\"${PROXY}\\\"\nhttps_proxy=\\\"${PROXY}\\\"\nHTTP_PROXY=\\\"${PROXY}\\\"\nHTTPS_PROXY=\\\"${PROXY}\\\"\" >> /etc/environment"
249
223 # generate cloud-init user data; mostly for manage_etc_hosts, but also get250 # generate cloud-init user data; mostly for manage_etc_hosts, but also get
224 # rid of some unnecessary stuff in the VM251 # rid of some unnecessary stuff in the VM
225 #252 #
@@ -256,6 +283,8 @@
256 - apt-get clean283 - apt-get clean
257 # Do a dist-upgrade:284 # Do a dist-upgrade:
258 - DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade285 - DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
286 # Set extra environment variables for testing.
287 - ${environment_setup}
259EOF288EOF
260289
261 EXTRA_OPTS=''290 EXTRA_OPTS=''
@@ -366,13 +395,13 @@
366 fi395 fi
367396
368 DELETE_CMD="neutron security-group-delete $SRVNAME"397 DELETE_CMD="neutron security-group-delete $SRVNAME"
369 if ! type neutron >/dev/null || ! neutron security-group-list >/dev/null; then398 if ! type neutron >/dev/null || ! neutron security-group-list >/dev/null 2>&1; then
370 DELETE_CMD="nova secgroup-delete $SRVNAME"399 DELETE_CMD="nova secgroup-delete $SRVNAME"
371 fi400 fi
372401
373 debug "Deleting $SRVNAME security-group"402 debug "Deleting $SRVNAME security-group"
374 retry=3403 retry=3
375 while ! eval "$DELETE_CMD"; do404 while ! eval "$DELETE_CMD" >/dev/null 2>&1; do
376 retry=$(( retry - 1 ))405 retry=$(( retry - 1 ))
377 if [ $retry -le 0 ]; then406 if [ $retry -le 0 ]; then
378 error "Timed out deleting secgroup. Aborting!"407 error "Timed out deleting secgroup. Aborting!"

Subscribers

People subscribed via source and target branches

to all changes: