~cprov/adt-cloud-worker/uci-nova-refix

« back to all changes in this revision

Viewing changes to uci-nova

  • Committer: Ubuntu CI Bot
  • Author(s): Evan Dandrea
  • Date: 2015-04-17 21:16:32 UTC
  • mfrom: (7.1.6 red-herrings)
  • Revision ID: ubuntu_ci_bot-20150417211632-pea9ueylcbwqhs5m
Suppressing noisy output. [r=Celso Providelo]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
 
1
#!/bin/sh -eu
2
2
#
3
3
# This script is part of autopkgtest
4
4
# autopkgtest is a tool for testing Debian binary packages
122
122
}
123
123
 
124
124
security_setup_nova() {
125
 
    debug "Creating specific nova security-group: $SRVNAME"
126
 
    nova secgroup-create $SRVNAME "$SRVNAME testbed"
127
 
 
128
 
    debug "Allowing ingress SSH ..."
129
 
    nova secgroup-add-rule $SRVNAME tcp 22 22 0.0.0.0/0
130
 
 
131
 
    debug "Egress traffic will respect external Firewall rules ..."
 
125
    if ! nova secgroup-create $SRVNAME "$SRVNAME testbed" >/dev/null 2&>1; then
 
126
        debug "Could not create specific nova security-group: $SRVNAME"
 
127
        exit 1
 
128
    fi
 
129
 
 
130
    if ! nova secgroup-add-rule $SRVNAME tcp 22 22 0.0.0.0/0 >/dev/null 2&>1; then
 
131
        debug "Could not allow ingress SSH."
 
132
        exit 1
 
133
    fi
132
134
}
133
135
 
134
136
security_setup_neutron() {
141
143
        --format csv -c id -c security_group --quote none \
142
144
        | grep $SRVNAME | cut -d',' -f1)
143
145
    for rule_id in $DEFAULT_RULES; do
144
 
        neutron security-group-rule-delete $rule_id
 
146
            neutron security-group-rule-delete $rule_id
145
147
    done
146
148
 
147
149
    debug "Allowing ingress SSH ..."
185
187
 
186
188
    # Setup testbed security with nova or neutron according to their
187
189
    # availability in the target cloud.
188
 
    if ! neutron security-group-list; then
189
 
        security_setup_nova
 
190
    if type neutron >/dev/null && neutron security-group-list; then
 
191
        debug "Setting up neutron secgroup"
 
192
        security_setup_neutron
190
193
    else
191
 
        security_setup_neutron
 
194
            security_setup_nova
192
195
    fi
193
196
        
194
197
    # generate cloud-init user data; mostly for manage_etc_hosts, but also get
315
318
        nova console-log $SRVNAME > $CONSOLE
316
319
    fi
317
320
 
318
 
    debug "Deleting $SRVNAME instance"
319
 
    nova delete $SRVNAME || true
320
 
 
321
 
    debug "Deleting $SRVNAME keypair"
322
 
    nova keypair-delete $SRVNAME || true
323
 
 
324
 
    debug "Deleting /tmp/$SRVNAME SSH keys"
325
 
    rm -rf /tmp/$SRVNAME || true
 
321
    if ! nova delete $SRVNAME >/dev/null >2&1; then
 
322
        error "Could not delete $SRVNAME instance."
 
323
    fi
 
324
 
 
325
    if ! nova keypair-delete $SRVNAME >2&1; then
 
326
        error "Could not delete $SRVNAME keypair."
 
327
    fi
 
328
 
 
329
    if ! rm -rf /tmp/$SRVNAME; then
 
330
        debug "Could not delete /tmp/$SRVNAME SSH keys"
 
331
    fi
326
332
 
327
333
    DELETE_CMD="neutron security-group-delete $SRVNAME"
328
334
    if ! neutron security-group-list; then
329
 
        DELETE_CMD="nova secgroup-delete $SRVNAME"
 
335
            DELETE_CMD="nova secgroup-delete $SRVNAME"
330
336
    fi
331
337
 
332
338
    debug "Deleting $SRVNAME security-group"