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
1=== modified file 'uci-nova'
2--- uci-nova 2015-04-27 18:14:06 +0000
3+++ uci-nova 2015-04-28 02:24:43 +0000
4@@ -19,6 +19,8 @@
5 # Name for the new server. A name will be generated if not specified.
6 # -m mirror | --mirror=mirror
7 # Optional ubuntu archive mirror to override the default.
8+# -p proxy_url | --proxy=proxy_url
9+# Optional HTTP[S] proxy url to populate testbed environment.
10 # -c console-log | --console=file-name
11 # Save the nova console-log of the server to the specified file.
12 #
13@@ -59,6 +61,7 @@
14 NET_ID=""
15 CONSOLE=""
16 MIRROR=""
17+PROXY=""
18 DEBUG=""
19
20
21@@ -78,8 +81,8 @@
22 parse_args() {
23 # Parse command line argument and populate environment
24
25- SHORTOPTS="f:,i:,N:,n:,m:,c:,d"
26- LONGOPTS="flavor:,image:,net-id:,name:,mirror:,console:,debug"
27+ SHORTOPTS="f:,i:,N:,n:,m:,p:,c:,d"
28+ LONGOPTS="flavor:,image:,net-id:,name:,mirror:,proxy:,console:,debug"
29
30 TEMP=$(getopt -o $SHORTOPTS --long $LONGOPTS -- "$@")
31 eval set -- "$TEMP"
32@@ -101,6 +104,9 @@
33 -m|--mirror)
34 MIRROR=$2
35 shift 2;;
36+ -p|--proxy)
37+ PROXY=$2
38+ shift 2;;
39 -c|--console)
40 CONSOLE=$2
41 shift 2;;
42@@ -173,6 +179,21 @@
43 --direction egress \
44 --remote-ip-prefix 91.189.88.0/21 \
45 $SRVNAME
46+
47+ if [ -n "$PROXY" ]; then
48+ debug "Allowing internet proxy egress traffic ..."
49+ proxy_hostname=$(echo $PROXY | sed -e "s/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/")
50+ if [ $(echo "$proxy_hostname" | grep -E "^[0-9]{1,3}(\.[0-9]{1,3}){3}$") ]; then
51+ proxy_ip=$proxy_hostname
52+ else
53+ proxy_ip=$(host $proxy_hostname | cut -d' ' -f4)
54+ fi
55+
56+ neutron security-group-rule-create \
57+ --direction egress \
58+ --remote-ip-prefix $proxy_ip/24 \
59+ $SRVNAME
60+ fi
61 }
62
63 # create a testbed (if necessary), configure ssh, copy ssh key into it,
64@@ -193,7 +214,7 @@
65
66 # Setup testbed security with nova or neutron according to their
67 # availability in the target cloud.
68- if type neutron >/dev/null && neutron security-group-list >/dev/null; then
69+ if type neutron >/dev/null && neutron security-group-list >/dev/null 2>&1; then
70 debug "Setting up neutron secgroup"
71 security_setup_neutron
72 else
73@@ -220,6 +241,12 @@
74 # from the performance perspective.
75 swap_setup="fallocate -l 4G /swapfile; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile; echo \"/swapfile none swap sw 0 0\" >> /etc/fstab"
76
77+ # Testbed environment setup to be executed by cloud-init.
78+ # Sets proxy-related environment variables, the local address and the
79+ # configured archive_host are excluded from http[s] proxying and general
80+ # http[s] proxying it set according to the user-given --proxy option.
81+ 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"
82+
83 # generate cloud-init user data; mostly for manage_etc_hosts, but also get
84 # rid of some unnecessary stuff in the VM
85 #
86@@ -256,6 +283,8 @@
87 - apt-get clean
88 # Do a dist-upgrade:
89 - DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
90+ # Set extra environment variables for testing.
91+ - ${environment_setup}
92 EOF
93
94 EXTRA_OPTS=''
95@@ -366,13 +395,13 @@
96 fi
97
98 DELETE_CMD="neutron security-group-delete $SRVNAME"
99- if ! type neutron >/dev/null || ! neutron security-group-list >/dev/null; then
100+ if ! type neutron >/dev/null || ! neutron security-group-list >/dev/null 2>&1; then
101 DELETE_CMD="nova secgroup-delete $SRVNAME"
102 fi
103
104 debug "Deleting $SRVNAME security-group"
105 retry=3
106- while ! eval "$DELETE_CMD"; do
107+ while ! eval "$DELETE_CMD" >/dev/null 2>&1; do
108 retry=$(( retry - 1 ))
109 if [ $retry -le 0 ]; then
110 error "Timed out deleting secgroup. Aborting!"

Subscribers

People subscribed via source and target branches

to all changes: