Grokking OpenStack

OpenStack - little pieces

Installing Devstack With Vagrant

Devstack - The OpenStack Development Environment

Who should install Devstack?

Those who wish to contribute to OpenStack code.

Those wishing to install OpenStack for production should install OpenStack from distribution packages or a tarball. Devstack is not recommended for production.

What is Devstack?

Devstack is a repository of code which will install and start an OpenStack developement and testing environment.

Where can I find the Devstack code?

Read up on the Devstack project and browse the code.

Why should I install Devstack?

Devstack is the environment used to run the tests on all new OpenStack code patches. New code has to pass these tests before they are merged to trunk. Using Devstack as a development environment helps contributors understand the entire life cycye of OpenStack code.

How do I install Devstack?

What do I need?

You need an isolated environment to install Devstack - a vm, a container or a separate hard drive - an environment that can be set up, taken down, over written and reinstalled without affecting the rest of your development environment.

In this post, I will give instructions for installing Devstack using vagrant - but you can install Devstack anywhere you want. I highly recommend you select an environment isolated from your local development environment - but the choice is yours.

  • install virtualbox (4.2.12 or 4.2.16 but not 4.2.14)
  • install vagrant (I used the debs for both virtualbox and vagrant)

I am using virtualbox 4.2.16 and vagrant 1.2.7 for this post.

  • mkdir devstack_vagrant
  • cd devstack_vagrant
  • vagrant box add precise32 http://files.vagrantup.com/precise32.box
  • vagrant init precise32

These commands will download a 32bit image of ubuntu precise from http://files.vagrantup.com. If you have the ability to use a 64bit image for virtualization (you may need to toggle your bios settings on a 64bit machine), you can replace the reference to 32 above with 64. So, vagrant box add precise64 http://files.vagrantup.com/precise64.box followed by vagrant init precise64.

We are using ubuntu precise on purpose since the majority of our testing for OpenStack code uses Devstack on an ubuntu precise server. You can use whatever server image you want, but if Devstack doesn’t install properly on it, I will suggest you try ubuntu precise.

  • open the Vagrantfile created by the vagrant init command in an editor, for example vi Vagrantfile
  • increase the amount of RAM allocated to the vm by editing the following lines to match the code below:
Vagrantfile
1
2
3
4
5
6
7
config.vm.provider :virtualbox do |vb|
#   # Don't boot with headless mode
#   vb.gui = true
#
#   # Use VBoxManage to customize the VM. For example to change memory:
  vb.customize ["modifyvm", :id, "--memory", "2048"]
end
  • save and close the file

Devstack requires at least 1.2G of RAM to run. Use the most you can afford with your setup. the code above allocates 2G of RAM to this vagrant vm.

  • vagrant up && vagrant ssh

This brings up the vm and opens a shell into the server image.

Since I use this set of instructions myself to create vms for development, the next command I usually run is:

  • ssh-keygen -t <rsa|dsa> posting the public key to my gerrit account, enabling me to submit patches to gerrit from the vm

Then I update apt-get and install dependencies then git clone devstack and cd inside:

sudo apt-get update && sudo apt-get -y install git vim-gtk libxml2-dev libxslt1-dev libpq-dev python-pip libsqlite3-dev && sudo apt-get -y build-dep python-mysqldb && sudo pip install git-review tox && git clone git://git.openstack.org/openstack-dev/devstack && cd devstack

I set my username, email and editor choice in git with:

  • git config --user.name "<user name>"
  • git config --user.email "<gerrit email>"
  • git config --user.editor "<editor>"

I am in the devstack root directory so I can run:

  • mv samples/localrc .

to get a copy of localrc in the root directory.

Then I run:

  • ./stack.sh

to have devstack download all the OpenStack development repositories and start the services.

You will have to be connected to the internet, at least the first time you run devstack, in order for all the repositories and their dependencies to be installed. Devstack will take a fair amount of time to install, your time will depend on your internect connection and the amount of RAM you have allocated to your vm.

After devstack has finished installing, source the openrc file to enable credentials:

  • source ~devstack/openrc

If you need to be the admin user, source the file with the admin argument:

  • source ~devstack/openrc admin

To stop devstack, run ./unstack.sh inside the devstack root directory.

To exit the vagrant vm, type exit. This closes the ssh shell to the vm and puts you back in your host session.

To stop the vagrant vm, type vagrant suspend or vagrant halt.

To remove the vagrant vm, type vagrant destroy. Don’t just remove the vagrant directory with rm -rf <vagrant directory>, you need to reclaim the memory allocated for the vm.

To restart a vagrant vm, type vagrant up.


If you want to use vagrant’s shell provisioning you can copy this for your Vagrantfile:

Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
  end
  config.vm.provision :shell do |shell|
    shell.inline = "apt-get update && apt-get -y install git vim-gtk libxml2-dev libxslt1-dev libpq-dev python-pip libsqlite3-dev && apt-get -y build-dep python-mysqldb && pip install git-review tox && git clone git://git.openstack.org/openstack-dev/devstack && chown -R vagrant:vagrant devstack"
  end
end

If you choose to use the above Vagrantfile, use the following commands:

  • vagrant up This will take a while to run, since this updates apt-get, installs the dependancies and then clones devstack
  • vagrant ssh

Subsequent commands to start the vm will have to specify not provisioning the vm:

  • vagrant up --no-provision

If you brought down the vagrant vm with vagrant suspend, you can bring it up again with vagrant resume, rather than using vagrant up --no-provision.


There is much to learn about using devstack, but this concludes the installation.

Thanks for reading,
Anita Kuno.

Comments