wiki:DevStack
Last modified 2 years ago Last modified on 10/29/15 12:40:20

DevStack enables working with upstream OpenStack code and related projects by providing a working OpenStack implementation to support your development environment. For example, if you want to code on Horizon (the web UI of Openstack), clone the upstream Horizon code and then configure it to work with your DevStack. This configuration lets you push changes into your DevStack instance and test them.

Setting up a DevStack instance for OpenStack is easy and a great way to learn about and contribute to the project. DevStack runs all of OpenStack in one machine. It uses the QEMU emulator so you can even launch its own instances.

It's easy to set your own DevStack instance on our OpenStack fabric using nova and a user-data file. If you are familiar with Kickstart, it's very similar but works for any distro or compatible cloud fabric.

Environment Assumptions

Make sure you have an instance running that supports execution of the nova commands. This is easiest using another instance in the fabric.

Set Up Security Rules

Create the security group with port 22 and 80 by default

nova secgroup-create devstack "Ports needed for devstack instance"
nova secgroup-add-rule devstack tcp 22 22 0.0.0.0/0
nova secgroup-add-rule devstack tcp 80 80 0.0.0.0/0

Define the User-data file

This tells the machine what actions to carry out during the install.

cat > devstack-user-data << EOF
#cloud-config
# based on 
# http://docs.openstack.org/developer/devstack/guides/single-vm.html
# with addtions to update from
# https://cloudinit.readthedocs.org/en/latest/topics/examples.html
package_upgrade: true

users:
  - default
  - name: stack
    lock_passwd: False
    sudo: ["ALL=(ALL) NOPASSWD:ALL\nDefaults:stack !requiretty"]
    shell: /bin/bash

write_files:
  - content: |
        #!/bin/sh
        DEBIAN_FRONTEND=noninteractive sudo apt-get -qqy update || sudo yum update -qy
        DEBIAN_FRONTEND=noninteractive sudo apt-get install -qqy git || sudo yum install -qy git
        sudo chown stack:stack /home/stack
        cd /home/stack
        git clone https://git.openstack.org/openstack-dev/devstack
        cd devstack
        echo '[[local|localrc]]' > local.conf
        echo ADMIN_PASSWORD=password >> local.conf
        echo MYSQL_PASSWORD=password >> local.conf
        echo RABBIT_PASSWORD=password >> local.conf
        echo SERVICE_PASSWORD=password >> local.conf
        echo SERVICE_TOKEN=tokentoken >> local.conf
        ./stack.sh
    path: /home/stack/start.sh
    permissions: 0755

runcmd:
  - su -l stack ./start.sh
EOF

Create the Server

One command does it all

nova boot --flavor m1.medium \
  --image trusty-server-14.04-cloudimg-amd64-disk1 \
  --key-name jpr-laptop --user-data ./devstack-user-data \
  --security-groups devstack --poll jpr-devstack

Assign a Public IP

You need to reserve an IP for our project:

nova floating-ip-create

This returns a table like:

+---------------+-----------+----------+------+
| Ip            | Server Id | Fixed Ip | Pool |
+---------------+-----------+----------+------+
| IP_ADDRESS    |           | -        | nova |
+---------------+-----------+----------+------+

Use the IP_ADDRESS in the following command

nova floating-ip-associate jpr-devstack $IP_ADDRESS

Access your OpenStack

Just open a browser to http://164.111.161.X where X is the last octet of the IP_ADDRESS above.

Enjoy.