Merge lp:~cprov/adt-cloud-worker/uci-nova-neutron-fallback into lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova

Proposed by Celso Providelo
Status: Merged
Merged at revision: 2
Proposed branch: lp:~cprov/adt-cloud-worker/uci-nova-neutron-fallback
Merge into: lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova
Diff against target: 106 lines (+46/-20)
1 file modified
uci-nova (+46/-20)
To merge this branch: bzr merge lp:~cprov/adt-cloud-worker/uci-nova-neutron-fallback
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Review via email: mp+253147@code.launchpad.net

Commit message

Coping with missing neutron security-groups capabilities (cannonistack and stackystack) and falling back to nova security-groups without egress traffic control.

Description of the change

Coping with missing neutron security-groups capabilities (cannonistack and stackystack) and falling back to nova security-groups without egress traffic control.

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

Tested against both canonistack and bootstack. Bootstack blocked egress traffic as expected, canonistack not so much. Both blocked ingress traffic as expected.

Just one question inline.

review: Needs Information
Revision history for this message
Francis Ginther (fginther) wrote :

Why was --poll removed?

"because it breaks on slow clouds (by reaching nova controller too often) and also because it wasn't really necessary, the scripts polls for ip-address and also ssh access moments later"

Thanks

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-03-12 15:20:04 +0000
3+++ uci-nova 2015-03-17 04:16:47 +0000
4@@ -115,24 +115,17 @@
5 fi
6 }
7
8-# create a testbed (if necessary), configure ssh, copy ssh key into it,
9-# configure sudo, etc.; print a list of "key=value" parameters to stdout on
10-# success
11-# required: login, hostname, and one of identity or password
12-# optional: port, options, capabilities
13-open() {
14- # Boot a nova instance and returns its connection parameters
15- [ -n "$SRVNAME" ] || SRVNAME=`mktemp -u adt-nova-XXXXXX`
16-
17- mkdir /tmp/$SRVNAME
18-
19- debug "Creating new SSH key on /tmp/$SRVNAME"
20- SSH_IDENTITY=/tmp/$SRVNAME/id_rsa
21- ssh-keygen -f $SSH_IDENTITY -q -N ""
22-
23- debug "Creating specific nova keypair: $SRVNAME"
24- nova keypair-add --pub-key $SSH_IDENTITY.pub $SRVNAME
25-
26+security_setup_nova() {
27+ debug "Creating specific nova security-group: $SRVNAME"
28+ nova secgroup-create $SRVNAME "$SRVNAME testbed"
29+
30+ debug "Allowing ingress SSH ..."
31+ nova secgroup-add-rule $SRVNAME tcp 22 22 0.0.0.0/0
32+
33+ debug "Egress traffic will respect external Firewall rules ..."
34+}
35+
36+security_setup_neutron() {
37 debug "Creating specific neutron security-group: $SRVNAME"
38 neutron security-group-create $SRVNAME \
39 --description "$SRVNAME testbed"
40@@ -166,6 +159,31 @@
41 --direction egress \
42 --remote-ip-prefix 91.189.88.0/21 \
43 $SRVNAME
44+}
45+
46+# create a testbed (if necessary), configure ssh, copy ssh key into it,
47+# configure sudo, etc.; print a list of "key=value" parameters to stdout on
48+# success
49+open() {
50+ # Boot a nova instance and returns its connection parameters
51+ [ -n "$SRVNAME" ] || SRVNAME=`mktemp -u adt-nova-XXXXXX`
52+
53+ mkdir /tmp/$SRVNAME
54+
55+ debug "Creating new SSH key on /tmp/$SRVNAME"
56+ SSH_IDENTITY=/tmp/$SRVNAME/id_rsa
57+ ssh-keygen -f $SSH_IDENTITY -q -N ""
58+
59+ debug "Creating specific nova keypair: $SRVNAME"
60+ nova keypair-add --pub-key $SSH_IDENTITY.pub $SRVNAME
61+
62+ # Setup testbed security with nova or neutron according to their
63+ # availability in the target cloud.
64+ if ! neutron security-group-list; then
65+ security_setup_nova
66+ else
67+ security_setup_neutron
68+ fi
69
70 # generate cloud-init user data; mostly for manage_etc_hosts, but also get
71 # rid of some unnecessary stuff in the VM
72@@ -191,7 +209,7 @@
73 OUT=$(nova boot --config-drive=1 \
74 --flavor $FLAVOR --image $IMAGE --user-data $userdata \
75 --key_name $SRVNAME --security-groups $SRVNAME \
76- $EXTRA_OPTS --poll $SRVNAME 2>&1) || {
77+ $EXTRA_OPTS $SRVNAME 2>&1) || {
78 error "nova boot failed:"
79 error "$OUT"
80 exit 1
81@@ -268,9 +286,14 @@
82 debug "Deleting /tmp/$SRVNAME SSH keys"
83 rm -rf /tmp/$SRVNAME || true
84
85+ DELETE_CMD="neutron security-group-delete $SRVNAME"
86+ if ! neutron security-group-list; then
87+ DELETE_CMD="nova secgroup-delete $SRVNAME"
88+ fi
89+
90 debug "Deleting $SRVNAME security-group"
91 retry=3
92- while ! neutron security-group-delete $SRVNAME; do
93+ while ! eval "$DELETE_CMD"; do
94 retry=$(( retry - 1 ))
95 if [ $retry -le 0 ]; then
96 error "Timed out deleting secgroup. Aborting!"
97@@ -312,6 +335,9 @@
98 shift
99 parse_args "$@"
100
101+# Don't leave stuff behind ...
102+trap "cleanup" 1 2 6 15
103+
104 case $cmd in
105 open)
106 open;;

Subscribers

People subscribed via source and target branches