Browse code

project to speed up development on physical hardware

Jesse Andrews authored on 2011/09/11 19:22:13
Showing 11 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+Tool to build nfs export openstack environments.  This is useful for development
1
+
2
+* todo: move as much from run to install as possible
3
+  * issue: HOST_IP will be different on each machine - might need to update / change stuff
4
+* todo: use local disk on nfs boots for instances
5
+* idea: create a live-cd / vmware preview image using this?
6
+* idea: use lxc to make the proto-image have everything?  so launching a new server is just turn on / updating / run?
0 7
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,11 @@
0
+pep8
1
+pylint
2
+python-pip
3
+screen
4
+unzip
5
+wget
6
+psmisc
7
+git-core
8
+lsof
9
+openssh-server
10
+vim
0 11
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,34 @@
0
+dnsmasq-base
1
+kpartx
2
+kvm
3
+gawk
4
+iptables
5
+ebtables
6
+sqlite3
7
+sudo
8
+kvm
9
+libvirt-bin
10
+vlan
11
+curl
12
+rabbitmq-server
13
+socat
14
+python-mox
15
+python-ipy
16
+python-paste
17
+python-migrate
18
+python-gflags
19
+python-greenlet
20
+python-libvirt
21
+python-libxml2
22
+python-routes
23
+python-netaddr
24
+python-pastedeploy
25
+python-eventlet
26
+python-cheetah
27
+python-carrot
28
+python-tempita
29
+python-sqlalchemy
30
+python-suds
31
+python-lockfile
32
+python-m2crypto
33
+python-boto
0 34
new file mode 100755
... ...
@@ -0,0 +1,52 @@
0
+#!/bin/bash
1
+
2
+# TODO: make dest not hardcoded
3
+
4
+NAME=$1
5
+DEST="/boxes/$NAME/nfs"
6
+
7
+mkdir -p /boxes/$NAME
8
+
9
+# remove old nfs filesystem if one exists
10
+rm -rf $DEST
11
+
12
+# build a proto image - natty + packages that will install (optimization)
13
+if [ ! -d nfs ]; then
14
+    debootstrap natty nfs
15
+    cp sources.list nfs/etc/apt/sources.list
16
+    chroot nfs apt-get update
17
+    chroot nfs apt-get install -y `cat apts/* | egrep -v "(rabbitmq|libvirt)"`
18
+    chroot nfs pip install `cat pips/*`
19
+    git clone https://github.com/cloudbuilders/nova.git nfs/opt/nova
20
+    git clone https://github.com/cloudbuilders/openstackx.git nfs/opt/openstackx
21
+    git clone https://github.com/cloudbuilders/noVNC.git nfs/opt/noVNC
22
+    git clone https://github.com/cloudbuilders/openstack-dashboard.git nfs/opt/dash
23
+    git clone https://github.com/cloudbuilders/python-novaclient.git nfs/opt/python-novaclient
24
+    git clone https://github.com/cloudbuilders/keystone.git nfs/opt/keystone
25
+    git clone https://github.com/cloudbuilders/glance.git nfs/opt/glance
26
+fi
27
+
28
+cp -pr nfs $DEST
29
+
30
+# set hostname
31
+echo $NAME > $DEST/etc/hostname
32
+echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
33
+
34
+# copy kernel modules
35
+cp -pr /lib/modules/`uname -r` $DEST/lib/modules
36
+
37
+# copy openstack installer and requirement lists to a new directory.
38
+mkdir -p $DEST/opt
39
+cp stack.sh $DEST/opt/stack.sh
40
+cp -r pips $DEST/opt
41
+cp -r apts $DEST/opt
42
+
43
+# injecting root's ssh key
44
+# FIXME: only do this if id_rsa.pub exists
45
+mkdir $DEST/root/.ssh
46
+chmod 700 $DEST/root/.ssh
47
+cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
48
+
49
+# set root password to password
50
+echo root:password | chroot $DEST chpasswd
51
+
0 52
new file mode 100644
... ...
@@ -0,0 +1,219 @@
0
+# based on debootstrap/scripts/natty
1
+
2
+case $ARCH in
3
+  amd64|i386)
4
+	default_mirror http://archive.ubuntu.com/ubuntu
5
+	;;
6
+  sparc)
7
+	case $SUITE in
8
+	  gutsy)
9
+	default_mirror http://archive.ubuntu.com/ubuntu
10
+	;;
11
+	  *)
12
+	default_mirror http://ports.ubuntu.com/ubuntu-ports
13
+	;;
14
+	esac
15
+	;;
16
+  *)
17
+	default_mirror http://ports.ubuntu.com/ubuntu-ports
18
+	;;
19
+esac
20
+mirror_style release
21
+download_style apt
22
+finddebs_style from-indices
23
+variants - buildd fakechroot minbase
24
+
25
+if doing_variant fakechroot; then
26
+	test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
27
+fi
28
+
29
+case $ARCH in
30
+	alpha|ia64) LIBC="libc6.1" ;;
31
+	*)          LIBC="libc6" ;;
32
+esac
33
+
34
+work_out_debs () {
35
+	required="$(get_debs Priority: required) openssh-server"
36
+
37
+	if doing_variant -; then
38
+		#required="$required $(get_debs Priority: important)"
39
+		#  ^^ should be getting debconf here somehow maybe
40
+		base="$(get_debs Priority: important)"
41
+	elif doing_variant buildd; then
42
+		base="$(get_debs Build-Essential: yes)"
43
+	elif doing_variant fakechroot || doing_variant minbase; then
44
+		base="apt"
45
+	fi
46
+}
47
+
48
+first_stage_install () {
49
+	extract $required
50
+
51
+	mkdir -p "$TARGET/var/lib/dpkg"
52
+	: >"$TARGET/var/lib/dpkg/status"
53
+	: >"$TARGET/var/lib/dpkg/available"
54
+
55
+	setup_etc
56
+	if [ ! -e "$TARGET/etc/fstab" ]; then
57
+		echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
58
+		chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
59
+	fi
60
+
61
+	if doing_variant fakechroot; then
62
+		setup_devices_fakechroot
63
+	else
64
+		setup_devices
65
+	fi
66
+
67
+	x_feign_install () {
68
+		local pkg="$1"
69
+		local deb="$(debfor $pkg)"
70
+		local ver="$(extract_deb_field "$TARGET/$deb" Version)"
71
+
72
+		mkdir -p "$TARGET/var/lib/dpkg/info"
73
+
74
+		echo \
75
+"Package: $pkg
76
+Version: $ver
77
+Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
78
+
79
+		touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
80
+	}
81
+
82
+	x_feign_install dpkg
83
+}
84
+
85
+second_stage_install () {
86
+	x_core_install () {
87
+		smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
88
+	}
89
+
90
+	p () {
91
+		baseprog="$(($baseprog + ${1:-1}))"
92
+	}
93
+
94
+	if doing_variant fakechroot; then
95
+		setup_proc_fakechroot
96
+	else
97
+		setup_proc
98
+		in_target /sbin/ldconfig
99
+	fi
100
+
101
+	DEBIAN_FRONTEND=noninteractive
102
+	DEBCONF_NONINTERACTIVE_SEEN=true
103
+	export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
104
+
105
+	baseprog=0
106
+	bases=7
107
+
108
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #1
109
+	info INSTCORE "Installing core packages..."
110
+
111
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #2
112
+	ln -sf mawk "$TARGET/usr/bin/awk"
113
+	x_core_install base-files base-passwd
114
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #3
115
+	x_core_install dpkg
116
+
117
+	if [ ! -e "$TARGET/etc/localtime" ]; then
118
+		ln -sf /usr/share/zoneinfo/Etc/UTC "$TARGET/etc/localtime"
119
+	fi
120
+
121
+	if doing_variant fakechroot; then
122
+		install_fakechroot_tools
123
+	fi
124
+
125
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #4
126
+	x_core_install $LIBC
127
+
128
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #5
129
+	x_core_install perl-base
130
+
131
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #6
132
+	rm "$TARGET/usr/bin/awk"
133
+	x_core_install mawk
134
+
135
+	p; progress $baseprog $bases INSTCORE "Installing core packages" #7
136
+	if doing_variant -; then
137
+		x_core_install debconf
138
+	fi
139
+
140
+	baseprog=0
141
+	bases=$(set -- $required; echo $#)
142
+
143
+	info UNPACKREQ "Unpacking required packages..."
144
+
145
+	smallyes '' |
146
+		(repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages.  This will be attempted up to five times." "" \
147
+		dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 |
148
+		dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
149
+
150
+	info CONFREQ "Configuring required packages..."
151
+
152
+	if doing_variant fakechroot; then
153
+	# fix initscripts postinst (no mounting possible, and wrong if condition)
154
+	sed -i '/dpkg.*--compare-versions/ s/\<lt\>/lt-nl/' "$TARGET/var/lib/dpkg/info/initscripts.postinst"
155
+	fi
156
+
157
+	mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
158
+	echo \
159
+"#!/bin/sh
160
+echo
161
+echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
162
+	chmod 755 "$TARGET/sbin/start-stop-daemon"
163
+
164
+	if [ -x "$TARGET/sbin/initctl" ]; then
165
+	  mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
166
+	  echo \
167
+"#!/bin/sh
168
+echo
169
+echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
170
+	  chmod 755 "$TARGET/sbin/initctl"
171
+	fi
172
+
173
+	setup_dselect_method apt
174
+
175
+	smallyes '' |
176
+		(in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
177
+		dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 |
178
+		dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
179
+
180
+	baseprog=0
181
+	bases="$(set -- $base; echo $#)"
182
+
183
+	info UNPACKBASE "Unpacking the base system..."
184
+
185
+	setup_available $required $base
186
+	done_predeps=
187
+	while predep=$(get_next_predep); do
188
+		# We have to resolve dependencies of pre-dependencies manually because
189
+		# dpkg --predep-package doesn't handle this.
190
+		predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
191
+		# XXX: progress is tricky due to how dpkg_progress works
192
+		# -- cjwatson 2009-07-29
193
+		p; smallyes '' |
194
+		in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
195
+		base=$(without "$base" "$predep")
196
+		done_predeps="$done_predeps $predep"
197
+	done
198
+
199
+	smallyes '' |
200
+		(repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" \
201
+		dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 |
202
+		dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING) 7>&1
203
+
204
+	info CONFBASE "Configuring the base system..."
205
+
206
+	smallyes '' |
207
+		(repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be re-attempted up to five times." "" \
208
+		dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 |
209
+		dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING) 7>&1
210
+
211
+	if [ -x "$TARGET/sbin/initctl.REAL" ]; then
212
+		mv "$TARGET/sbin/initctl.REAL" "$TARGET/sbin/initctl"
213
+	fi
214
+	mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
215
+
216
+	progress $bases $bases CONFBASE "Configuring base system"
217
+	info BASESUCCESS "Base system installed successfully."
218
+}
0 219
new file mode 100644
... ...
@@ -0,0 +1,22 @@
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
+nova-adminclient
7
+python-cloudfiles
8
+python-dateutil
9
+routes
10
+webob
11
+sqlalchemy
12
+paste
13
+PasteDeploy
14
+sqlalchemy-migrate
15
+eventlet
16
+xattr
17
+pep8
18
+pylint
19
+
20
+-e git+https://github.com/jacobian/openstack.compute.git#egg=openstack
21
+
0 22
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 100755
... ...
@@ -0,0 +1,261 @@
0
+#!/usr/bin/env bash
1
+
2
+# **stack.sh** is rackspace cloudbuilder's opinionated openstack installation.
3
+
4
+# Quit script on error
5
+set -o errexit
6
+
7
+# Log commands as they are run for debugging
8
+set -o xtrace
9
+
10
+DIR=`pwd`
11
+DEST=/opt
12
+CMD=$1
13
+
14
+# Set hte destination directories for openstack projects
15
+NOVA_DIR=$DEST/nova
16
+DASH_DIR=$DEST/dash
17
+GLANCE_DIR=$DEST/glance
18
+KEYSTONE_DIR=$DEST/keystone
19
+NOVACLIENT_DIR=$DEST/python-novaclient
20
+API_DIR=$DEST/openstackx
21
+NOVNC_DIR=$DEST/noVNC
22
+
23
+# Use the first IP unless an explicit is set by a HOST_IP environment variable
24
+if [ ! -n "$HOST_IP" ]; then
25
+    HOST_IP=`LC_ALL=C ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
26
+fi
27
+
28
+# NOVA CONFIGURATION
29
+INTERFACE=${INTERFACE:-eth0}
30
+FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27}
31
+FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
32
+LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu}
33
+NET_MAN=${NET_MAN:-VlanManager}
34
+# NOTE(vish): If you are using FlatDHCP on multiple hosts, set the interface
35
+#             below but make sure that the interface doesn't already have an
36
+#             ip or you risk breaking things.
37
+# FLAT_INTERFACE=eth0
38
+
39
+SQL_CONN=sqlite:///$NOVA_DIR/nova.sqlite
40
+
41
+# clone a git repository to a location, or if it already
42
+# exists, fetch and checkout remote master
43
+function clone_or_up {
44
+    if [ -d $2 ]; then
45
+        cd $2
46
+        git fetch origin
47
+        git checkout origin/master
48
+    else
49
+        git clone $1 $2
50
+    fi
51
+}
52
+
53
+# You should only have to run this once
54
+if [ "$CMD" == "install" ]; then
55
+    #apt-get install -y python-software-properties
56
+    # FIXME: do we still need this?
57
+    # DELETEME: add-apt-repository ppa:nova-core/trunk
58
+    # DELETEME: apt-get update -qq
59
+
60
+    # fixme: do we need: python-boto
61
+    apt-get install -y -q `cat $DIR/apts/*`
62
+
63
+    # install python requirements
64
+    pip install -r $DIR/pips/dash
65
+
66
+    # TODO: kill openstackx
67
+    clone_or_up https://github.com/cloudbuilders/nova.git $NOVA_DIR
68
+    clone_or_up https://github.com/cloudbuilders/openstackx.git $API_DIR
69
+    clone_or_up https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
70
+    clone_or_up https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
71
+    clone_or_up https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
72
+    clone_or_up https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
73
+    clone_or_up https://github.com/cloudbuilders/glance.git $GLANCE_DIR
74
+
75
+    mkdir -p $NOVA_DIR/instances
76
+    mkdir -p $NOVA_DIR/networks
77
+
78
+    # these components are imported into each other...
79
+    cd $NOVACLIENT_DIR; python setup.py develop
80
+    cd $KEYSTONE_DIR; python setup.py develop
81
+    cd $GLANCE_DIR; python setup.py develop
82
+    cd $API_DIR; python setup.py develop
83
+    cd $DASH_DIR/django-openstack; python setup.py develop
84
+    cd $DASH_DIR/openstack-dashboard; python setup.py develop
85
+    # dash currently imports quantum even if you aren't using it
86
+    cd $DASH_DIR/openstack-dashboard
87
+    mkdir quantum
88
+    touch quantum/__init__.py
89
+    touch quantum/client.py
90
+
91
+
92
+    # attempt to load kvm and nbd modules
93
+    modprobe kvm || true
94
+    modprobe nbd || true
95
+    /etc/init.d/libvirt-bin restart
96
+
97
+    # install dashboard
98
+    cd $DASH_DIR/openstack-dashboard
99
+    cp local/local_settings.py.example local/local_settings.py
100
+#    python tools/install_venv.py
101
+    dashboard/manage.py syncdb
102
+    # setup apache
103
+    mkdir $DASH_DIR/.blackhole
104
+
105
+#    cat > $DASH_DIR/openstack-dashboard/dashboard/wsgi/local.wsgi <<EOF
106
+#import sys
107
+#sys.path.append('/$DASH_DIR/openstack-dashboard/.dashboard-venv/lib/python2.6/site-packages/')
108
+#sys.path.append('/$DASH_DIR/openstack-dashboard/.dashboard-venv/lib/python2.7/site-packages/')
109
+#sys.path.append('/$DASH_DIR/openstack-dashboard/')
110
+#sys.path.append('/$DASH_DIR/django-openstack/')
111
+#sys.path.append('/$API_DIR')
112
+#sys.path.append('/$DASH_DIR/openstack-dashboard/.dashboard-venv/src/openstack')
113
+#
114
+#EOF
115
+    cat $DASH_DIR/openstack-dashboard/dashboard/wsgi/django.wsgi >> $DASH_DIR/openstack-dashboard/dashboard/wsgi/local.wsgi
116
+
117
+    cat > /etc/apache2/sites-enabled/000-default <<EOF
118
+<VirtualHost *:80>
119
+    WSGIScriptAlias / $DASH_DIR/openstack-dashboard/dashboard/wsgi/local.wsgi
120
+    WSGIDaemonProcess dashboard user=www-data group=www-data processes=3 threads=10
121
+    WSGIProcessGroup dashboard
122
+
123
+    DocumentRoot $DASH_DIR/.blackhole/
124
+    Alias /media $DASH_DIR/openstack-dashboard/media
125
+
126
+    <Directory />
127
+        Options FollowSymLinks
128
+        AllowOverride None
129
+    </Directory>
130
+
131
+    <Directory $DASH_DIR/>
132
+        Options Indexes FollowSymLinks MultiViews
133
+        AllowOverride None
134
+        Order allow,deny
135
+        allow from all
136
+    </Directory>
137
+
138
+    ErrorLog /var/log/apache2/error.log
139
+    LogLevel warn
140
+    CustomLog /var/log/apache2/access.log combined
141
+</VirtualHost>
142
+EOF
143
+
144
+    chown -R www-data:www-data $DASH_DIR
145
+
146
+    mkdir -p /var/log/glance
147
+
148
+    mkdir -p $DEST/images
149
+    wget -c http://images.ansolabs.com/tty.tgz
150
+    tar -C $DEST/images -zxf tty.tgz
151
+    exit
152
+fi
153
+
154
+# Configure screen
155
+cat >~/.screenrc <<EOF
156
+hardstatus on
157
+hardstatus alwayslastline
158
+hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G}%H %{..Y}%d/%m %c"
159
+
160
+defscrollback 1024
161
+
162
+vbell off
163
+startup_message off
164
+EOF
165
+
166
+NL=`echo -ne '\015'`
167
+
168
+function screen_it {
169
+    screen -S nova -X screen -t $1
170
+    screen -S nova -p $1 -X stuff "$2$NL"
171
+}
172
+
173
+function add_nova_flag {
174
+    echo "$1" >> $NOVA_DIR/bin/nova.conf
175
+}
176
+
177
+if [ "$CMD" == "run" ] || [ "$CMD" == "run_detached" ]; then
178
+
179
+    rm -f $NOVA_DIR/bin/nova.conf
180
+
181
+    add_nova_flag "--verbose"
182
+    add_nova_flag "--nodaemon"
183
+    add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
184
+    add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
185
+    add_nova_flag "--my_ip=$HOST_IP"
186
+    add_nova_flag "--public_interface=$INTERFACE"
187
+    add_nova_flag "--vlan_interface=$INTERFACE"
188
+    add_nova_flag "--sql_connection=$SQL_CONN"
189
+    add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
190
+    add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
191
+    add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
192
+    add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/noVNC/noVNC"
193
+
194
+    if [ -n "$FLAT_INTERFACE" ]; then
195
+        add_nova_flag "--flat_interface=$FLAT_INTERFACE"
196
+    fi
197
+
198
+    add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
199
+    add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
200
+
201
+    killall dnsmasq || true
202
+    screen -d -m -S nova -t nova
203
+    sleep 1
204
+    rm -f $NOVA_DIR/nova.sqlite
205
+    rm -rf $NOVA_DIR/instances
206
+    mkdir -p $NOVA_DIR/instances
207
+    rm -rf $NOVA_DIR/networks
208
+    mkdir -p $NOVA_DIR/networks
209
+
210
+    # create the database
211
+    $NOVA_DIR/bin/nova-manage db sync
212
+    rm -f keystone.db
213
+    # add default data
214
+    curl -OL https://raw.github.com/cloudbuilders/deploy.sh/master/initial_data.sh
215
+    BIN_DIR=$KEYSTONE_DIR/bin bash initial_data.sh
216
+
217
+    # create a small network
218
+    $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
219
+
220
+    # create some floating ips
221
+    $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
222
+
223
+    # nova api crashes if we start it with a regular screen command,
224
+    # so send the start command by forcing text into the window.
225
+
226
+    rm -rf /var/lib/glance/images/*
227
+    rm -f $GLANCE_DIR/glance.sqlite
228
+
229
+    screen_it n-api "$NOVA_DIR/bin/nova-api"
230
+    screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
231
+    screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
232
+    screen_it cpu "$NOVA_DIR/bin/nova-compute"
233
+    screen_it net "$NOVA_DIR/bin/nova-network"
234
+    screen_it sched "$NOVA_DIR/bin/nova-scheduler"
235
+    screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_DIR/etc/keystone.conf"
236
+    screen_it dash "/etc/init.d/apache2 restart; tail -f /var/log/apache2/error.log"
237
+    screen_it vnc "$NOVA_DIR/bin/nova-vncproxy"
238
+    screen_it test ""
239
+
240
+    # FIXME: switch to just importing images
241
+    # remove previously converted images
242
+    rm -rf $DIR/images/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]
243
+    $NOVA_DIR/bin/nova-manage image convert $DIR/images
244
+
245
+    if [ "$CMD" != "run_detached" ]; then
246
+      screen -S nova -x
247
+    fi
248
+fi
249
+
250
+if [ "$CMD" == "run" ] || [ "$CMD" == "terminate" ]; then
251
+    virsh list | grep i- | awk '{print $1}' | xargs -n1 virsh destroy
252
+    $NOVA_DIR/tools/clean-vlans
253
+    echo "FIXME: clean networks?"
254
+fi
255
+
256
+if [ "$CMD" == "run" ] || [ "$CMD" == "clean" ]; then
257
+    screen -S nova -X quit
258
+    rm -f *.pid*
259
+fi
260
+