|
...
|
...
|
@@ -10,7 +10,6 @@ set -o xtrace
|
|
10
|
10
|
|
|
11
|
11
|
DIR=`pwd`
|
|
12
|
12
|
DEST=/opt
|
|
13
|
|
-CMD=$1
|
|
14
|
13
|
|
|
15
|
14
|
# Set the destination directories for openstack projects
|
|
16
|
15
|
NOVA_DIR=$DEST/nova
|
|
...
|
...
|
@@ -41,95 +40,91 @@ NET_MAN=${NET_MAN:-VlanManager}
|
|
41
|
41
|
# TODO: switch to mysql for all services
|
|
42
|
42
|
SQL_CONN=sqlite:///$NOVA_DIR/nova.sqlite
|
|
43
|
43
|
|
|
44
|
|
-# FIXME: commands should be: stack.sh all or list of services to install/run
|
|
45
|
|
-
|
|
46
|
|
-# You should only have to run this once
|
|
47
|
|
-if [ "$CMD" == "install" ]; then
|
|
48
|
|
- # install apt requirements
|
|
49
|
|
- apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
|
|
50
|
|
-
|
|
51
|
|
- # install python requirements
|
|
52
|
|
- pip install `cat $DIR/pips/*`
|
|
53
|
|
-
|
|
54
|
|
- # compute service
|
|
55
|
|
- git clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
|
|
56
|
|
- # image catalog service
|
|
57
|
|
- git clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
|
|
58
|
|
- # unified auth system (manages accounts/tokens)
|
|
59
|
|
- git clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
|
|
60
|
|
- # a websockets/html5 or flash powered VNC console for vm instances
|
|
61
|
|
- git clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
|
|
62
|
|
- # django powered web control panel for openstack
|
|
63
|
|
- git clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
|
|
64
|
|
- # python client library to nova that dashboard (and others) use
|
|
65
|
|
- git clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
|
|
66
|
|
- # openstackx is a collection of extensions to openstack.compute & nova
|
|
67
|
|
- # that is *deprecated*. The code is being moved into python-novaclient & nova.
|
|
68
|
|
- git clone https://github.com/cloudbuilders/openstackx.git $API_DIR
|
|
69
|
|
-
|
|
70
|
|
- # setup our checkouts so they are installed into python path
|
|
71
|
|
- # allowing `import nova` or `import glance.client`
|
|
72
|
|
- cd $NOVACLIENT_DIR; python setup.py develop
|
|
73
|
|
- cd $KEYSTONE_DIR; python setup.py develop
|
|
74
|
|
- cd $GLANCE_DIR; python setup.py develop
|
|
75
|
|
- cd $API_DIR; python setup.py develop
|
|
76
|
|
- cd $DASH_DIR/django-openstack; python setup.py develop
|
|
77
|
|
- cd $DASH_DIR/openstack-dashboard; python setup.py develop
|
|
78
|
|
-
|
|
79
|
|
- # attempt to load modules: kvm (hardware virt) and nbd (network block
|
|
80
|
|
- # device - used to manage qcow images)
|
|
81
|
|
- modprobe nbd || true
|
|
82
|
|
- modprobe kvm || true
|
|
83
|
|
- # if kvm wasn't running before we need to restart libvirt to enable it
|
|
84
|
|
- /etc/init.d/libvirt-bin restart
|
|
85
|
|
-
|
|
86
|
|
- # setup nova instance directory
|
|
87
|
|
- mkdir -p $NOVA_DIR/instances
|
|
88
|
|
-
|
|
89
|
|
- # if there is a partition labeled nova-instances use it (ext filesystems
|
|
90
|
|
- # can be labeled via e2label)
|
|
91
|
|
- if [ -L /dev/disk/by-label/nova-instances ]; then
|
|
92
|
|
- mount -L nova-instances /$NOVA_DIR/instances
|
|
93
|
|
- fi
|
|
94
|
|
-
|
|
95
|
|
- # *Dashboard*: setup django application to serve via apache/wsgi
|
|
96
|
|
-
|
|
97
|
|
- # Dash currently imports quantum even if you aren't using it. Instead
|
|
98
|
|
- # of installing quantum we can create a simple module that will pass the
|
|
99
|
|
- # initial imports
|
|
100
|
|
- mkdir $DASH_DIR/openstack-dashboard/quantum
|
|
101
|
|
- touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
|
|
102
|
|
- touch $DASH_DIR/openstack-dashboard/quantum/client.py
|
|
103
|
|
- # local_settings has
|
|
104
|
|
- cd $DASH_DIR/openstack-dashboard
|
|
105
|
|
- cp local/local_settings.py.example local/local_settings.py
|
|
106
|
|
- dashboard/manage.py syncdb
|
|
107
|
|
-
|
|
108
|
|
- # # Setup Apache
|
|
109
|
|
- # create an empty directory to use as our
|
|
110
|
|
- mkdir $DASH_DIR/.blackhole
|
|
111
|
|
- # FIXME(ja): can't figure out how to make $DASH_DIR work in sed, also install to available/a2e it
|
|
112
|
|
- cat $DIR/files/000-default.template | sed 's/%DASH_DIR%/\/opt\/dash/g' > /etc/apache2/sites-enabled/000-default
|
|
113
|
|
-
|
|
114
|
|
- chown -R www-data:www-data $DASH_DIR
|
|
115
|
|
-
|
|
116
|
|
- mkdir -p /var/log/glance
|
|
117
|
|
-
|
|
118
|
|
- # prepare initial images for loading into glance
|
|
119
|
|
- if [ ! -f $DEST/tty.tgz ]; then
|
|
120
|
|
- wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
|
|
121
|
|
- fi
|
|
122
|
|
-
|
|
123
|
|
- mkdir -p $DEST/images
|
|
124
|
|
- tar -C $DEST/images -zxf $DEST/tty.tgz
|
|
125
|
|
-
|
|
126
|
|
- # add useful screenrc
|
|
127
|
|
- cp $DIR/files/screenrc ~/.screenrc
|
|
128
|
|
-
|
|
129
|
|
- # TODO: update current user to allow sudo for all commands in files/sudo/*
|
|
130
|
|
- exit
|
|
|
44
|
+# FIXME: commands should be: stack.sh should allow specifying a subset of services
|
|
|
45
|
+
|
|
|
46
|
+# install apt requirements
|
|
|
47
|
+apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
|
|
|
48
|
+
|
|
|
49
|
+# install python requirements
|
|
|
50
|
+pip install `cat $DIR/pips/*`
|
|
|
51
|
+
|
|
|
52
|
+# compute service
|
|
|
53
|
+git clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
|
|
|
54
|
+# image catalog service
|
|
|
55
|
+git clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
|
|
|
56
|
+# unified auth system (manages accounts/tokens)
|
|
|
57
|
+git clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
|
|
|
58
|
+# a websockets/html5 or flash powered VNC console for vm instances
|
|
|
59
|
+git clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
|
|
|
60
|
+# django powered web control panel for openstack
|
|
|
61
|
+git clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
|
|
|
62
|
+# python client library to nova that dashboard (and others) use
|
|
|
63
|
+git clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
|
|
|
64
|
+# openstackx is a collection of extensions to openstack.compute & nova
|
|
|
65
|
+# that is *deprecated*. The code is being moved into python-novaclient & nova.
|
|
|
66
|
+git clone https://github.com/cloudbuilders/openstackx.git $API_DIR
|
|
|
67
|
+
|
|
|
68
|
+# setup our checkouts so they are installed into python path
|
|
|
69
|
+# allowing `import nova` or `import glance.client`
|
|
|
70
|
+cd $NOVACLIENT_DIR; python setup.py develop
|
|
|
71
|
+cd $KEYSTONE_DIR; python setup.py develop
|
|
|
72
|
+cd $GLANCE_DIR; python setup.py develop
|
|
|
73
|
+cd $API_DIR; python setup.py develop
|
|
|
74
|
+cd $DASH_DIR/django-openstack; python setup.py develop
|
|
|
75
|
+cd $DASH_DIR/openstack-dashboard; python setup.py develop
|
|
|
76
|
+
|
|
|
77
|
+# attempt to load modules: kvm (hardware virt) and nbd (network block
|
|
|
78
|
+# device - used to manage qcow images)
|
|
|
79
|
+modprobe nbd || true
|
|
|
80
|
+modprobe kvm || true
|
|
|
81
|
+# if kvm wasn't running before we need to restart libvirt to enable it
|
|
|
82
|
+/etc/init.d/libvirt-bin restart
|
|
|
83
|
+
|
|
|
84
|
+# setup nova instance directory
|
|
|
85
|
+mkdir -p $NOVA_DIR/instances
|
|
|
86
|
+
|
|
|
87
|
+# if there is a partition labeled nova-instances use it (ext filesystems
|
|
|
88
|
+# can be labeled via e2label)
|
|
|
89
|
+if [ -L /dev/disk/by-label/nova-instances ]; then
|
|
|
90
|
+ mount -L nova-instances /$NOVA_DIR/instances
|
|
131
|
91
|
fi
|
|
132
|
92
|
|
|
|
93
|
+# *Dashboard*: setup django application to serve via apache/wsgi
|
|
|
94
|
+
|
|
|
95
|
+# Dash currently imports quantum even if you aren't using it. Instead
|
|
|
96
|
+# of installing quantum we can create a simple module that will pass the
|
|
|
97
|
+# initial imports
|
|
|
98
|
+mkdir $DASH_DIR/openstack-dashboard/quantum
|
|
|
99
|
+touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
|
|
|
100
|
+touch $DASH_DIR/openstack-dashboard/quantum/client.py
|
|
|
101
|
+# local_settings has
|
|
|
102
|
+cd $DASH_DIR/openstack-dashboard
|
|
|
103
|
+cp local/local_settings.py.example local/local_settings.py
|
|
|
104
|
+dashboard/manage.py syncdb
|
|
|
105
|
+
|
|
|
106
|
+# ## Setup Apache
|
|
|
107
|
+# create an empty directory to use as our
|
|
|
108
|
+mkdir $DASH_DIR/.blackhole
|
|
|
109
|
+# FIXME(ja): can't figure out how to make $DASH_DIR work in sed, also install to available/a2e it
|
|
|
110
|
+cat $DIR/files/000-default.template | sed 's/%DASH_DIR%/\/opt\/dash/g' > /etc/apache2/sites-enabled/000-default
|
|
|
111
|
+
|
|
|
112
|
+chown -R www-data:www-data $DASH_DIR
|
|
|
113
|
+
|
|
|
114
|
+mkdir -p /var/log/glance
|
|
|
115
|
+
|
|
|
116
|
+# prepare initial images for loading into glance
|
|
|
117
|
+if [ ! -f $DEST/tty.tgz ]; then
|
|
|
118
|
+ wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
|
|
|
119
|
+fi
|
|
|
120
|
+
|
|
|
121
|
+mkdir -p $DEST/images
|
|
|
122
|
+tar -C $DEST/images -zxf $DEST/tty.tgz
|
|
|
123
|
+
|
|
|
124
|
+# add useful screenrc
|
|
|
125
|
+cp $DIR/files/screenrc ~/.screenrc
|
|
|
126
|
+
|
|
|
127
|
+# TODO: update current user to allow sudo for all commands in files/sudo/*
|
|
|
128
|
+
|
|
133
|
129
|
NL=`echo -ne '\015'`
|
|
134
|
130
|
|
|
135
|
131
|
function screen_it {
|
|
...
|
...
|
@@ -143,89 +138,71 @@ function add_nova_flag {
|
|
143
|
143
|
echo "$1" >> $NOVA_DIR/bin/nova.conf
|
|
144
|
144
|
}
|
|
145
|
145
|
|
|
146
|
|
-if [ "$CMD" == "run" ] || [ "$CMD" == "run_detached" ]; then
|
|
147
|
|
-
|
|
148
|
|
- # (re)create nova.conf
|
|
149
|
|
- rm -f $NOVA_DIR/bin/nova.conf
|
|
150
|
|
- add_nova_flag "--verbose"
|
|
151
|
|
- add_nova_flag "--nodaemon"
|
|
152
|
|
- add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
|
|
153
|
|
- add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
|
|
154
|
|
- add_nova_flag "--my_ip=$HOST_IP"
|
|
155
|
|
- add_nova_flag "--public_interface=$INTERFACE"
|
|
156
|
|
- add_nova_flag "--vlan_interface=$INTERFACE"
|
|
157
|
|
- add_nova_flag "--sql_connection=$SQL_CONN"
|
|
158
|
|
- add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
|
|
159
|
|
- add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
|
|
160
|
|
- add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
|
|
161
|
|
- add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/noVNC/noVNC"
|
|
162
|
|
- add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
|
|
163
|
|
- add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
|
|
164
|
|
- if [ -n "$FLAT_INTERFACE" ]; then
|
|
165
|
|
- add_nova_flag "--flat_interface=$FLAT_INTERFACE"
|
|
166
|
|
- fi
|
|
167
|
|
-
|
|
168
|
|
- # create a new named screen to store things in
|
|
169
|
|
- screen -d -m -S nova -t nova
|
|
170
|
|
- sleep 1
|
|
171
|
|
-
|
|
172
|
|
- # Clean out the instances directory
|
|
173
|
|
- rm -rf $NOVA_DIR/instances/*
|
|
174
|
|
-
|
|
175
|
|
- # delete traces of nova networks from prior runs
|
|
176
|
|
- killall dnsmasq || true
|
|
177
|
|
- rm -rf $NOVA_DIR/networks
|
|
178
|
|
- mkdir -p $NOVA_DIR/networks
|
|
179
|
|
-
|
|
180
|
|
- # (re)create nova database
|
|
181
|
|
- rm -f $NOVA_DIR/nova.sqlite
|
|
182
|
|
- $NOVA_DIR/bin/nova-manage db sync
|
|
183
|
|
-
|
|
184
|
|
- # initialize keystone with default users/endpoints
|
|
185
|
|
- # FIXME(ja): move initial_data.sh into this script
|
|
186
|
|
- rm -f /opt/keystone/keystone.db
|
|
187
|
|
- curl -OL https://raw.github.com/cloudbuilders/deploy.sh/master/initial_data.sh
|
|
188
|
|
- BIN_DIR=$KEYSTONE_DIR/bin bash initial_data.sh
|
|
189
|
|
-
|
|
190
|
|
- # create a small network
|
|
191
|
|
- $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
|
|
192
|
|
-
|
|
193
|
|
- # create some floating ips
|
|
194
|
|
- $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
|
|
195
|
|
-
|
|
196
|
|
- # delete existing glance images/database. Glance will recreate the db
|
|
197
|
|
- # when it is ran.
|
|
198
|
|
- rm -rf /var/lib/glance/images/*
|
|
199
|
|
- rm -f $GLANCE_DIR/glance.sqlite
|
|
200
|
|
-
|
|
201
|
|
- screen_it n-api "$NOVA_DIR/bin/nova-api"
|
|
202
|
|
- screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
|
|
203
|
|
- screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
|
|
204
|
|
- screen_it cpu "$NOVA_DIR/bin/nova-compute"
|
|
205
|
|
- screen_it net "$NOVA_DIR/bin/nova-network"
|
|
206
|
|
- screen_it sched "$NOVA_DIR/bin/nova-scheduler"
|
|
207
|
|
- screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_DIR/etc/keystone.conf"
|
|
208
|
|
- screen_it vnc "$NOVA_DIR/bin/nova-vncproxy"
|
|
209
|
|
- screen_it dash "/etc/init.d/apache2 restart; tail -f /var/log/apache2/error.log"
|
|
210
|
|
-
|
|
211
|
|
- # FIXME: switch to just importing images
|
|
212
|
|
- # remove previously converted images
|
|
213
|
|
- 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]
|
|
214
|
|
- $NOVA_DIR/bin/nova-manage image convert $DIR/images
|
|
215
|
|
-
|
|
216
|
|
- if [ "$CMD" != "run_detached" ]; then
|
|
217
|
|
- screen -S nova -x
|
|
218
|
|
- fi
|
|
|
146
|
+# (re)create nova.conf
|
|
|
147
|
+rm -f $NOVA_DIR/bin/nova.conf
|
|
|
148
|
+add_nova_flag "--verbose"
|
|
|
149
|
+add_nova_flag "--nodaemon"
|
|
|
150
|
+add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
|
|
|
151
|
+add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
|
|
|
152
|
+add_nova_flag "--my_ip=$HOST_IP"
|
|
|
153
|
+add_nova_flag "--public_interface=$INTERFACE"
|
|
|
154
|
+add_nova_flag "--vlan_interface=$INTERFACE"
|
|
|
155
|
+add_nova_flag "--sql_connection=$SQL_CONN"
|
|
|
156
|
+add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
|
|
|
157
|
+add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
|
|
|
158
|
+add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
|
|
|
159
|
+add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/noVNC/noVNC"
|
|
|
160
|
+add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
|
|
|
161
|
+add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
|
|
|
162
|
+if [ -n "$FLAT_INTERFACE" ]; then
|
|
|
163
|
+ add_nova_flag "--flat_interface=$FLAT_INTERFACE"
|
|
219
|
164
|
fi
|
|
220
|
165
|
|
|
221
|
|
-if [ "$CMD" == "run" ] || [ "$CMD" == "terminate" ]; then
|
|
222
|
|
- virsh list | grep i- | awk '{print $1}' | xargs -n1 virsh destroy
|
|
223
|
|
- $NOVA_DIR/tools/clean-vlans
|
|
224
|
|
- echo "FIXME: clean networks?"
|
|
225
|
|
-fi
|
|
226
|
|
-
|
|
227
|
|
-if [ "$CMD" == "run" ] || [ "$CMD" == "clean" ]; then
|
|
228
|
|
- screen -S nova -X quit
|
|
229
|
|
- rm -f *.pid*
|
|
230
|
|
-fi
|
|
|
166
|
+# create a new named screen to store things in
|
|
|
167
|
+screen -d -m -S nova -t nova
|
|
|
168
|
+sleep 1
|
|
|
169
|
+
|
|
|
170
|
+# Clean out the instances directory
|
|
|
171
|
+rm -rf $NOVA_DIR/instances/*
|
|
|
172
|
+
|
|
|
173
|
+# delete traces of nova networks from prior runs
|
|
|
174
|
+killall dnsmasq || true
|
|
|
175
|
+rm -rf $NOVA_DIR/networks
|
|
|
176
|
+mkdir -p $NOVA_DIR/networks
|
|
|
177
|
+
|
|
|
178
|
+# (re)create nova database
|
|
|
179
|
+rm -f $NOVA_DIR/nova.sqlite
|
|
|
180
|
+$NOVA_DIR/bin/nova-manage db sync
|
|
|
181
|
+
|
|
|
182
|
+# initialize keystone with default users/endpoints
|
|
|
183
|
+# FIXME(ja): move initial_data.sh into this script
|
|
|
184
|
+rm -f /opt/keystone/keystone.db
|
|
|
185
|
+curl -OL https://raw.github.com/cloudbuilders/deploy.sh/master/initial_data.sh
|
|
|
186
|
+BIN_DIR=$KEYSTONE_DIR/bin bash initial_data.sh
|
|
|
187
|
+
|
|
|
188
|
+# create a small network
|
|
|
189
|
+$NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
|
|
|
190
|
+
|
|
|
191
|
+# create some floating ips
|
|
|
192
|
+$NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
|
|
|
193
|
+
|
|
|
194
|
+# delete existing glance images/database. Glance will recreate the db
|
|
|
195
|
+# when it is ran.
|
|
|
196
|
+rm -rf /var/lib/glance/images/*
|
|
|
197
|
+rm -f $GLANCE_DIR/glance.sqlite
|
|
|
198
|
+
|
|
|
199
|
+screen_it n-api "$NOVA_DIR/bin/nova-api"
|
|
|
200
|
+screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
|
|
|
201
|
+screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
|
|
|
202
|
+screen_it cpu "$NOVA_DIR/bin/nova-compute"
|
|
|
203
|
+screen_it net "$NOVA_DIR/bin/nova-network"
|
|
|
204
|
+screen_it sched "$NOVA_DIR/bin/nova-scheduler"
|
|
|
205
|
+screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_DIR/etc/keystone.conf"
|
|
|
206
|
+screen_it vnc "$NOVA_DIR/bin/nova-vncproxy"
|
|
|
207
|
+screen_it dash "/etc/init.d/apache2 restart; tail -f /var/log/apache2/error.log"
|
|
|
208
|
+
|
|
|
209
|
+# FIXME: switch to just importing images
|
|
|
210
|
+# remove previously converted images
|
|
|
211
|
+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]
|
|
|
212
|
+$NOVA_DIR/bin/nova-manage image convert $DIR/images
|
|
231
|
213
|
|