Browse code

Merge remote-tracking branch 'upstream/master' into rcb-master

Dean Troyer authored on 2011/10/12 07:57:16
Showing 32 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+proto
1
+*~
2
+localrc
0 3
new file mode 100644
... ...
@@ -0,0 +1,42 @@
0
+Tool to quickly deploy openstack dev environments.
1
+
2
+# Goals
3
+
4
+* To quickly build dev openstack environments in clean natty environments
5
+* To describe working configurations of openstack (which code branches work together?  what do config files look like for those branches?)
6
+* To make it easier for developers to dive into openstack so that they can productively contribute without having to understand every part of the system at once
7
+* To make it easy to prototype cross-project features
8
+
9
+Be sure to carefully read these scripts before you run them as they install software and may alter your networking configuration.
10
+
11
+# To start a dev cloud on your local machine (installing on a dedicated vm is safer!):
12
+
13
+    ./stack.sh
14
+
15
+If working correctly, you should be able to access openstack endpoints, like:
16
+
17
+* Dashboard: http://myhost/
18
+* Keystone: http://myhost:5000/v2.0/
19
+
20
+# To start a dev cloud in an lxc container:
21
+
22
+    ./build_lxc.sh
23
+
24
+You will need to configure a bridge and network on your host machine (by default br0) before starting build_lxc.sh.  A sample host-only network configuration can be found in lxc_network_hostonlyplusnat.sh.
25
+
26
+# Customizing
27
+
28
+You can tweak environment variables by creating file name 'localrc' should you need to override defaults.  It is likely that you will need to do this to tweak your networking configuration should you need to access your cloud from a different host.
29
+
30
+# Todo
31
+
32
+* Add python-novaclient cli support
33
+* syslog
34
+* allow rabbit connection to be specified via environment variables with sensible defaults
35
+* Add volume support
36
+* Add quantum support
37
+
38
+# Future
39
+
40
+* idea: move from screen to tmux?
41
+* idea: create a live-cd / vmware preview image using this?
0 42
new file mode 100755
... ...
@@ -0,0 +1,251 @@
0
+#!/usr/bin/env bash
1
+
2
+# Sanity check
3
+if [ "$EUID" -ne "0" ]; then
4
+  echo "This script must be run with root privileges."
5
+  exit 1
6
+fi
7
+
8
+# Warn users who aren't on natty
9
+if ! grep -q natty /etc/lsb-release; then
10
+    echo "WARNING: this script has only been tested on natty"
11
+fi
12
+
13
+# Source params
14
+source ./stackrc
15
+
16
+# Store cwd
17
+CWD=`pwd`
18
+
19
+# Configurable params
20
+BRIDGE=${BRIDGE:-br0}
21
+CONTAINER=${CONTAINER:-STACK}
22
+CONTAINER_IP=${CONTAINER_IP:-192.168.1.50}
23
+CONTAINER_CIDR=${CONTAINER_CIDR:-$CONTAINER_IP/24}
24
+CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0}
25
+CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1}
26
+NAMESERVER=${NAMESERVER:-$CONTAINER_GATEWAY}
27
+COPYENV=${COPYENV:-1}
28
+DEST=${DEST:-/opt/stack}
29
+
30
+# Param string to pass to stack.sh.  Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
31
+STACKSH_PARAMS=${STACKSH_PARAMS:-}
32
+
33
+# Option to use the version of devstack on which we are currently working
34
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
35
+
36
+
37
+# Install deps
38
+apt-get install -y lxc debootstrap
39
+
40
+# Install cgroup-bin from source, since the packaging is buggy and possibly incompatible with our setup
41
+if ! which cgdelete | grep -q cgdelete; then
42
+    apt-get install -y g++ bison flex libpam0g-dev make
43
+    wget http://sourceforge.net/projects/libcg/files/libcgroup/v0.37.1/libcgroup-0.37.1.tar.bz2/download -O /tmp/libcgroup-0.37.1.tar.bz2
44
+    cd /tmp && bunzip2 libcgroup-0.37.1.tar.bz2  && tar xfv libcgroup-0.37.1.tar
45
+    cd libcgroup-0.37.1
46
+    ./configure
47
+    make install
48
+    ldconfig
49
+fi
50
+
51
+# Create lxc configuration
52
+LXC_CONF=/tmp/$CONTAINER.conf
53
+cat > $LXC_CONF <<EOF
54
+lxc.network.type = veth
55
+lxc.network.link = $BRIDGE
56
+lxc.network.flags = up
57
+lxc.network.ipv4 = $CONTAINER_CIDR
58
+# allow tap/tun devices
59
+lxc.cgroup.devices.allow = c 10:200 rwm
60
+EOF
61
+
62
+# Shutdown any existing container
63
+lxc-stop -n $CONTAINER
64
+
65
+# This kills zombie containers
66
+if [ -d /cgroup/$CONTAINER ]; then
67
+    cgdelete -r cpu,net_cls:$CONTAINER
68
+fi
69
+
70
+# git clone only if directory doesn't exist already.  Since ``DEST`` might not
71
+# be owned by the installation user, we create the directory and change the
72
+# ownership to the proper user.
73
+function git_clone {
74
+    if [ ! -d $2 ]; then
75
+        sudo mkdir $2
76
+        sudo chown `whoami` $2
77
+        git clone $1 $2
78
+        cd $2
79
+        # This checkout syntax works for both branches and tags
80
+        git checkout $3
81
+    fi
82
+}
83
+
84
+# Location of the base image directory
85
+CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
86
+
87
+# Provide option to do totally clean install
88
+if [ "$CLEAR_LXC_CACHE" = "1" ]; then
89
+    rm -rf $CACHEDIR
90
+fi
91
+
92
+# Warm the base image on first install
93
+if [ ! -f $CACHEDIR/bootstrapped ]; then
94
+    # by deleting the container, we force lxc-create to re-bootstrap (lxc is
95
+    # lazy and doesn't do anything if a container already exists)
96
+    lxc-destroy -n $CONTAINER
97
+    # trigger the initial debootstrap
98
+    lxc-create -n $CONTAINER -t natty -f $LXC_CONF
99
+    chroot $CACHEDIR apt-get update
100
+    chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
101
+    chroot $CACHEDIR pip install `cat files/pips/*`
102
+    touch $CACHEDIR/bootstrapped
103
+fi
104
+
105
+# Clean out code repos if directed to do so
106
+if [ "$CLEAN" = "1" ]; then
107
+    rm -rf $CACHEDIR/$DEST
108
+fi
109
+
110
+# Cache openstack code
111
+mkdir -p $CACHEDIR/$DEST
112
+git_clone $NOVA_REPO $CACHEDIR/$DEST/nova $NOVA_BRANCH
113
+git_clone $GLANCE_REPO $CACHEDIR/$DEST/glance $GLANCE_BRANCH
114
+git_clone $KEYSTONE_REPO $CACHEDIR/$DESTkeystone $KEYSTONE_BRANCH
115
+git_clone $NOVNC_REPO $CACHEDIR/$DEST/novnc $NOVNC_BRANCH
116
+git_clone $DASH_REPO $CACHEDIR/$DEST/dash $DASH_BRANCH $DASH_TAG
117
+git_clone $NOVACLIENT_REPO $CACHEDIR/$DEST/python-novaclient $NOVACLIENT_BRANCH
118
+git_clone $OPENSTACKX_REPO $CACHEDIR/$DEST/openstackx $OPENSTACKX_BRANCH
119
+
120
+# Use this version of devstack?
121
+if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
122
+    rm -rf $CACHEDIR/$DEST/devstack
123
+    cp -pr $CWD $CACHEDIR/$DEST/devstack
124
+fi
125
+
126
+# Destroy the old container
127
+lxc-destroy -n $CONTAINER
128
+
129
+# If this call is to TERMINATE the container then exit
130
+if [ "$TERMINATE" = "1" ]; then
131
+    exit
132
+fi
133
+
134
+# Create the container
135
+lxc-create -n $CONTAINER -t natty -f $LXC_CONF
136
+
137
+# Specify where our container rootfs lives
138
+ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/
139
+
140
+# Create a stack user that is a member of the libvirtd group so that stack
141
+# is able to interact with libvirt.
142
+chroot $ROOTFS groupadd libvirtd
143
+chroot $ROOTFS useradd stack -s /bin/bash -d $DEST -G libvirtd
144
+
145
+# a simple password - pass
146
+echo stack:pass | chroot $ROOTFS chpasswd
147
+
148
+# and has sudo ability (in the future this should be limited to only what
149
+# stack requires)
150
+echo "stack ALL=(ALL) NOPASSWD: ALL" >> $ROOTFS/etc/sudoers
151
+
152
+# Copy kernel modules
153
+mkdir -p $ROOTFS/lib/modules/`uname -r`/kernel
154
+cp -p /lib/modules/`uname -r`/modules.dep $ROOTFS/lib/modules/`uname -r`/
155
+cp -pR /lib/modules/`uname -r`/kernel/net $ROOTFS/lib/modules/`uname -r`/kernel/
156
+
157
+# Gracefully cp only if source file/dir exists
158
+function cp_it {
159
+    if [ -e $1 ] || [ -d $1 ]; then
160
+        cp -pRL $1 $2
161
+    fi
162
+}
163
+
164
+# Copy over your ssh keys and env if desired
165
+if [ "$COPYENV" = "1" ]; then
166
+    cp_it ~/.ssh $ROOTFS/$DEST/.ssh
167
+    cp_it ~/.ssh/id_rsa.pub $ROOTFS/$DEST/.ssh/authorized_keys
168
+    cp_it ~/.gitconfig $ROOTFS/$DEST/.gitconfig
169
+    cp_it ~/.vimrc $ROOTFS/$DEST/.vimrc
170
+    cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc
171
+fi
172
+
173
+# Make our ip address hostnames look nice at the command prompt
174
+echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/$DEST/.bashrc
175
+echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/etc/profile
176
+
177
+# Give stack ownership over $DEST so it may do the work needed
178
+chroot $ROOTFS chown -R stack $DEST
179
+
180
+# Configure instance network
181
+INTERFACES=$ROOTFS/etc/network/interfaces
182
+cat > $INTERFACES <<EOF
183
+auto lo
184
+iface lo inet loopback
185
+
186
+auto eth0
187
+iface eth0 inet static
188
+        address $CONTAINER_IP
189
+        netmask $CONTAINER_NETMASK
190
+        gateway $CONTAINER_GATEWAY
191
+EOF
192
+
193
+# Configure the runner
194
+RUN_SH=$ROOTFS/$DEST/run.sh
195
+cat > $RUN_SH <<EOF
196
+#!/usr/bin/env bash
197
+# Make sure dns is set up
198
+echo "nameserver $NAMESERVER" | sudo resolvconf -a eth0
199
+sleep 1
200
+
201
+# Kill any existing screens
202
+killall screen
203
+
204
+# Install and run stack.sh
205
+sudo apt-get update
206
+sudo apt-get -y --force-yes install git-core vim-nox sudo
207
+if [ ! -d "$DEST/devstack" ]; then
208
+    git clone git://github.com/cloudbuilders/devstack.git $DEST/devstack
209
+fi
210
+cd $DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log
211
+echo >> /$DEST/run.sh.log
212
+echo >> /$DEST/run.sh.log
213
+echo "All done! Time to start clicking." >> /$DEST/run.sh.log
214
+EOF
215
+
216
+# Make the run.sh executable
217
+chmod 755 $RUN_SH
218
+
219
+# Make runner launch on boot
220
+RC_LOCAL=$ROOTFS/etc/rc.local
221
+cat > $RC_LOCAL <<EOF
222
+#!/bin/sh -e
223
+su -c "$DEST/run.sh" stack
224
+EOF
225
+
226
+# Configure cgroup directory
227
+if ! mount | grep -q cgroup; then
228
+    mkdir -p /cgroup
229
+    mount none -t cgroup /cgroup
230
+fi
231
+
232
+# Start our container
233
+lxc-start -d -n $CONTAINER
234
+
235
+# Done creating the container, let's tail the log
236
+echo
237
+echo "============================================================="
238
+echo "                          -- YAY! --"
239
+echo "============================================================="
240
+echo
241
+echo "We're done creating the container, about to start tailing the"
242
+echo "stack.sh log. It will take a second or two to start."
243
+echo
244
+echo "Just CTRL-C at any time to stop tailing."
245
+
246
+while [ ! -e "$ROOTFS/$DEST/run.sh.log" ]; do
247
+  sleep 1
248
+done
249
+
250
+tail -F $ROOTFS/$DEST/run.sh.log
0 251
new file mode 100755
... ...
@@ -0,0 +1,39 @@
0
+#!/usr/bin/env bash
1
+# Head node host, which runs glance, api, keystone
2
+HEAD_HOST=${HEAD_HOST:-192.168.1.52}
3
+COMPUTE_HOSTS=${COMPUTE_HOSTS:-192.168.1.53,192.168.1.54}
4
+
5
+# Networking params
6
+NAMESERVER=${NAMESERVER:-192.168.1.1}
7
+GATEWAY=${GATEWAY:-192.168.1.1}
8
+NETMASK=${NETMASK:-255.255.255.0}
9
+FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30}
10
+
11
+# Setting this to 1 shuts down and destroys our containers without relaunching.
12
+TERMINATE=${TERMINATE:-0}
13
+
14
+# Variables common amongst all hosts in the cluster
15
+COMMON_VARS="MYSQL_HOST=$HEAD_HOST RABBIT_HOST=$HEAD_HOST GLANCE_HOSTPORT=$HEAD_HOST:9292 NET_MAN=FlatDHCPManager FLAT_INTERFACE=eth0 FLOATING_RANGE=$FLOATING_RANGE MULTI_HOST=1"
16
+
17
+# Helper to launch containers
18
+function run_lxc {
19
+    # For some reason container names with periods can cause issues :/
20
+    CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./build_lxc.sh
21
+}
22
+
23
+# Launch the head node - headnode uses a non-ip domain name,
24
+# because rabbit won't launch with an ip addr hostname :(
25
+run_lxc STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,dash,mysql,rabbit"
26
+
27
+# Wait till the head node is up
28
+if [ ! "$TERMINATE" = "1" ]; then
29
+    while ! wget -q -O- http://$HEAD_HOST | grep -q username; do
30
+        echo "Waiting for head node ($HEAD_HOST) to start..."
31
+        sleep 5
32
+    done
33
+fi
34
+
35
+# Launch the compute hosts
36
+for compute_host in ${COMPUTE_HOSTS//,/ }; do
37
+    run_lxc $compute_host $compute_host "ENABLED_SERVICES=n-cpu,n-net,n-api"
38
+done
0 39
new file mode 100755
... ...
@@ -0,0 +1,117 @@
0
+#!/bin/bash
1
+
2
+PROGDIR=`dirname $0`
3
+CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
4
+
5
+# Source params
6
+source ./stackrc
7
+
8
+# Store cwd
9
+CWD=`pwd`
10
+
11
+NAME=$1
12
+NFSDIR="/nfs/$NAME"
13
+DEST=${DEST:-/opt/stack}
14
+
15
+# Option to use the version of devstack on which we are currently working
16
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
17
+
18
+# remove old nfs filesystem if one exists
19
+rm -rf $DEST
20
+
21
+# clean install of natty
22
+if [ ! -d $CHROOTCACHE/natty-base ]; then
23
+    $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
24
+    # copy kernel modules...  
25
+    # NOTE(ja): is there a better way to do this?
26
+    cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
27
+    # a simple password - pass
28
+    echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
29
+fi
30
+
31
+# prime natty with as many apt/pips as we can
32
+if [ ! -d $CHROOTCACHE/natty-dev ]; then
33
+    rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
34
+    chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
35
+    chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
36
+
37
+    # Create a stack user that is a member of the libvirtd group so that stack 
38
+    # is able to interact with libvirt.
39
+    chroot $CHROOTCACHE/natty-dev groupadd libvirtd
40
+    chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
41
+    mkdir -p $CHROOTCACHE/natty-dev/$DEST
42
+    chown stack $CHROOTCACHE/natty-dev/$DEST
43
+
44
+    # a simple password - pass
45
+    echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
46
+
47
+    # and has sudo ability (in the future this should be limited to only what 
48
+    # stack requires)
49
+    echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
50
+fi
51
+
52
+# clone git repositories onto the system
53
+# ======================================
54
+
55
+if [ ! -d $CHROOTCACHE/natty-stack ]; then
56
+    rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
57
+fi
58
+
59
+# git clone only if directory doesn't exist already.  Since ``DEST`` might not
60
+# be owned by the installation user, we create the directory and change the
61
+# ownership to the proper user.
62
+function git_clone {
63
+
64
+    # clone new copy or fetch latest changes
65
+    CHECKOUT=$CHROOTCACHE/natty-stack$2
66
+    if [ ! -d $CHECKOUT ]; then
67
+        mkdir -p $CHECKOUT
68
+        git clone $1 $CHECKOUT
69
+    else
70
+        pushd $CHECKOUT
71
+        git fetch
72
+        popd
73
+    fi
74
+
75
+    # FIXME(ja): checkout specified version (should works for branches and tags)
76
+
77
+    pushd $CHECKOUT
78
+    # checkout the proper branch/tag
79
+    git checkout $3
80
+    # force our local version to be the same as the remote version
81
+    git reset --hard origin/$3
82
+    popd
83
+
84
+    # give ownership to the stack user
85
+    chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
86
+}
87
+
88
+git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
89
+git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
90
+git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
91
+git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
92
+git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG
93
+git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
94
+git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
95
+
96
+chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files
97
+wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz
98
+
99
+# Use this version of devstack?
100
+if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
101
+    rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
102
+    cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
103
+fi
104
+
105
+cp -pr $CHROOTCACHE/natty-stack $NFSDIR
106
+
107
+# set hostname
108
+echo $NAME > $NFSDIR/etc/hostname
109
+echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts
110
+
111
+# injecting root's public ssh key if it exists
112
+if [ -f /root/.ssh/id_rsa.pub ]; then
113
+    mkdir $NFSDIR/root/.ssh
114
+    chmod 700 $NFSDIR/root/.ssh
115
+    cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys
116
+fi
0 117
new file mode 100755
... ...
@@ -0,0 +1,116 @@
0
+#!/bin/bash -e
1
+# build_pxe_boot.sh - Create a PXE boot environment
2
+#
3
+# build_pxe_boot.sh [-k kernel-version] destdir
4
+#
5
+# Assumes syslinux is installed
6
+# Assumes devstack files are in `pwd`/pxe
7
+# Only needs to run as root if the destdir permissions require it
8
+
9
+UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
10
+
11
+MEMTEST_VER=4.10
12
+MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
13
+MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
14
+
15
+KVER=`uname -r`
16
+if [ "$1" = "-k" ]; then
17
+    KVER=$2
18
+    shift;shift
19
+fi
20
+
21
+DEST_DIR=${1:-/tmp}/tftpboot
22
+PXEDIR=${PXEDIR:-/var/cache/devstack/pxe}
23
+OPWD=`pwd`
24
+PROGDIR=`dirname $0`
25
+
26
+mkdir -p $DEST_DIR/pxelinux.cfg
27
+cd $DEST_DIR
28
+for i in memdisk menu.c32 pxelinux.0; do
29
+	cp -p /usr/lib/syslinux/$i $DEST_DIR
30
+done
31
+
32
+DEFAULT=$DEST_DIR/pxelinux.cfg/default
33
+cat >$DEFAULT <<EOF
34
+default menu.c32
35
+prompt 0
36
+timeout 0
37
+
38
+MENU TITLE PXE Boot Menu
39
+
40
+EOF
41
+
42
+# Setup devstack boot
43
+mkdir -p $DEST_DIR/ubuntu
44
+if [ ! -d $PXEDIR ]; then
45
+    mkdir -p $PXEDIR
46
+fi
47
+if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then
48
+    sudo chmod 644 /boot/vmlinuz-${KVER}
49
+    if [ ! -r /boot/vmlinuz-${KVER} ]; then
50
+        echo "No kernel found"
51
+    else
52
+        cp -p /boot/vmlinuz-${KVER} $PXEDIR
53
+    fi
54
+fi
55
+cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
56
+if [ ! -r $PXEDIR/stack-initrd.gz ]; then
57
+    cd $OPWD
58
+    sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz
59
+fi
60
+cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
61
+cat >>$DEFAULT <<EOF
62
+
63
+LABEL devstack
64
+    MENU LABEL ^devstack
65
+    MENU DEFAULT
66
+    KERNEL ubuntu/vmlinuz-$KVER
67
+    APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
68
+EOF
69
+
70
+# Get Ubuntu
71
+if [ -d $PXEDIR ]; then
72
+    cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
73
+fi
74
+cat >>$DEFAULT <<EOF
75
+
76
+LABEL ubuntu
77
+    MENU LABEL ^Ubuntu Natty
78
+    KERNEL ubuntu/vmlinuz-$KVER
79
+    APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
80
+EOF
81
+
82
+# Get Memtest
83
+cd $DEST_DIR
84
+if [ ! -r $MEMTEST_BIN ]; then
85
+    wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
86
+    gunzip $MEMTEST_BIN
87
+fi
88
+cat >>$DEFAULT <<EOF
89
+
90
+LABEL memtest
91
+    MENU LABEL ^Memtest86+
92
+    KERNEL $MEMTEST_BIN
93
+EOF
94
+
95
+# Get FreeDOS
96
+mkdir -p $DEST_DIR/freedos
97
+cd $DEST_DIR/freedos
98
+wget -N --quiet http://www.fdos.org/bootdisks/autogen/FDSTD.288.gz
99
+gunzip -f FDSTD.288.gz
100
+cat >>$DEFAULT <<EOF
101
+
102
+LABEL freedos
103
+	MENU LABEL ^FreeDOS bootdisk
104
+	KERNEL memdisk
105
+	APPEND initrd=freedos/FDSTD.288
106
+EOF
107
+
108
+# Local disk boot
109
+cat >>$DEFAULT <<EOF
110
+
111
+LABEL local
112
+    MENU LABEL ^Local disk
113
+    MENU DEFAULT
114
+    LOCALBOOT 0
115
+EOF
0 116
new file mode 100755
... ...
@@ -0,0 +1,135 @@
0
+#!/bin/bash
1
+
2
+if [ ! "$#" -eq "1" ]; then
3
+    echo "$0 builds a gziped natty openstack install"
4
+    echo "usage: $0 dest"
5
+    exit 1
6
+fi
7
+
8
+PROGDIR=`dirname $0`
9
+CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
10
+
11
+# Source params
12
+source ./stackrc
13
+
14
+# Store cwd
15
+CWD=`pwd`
16
+
17
+DEST=${DEST:-/opt/stack}
18
+
19
+# Option to use the version of devstack on which we are currently working
20
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
21
+
22
+# clean install of natty
23
+if [ ! -d $CHROOTCACHE/natty-base ]; then
24
+    $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
25
+    # copy kernel modules...  
26
+    # NOTE(ja): is there a better way to do this?
27
+    cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
28
+    # a simple password - pass
29
+    echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
30
+fi
31
+
32
+# prime natty with as many apt/pips as we can
33
+if [ ! -d $CHROOTCACHE/natty-dev ]; then
34
+    rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
35
+    chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
36
+    chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
37
+
38
+    # Create a stack user that is a member of the libvirtd group so that stack 
39
+    # is able to interact with libvirt.
40
+    chroot $CHROOTCACHE/natty-dev groupadd libvirtd
41
+    chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
42
+    mkdir -p $CHROOTCACHE/natty-dev/$DEST
43
+    chown stack $CHROOTCACHE/natty-dev/$DEST
44
+
45
+    # a simple password - pass
46
+    echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
47
+
48
+    # and has sudo ability (in the future this should be limited to only what 
49
+    # stack requires)
50
+    echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
51
+fi
52
+
53
+# clone git repositories onto the system
54
+# ======================================
55
+
56
+if [ ! -d $CHROOTCACHE/natty-stack ]; then
57
+    rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
58
+fi
59
+
60
+# git clone only if directory doesn't exist already.  Since ``DEST`` might not
61
+# be owned by the installation user, we create the directory and change the
62
+# ownership to the proper user.
63
+function git_clone {
64
+
65
+    # clone new copy or fetch latest changes
66
+    CHECKOUT=$CHROOTCACHE/natty-stack$2
67
+    if [ ! -d $CHECKOUT ]; then
68
+        mkdir -p $CHECKOUT
69
+        git clone $1 $CHECKOUT
70
+    else
71
+        pushd $CHECKOUT
72
+        git fetch
73
+        popd
74
+    fi
75
+
76
+    # FIXME(ja): checkout specified version (should works for branches and tags)
77
+
78
+    pushd $CHECKOUT
79
+    # checkout the proper branch/tag
80
+    git checkout $3
81
+    # force our local version to be the same as the remote version
82
+    git reset --hard origin/$3
83
+    popd
84
+
85
+    # give ownership to the stack user
86
+    chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
87
+}
88
+
89
+git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
90
+git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
91
+git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
92
+git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
93
+git_clone $DASH_REPO $DEST/dash $DASH_BRANCH
94
+git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
95
+git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
96
+
97
+# Use this version of devstack?
98
+if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
99
+    rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
100
+    cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
101
+fi
102
+
103
+# Configure host network for DHCP
104
+mkdir -p $CHROOTCACHE/natty-stack/etc/network
105
+cat > $CHROOTCACHE/natty-stack/etc/network/interfaces <<EOF
106
+auto lo
107
+iface lo inet loopback
108
+
109
+auto eth0
110
+iface eth0 inet dhcp
111
+EOF
112
+
113
+# build a new image
114
+BASE=$CHROOTCACHE/build.$$
115
+IMG=$BASE.img
116
+MNT=$BASE/
117
+
118
+# (quickly) create a 2GB blank filesystem
119
+dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG
120
+# force it to be initialized as ext2
121
+mkfs.ext2 -F $IMG
122
+
123
+# mount blank image loopback and load it
124
+mkdir -p $MNT
125
+mount -o loop $IMG $MNT
126
+rsync -azH $CHROOTCACHE/natty-stack/ $MNT
127
+
128
+# umount and cleanup
129
+umount $MNT
130
+rmdir $MNT
131
+
132
+# gzip into final location
133
+gzip -1 $IMG -c > $1
134
+
0 135
new file mode 100755
... ...
@@ -0,0 +1,82 @@
0
+#!/usr/bin/env bash
1
+
2
+# **exercise.sh** - using the cloud can be fun
3
+
4
+# we will use the ``nova`` cli tool provided by the ``python-novaclient``
5
+# package
6
+#
7
+
8
+
9
+# This script exits on an error so that errors don't compound and you see 
10
+# only the first error that occured.
11
+set -o errexit
12
+
13
+# Print the commands being run so that we can see the command that triggers 
14
+# an error.  It is also useful for following allowing as the install occurs.
15
+set -o xtrace
16
+
17
+
18
+# Settings
19
+# ========
20
+
21
+HOST=${HOST:-localhost}
22
+
23
+# Nova original used project_id as the *account* that owned resources (servers,
24
+# ip address, ...)   With the addition of Keystone we have standardized on the
25
+# term **tenant** as the entity that owns the resources.  **novaclient** still
26
+# uses the old deprecated terms project_id.  Note that this field should now be
27
+# set to tenant_name, not tenant_id.
28
+export NOVA_PROJECT_ID=${TENANT:-demo}
29
+
30
+# In addition to the owning entity (tenant), nova stores the entity performing
31
+# the action as the **user**.
32
+export NOVA_USERNAME=${USERNAME:-demo}
33
+
34
+# With Keystone you pass the keystone password instead of an api key.
35
+export NOVA_API_KEY=${PASSWORD:-secrete}
36
+
37
+# With the addition of Keystone, to use an openstack cloud you should 
38
+# authenticate against keystone, which returns a **Token** and **Service 
39
+# Catalog**.  The catalog contains the endpoint for all services the user/tenant 
40
+# has access to - including nova, glance, keystone, swift, ...  We currently 
41
+# recommend using the 2.0 *auth api*.  
42
+#
43
+# *NOTE*: Using the 2.0 *auth api* does mean that compute api is 2.0.  We will
44
+# use the 1.1 *compute api*
45
+export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/}
46
+
47
+# Currently novaclient needs you to specify the *compute api* version.  This
48
+# needs to match the config of your catalog returned by Keystone.
49
+export NOVA_VERSION=1.1
50
+
51
+# FIXME - why does this need to be specified?
52
+export NOVA_REGION_NAME=RegionOne
53
+
54
+
55
+# Get a token for clients that don't support service catalog
56
+# ==========================================================
57
+SERVICE_TOKEN=`curl -s -d  "{\"auth\":{\"passwordCredentials\": {\"username\": \"$NOVA_PROJECT_ID\", \"password\": \"$NOVA_API_KEY\"}}}" -H "Content-type: application/json" http://$HOST:5000/v2.0/tokens | python -c "import sys; import json; tok = json.loads(sys.stdin.read()); print tok['access']['token']['id'];"`
58
+
59
+# Launching a server
60
+# ==================
61
+
62
+# List servers for tenant:
63
+nova list
64
+
65
+# List of flavors:
66
+nova flavor-list
67
+
68
+# Images
69
+# ------
70
+
71
+# Nova has a **deprecated** way of listing images.
72
+nova image-list
73
+
74
+# But we recommend using glance directly
75
+glance -A $SERVICE_TOKEN index
76
+
77
+# show details of the active servers::
78
+#
79
+#     nova show 1234
80
+#
81
+nova list | grep ACTIVE | cut -d \| -f2 | xargs -n1 nova show
0 82
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+<VirtualHost *:80>
1
+    WSGIScriptAlias / %DASH_DIR%/openstack-dashboard/dashboard/wsgi/django.wsgi
2
+    WSGIDaemonProcess dashboard user=%USER% group=%USER% processes=3 threads=10
3
+    SetEnv APACHE_RUN_USER %USER%
4
+    SetEnv APACHE_RUN_GROUP %USER%
5
+    WSGIProcessGroup dashboard
6
+
7
+    DocumentRoot %DASH_DIR%/.blackhole/
8
+    Alias /media %DASH_DIR%/openstack-dashboard/media
9
+
10
+    <Directory />
11
+        Options FollowSymLinks
12
+        AllowOverride None
13
+    </Directory>
14
+
15
+    <Directory %DASH_DIR%/>
16
+        Options Indexes FollowSymLinks MultiViews
17
+        AllowOverride None
18
+        Order allow,deny
19
+        allow from all
20
+    </Directory>
21
+
22
+    ErrorLog /var/log/apache2/error.log
23
+    LogLevel warn
24
+    CustomLog /var/log/apache2/access.log combined
25
+</VirtualHost>
26
+
0 27
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+apache2
1
+libapache2-mod-wsgi
2
+python-dateutil
3
+python-anyjson
0 4
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+pep8
1
+pylint
2
+python-pip
3
+screen
4
+unzip
5
+wget
6
+psmisc
7
+git-core
8
+lsof # useful when debugging
9
+openssh-server
10
+vim-nox
11
+locate # useful when debugging
12
+python-virtualenv
13
+python-unittest2
0 14
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+python-eventlet
1
+python-routes
2
+python-greenlet
3
+python-argparse
4
+python-sqlalchemy
5
+python-wsgiref
6
+python-pastedeploy
7
+python-xattr
0 8
new file mode 100644
... ...
@@ -0,0 +1,15 @@
0
+python-setuptools
1
+python-dev
2
+python-lxml
3
+python-pastescript
4
+python-pastedeploy
5
+python-paste
6
+sqlite3
7
+python-pysqlite2
8
+python-sqlalchemy
9
+python-webob
10
+python-greenlet
11
+python-routes
12
+libldap2-dev
13
+libsasl2-dev
14
+
0 15
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+dnsmasq-base
1
+kpartx
2
+mysql-server
3
+python-mysqldb
4
+kvm
5
+gawk
6
+iptables
7
+ebtables
8
+sqlite3
9
+sudo
10
+kvm
11
+libvirt-bin
12
+vlan
13
+curl
14
+rabbitmq-server
15
+socat # used by ajaxterm
16
+python-mox
17
+python-paste
18
+python-migrate
19
+python-gflags
20
+python-greenlet
21
+python-libvirt
22
+python-libxml2
23
+python-routes
24
+python-netaddr
25
+python-pastedeploy
26
+python-eventlet
27
+python-cheetah
28
+python-carrot
29
+python-tempita
30
+python-sqlalchemy
31
+python-suds
32
+python-lockfile
33
+python-m2crypto
34
+python-boto
0 35
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+python-numpy
0 1
new file mode 100644
... ...
@@ -0,0 +1,18 @@
0
+# a collection of packages that speed up installation as they are dependencies
1
+# of packages we can't install during bootstraping (rabbitmq-server, 
2
+# mysql-server, libvirt-bin)
3
+#
4
+# NOTE: only add packages to this file that aren't needed directly
5
+mysql-common
6
+mysql-client-5.1
7
+erlang-base
8
+erlang-ssl 
9
+erlang-nox
10
+erlang-inets
11
+erlang-mnesia
12
+libhtml-template-perl
13
+gettext-base
14
+libavahi-client3
15
+libxml2-utils
16
+libpciaccess0
17
+libparted0debian1
0 18
new file mode 100644
... ...
@@ -0,0 +1,98 @@
0
+import os
1
+
2
+DEBUG = True
3
+TEMPLATE_DEBUG = DEBUG
4
+PROD = False
5
+USE_SSL = False
6
+
7
+LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
8
+
9
+# FIXME: We need to change this to mysql, instead of sqlite.
10
+DATABASES = {
11
+    'default': {
12
+        'ENGINE': 'django.db.backends.sqlite3',
13
+        'NAME': os.path.join(LOCAL_PATH, 'dashboard_openstack.sqlite3'),
14
+    },
15
+}
16
+
17
+CACHE_BACKEND = 'dummy://'
18
+
19
+# Add apps to dash installation.
20
+INSTALLED_APPS = (
21
+    'dashboard',
22
+    'django.contrib.contenttypes',
23
+    'django.contrib.sessions',
24
+    'django.contrib.messages',
25
+    'django.contrib.staticfiles',
26
+    'django_openstack',
27
+    'django_openstack.templatetags',
28
+    'mailer',
29
+)
30
+
31
+
32
+# Send email to the console by default
33
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
34
+# Or send them to /dev/null
35
+#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
36
+
37
+# django-mailer uses a different settings attribute
38
+MAILER_EMAIL_BACKEND = EMAIL_BACKEND
39
+
40
+# Configure these for your outgoing email host
41
+# EMAIL_HOST = 'smtp.my-company.com'
42
+# EMAIL_PORT = 25
43
+# EMAIL_HOST_USER = 'djangomail'
44
+# EMAIL_HOST_PASSWORD = 'top-secret!'
45
+
46
+# FIXME: This needs to be changed to allow for multi-node setup.
47
+OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0/"
48
+OPENSTACK_KEYSTONE_ADMIN_URL = "http://localhost:35357/v2.0"
49
+OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
50
+
51
+# NOTE(tres): Available services should come from the service
52
+#             catalog in Keystone.
53
+SWIFT_ENABLED = False
54
+
55
+# Configure quantum connection details for networking
56
+QUANTUM_ENABLED = False
57
+QUANTUM_URL = '127.0.0.1'
58
+QUANTUM_PORT = '9696'
59
+QUANTUM_TENANT = '1234'
60
+QUANTUM_CLIENT_VERSION='0.1'
61
+
62
+# No monitoring links currently
63
+EXTERNAL_MONITORING = []
64
+
65
+# Uncomment the following segment to silence most logging
66
+# django.db and boto DEBUG logging is extremely verbose.
67
+#LOGGING = {
68
+#        'version': 1,
69
+#        # set to True will disable all logging except that specified, unless
70
+#        # nothing is specified except that django.db.backends will still log,
71
+#        # even when set to True, so disable explicitly
72
+#        'disable_existing_loggers': False,
73
+#        'handlers': {
74
+#            'null': {
75
+#                'level': 'DEBUG',
76
+#                'class': 'django.utils.log.NullHandler',
77
+#                },
78
+#            'console': {
79
+#                'level': 'DEBUG',
80
+#                'class': 'logging.StreamHandler',
81
+#                },
82
+#            },
83
+#        'loggers': {
84
+#            # Comment or Uncomment these to turn on/off logging output
85
+#            'django.db.backends': {
86
+#                'handlers': ['null'],
87
+#                'propagate': False,
88
+#                },
89
+#            'django_openstack': {
90
+#                'handlers': ['null'],
91
+#                'propagate': False,
92
+#            },
93
+#        }
94
+#}
95
+
96
+# How much ram on each compute host?
97
+COMPUTE_HOST_RAM_GB = 16
0 98
new file mode 100644
... ...
@@ -0,0 +1,178 @@
0
+[DEFAULT]
1
+# Show more verbose log output (sets INFO log level output)
2
+verbose = True
3
+
4
+# Show debugging output in logs (sets DEBUG log level output)
5
+debug = True
6
+
7
+# Which backend store should Glance use by default is not specified
8
+# in a request to add a new image to Glance? Default: 'file'
9
+# Available choices are 'file', 'swift', and 's3'
10
+default_store = file
11
+
12
+# Address to bind the API server
13
+bind_host = 0.0.0.0
14
+
15
+# Port the bind the API server to
16
+bind_port = 9292
17
+
18
+# Address to find the registry server
19
+registry_host = 0.0.0.0
20
+
21
+# Port the registry server is listening on
22
+registry_port = 9191
23
+
24
+# Log to this file. Make sure you do not set the same log
25
+# file for both the API and registry servers!
26
+log_file = %DEST%/glance/api.log
27
+
28
+# Send logs to syslog (/dev/log) instead of to file specified by `log_file`
29
+use_syslog = False
30
+
31
+# ============ Notification System Options =====================
32
+
33
+# Notifications can be sent when images are create, updated or deleted.
34
+# There are three methods of sending notifications, logging (via the
35
+# log_file directive), rabbit (via a rabbitmq queue) or noop (no
36
+# notifications sent, the default)
37
+notifier_strategy = noop
38
+
39
+# Configuration options if sending notifications via rabbitmq (these are
40
+# the defaults)
41
+rabbit_host = localhost
42
+rabbit_port = 5672
43
+rabbit_use_ssl = false
44
+rabbit_userid = guest
45
+rabbit_password = guest
46
+rabbit_virtual_host = /
47
+rabbit_notification_topic = glance_notifications
48
+
49
+# ============ Filesystem Store Options ========================
50
+
51
+# Directory that the Filesystem backend store
52
+# writes image data to
53
+filesystem_store_datadir = %DEST%/glance/images/
54
+
55
+# ============ Swift Store Options =============================
56
+
57
+# Address where the Swift authentication service lives
58
+swift_store_auth_address = 127.0.0.1:8080/v1.0/
59
+
60
+# User to authenticate against the Swift authentication service
61
+swift_store_user = jdoe
62
+
63
+# Auth key for the user authenticating against the
64
+# Swift authentication service
65
+swift_store_key = a86850deb2742ec3cb41518e26aa2d89
66
+
67
+# Container within the account that the account should use
68
+# for storing images in Swift
69
+swift_store_container = glance
70
+
71
+# Do we create the container if it does not exist?
72
+swift_store_create_container_on_put = False
73
+
74
+# What size, in MB, should Glance start chunking image files
75
+# and do a large object manifest in Swift? By default, this is
76
+# the maximum object size in Swift, which is 5GB
77
+swift_store_large_object_size = 5120
78
+
79
+# When doing a large object manifest, what size, in MB, should
80
+# Glance write chunks to Swift? This amount of data is written
81
+# to a temporary disk buffer during the process of chunking
82
+# the image file, and the default is 200MB
83
+swift_store_large_object_chunk_size = 200
84
+
85
+# Whether to use ServiceNET to communicate with the Swift storage servers.
86
+# (If you aren't RACKSPACE, leave this False!)
87
+#
88
+# To use ServiceNET for authentication, prefix hostname of
89
+# `swift_store_auth_address` with 'snet-'.
90
+# Ex. https://example.com/v1.0/ -> https://snet-example.com/v1.0/
91
+swift_enable_snet = False
92
+
93
+# ============ S3 Store Options =============================
94
+
95
+# Address where the S3 authentication service lives
96
+s3_store_host = 127.0.0.1:8080/v1.0/
97
+
98
+# User to authenticate against the S3 authentication service
99
+s3_store_access_key = <20-char AWS access key>
100
+
101
+# Auth key for the user authenticating against the
102
+# S3 authentication service
103
+s3_store_secret_key = <40-char AWS secret key>
104
+
105
+# Container within the account that the account should use
106
+# for storing images in S3. Note that S3 has a flat namespace,
107
+# so you need a unique bucket name for your glance images. An
108
+# easy way to do this is append your AWS access key to "glance".
109
+# S3 buckets in AWS *must* be lowercased, so remember to lowercase
110
+# your AWS access key if you use it in your bucket name below!
111
+s3_store_bucket = <lowercased 20-char aws access key>glance
112
+
113
+# Do we create the bucket if it does not exist?
114
+s3_store_create_bucket_on_put = False
115
+
116
+# ============ Image Cache Options ========================
117
+
118
+image_cache_enabled = False
119
+
120
+# Directory that the Image Cache writes data to
121
+# Make sure this is also set in glance-pruner.conf
122
+image_cache_datadir = /var/lib/glance/image-cache/
123
+
124
+# Number of seconds after which we should consider an incomplete image to be
125
+# stalled and eligible for reaping
126
+image_cache_stall_timeout = 86400
127
+
128
+# ============ Delayed Delete Options =============================
129
+
130
+# Turn on/off delayed delete
131
+delayed_delete = False
132
+
133
+# Delayed delete time in seconds
134
+scrub_time = 43200
135
+
136
+# Directory that the scrubber will use to remind itself of what to delete
137
+# Make sure this is also set in glance-scrubber.conf
138
+scrubber_datadir = /var/lib/glance/scrubber
139
+
140
+[pipeline:glance-api]
141
+#pipeline = versionnegotiation context apiv1app
142
+# NOTE: use the following pipeline for keystone
143
+pipeline = versionnegotiation authtoken context apiv1app
144
+
145
+# To enable Image Cache Management API replace pipeline with below:
146
+# pipeline = versionnegotiation context imagecache apiv1app
147
+# NOTE: use the following pipeline for keystone auth (with caching)
148
+# pipeline = versionnegotiation authtoken context imagecache apiv1app
149
+
150
+[pipeline:versions]
151
+pipeline = versionsapp
152
+
153
+[app:versionsapp]
154
+paste.app_factory = glance.api.versions:app_factory
155
+
156
+[app:apiv1app]
157
+paste.app_factory = glance.api.v1:app_factory
158
+
159
+[filter:versionnegotiation]
160
+paste.filter_factory = glance.api.middleware.version_negotiation:filter_factory
161
+
162
+[filter:imagecache]
163
+paste.filter_factory = glance.api.middleware.image_cache:filter_factory
164
+
165
+[filter:context]
166
+paste.filter_factory = glance.common.context:filter_factory
167
+
168
+[filter:authtoken]
169
+paste.filter_factory = keystone.middleware.auth_token:filter_factory
170
+service_protocol = http
171
+service_host = 127.0.0.1
172
+service_port = 5000
173
+auth_host = 127.0.0.1
174
+auth_port = 35357
175
+auth_protocol = http
176
+auth_uri = http://127.0.0.1:5000/
177
+admin_token = %SERVICE_TOKEN%
0 178
new file mode 100644
... ...
@@ -0,0 +1,70 @@
0
+[DEFAULT]
1
+# Show more verbose log output (sets INFO log level output)
2
+verbose = True
3
+
4
+# Show debugging output in logs (sets DEBUG log level output)
5
+debug = True
6
+
7
+# Address to bind the registry server
8
+bind_host = 0.0.0.0
9
+
10
+# Port the bind the registry server to
11
+bind_port = 9191
12
+
13
+# Log to this file. Make sure you do not set the same log
14
+# file for both the API and registry servers!
15
+log_file = %DEST%/glance/registry.log
16
+
17
+# Where to store images
18
+filesystem_store_datadir = %DEST%/glance/images
19
+
20
+# Send logs to syslog (/dev/log) instead of to file specified by `log_file`
21
+use_syslog = False
22
+
23
+# SQLAlchemy connection string for the reference implementation
24
+# registry server. Any valid SQLAlchemy connection string is fine.
25
+# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
26
+sql_connection = %SQL_CONN%
27
+
28
+# Period in seconds after which SQLAlchemy should reestablish its connection
29
+# to the database.
30
+#
31
+# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
32
+# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
33
+# notice this, you can lower this value to ensure that SQLAlchemy reconnects
34
+# before MySQL can drop the connection.
35
+sql_idle_timeout = 3600
36
+
37
+# Limit the api to return `param_limit_max` items in a call to a container. If
38
+# a larger `limit` query param is provided, it will be reduced to this value.
39
+api_limit_max = 1000
40
+
41
+# If a `limit` query param is not provided in an api request, it will
42
+# default to `limit_param_default`
43
+limit_param_default = 25
44
+
45
+[pipeline:glance-registry]
46
+#pipeline = context registryapp
47
+# NOTE: use the following pipeline for keystone
48
+pipeline = authtoken keystone_shim context registryapp
49
+
50
+[app:registryapp]
51
+paste.app_factory = glance.registry.server:app_factory
52
+
53
+[filter:context]
54
+context_class = glance.registry.context.RequestContext
55
+paste.filter_factory = glance.common.context:filter_factory
56
+
57
+[filter:authtoken]
58
+paste.filter_factory = keystone.middleware.auth_token:filter_factory
59
+service_protocol = http
60
+service_host = 127.0.0.1
61
+service_port = 5000
62
+auth_host = 127.0.0.1
63
+auth_port = 35357
64
+auth_protocol = http
65
+auth_uri = http://127.0.0.1:5000/
66
+admin_token = %SERVICE_TOKEN%
67
+
68
+[filter:keystone_shim]
69
+paste.filter_factory = keystone.middleware.glance_auth_token:filter_factory
0 70
new file mode 100644
... ...
@@ -0,0 +1,86 @@
0
+[DEFAULT]
1
+# Show more verbose log output (sets INFO log level output)
2
+verbose = False
3
+
4
+# Show debugging output in logs (sets DEBUG log level output)
5
+debug = False
6
+
7
+# Which backend store should Keystone use by default.
8
+# Default: 'sqlite'
9
+# Available choices are 'sqlite' [future will include LDAP, PAM, etc]
10
+default_store = sqlite
11
+
12
+# Log to this file. Make sure you do not set the same log
13
+# file for both the API and registry servers!
14
+log_file = %DEST%/keystone/keystone.log
15
+
16
+# List of backends to be configured
17
+backends = keystone.backends.sqlalchemy
18
+#For LDAP support, add: ,keystone.backends.ldap
19
+
20
+# Dictionary Maps every service to a header.Missing services would get header
21
+# X_(SERVICE_NAME) Key => Service Name, Value => Header Name
22
+service-header-mappings = {
23
+	'nova' : 'X-Server-Management-Url',
24
+	'swift' : 'X-Storage-Url',
25
+	'cdn' : 'X-CDN-Management-Url'}
26
+
27
+# Address to bind the API server
28
+# TODO Properties defined within app not available via pipeline.
29
+service_host = 0.0.0.0
30
+
31
+# Port the bind the API server to
32
+service_port = 5000
33
+
34
+# Address to bind the Admin API server
35
+admin_host = 0.0.0.0
36
+
37
+# Port the bind the Admin API server to
38
+admin_port = 35357
39
+
40
+#Role that allows to perform admin operations.
41
+keystone-admin-role = KeystoneAdmin
42
+
43
+#Role that allows to perform service admin operations.
44
+keystone-service-admin-role = KeystoneServiceAdmin
45
+
46
+[keystone.backends.sqlalchemy]
47
+# SQLAlchemy connection string for the reference implementation registry
48
+# server. Any valid SQLAlchemy connection string is fine.
49
+# See: http://bit.ly/ideIpI
50
+#sql_connection = sqlite:///keystone.db
51
+sql_connection = %SQL_CONN%
52
+backend_entities = ['UserRoleAssociation', 'Endpoints', 'Role', 'Tenant',
53
+                    'User', 'Credentials', 'EndpointTemplates', 'Token',
54
+                    'Service']
55
+
56
+# Period in seconds after which SQLAlchemy should reestablish its connection
57
+# to the database.
58
+sql_idle_timeout = 30
59
+
60
+[pipeline:admin]
61
+pipeline =
62
+	urlrewritefilter
63
+	admin_api
64
+
65
+[pipeline:keystone-legacy-auth]
66
+pipeline =
67
+	urlrewritefilter
68
+    legacy_auth
69
+    RAX-KEY-extension
70
+    service_api
71
+
72
+[app:service_api]
73
+paste.app_factory = keystone.server:service_app_factory
74
+
75
+[app:admin_api]
76
+paste.app_factory = keystone.server:admin_app_factory
77
+
78
+[filter:urlrewritefilter]
79
+paste.filter_factory = keystone.middleware.url:filter_factory
80
+
81
+[filter:legacy_auth]
82
+paste.filter_factory = keystone.frontends.legacy_token_auth:filter_factory
83
+
84
+[filter:RAX-KEY-extension]
85
+paste.filter_factory = keystone.contrib.extensions.service.raxkey.frontend:filter_factory
0 86
new file mode 100755
... ...
@@ -0,0 +1,43 @@
0
+#!/bin/bash
1
+BIN_DIR=${BIN_DIR:-.}
2
+# Tenants
3
+$BIN_DIR/keystone-manage $* tenant add admin
4
+$BIN_DIR/keystone-manage $* tenant add demo
5
+$BIN_DIR/keystone-manage $* tenant add invisible_to_admin
6
+
7
+# Users
8
+$BIN_DIR/keystone-manage $* user add admin %ADMIN_PASSWORD%
9
+$BIN_DIR/keystone-manage $* user add demo %ADMIN_PASSWORD%
10
+
11
+# Roles
12
+$BIN_DIR/keystone-manage $* role add Admin
13
+$BIN_DIR/keystone-manage $* role add Member
14
+$BIN_DIR/keystone-manage $* role add KeystoneAdmin
15
+$BIN_DIR/keystone-manage $* role add KeystoneServiceAdmin
16
+$BIN_DIR/keystone-manage $* role grant Admin admin admin
17
+$BIN_DIR/keystone-manage $* role grant Member demo demo
18
+$BIN_DIR/keystone-manage $* role grant Member demo invisible_to_admin
19
+$BIN_DIR/keystone-manage $* role grant Admin admin demo
20
+$BIN_DIR/keystone-manage $* role grant Admin admin
21
+$BIN_DIR/keystone-manage $* role grant KeystoneAdmin admin
22
+$BIN_DIR/keystone-manage $* role grant KeystoneServiceAdmin admin
23
+
24
+# Services
25
+$BIN_DIR/keystone-manage $* service add nova compute "Nova Compute Service"
26
+$BIN_DIR/keystone-manage $* service add glance image "Glance Image Service"
27
+$BIN_DIR/keystone-manage $* service add keystone identity "Keystone Identity Service"
28
+
29
+#endpointTemplates
30
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne nova http://%HOST_IP%:8774/v1.1/%tenant_id% http://%HOST_IP%:8774/v1.1/%tenant_id%  http://%HOST_IP%:8774/v1.1/%tenant_id% 1 1
31
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne glance http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% 1 1
32
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne keystone http://%HOST_IP%:5000/v2.0 http://%HOST_IP%:35357/v2.0 http://%HOST_IP%:5000/v2.0 1 1
33
+# $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://%HOST_IP%:8080/v1/AUTH_%tenant_id% http://%HOST_IP%:8080/ http://%HOST_IP%:8080/v1/AUTH_%tenant_id% 1 1
34
+
35
+# Tokens
36
+$BIN_DIR/keystone-manage $* token add %SERVICE_TOKEN% admin admin 2015-02-05T00:00
37
+
38
+# EC2 related creds - note we are setting the token to user_password
39
+# but keystone doesn't parse them - it is just a blob from keystone's 
40
+# point of view
41
+$BIN_DIR/keystone-manage $* credentials add admin EC2 'admin_%ADMIN_PASSWORD%' admin admin || echo "no support for adding credentials"
42
+$BIN_DIR/keystone-manage $* credentials add demo EC2 'demo_%ADMIN_PASSWORD%' demo demo || echo "no support for adding credentials"
0 43
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+nose==1.0.0
1
+Django==1.3
2
+django-nose==0.1.2
3
+django-mailer
4
+django-registration==0.7
5
+kombu
6
+python-cloudfiles
7
+python-dateutil
8
+routes
9
+webob
10
+sqlalchemy
11
+paste
12
+PasteDeploy
13
+sqlalchemy-migrate
14
+eventlet
15
+xattr
16
+pep8
17
+pylint
18
+
19
+-e git+https://github.com/jacobian/openstack.compute.git#egg=openstack
20
+
0 21
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+PassLib
0 1
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+hardstatus on
1
+hardstatus alwayslastline
2
+hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G}%H %{..Y}%d/%m %c"
3
+
4
+defscrollback 1024
5
+
6
+vbell off
7
+startup_message off
8
+
0 9
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+deb http://us.archive.ubuntu.com/ubuntu/ natty main restricted
1
+deb http://us.archive.ubuntu.com/ubuntu/ natty-updates main restricted
2
+deb http://us.archive.ubuntu.com/ubuntu/ natty universe
3
+deb http://us.archive.ubuntu.com/ubuntu/ natty-updates universe
4
+deb http://us.archive.ubuntu.com/ubuntu/ natty multiverse
5
+deb http://us.archive.ubuntu.com/ubuntu/ natty-updates multiverse
6
+deb http://security.ubuntu.com/ubuntu natty-security main restricted
7
+deb http://security.ubuntu.com/ubuntu natty-security universe
8
+deb http://security.ubuntu.com/ubuntu natty-security multiverse
0 9
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+socat
0 1
new file mode 100755
... ...
@@ -0,0 +1,93 @@
0
+#!/bin/bash
1
+
2
+# Print some usage info
3
+function usage {
4
+  echo "Usage: $0 [OPTION] [host_ip]"
5
+  echo "Set up temporary networking for LXC"
6
+  echo ""
7
+  echo "  -n, --dry-run            Just print the commands that would execute."
8
+  echo "  -h, --help               Print this usage message."
9
+  echo ""
10
+  exit
11
+}
12
+
13
+# Allow passing the ip address on the command line.
14
+function process_option {
15
+  case "$1" in
16
+    -h|--help) usage;;
17
+    -n|--dry-run) dry_run=1;;
18
+    *) host_ip="$1"
19
+  esac
20
+}
21
+
22
+# Set up some defaults
23
+host_ip=
24
+dry_run=0
25
+bridge=br0
26
+DRIER=
27
+
28
+# Process the args
29
+for arg in "$@"; do
30
+  process_option $arg
31
+done
32
+
33
+if [ $dry_run ]; then
34
+  DRIER=echo
35
+fi
36
+
37
+if [ "$UID" -ne "0" ]; then
38
+  echo "This script must be run with root privileges."
39
+  exit 1
40
+fi
41
+
42
+# Check for bridge-utils.
43
+BRCTL=`which brctl`
44
+if [ ! -x "$BRCTL" ]; then
45
+  echo "This script requires you to install bridge-utils."
46
+  echo "Try: sudo apt-get install bridge-utils."
47
+  exit 1
48
+fi
49
+
50
+# Scare off the nubs.
51
+echo "====================================================="
52
+echo
53
+echo "WARNING"
54
+echo
55
+echo "This script will modify your current network setup,"
56
+echo "this can be a scary thing and it is recommended that"
57
+echo "you have something equivalent to physical access to"
58
+echo "this machine before continuing in case your network"
59
+echo "gets all funky."
60
+echo
61
+echo "If you don't want to continue, hit CTRL-C now."
62
+
63
+if [ -z "$host_ip" ];
64
+then
65
+  echo "Otherwise, please type in your host's ip address and"
66
+  echo "hit enter."
67
+  echo
68
+  echo "====================================================="
69
+  read host_ip
70
+else
71
+  echo "Otherwise hit enter."
72
+  echo
73
+  echo "====================================================="
74
+  read accept
75
+fi
76
+
77
+
78
+# Add a bridge interface, this will choke if there is already
79
+# a bridge named $bridge
80
+$DRIER $BRCTL addbr $bridge
81
+$DRIER ip addr add 192.168.1.1/24 dev $bridge
82
+if [ $dry_run ]; then
83
+  echo "echo 1 > /proc/sys/net/ipv4/ip_forward"
84
+else
85
+  echo 1 > /proc/sys/net/ipv4/ip_forward
86
+fi
87
+$DRIER ifconfig $bridge up
88
+
89
+# Set up the NAT for the instances
90
+$DRIER iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source $host_ip
91
+$DRIER iptables -I FORWARD -s 192.168.1.0/24 -j ACCEPT
92
+
0 93
new file mode 100755
... ...
@@ -0,0 +1,178 @@
0
+#!/bin/bash
1
+# make_image.sh - Create Ubuntu images in various formats
2
+#
3
+# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw
4
+#
5
+# Requires sudo to root
6
+
7
+ROOTSIZE=${ROOTSIZE:-8192}
8
+SWAPSIZE=${SWAPSIZE:-1024}
9
+MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
10
+
11
+usage() {
12
+    echo "Usage: $0 - Create Ubuntu images"
13
+    echo ""
14
+    echo "$0 [-m] [-r rootsize] [-s swapsize] release format"
15
+    echo "$0 -C [-m] release chrootdir"
16
+    echo "$0 -I [-r rootsize] [-s swapsize] chrootdir format"
17
+    echo ""
18
+    echo "-C        - Create the initial chroot dir"
19
+    echo "-I        - Create the final image from a chroot"
20
+    echo "-m        - minimal installation"
21
+    echo "-r size   - root fs size in MB"
22
+    echo "-s size   - swap fs size in MB"
23
+    echo "release   - Ubuntu release: jaunty - oneric"
24
+    echo "format    - image format: qcow2, vmdk, vdi, vhd, xen, raw, fs"
25
+    exit 1
26
+}
27
+
28
+while getopts CIhmr:s: c; do
29
+    case $c in
30
+        C)  CHROOTONLY=1
31
+            ;;
32
+        I)  IMAGEONLY=1
33
+            ;;
34
+        h)  usage
35
+            ;;
36
+        m)  MINIMAL=1
37
+            ;;
38
+        r)  ROOTSIZE=$OPTARG
39
+            ;;
40
+        s)  SWAPSIZE=$OPTARG
41
+            ;;
42
+    esac
43
+done
44
+shift `expr $OPTIND - 1`
45
+
46
+if [ ! "$#" -eq "2" -o -n "$CHROOTONLY" -a -n "$IMAGEONLY" ]; then
47
+    usage
48
+fi
49
+
50
+# Default args
51
+RELEASE=$1
52
+FORMAT=$2
53
+CHROOTDIR=""
54
+
55
+if [ -n "$CHROOTONLY" ]; then
56
+    RELEASE=$1
57
+    CHROOTDIR=$2
58
+    FORMAT="pass"
59
+fi
60
+
61
+if [ -n "$IMAGEONLY" ]; then
62
+    CHROOTDIR=$1
63
+    FORMAT=$2
64
+    RELEASE="pass"
65
+fi
66
+
67
+case $FORMAT in
68
+    kvm|qcow2)  FORMAT=qcow2
69
+                QFORMAT=qcow2
70
+                HYPER=kvm
71
+                ;;
72
+    vmserver|vmdk)
73
+                FORMAT=vmdk
74
+                QFORMAT=vmdk
75
+                HYPER=vmserver
76
+                ;;
77
+    vbox|vdi)   FORMAT=vdi
78
+                QFORMAT=vdi
79
+                HYPER=kvm
80
+                ;;
81
+    vhd|vpc)    FORMAT=vhd
82
+                QFORMAT=vpc
83
+                HYPER=kvm
84
+                ;;
85
+    xen)        FORMAT=raw
86
+                QFORMAT=raw
87
+                HYPER=xen
88
+                ;;
89
+    raw)        FORMAT=raw
90
+                QFORMAT=raw
91
+                HYPER=kvm
92
+                ;;
93
+    pass)       ;;
94
+    *)          echo "Unknown format: $FORMAT"
95
+                usage
96
+esac
97
+
98
+case $RELEASE in
99
+    natty)      ;;
100
+    maverick)   ;;
101
+    lucid)      ;;
102
+    karmic)     ;;
103
+    jaunty)     ;;
104
+    pass)       ;;
105
+    *)          echo "Unknown release: $RELEASE"
106
+                usage
107
+                ;;
108
+esac
109
+
110
+# Install stuff if necessary
111
+if [ -z `which vmbuilder` ]; then
112
+    sudo apt-get install ubuntu-vm-builder
113
+fi
114
+
115
+if [ -n "$CHROOTONLY" ]; then
116
+    # Build a chroot directory
117
+    HYPER=kvm
118
+    if [ "$MINIMAL" = 1 ]; then
119
+        ARGS="--variant=minbase"
120
+        for i in $MIN_PKGS; do
121
+            ARGS="$ARGS --addpkg=$i"
122
+        done
123
+    fi
124
+    sudo vmbuilder $HYPER ubuntu $ARGS \
125
+      --suite $RELEASE \
126
+      --only-chroot \
127
+      --chroot-dir=$CHROOTDIR \
128
+      --overwrite \
129
+      --addpkg=$MIN_PKGS \
130
+
131
+    sudo cp -p files/sources.list $CHROOTDIR/etc/apt/sources.list
132
+    sudo chroot $CHROOTDIR apt-get update
133
+
134
+    exit 0
135
+fi
136
+
137
+# Build the image
138
+TMPDIR=tmp
139
+TMPDISK=`mktemp imgXXXXXXXX`
140
+SIZE=$[$ROOTSIZE+$SWAPSIZE+1]
141
+dd if=/dev/null of=$TMPDISK bs=1M seek=$SIZE count=1
142
+
143
+if [ -n "$IMAGEONLY" ]; then
144
+    # Build image from chroot
145
+    sudo vmbuilder $HYPER ubuntu $ARGS \
146
+      --existing-chroot=$CHROOTDIR \
147
+      --overwrite \
148
+      --rootsize=$ROOTSIZE \
149
+      --swapsize=$SWAPSIZE \
150
+      --tmpfs - \
151
+      --raw=$TMPDISK \
152
+
153
+else
154
+    # Do the whole shebang in one pass
155
+        ARGS="--variant=minbase"
156
+        for i in $MIN_PKGS; do
157
+            ARGS="$ARGS --addpkg=$i"
158
+        done
159
+    sudo vmbuilder $HYPER ubuntu $ARGS \
160
+      --suite $RELEASE \
161
+      --overwrite \
162
+      --rootsize=$ROOTSIZE \
163
+      --swapsize=$SWAPSIZE \
164
+      --tmpfs - \
165
+      --raw=$TMPDISK \
166
+
167
+fi
168
+
169
+if [ "$FORMAT" = "raw" ]; then
170
+    # Get image
171
+    mv $TMPDISK $RELEASE.$FORMAT
172
+else
173
+    # Convert image
174
+    qemu-img convert -O $QFORMAT $TMPDISK $RELEASE.$FORMAT
175
+    rm $TMPDISK
176
+fi
177
+rm -rf ubuntu-$HYPER
0 178
new file mode 100755
... ...
@@ -0,0 +1,672 @@
0
+#!/usr/bin/env bash
1
+
2
+# **stack.sh** is an opinionated openstack developer installation.
3
+
4
+# This script installs and configures *nova*, *glance*, *dashboard* and *keystone*
5
+
6
+# This script allows you to specify configuration options of what git 
7
+# repositories to use, enabled services, network configuration and various
8
+# passwords.  If you are crafty you can run the script on multiple nodes using
9
+# shared settings for common resources (mysql, rabbitmq) and build a multi-node
10
+# developer install.
11
+
12
+# To keep this script simple we assume you are running on an **Ubuntu 11.04
13
+# Natty** machine.  It should work in a VM or physical server.  Additionally we
14
+# put the list of *apt* and *pip* dependencies and other configuration files in
15
+# this repo.  So start by grabbing this script and the dependencies.
16
+
17
+# Learn more and get the most recent version at http://devstack.org
18
+
19
+# Sanity Check
20
+# ============
21
+
22
+# Record the start time.  This allows us to print how long this script takes to run.
23
+START_TIME=`python -c "import time; print time.time()"`
24
+
25
+# Warn users who aren't on natty, but allow them to override check and attempt
26
+# installation with ``FORCE=yes ./stack``
27
+if ! grep -q natty /etc/lsb-release; then
28
+    echo "WARNING: this script has only been tested on natty"
29
+    if [[ "$FORCE" != "yes" ]]; then
30
+        echo "If you wish to run this script anyway run with FORCE=yes"
31
+        exit 1
32
+    fi
33
+fi
34
+
35
+# stack.sh keeps the list of **apt** and **pip** dependencies in external
36
+# files, along with config templates and other useful files.  You can find these
37
+# in the ``files`` directory (next to this script).  We will reference this
38
+# directory using the ``FILES`` variable in this script.
39
+FILES=`pwd`/files
40
+if [ ! -d $FILES ]; then
41
+    echo "ERROR: missing devstack/files - did you grab more than just stack.sh?"
42
+    exit 1
43
+fi
44
+
45
+# OpenStack is designed to be run as a regular user (Dashboard will fail to run
46
+# as root, since apache refused to startup serve content from root user).  If
47
+# stack.sh is run as root, it automatically creates a stack user with
48
+# sudo privileges and runs as that user.
49
+
50
+if [[ $EUID -eq 0 ]]; then
51
+    echo "You are running this script as root."
52
+
53
+    # since this script runs as a normal user, we need to give that user
54
+    # ability to run sudo
55
+    apt-get update
56
+    apt-get install -qqy sudo
57
+
58
+    if ! getent passwd | grep -q stack; then
59
+        echo "Creating a user called stack"
60
+        useradd -U -G sudo -s /bin/bash -m stack
61
+    fi
62
+    echo "Giving stack user passwordless sudo priviledges"
63
+    echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
64
+
65
+    echo "Copying files to stack user"
66
+    cp -r -f `pwd` /home/stack/
67
+    THIS_DIR=$(basename $(dirname $(readlink -f $0)))
68
+    chown -R stack /home/stack/$THIS_DIR
69
+    echo "Running the script as stack in 3 seconds..."
70
+    sleep 3
71
+    if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
72
+	exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack
73
+    else
74
+	exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh" stack
75
+    fi
76
+    exit 0
77
+fi
78
+
79
+# So that errors don't compound we exit on any errors so you see only the
80
+# first error that occured.
81
+set -o errexit
82
+
83
+# Print the commands being run so that we can see the command that triggers
84
+# an error.  It is also useful for following allowing as the install occurs.
85
+set -o xtrace
86
+
87
+# Settings
88
+# ========
89
+
90
+# This script is customizable through setting environment variables.  If you
91
+# want to override a setting you can either::
92
+#
93
+#     export MYSQL_PASS=anothersecret
94
+#     ./stack.sh
95
+#
96
+# You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh``
97
+#
98
+# Additionally, you can put any local variables into a ``localrc`` file, like::
99
+#
100
+#     MYSQL_PASS=anothersecret
101
+#     MYSQL_USER=hellaroot
102
+#
103
+# We try to have sensible defaults, so you should be able to run ``./stack.sh``
104
+# in most cases.
105
+#
106
+# We our settings from ``stackrc``.  This file is distributed with devstack and
107
+# contains locations for what repositories to use.  If you want to use other 
108
+# repositories and branches, you can add your own settings with another file 
109
+# called ``localrc``
110
+#
111
+# If ``localrc`` exists, then ``stackrc`` will load those settings.  This is 
112
+# useful for changing a branch or repostiory to test other versions.  Also you
113
+# can store your other settings like **MYSQL_PASS** or **ADMIN_PASSWORD** instead
114
+# of letting devstack generate random ones for you.
115
+source ./stackrc
116
+
117
+# Destination path for installation ``DEST``
118
+DEST=${DEST:-/opt/stack}
119
+sudo mkdir -p $DEST
120
+sudo chown `whoami` $DEST
121
+
122
+# Set the destination directories for openstack projects
123
+NOVA_DIR=$DEST/nova
124
+DASH_DIR=$DEST/dash
125
+GLANCE_DIR=$DEST/glance
126
+KEYSTONE_DIR=$DEST/keystone
127
+NOVACLIENT_DIR=$DEST/python-novaclient
128
+OPENSTACKX_DIR=$DEST/openstackx
129
+NOVNC_DIR=$DEST/noVNC
130
+
131
+# Specify which services to launch.  These generally correspond to screen tabs
132
+ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit}
133
+
134
+# Nova hypervisor configuration.  We default to **kvm** but will drop back to
135
+# **qemu** if we are unable to load the kvm module.  Stack.sh can also install
136
+# an **LXC** based system.
137
+LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
138
+
139
+# nova supports pluggable schedulers.  ``SimpleScheduler`` should work in most
140
+# cases unless you are working on multi-zone mode.
141
+SCHEDULER=${SCHEDULER:-nova.scheduler.simple.SimpleScheduler}
142
+
143
+# Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
144
+if [ ! -n "$HOST_IP" ]; then
145
+    HOST_IP=`LC_ALL=C /sbin/ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
146
+fi
147
+
148
+# Nova Network Configuration
149
+# --------------------------
150
+
151
+# FIXME: more documentation about why these are important flags.  Also 
152
+# we should make sure we use the same variable names as the flag names.
153
+
154
+PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-eth0}
155
+FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
156
+FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
157
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.1/28}
158
+NET_MAN=${NET_MAN:-FlatDHCPManager}
159
+EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
160
+FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
161
+VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE}
162
+
163
+# Multi-host is a mode where each compute node runs its own network node.  This
164
+# allows network operations and routing for a VM to occur on the server that is
165
+# running the VM - removing a SPOF and bandwidth bottleneck.
166
+MULTI_HOST=${MULTI_HOST:-0}
167
+
168
+# If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
169
+# variable but make sure that the interface doesn't already have an
170
+# ip or you risk breaking things.
171
+#
172
+# **DHCP Warning**:  If your flat interface device uses DHCP, there will be a 
173
+# hiccup while the network is moved from the flat interface to the flat network 
174
+# bridge.  This will happen when you launch your first instance.  Upon launch 
175
+# you will lose all connectivity to the node, and the vm launch will probably 
176
+# fail.
177
+# 
178
+# If you are running on a single node and don't need to access the VMs from 
179
+# devices other than that node, you can set the flat interface to the same
180
+# value as ``FLAT_NETWORK_BRIDGE``.  This will stop the network hiccup from 
181
+# occuring.
182
+FLAT_INTERFACE=${FLAT_INTERFACE:-eth0}
183
+
184
+## FIXME(ja): should/can we check that FLAT_INTERFACE is sane?
185
+
186
+
187
+# MySQL & RabbitMQ
188
+# ----------------
189
+
190
+# We configure Nova, Dashboard, Glance and Keystone to use MySQL as their 
191
+# database server.  While they share a single server, each has their own
192
+# database and tables.
193
+
194
+# By default this script will install and configure MySQL.  If you want to 
195
+# use an existing server, you can pass in the user/password/host parameters.
196
+# You will need to send the same ``MYSQL_PASS`` to every host if you are doing
197
+# a multi-node devstack installation.
198
+MYSQL_USER=${MYSQL_USER:-root}
199
+MYSQL_PASS=${MYSQL_PASS:-`openssl rand -hex 12`}
200
+MYSQL_HOST=${MYSQL_HOST:-localhost}
201
+
202
+# don't specify /db in this string, so we can use it for multiple services
203
+BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST}
204
+
205
+# Rabbit connection info
206
+RABBIT_HOST=${RABBIT_HOST:-localhost}
207
+RABBIT_PASSWORD=${RABBIT_PASSWORD:-`openssl rand -hex 12`}
208
+
209
+# Glance connection info.  Note the port must be specified.
210
+GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
211
+
212
+# Keystone
213
+# --------
214
+
215
+# Service Token - Openstack components need to have an admin token
216
+# to validate user tokens.
217
+SERVICE_TOKEN=${SERVICE_TOKEN:-`openssl rand -hex 12`}
218
+# Dash currently truncates usernames and passwords at 20 characters
219
+# so use 10 bytes
220
+ADMIN_PASSWORD=${ADMIN_PASSWORD:-`openssl rand -hex 10`}
221
+
222
+
223
+# Install Packages
224
+# ================
225
+#
226
+# Openstack uses a fair number of other projects.
227
+
228
+
229
+# install apt requirements
230
+sudo apt-get install -qqy `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"`
231
+
232
+# install python requirements
233
+sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
234
+
235
+# git clone only if directory doesn't exist already.  Since ``DEST`` might not
236
+# be owned by the installation user, we create the directory and change the
237
+# ownership to the proper user.
238
+function git_clone {
239
+    if [ ! -d $2 ]; then
240
+        sudo mkdir $2
241
+        sudo chown `whoami` $2
242
+        git clone $1 $2
243
+        cd $2
244
+        # This checkout syntax works for both branches and tags
245
+        git checkout $3
246
+    fi
247
+}
248
+
249
+# compute service
250
+git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
251
+# image catalog service
252
+git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH
253
+# unified auth system (manages accounts/tokens)
254
+git_clone $KEYSTONE_REPO $KEYSTONE_DIR $KEYSTONE_BRANCH
255
+# a websockets/html5 or flash powered VNC console for vm instances
256
+git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH
257
+# django powered web control panel for openstack
258
+git_clone $DASH_REPO $DASH_DIR $DASH_BRANCH $DASH_TAG
259
+# python client library to nova that dashboard (and others) use
260
+git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
261
+# openstackx is a collection of extensions to openstack.compute & nova
262
+# that is *deprecated*.  The code is being moved into python-novaclient & nova.
263
+git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH
264
+
265
+# Initialization
266
+# ==============
267
+
268
+
269
+# setup our checkouts so they are installed into python path
270
+# allowing ``import nova`` or ``import glance.client``
271
+cd $NOVA_DIR; sudo python setup.py develop
272
+cd $NOVACLIENT_DIR; sudo python setup.py develop
273
+cd $KEYSTONE_DIR; sudo python setup.py develop
274
+cd $GLANCE_DIR; sudo python setup.py develop
275
+cd $OPENSTACKX_DIR; sudo python setup.py develop
276
+cd $DASH_DIR/django-openstack; sudo python setup.py develop
277
+cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
278
+
279
+# Add a useful screenrc.  This isn't required to run openstack but is we do
280
+# it since we are going to run the services in screen for simple
281
+cp $FILES/screenrc ~/.screenrc
282
+
283
+## TODO: update current user to allow sudo for all commands in files/sudo/*
284
+
285
+# Rabbit
286
+# ---------
287
+
288
+if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then
289
+    # Install and start rabbitmq-server
290
+    sudo apt-get install -y -q rabbitmq-server
291
+    # change the rabbit password since the default is "guest"
292
+    sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
293
+fi
294
+
295
+# Mysql
296
+# ---------
297
+
298
+if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
299
+
300
+    # Seed configuration with mysql password so that apt-get install doesn't
301
+    # prompt us for a password upon install.
302
+    cat <<MYSQL_PRESEED | sudo debconf-set-selections
303
+mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
304
+mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
305
+mysql-server-5.1 mysql-server/start_on_boot boolean true
306
+MYSQL_PRESEED
307
+
308
+    # Install and start mysql-server
309
+    sudo apt-get -y -q install mysql-server
310
+    # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
311
+    sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';"
312
+
313
+    # Edit /etc/mysql/my.cnf to change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) and restart the mysql service:
314
+    sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
315
+    sudo service mysql restart
316
+fi
317
+
318
+
319
+# Dashboard
320
+# ---------
321
+
322
+# Setup the django dashboard application to serve via apache/wsgi
323
+
324
+if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
325
+
326
+    # Dash currently imports quantum even if you aren't using it.  Instead
327
+    # of installing quantum we can create a simple module that will pass the
328
+    # initial imports
329
+    mkdir -p  $DASH_DIR/openstack-dashboard/quantum || true
330
+    touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
331
+    touch $DASH_DIR/openstack-dashboard/quantum/client.py
332
+
333
+
334
+    # ``local_settings.py`` is used to override dashboard default settings.
335
+    cp $FILES/dash_settings.py $DASH_DIR/openstack-dashboard/local/local_settings.py
336
+
337
+    cd $DASH_DIR/openstack-dashboard
338
+    dashboard/manage.py syncdb
339
+
340
+    # create an empty directory that apache uses as docroot
341
+    sudo mkdir -p $DASH_DIR/.blackhole
342
+
343
+    ## Configure apache's 000-default to run dashboard
344
+    sudo cp $FILES/000-default.template /etc/apache2/sites-enabled/000-default
345
+    sudo sed -e "s,%USER%,$USER,g" -i /etc/apache2/sites-enabled/000-default
346
+    sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
347
+fi
348
+
349
+
350
+# Glance
351
+# ------
352
+
353
+if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
354
+    GLANCE_IMAGE_DIR=$DEST/glance/images
355
+    # Delete existing images
356
+    rm -rf $GLANCE_IMAGE_DIR
357
+
358
+    # Use local glance directories
359
+    mkdir -p $GLANCE_IMAGE_DIR
360
+
361
+    # (re)create glance database
362
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS glance;'
363
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
364
+    # Copy over our glance-registry.conf
365
+    GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
366
+    cp $FILES/glance-registry.conf $GLANCE_CONF
367
+    sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
368
+    sudo sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $GLANCE_CONF
369
+    sudo sed -e "s,%DEST%,$DEST,g" -i $GLANCE_CONF
370
+
371
+    GLANCE_API_CONF=$GLANCE_DIR/etc/glance-api.conf
372
+    cp $FILES/glance-api.conf $GLANCE_API_CONF
373
+    sudo sed -e "s,%DEST%,$DEST,g" -i $GLANCE_API_CONF
374
+    sudo sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $GLANCE_API_CONF
375
+fi
376
+
377
+# Nova
378
+# ----
379
+
380
+# We are going to use the sample http middleware configuration from the keystone
381
+# project to launch nova.  This paste config adds the configuration required
382
+# for nova to validate keystone tokens - except we need to switch the config
383
+# to use our admin token instead (instead of the token from their sample data).
384
+sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini
385
+
386
+if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
387
+
388
+    # Virtualization Configuration
389
+    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
390
+
391
+    # attempt to load modules: network block device - used to manage qcow images
392
+    sudo modprobe nbd || true
393
+
394
+    # Check for kvm (hardware based virtualization).  If unable to load kvm, 
395
+    # set the libvirt type to qemu.  Note: many systems come with hardware 
396
+    # virtualization disabled in BIOS.
397
+    if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then
398
+        sudo modprobe kvm || true
399
+        if [ ! -e /dev/kvm ]; then
400
+            echo "WARNING: Switching to QEMU"
401
+            LIBVIRT_TYPE=qemu
402
+        fi
403
+    fi
404
+
405
+    # Install and configure **LXC** if specified.  LXC is another approach to
406
+    # splitting a system into many smaller parts.  LXC uses cgroups and chroot
407
+    # to simulate multiple systems.
408
+    if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
409
+        sudo apt-get install lxc -y
410
+        # lxc requires cgroups to be configured on /cgroup
411
+        sudo mkdir -p /cgroup
412
+        if ! grep -q cgroup /etc/fstab; then
413
+            echo none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0 | sudo tee -a /etc/fstab
414
+        fi
415
+        if ! mount -n | grep -q cgroup; then
416
+            sudo mount /cgroup
417
+        fi
418
+    fi
419
+
420
+    # User needs to be member of libvirtd group for nova-compute to use libvirt.
421
+    sudo usermod -a -G libvirtd `whoami`
422
+    # if kvm wasn't running before we need to restart libvirt to enable it
423
+    sudo /etc/init.d/libvirt-bin restart
424
+
425
+
426
+    # Instance Storage
427
+    # ~~~~~~~~~~~~~~~~
428
+
429
+    # Nova stores each instance in its own directory.
430
+    mkdir -p $NOVA_DIR/instances
431
+
432
+    # if there is a partition labeled nova-instances use it (ext filesystems
433
+    # can be labeled via e2label)
434
+    ## FIXME: if already mounted this blows up...
435
+    if [ -L /dev/disk/by-label/nova-instances ]; then
436
+        sudo mount -L nova-instances $NOVA_DIR/instances
437
+        sudo chown -R `whoami` $NOVA_DIR/instances
438
+    fi
439
+
440
+    # Clean out the instances directory.
441
+    sudo rm -rf $NOVA_DIR/instances/*
442
+fi
443
+
444
+if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
445
+    # delete traces of nova networks from prior runs
446
+    sudo killall dnsmasq || true
447
+    rm -rf $NOVA_DIR/networks
448
+    mkdir -p $NOVA_DIR/networks
449
+fi
450
+
451
+function add_nova_flag {
452
+    echo "$1" >> $NOVA_DIR/bin/nova.conf
453
+}
454
+
455
+# (re)create nova.conf
456
+rm -f $NOVA_DIR/bin/nova.conf
457
+add_nova_flag "--verbose"
458
+add_nova_flag "--nodaemon"
459
+add_nova_flag "--scheduler_driver=$SCHEDULER"
460
+add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
461
+add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
462
+add_nova_flag "--my_ip=$HOST_IP"
463
+add_nova_flag "--public_interface=$PUBLIC_INTERFACE"
464
+add_nova_flag "--vlan_interface=$VLAN_INTERFACE"
465
+add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
466
+add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
467
+add_nova_flag "--osapi_extensions_path=$OPENSTACKX_DIR/extensions"
468
+add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
469
+add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
470
+add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
471
+add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
472
+add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
473
+add_nova_flag "--rabbit_host=$RABBIT_HOST"
474
+add_nova_flag "--rabbit_password=$RABBIT_PASSWORD"
475
+add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
476
+add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE"
477
+if [ -n "$FLAT_INTERFACE" ]; then
478
+    add_nova_flag "--flat_interface=$FLAT_INTERFACE"
479
+fi
480
+if [ -n "$MULTI_HOST" ]; then
481
+    add_nova_flag "--multi_host=$MULTI_HOST"
482
+fi
483
+
484
+# Nova Database
485
+# ~~~~~~~~~~~~~
486
+
487
+# All nova components talk to a central database.  We will need to do this step
488
+# only once for an entire cluster.
489
+
490
+if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
491
+    # (re)create nova database
492
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS nova;'
493
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
494
+
495
+    # (re)create nova database
496
+    $NOVA_DIR/bin/nova-manage db sync
497
+
498
+    # create a small network
499
+    $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE
500
+
501
+    # create some floating ips
502
+    $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
503
+fi
504
+
505
+
506
+# Keystone
507
+# --------
508
+
509
+if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
510
+    # (re)create keystone database
511
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS keystone;'
512
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
513
+
514
+    # FIXME (anthony) keystone should use keystone.conf.example
515
+    KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
516
+    cp $FILES/keystone.conf $KEYSTONE_CONF
517
+    sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
518
+    sudo sed -e "s,%DEST%,$DEST,g" -i $KEYSTONE_CONF
519
+
520
+    # keystone_data.sh creates our admin user and our ``SERVICE_TOKEN``.
521
+    KEYSTONE_DATA=$KEYSTONE_DIR/bin/keystone_data.sh
522
+    cp $FILES/keystone_data.sh $KEYSTONE_DATA
523
+    sudo sed -e "s,%HOST_IP%,$HOST_IP,g" -i $KEYSTONE_DATA
524
+    sudo sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $KEYSTONE_DATA
525
+    sudo sed -e "s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g" -i $KEYSTONE_DATA
526
+    # initialize keystone with default users/endpoints
527
+    BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA
528
+fi
529
+
530
+
531
+# Launch Services
532
+# ===============
533
+
534
+# nova api crashes if we start it with a regular screen command,
535
+# so send the start command by forcing text into the window.
536
+# Only run the services specified in ``ENABLED_SERVICES``
537
+
538
+# our screen helper to launch a service in a hidden named screen
539
+function screen_it {
540
+    NL=`echo -ne '\015'`
541
+    if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
542
+        screen -S nova -X screen -t $1
543
+        screen -S nova -p $1 -X stuff "$2$NL"
544
+    fi
545
+}
546
+
547
+# create a new named screen to run processes in
548
+screen -d -m -S nova -t nova
549
+sleep 1
550
+
551
+# launch the glance registery service
552
+if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
553
+    screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
554
+fi
555
+
556
+# launch the glance api and wait for it to answer before continuing
557
+if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
558
+    screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
559
+    while ! wget -q -O- http://$GLANCE_HOSTPORT; do
560
+        echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
561
+        sleep 1
562
+    done
563
+fi
564
+
565
+# launch the keystone and wait for it to answer before continuing
566
+if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
567
+    screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d"
568
+    while ! wget -q -O- http://127.0.0.1:5000; do
569
+        echo "Waiting for keystone to start..."
570
+        sleep 1
571
+    done
572
+fi
573
+
574
+# launch the nova-api and wait for it to answer before continuing
575
+if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
576
+    screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
577
+    while ! wget -q -O- http://127.0.0.1:8774; do
578
+        echo "Waiting for nova-api to start..."
579
+        sleep 1
580
+    done
581
+fi
582
+# Launching nova-compute should be as simple as running ``nova-compute`` but
583
+# have to do a little more than that in our script.  Since we add the group
584
+# ``libvirtd`` to our user in this script, when nova-compute is run it is
585
+# within the context of our original shell (so our groups won't be updated).
586
+# We can send the command nova-compute to the ``newgrp`` command to execute
587
+# in a specific context.
588
+screen_it n-cpu "cd $NOVA_DIR && echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd"
589
+screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
590
+screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
591
+screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf"
592
+screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
593
+
594
+# Install Images
595
+# ==============
596
+
597
+# Upload a couple images to glance.  **TTY** is a simple small image that use the 
598
+# lets you login to it with username/password of user/password.  TTY is useful 
599
+# for basic functionality.  We all include an Ubuntu cloud build of **Natty**.
600
+# Natty uses cloud-init, supporting login via keypair and sending scripts as
601
+# userdata.  
602
+#
603
+# Read more about cloud-init at https://help.ubuntu.com/community/CloudInit
604
+
605
+if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
606
+    # create a directory for the downloadedthe images tarballs.
607
+    mkdir -p $FILES/images
608
+
609
+    # Debug Image (TTY)
610
+    # -----------------
611
+
612
+    # Downloads the image (ami/aki/ari style), then extracts it.  Upon extraction
613
+    # we upload to glance with the glance cli tool.  TTY is a stripped down 
614
+    # version of ubuntu.
615
+    if [ ! -f $FILES/tty.tgz ]; then
616
+        wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz
617
+    fi
618
+
619
+    # extract ami-tty/image, aki-tty/image & ari-tty/image
620
+    tar -zxf $FILES/tty.tgz -C $FILES/images
621
+
622
+    # Use glance client to add the kernel, ramdisk and finally the root 
623
+    # filesystem.  We parse the results of the uploads to get glance IDs of the
624
+    # ramdisk and kernel and use them for the root filesystem.
625
+    RVAL=`glance add -A $SERVICE_TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
626
+    KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
627
+    RVAL=`glance add -A $SERVICE_TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
628
+    RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
629
+    glance add -A $SERVICE_TOKEN name="tty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID ramdisk_id=$RAMDISK_ID < $FILES/images/ami-tty/image
630
+
631
+    # Ubuntu 11.04 aka Natty
632
+    # ----------------------
633
+
634
+    # Downloaded from ubuntu enterprise cloud images.  This
635
+    # image doesn't use the ramdisk functionality
636
+    if [ ! -f $FILES/natty.tgz ]; then
637
+        wget -c http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz -O $FILES/natty.tgz
638
+    fi
639
+    
640
+    tar -zxf $FILES/natty.tgz -C $FILES/images
641
+
642
+    RVAL=`glance add -A $SERVICE_TOKEN name="uec-natty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/natty-server-cloudimg-amd64-vmlinuz-virtual`
643
+    KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
644
+    glance add -A $SERVICE_TOKEN name="uec-natty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID < $FILES/images/natty-server-cloudimg-amd64.img
645
+
646
+fi
647
+
648
+# Using the cloud
649
+# ===============
650
+
651
+# If you installed the dashboard on this server, then you should be able
652
+# to access the site using your browser.
653
+if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
654
+    echo "dashboard is now available at http://$HOST_IP/"
655
+fi
656
+
657
+# If keystone is present, you can point nova cli to this server
658
+if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
659
+    echo "keystone is serving at http://$HOST_IP:5000/v2.0/"
660
+    echo "examples on using novaclient command line is in exercise.sh"
661
+    echo "the default users are: admin and demo"
662
+    echo "the password: $ADMIN_PASSWORD"
663
+fi
664
+
665
+# Fin
666
+# ===
667
+
668
+# End our timer and give a timing summary
669
+END_TIME=`python -c "import time; print time.time()"`
670
+ELAPSED=`python -c "print $END_TIME - $START_TIME"`
671
+echo "stack.sh completed in $ELAPSED seconds."
0 672
new file mode 100644
... ...
@@ -0,0 +1,33 @@
0
+# compute service
1
+NOVA_REPO=https://github.com/cloudbuilders/nova.git
2
+NOVA_BRANCH=diablo
3
+
4
+# image catalog service
5
+GLANCE_REPO=https://github.com/cloudbuilders/glance.git
6
+GLANCE_BRANCH=diablo
7
+
8
+# unified auth system (manages accounts/tokens)
9
+KEYSTONE_REPO=https://github.com/cloudbuilders/keystone.git
10
+KEYSTONE_BRANCH=diablo
11
+
12
+# a websockets/html5 or flash powered VNC console for vm instances
13
+NOVNC_REPO=https://github.com/cloudbuilders/noVNC.git
14
+NOVNC_BRANCH=master
15
+
16
+# django powered web control panel for openstack
17
+DASH_REPO=https://github.com/cloudbuilders/openstack-dashboard.git
18
+DASH_BRANCH=master
19
+
20
+# python client library to nova that dashboard (and others) use
21
+NOVACLIENT_REPO=https://github.com/cloudbuilders/python-novaclient.git
22
+NOVACLIENT_BRANCH=master
23
+
24
+# openstackx is a collection of extensions to openstack.compute & nova
25
+# that is *deprecated*.  The code is being moved into python-novaclient & nova.
26
+OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git
27
+OPENSTACKX_BRANCH=diablo
28
+
29
+# allow local overrides of env variables
30
+if [ -f ./localrc ]; then
31
+    source ./localrc
32
+fi
0 33
new file mode 100644
... ...
@@ -0,0 +1,154 @@
0
+#!/bin/bash
1
+# install_openvpn.sh - Install OpenVPN and generate required certificates
2
+#
3
+# install_openvpn.sh --client name
4
+# install_openvpn.sh --server [name]
5
+#
6
+# name is used on the CN of the generated cert, and the filename of
7
+# the configuration, certificate and key files.
8
+#
9
+# --server mode configures the host with a running OpenVPN server instance
10
+# --client mode creates a tarball of a client configuration for this server
11
+
12
+# VPN Config
13
+VPN_SERVER=${VPN_SERVER:-`ifconfig eth0 | awk "/inet addr:/ { print \$2 }" | cut -d: -f2`}  # 50.56.12.212
14
+VPN_PROTO=${VPN_PROTO:-tcp}
15
+VPN_PORT=${VPN_PORT:-6081}
16
+VPN_DEV=${VPN_DEV:-tun}
17
+VPN_CLIENT_NET=${VPN_CLIENT_NET:-172.16.28.0}
18
+VPN_CLIENT_MASK=${VPN_CLIENT_MASK:-255.255.255.0}
19
+VPN_LOCAL_NET=${VPN_LOCAL_NET:-10.0.0.0}
20
+VPN_LOCAL_MASK=${VPN_LOCAL_MASK:-255.255.0.0}
21
+
22
+VPN_DIR=/etc/openvpn
23
+CA_DIR=/etc/openvpn/easy-rsa
24
+
25
+usage() {
26
+    echo "$0 - OpenVPN install and certificate generation"
27
+    echo ""
28
+    echo "$0 --client name"
29
+    echo "$0 --server [name]"
30
+    echo ""
31
+    echo " --server mode configures the host with a running OpenVPN server instance"
32
+    echo " --client mode creates a tarball of a client configuration for this server"
33
+    exit 1
34
+}
35
+
36
+if [ -z $1 ]; then
37
+    usage
38
+fi
39
+
40
+# Install OpenVPN
41
+if [ ! -x `which openvpn` ]; then
42
+    apt-get install -y openvpn bridge-utils
43
+fi
44
+if [ ! -d $CA_DIR ]; then
45
+    cp -pR /usr/share/doc/openvpn/examples/easy-rsa/2.0/ $CA_DIR
46
+fi
47
+
48
+OPWD=`pwd`
49
+cd $CA_DIR
50
+source ./vars
51
+
52
+# Override the defaults
53
+export KEY_COUNTRY="US"
54
+export KEY_PROVINCE="TX"
55
+export KEY_CITY="SanAntonio"
56
+export KEY_ORG="Cloudbuilders"
57
+export KEY_EMAIL="rcb@lists.rackspace.com"
58
+
59
+if [ ! -r $CA_DIR/keys/dh1024.pem ]; then
60
+    # Initialize a new CA
61
+    $CA_DIR/clean-all
62
+    $CA_DIR/build-dh
63
+    $CA_DIR/pkitool --initca
64
+    openvpn --genkey --secret $CA_DIR/keys/ta.key  ## Build a TLS key
65
+fi
66
+
67
+do_server() {
68
+    NAME=$1
69
+    # Generate server certificate
70
+    $CA_DIR/pkitool --server $NAME
71
+
72
+    (cd $CA_DIR/keys;
73
+        cp $NAME.crt $NAME.key ca.crt dh1024.pem ta.key $VPN_DIR
74
+    )
75
+    cat >$VPN_DIR/$NAME.conf <<EOF
76
+proto $VPN_PROTO
77
+port $VPN_PORT
78
+dev $VPN_DEV
79
+cert $NAME.crt
80
+key $NAME.key  # This file should be kept secret
81
+ca ca.crt
82
+dh dh1024.pem
83
+duplicate-cn
84
+server $VPN_CLIENT_NET $VPN_CLIENT_MASK
85
+ifconfig-pool-persist ipp.txt
86
+push "route $VPN_LOCAL_NET $VPN_LOCAL_MASK"
87
+comp-lzo
88
+user nobody
89
+group nobody
90
+persist-key
91
+persist-tun
92
+status openvpn-status.log
93
+EOF
94
+    /etc/init.d/openvpn restart
95
+}
96
+
97
+do_client() {
98
+    NAME=$1
99
+    # Generate a client certificate
100
+    $CA_DIR/pkitool $NAME
101
+
102
+    TMP_DIR=`mktemp -d`
103
+    (cd $CA_DIR/keys;
104
+        cp -p ca.crt ta.key $NAME.key $NAME.crt $TMP_DIR
105
+    )
106
+    if [ -r $VPN_DIR/hostname ]; then
107
+        HOST=`cat $VPN_DIR/hostname`
108
+    else
109
+        HOST=`hostname`
110
+    fi
111
+    cat >$TMP_DIR/$HOST.conf <<EOF
112
+proto $VPN_PROTO
113
+port $VPN_PORT
114
+dev $VPN_DEV
115
+cert $NAME.crt
116
+key $NAME.key  # This file should be kept secret
117
+ca ca.crt
118
+client
119
+remote $VPN_SERVER $VPN_PORT
120
+resolv-retry infinite
121
+nobind
122
+user nobody
123
+group nobody
124
+persist-key
125
+persist-tun
126
+comp-lzo
127
+verb 3
128
+EOF
129
+    (cd $TMP_DIR; tar cf $OPWD/$NAME.tar *)
130
+    rm -rf $TMP_DIR
131
+    echo "Client certificate and configuration is in $OPWD/$NAME.tar"
132
+}
133
+
134
+# Process command line args
135
+case $1 in
136
+    --client)   if [ -z $2 ]; then
137
+                    usage
138
+                fi
139
+                do_client $2
140
+                ;;
141
+    --server)   if [ -z $2 ]; then
142
+                    NAME=`hostname`
143
+                else
144
+                    NAME=$2
145
+                    # Save for --client use
146
+                    echo $NAME >$VPN_DIR/hostname
147
+                fi
148
+                do_server $NAME
149
+                ;;
150
+    --clean)    $CA_DIR/clean-all
151
+                ;;
152
+    *)          usage
153
+esac
0 154
new file mode 100755
... ...
@@ -0,0 +1,90 @@
0
+#!/bin/bash
1
+# upload_image.sh - Upload Ubuntu images (create if necessary) in various formats
2
+# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc)
3
+# Requires sudo to root
4
+
5
+usage() {
6
+    echo "$0 - Upload images to OpenStack"
7
+    echo ""
8
+    echo "$0 [-h host] [-p port] release format"
9
+    exit 1
10
+}
11
+
12
+HOST=${HOST:-localhost}
13
+PORT=${PORT:-9292}
14
+DEST=${DEST:-/opt/stack}
15
+
16
+while getopts h:p: c; do
17
+    case $c in
18
+        h)  HOST=$OPTARG
19
+            ;;
20
+        p)  PORT=$OPTARG
21
+            ;;
22
+    esac
23
+done
24
+shift `expr $OPTIND - 1`
25
+
26
+RELEASE=$1
27
+FORMAT=$2
28
+
29
+case $FORMAT in
30
+    kvm|qcow2)  FORMAT=qcow2
31
+                TARGET=kvm
32
+                ;;
33
+    vmserver|vmdk)
34
+                FORMAT=vmdk
35
+                TARGET=vmserver
36
+                ;;
37
+    vbox|vdi)   TARGET=kvm
38
+                FORMAT=vdi
39
+                ;;
40
+    vhd|vpc)    TARGET=kvm
41
+                FORMAT=vhd
42
+                ;;
43
+    *)          echo "Unknown format: $FORMAT"
44
+                usage
45
+esac
46
+
47
+case $RELEASE in
48
+    natty)      ;;
49
+    maverick)   ;;
50
+    lucid)      ;;
51
+    karmic)     ;;
52
+    jaunty)     ;;
53
+    *)          if [ ! -r $RELEASE.$FORMAT ]; then
54
+                    echo "Unknown release: $RELEASE"
55
+                    usage
56
+                fi
57
+                ;;
58
+esac
59
+
60
+GLANCE=`which glance`
61
+if [ -z "$GLANCE" ]; then
62
+    if [ -x "$DEST/glance/bin/glance" ]; then
63
+        # Look for stack.sh's install
64
+        GLANCE="$DEST/glance/bin/glance"
65
+    else
66
+        # Install Glance client in $DEST
67
+        echo "Glance not found, must install client"
68
+        OWD=`pwd`
69
+        cd $DEST
70
+        sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr
71
+        sudo pip install kombu
72
+        sudo git clone https://github.com/cloudbuilders/glance.git
73
+        cd glance
74
+        sudo python setup.py develop
75
+        cd $OWD
76
+        GLANCE=`which glance`
77
+    fi
78
+fi
79
+
80
+# Create image if it doesn't exist
81
+if [ ! -r $RELEASE.$FORMAT ]; then
82
+    DIR=`dirname $0`
83
+    echo "$RELEASE.$FORMAT not found, creating..."
84
+    $DIR/make_image.sh $RELEASE $FORMAT
85
+fi
86
+
87
+# Upload the image
88
+echo "Uploading image $RELEASE.$FORMAT to $HOST"
89
+$GLANCE add name=$RELEASE.$FORMAT is_public=true disk_format=$FORMAT --host $HOST --port $PORT <$RELEASE.$FORMAT