...
|
...
|
@@ -1,6 +1,6 @@
|
1
|
1
|
#!/usr/bin/env bash
|
2
|
2
|
|
3
|
|
-# **stack.sh** is rackspace cloudbuilder's opinionated openstack installation.
|
|
3
|
+# **stack.sh** is rackspace cloudbuilder's opinionated openstack dev installation.
|
4
|
4
|
|
5
|
5
|
# Quit script on error
|
6
|
6
|
set -o errexit
|
...
|
...
|
@@ -12,7 +12,7 @@ DIR=`pwd`
|
12
|
12
|
DEST=/opt
|
13
|
13
|
CMD=$1
|
14
|
14
|
|
15
|
|
-# Set hte destination directories for openstack projects
|
|
15
|
+# Set the destination directories for openstack projects
|
16
|
16
|
NOVA_DIR=$DEST/nova
|
17
|
17
|
DASH_DIR=$DEST/dash
|
18
|
18
|
GLANCE_DIR=$DEST/glance
|
...
|
...
|
@@ -39,17 +39,9 @@ NET_MAN=${NET_MAN:-VlanManager}
|
39
|
39
|
|
40
|
40
|
SQL_CONN=sqlite:///$NOVA_DIR/nova.sqlite
|
41
|
41
|
|
42
|
|
-# clone a git repository to a location, or if it already
|
43
|
|
-# exists, fetch and checkout remote master
|
44
|
|
-function clone_or_up {
|
45
|
|
- if [ -d $2 ]; then
|
46
|
|
- echo commenting out update for now for speed
|
47
|
|
- # cd $2
|
48
|
|
- # git fetch origin
|
49
|
|
- # git checkout origin/master
|
50
|
|
- else
|
51
|
|
- git clone $1 $2
|
52
|
|
- fi
|
|
42
|
+# clone a git repository to a location
|
|
43
|
+function ginstall {
|
|
44
|
+ git clone $1 $2
|
53
|
45
|
}
|
54
|
46
|
|
55
|
47
|
# You should only have to run this once
|
...
|
...
|
@@ -60,43 +52,63 @@ if [ "$CMD" == "install" ]; then
|
60
|
60
|
# install python requirements
|
61
|
61
|
pip install `cat $DIR/pips/*`
|
62
|
62
|
|
63
|
|
- # TODO: kill openstackx
|
64
|
|
- clone_or_up https://github.com/cloudbuilders/nova.git $NOVA_DIR
|
65
|
|
- clone_or_up https://github.com/cloudbuilders/openstackx.git $API_DIR
|
66
|
|
- clone_or_up https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
|
67
|
|
- clone_or_up https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
|
68
|
|
- clone_or_up https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
|
69
|
|
- clone_or_up https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
|
70
|
|
- clone_or_up https://github.com/cloudbuilders/glance.git $GLANCE_DIR
|
71
|
|
-
|
72
|
|
- mkdir -p $NOVA_DIR/instances
|
73
|
|
- mkdir -p $NOVA_DIR/networks
|
74
|
|
-
|
75
|
|
- # these components are imported into each other...
|
|
63
|
+ # vm service
|
|
64
|
+ ginstall https://github.com/cloudbuilders/nova.git $NOVA_DIR
|
|
65
|
+ # a websockets/html5 or flash powered VNC console for vm instances
|
|
66
|
+ ginstall https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
|
|
67
|
+ # django powered web control panel for openstack
|
|
68
|
+ ginstall https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
|
|
69
|
+ # python client library to nova that dashboard (and others) use
|
|
70
|
+ ginstall https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
|
|
71
|
+ # unified auth system (manages accounts/tokens)
|
|
72
|
+ ginstall https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
|
|
73
|
+ # image catalog
|
|
74
|
+ ginstall https://github.com/cloudbuilders/glance.git $GLANCE_DIR
|
|
75
|
+ # openstackx is a collection of extensions to openstack.compute & nova
|
|
76
|
+ # that is *deprecated*. The code is being moved into python-novaclient & nova.
|
|
77
|
+ ginstall https://github.com/cloudbuilders/openstackx.git $API_DIR
|
|
78
|
+
|
|
79
|
+ # setup our checkouts so they are installed into python path
|
|
80
|
+ # allowing `import nova` or `import glance.client`
|
76
|
81
|
cd $NOVACLIENT_DIR; python setup.py develop
|
77
|
82
|
cd $KEYSTONE_DIR; python setup.py develop
|
78
|
83
|
cd $GLANCE_DIR; python setup.py develop
|
79
|
84
|
cd $API_DIR; python setup.py develop
|
80
|
85
|
cd $DASH_DIR/django-openstack; python setup.py develop
|
81
|
86
|
cd $DASH_DIR/openstack-dashboard; python setup.py develop
|
82
|
|
- # HACK: dash currently imports quantum even if you aren't using it
|
83
|
|
- cd $DASH_DIR/openstack-dashboard
|
84
|
|
- mkdir quantum
|
85
|
|
- touch quantum/__init__.py
|
86
|
|
- touch quantum/client.py
|
87
|
87
|
|
88
|
|
- # attempt to load kvm and nbd modules
|
89
|
|
- modprobe kvm || true
|
|
88
|
+ # attempt to load modules: kvm (hardware virt) and nbd (network block
|
|
89
|
+ # device - used to manage qcow images)
|
90
|
90
|
modprobe nbd || true
|
|
91
|
+ modprobe kvm || true
|
|
92
|
+ # if kvm wasn't running before we need to restart libvirt to enable it
|
91
|
93
|
/etc/init.d/libvirt-bin restart
|
92
|
94
|
|
93
|
|
- # install dashboard
|
|
95
|
+ # setup nova instance directory
|
|
96
|
+ mkdir -p $NOVA_DIR/instances
|
|
97
|
+
|
|
98
|
+ # if there is a partition labeled nova-instances use it (ext filesystems
|
|
99
|
+ # can be labeled via e2label)
|
|
100
|
+ if [ -L /dev/disk/by-label/nova-instances ]; then
|
|
101
|
+ mount -L nova-instances /$NOVA_DIR/instances
|
|
102
|
+ fi
|
|
103
|
+
|
|
104
|
+ # *Dashboard*: setup django application to serve via apache/wsgi
|
|
105
|
+
|
|
106
|
+ # Dash currently imports quantum even if you aren't using it. Instead
|
|
107
|
+ # of installing quantum we can create a simple module that will pass the
|
|
108
|
+ # initial imports
|
|
109
|
+ mkdir $DASH_DIR/openstack-dashboard/quantum
|
|
110
|
+ touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
|
|
111
|
+ touch $DASH_DIR/openstack-dashboard/quantum/client.py
|
|
112
|
+ # local_settings has
|
94
|
113
|
cd $DASH_DIR/openstack-dashboard
|
95
|
114
|
cp local/local_settings.py.example local/local_settings.py
|
96
|
115
|
dashboard/manage.py syncdb
|
97
|
|
- # setup apache
|
98
|
|
- mkdir $DASH_DIR/.blackhole
|
99
|
116
|
|
|
117
|
+ # *Setup Apache*
|
|
118
|
+ # create an empty directory to use as our
|
|
119
|
+ mkdir $DASH_DIR/.blackhole
|
100
|
120
|
# FIXME(ja): can't figure out how to make $DASH_DIR work in sed, also install to available/a2e it
|
101
|
121
|
cat $DIR/files/000-default.template | sed "s/%DASH_DIR%/\/opt\/dash/g" > /etc/apache2/sites-enabled/000-default
|
102
|
122
|
|
...
|
...
|
@@ -104,6 +116,7 @@ if [ "$CMD" == "install" ]; then
|
104
|
104
|
|
105
|
105
|
mkdir -p /var/log/glance
|
106
|
106
|
|
|
107
|
+ # prepare initial images for loading into glance
|
107
|
108
|
if [ ! -f $DEST/tty.tgz ]; then
|
108
|
109
|
wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
|
109
|
110
|
fi
|
...
|
...
|
@@ -119,6 +132,8 @@ fi
|
119
|
119
|
NL=`echo -ne '\015'`
|
120
|
120
|
|
121
|
121
|
function screen_it {
|
|
122
|
+ # nova api crashes if we start it with a regular screen command,
|
|
123
|
+ # so send the start command by forcing text into the window.
|
122
|
124
|
screen -S nova -X screen -t $1
|
123
|
125
|
screen -S nova -p $1 -X stuff "$2$NL"
|
124
|
126
|
}
|
...
|
...
|
@@ -129,8 +144,8 @@ function add_nova_flag {
|
129
|
129
|
|
130
|
130
|
if [ "$CMD" == "run" ] || [ "$CMD" == "run_detached" ]; then
|
131
|
131
|
|
|
132
|
+ # (re)create nova.conf
|
132
|
133
|
rm -f $NOVA_DIR/bin/nova.conf
|
133
|
|
-
|
134
|
134
|
add_nova_flag "--verbose"
|
135
|
135
|
add_nova_flag "--nodaemon"
|
136
|
136
|
add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
|
...
|
...
|
@@ -143,32 +158,31 @@ if [ "$CMD" == "run" ] || [ "$CMD" == "run_detached" ]; then
|
143
|
143
|
add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
|
144
|
144
|
add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
|
145
|
145
|
add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/noVNC/noVNC"
|
146
|
|
-
|
|
146
|
+ add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
|
|
147
|
+ add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
|
147
|
148
|
if [ -n "$FLAT_INTERFACE" ]; then
|
148
|
149
|
add_nova_flag "--flat_interface=$FLAT_INTERFACE"
|
149
|
150
|
fi
|
150
|
151
|
|
151
|
|
- add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
|
152
|
|
- add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
|
153
|
|
-
|
154
|
|
- killall dnsmasq || true
|
|
152
|
+ # create a new named screen to store things in
|
155
|
153
|
screen -d -m -S nova -t nova
|
156
|
154
|
sleep 1
|
157
|
|
- rm -f $NOVA_DIR/nova.sqlite
|
|
155
|
+
|
|
156
|
+ # Clean out the instances directory
|
158
|
157
|
rm -rf $NOVA_DIR/instances/*
|
159
|
|
- mkdir -p $NOVA_DIR/instances
|
160
|
|
- # if there is a partition labeled nova-instances use it (ext filesystems
|
161
|
|
- # can be labeled via e2label)
|
162
|
|
- if [ -L /dev/disk/by-label/nova-instances ]; then
|
163
|
|
- mount -L nova-instances /$NOVA_DIR/instances
|
164
|
|
- fi
|
|
158
|
+
|
|
159
|
+ # delete traces of nova networks from prior runs
|
|
160
|
+ killall dnsmasq || true
|
165
|
161
|
rm -rf $NOVA_DIR/networks
|
166
|
162
|
mkdir -p $NOVA_DIR/networks
|
167
|
163
|
|
168
|
|
- # create the database
|
|
164
|
+ # (re)create nova database
|
|
165
|
+ rm -f $NOVA_DIR/nova.sqlite
|
169
|
166
|
$NOVA_DIR/bin/nova-manage db sync
|
170
|
|
- rm -f keystone.db
|
171
|
|
- # add default data
|
|
167
|
+
|
|
168
|
+ # initialize keystone with default users/endpoints
|
|
169
|
+ # FIXME(ja): move initial_data.sh into this script
|
|
170
|
+ rm -f /opt/keystone/keystone.db
|
172
|
171
|
curl -OL https://raw.github.com/cloudbuilders/deploy.sh/master/initial_data.sh
|
173
|
172
|
BIN_DIR=$KEYSTONE_DIR/bin bash initial_data.sh
|
174
|
173
|
|
...
|
...
|
@@ -178,11 +192,11 @@ if [ "$CMD" == "run" ] || [ "$CMD" == "run_detached" ]; then
|
178
|
178
|
# create some floating ips
|
179
|
179
|
$NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
|
180
|
180
|
|
|
181
|
+ # delete existing glance images/database. Glance will recreate the db
|
|
182
|
+ # when it is ran.
|
181
|
183
|
rm -rf /var/lib/glance/images/*
|
182
|
184
|
rm -f $GLANCE_DIR/glance.sqlite
|
183
|
185
|
|
184
|
|
- # nova api crashes if we start it with a regular screen command,
|
185
|
|
- # so send the start command by forcing text into the window.
|
186
|
186
|
screen_it n-api "$NOVA_DIR/bin/nova-api"
|
187
|
187
|
screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
|
188
|
188
|
screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
|