~conjure/conjure/openstack-deb

« back to all changes in this revision

Viewing changes to bundles/bundle-common.sh

  • Committer: Adam Stokes
  • Date: 2016-05-26 12:56:29 UTC
  • Revision ID: git-v1:7c86e3f94eae3b49385027d06b43b3b07cd456ec
Patch conjure (#7)

* start movement to conjure 2.0 format

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>

* cleanup

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>

* update metadata

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>

* cleanup

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>

* remove conjure from install file

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
. /usr/share/conjure-up/hooklib/common.sh
2
 
 
3
 
fail_cleanly() {
4
 
    exposeResult "$1" 1 "false"
5
 
}
6
 
 
7
 
# Get host namserver
8
 
get_host_ns() {
9
 
    perl -lne 's/^nameserver\s+// or next; s/\s.*//; print && exit' /etc/resolv.conf
10
 
}
11
 
 
12
 
# NEUTRON
13
 
# Configures neutron
14
 
config_neutron() {
15
 
    if ! neutron net-show ext-net > /dev/null 2>&1; then
16
 
        debug openstack "adding ext-net"
17
 
        if ! neutron net-create --router:external ext-net > /dev/null 2>&1; then
18
 
            fail_cleanly "Neutron not ready yet..."
19
 
        fi
20
 
    fi
21
 
 
22
 
    if ! neutron subnet-show ext-subnet > /dev/null 2>&1; then
23
 
        debug openstack "adding ext-subnet"
24
 
        if ! neutron subnet-create --name ext-subnet ext-net 10.99.0.0/24 \
25
 
             --gateway 10.99.0.1 --disable-dhcp \
26
 
             --allocation-pool start=10.99.0.3,end=10.99.0.254 > /dev/null 2>&1; then
27
 
            fail_cleanly "Neutron not ready yet..."
28
 
        fi
29
 
    fi
30
 
 
31
 
    if ! neutron net-show ubuntu-net > /dev/null 2>&1; then
32
 
        debug openstack "adding ubuntu-net"
33
 
        if ! neutron net-create ubuntu-net --shared > /dev/null 2>&1; then
34
 
            fail_cleanly "Neutron not ready yet..."
35
 
        fi
36
 
    fi
37
 
 
38
 
    if ! neutron subnet-show ubuntu-subnet > /dev/null 2>&1; then
39
 
        debug openstack "adding ubuntu-subnet"
40
 
        if ! neutron subnet-create --name ubuntu-subnet \
41
 
             --gateway 10.101.0.1 \
42
 
             --dns-nameserver $(get_host_ns) ubuntu-net 10.101.0.0/24 > /dev/null 2>&1; then
43
 
            fail_cleanly "Neutron not ready yet..."
44
 
        fi
45
 
    fi
46
 
 
47
 
    if ! neutron router-show ubuntu-router > /dev/null 2>&1; then
48
 
        debug openstack "adding ubuntu-router"
49
 
        if ! neutron router-create ubuntu-router > /dev/null 2>&1; then
50
 
            fail_cleanly "Neutron not ready yet..."
51
 
        fi
52
 
    fi
53
 
 
54
 
    if ! neutron router-interface-add ubuntu-router ubuntu-subnet > /dev/null 2>&1; then
55
 
        debug openstack "Neutron not ready yet..."
56
 
    fi
57
 
 
58
 
    debug openstack "setting router gateway"
59
 
    if ! neutron router-gateway-set ubuntu-router ext-net > /dev/null 2>&1; then
60
 
        debug openstack "Neutron not ready yet..."
61
 
    fi
62
 
 
63
 
    # create pool of at least 5 floating ips
64
 
    debug openstack "creating floating ips"
65
 
    existingips=$(neutron floatingip-list -f csv | tail -n +2| wc -l)
66
 
    to_create=$((10 - existingips))
67
 
    i=0
68
 
    while [ $i -ne $to_create ]; do
69
 
        neutron floatingip-create ext-net > /dev/null 2>&1
70
 
        i=$((i + 1))
71
 
    done
72
 
 
73
 
    # configure security groups
74
 
    debug openstack "setting security roles"
75
 
    neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol icmp --remote-ip-prefix 0.0.0.0/0 default > /dev/null 2>&1 || true
76
 
    neutron security-group-rule-create --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22 --remote-ip-prefix 0.0.0.0/0 default > /dev/null 2>&1 || true
77
 
    debug openstack "neutron configured!"
78
 
}