OpenStack, Devstack and Horizon — Installing and setting up a basic OpenStack environment
Updated as of 28/Feb/2018
It is recommended install Devstack on a virtual machine as you can easily get rid of it without having much to lose if it were to crash and also ensuring that everything related to it has been removed so there are no unexpected clashes or errors when you come to reinstall it.
With my particular setup, as a front end developer, I prefer working on my mac rather than directly on my virtual machine. Therefore in this walk through I will be talking about how to set up your virtual machine, installing devstack there, then accessing that devstack from outside of your vm and setting up horizon locally on your mac or whatever system you choose to operate on.
Setting up your virtual machine
For this setup I am using VMware Fusion, however you can also setup your DevStack virtual environment using Parallels or by using the free software VirtualBox.
1. Download the relevant version of Ubuntu for your operating system http://www.ubuntu.com/download/desktop
2. Start up your virtual machine software and create a new machine.
3. Select linux from the list of supported operating systems followed by ‘install from image’ and select the ubuntu image you downloaded in step 1.
4. Provide a name you want to give your VM and the location for your VM files i.e. C:\VM\
5. Under the settings for processors and memory, ensure that you give the VM a minimum of 2 processor cores and the memory to 4096mb.
6. If you are using a new version of VMware you will be able to just set the VM to inherit the same network settings as the host computer, however if you are using an older version or VirtualBox set the network type to use bridged networking.
7. Leave other settings as default, press finish and let the Ubuntu installation run it’s course.
With the above settings you should have an Ubunutu VM ready you to install Devstack.
- Login to your Ubuntu virtual machine with ssh or the console and create the non-root sudo user to run Devstack with:
sudo useradd -s /bin/bash -d /opt/stack -m stack
2. Give the stack user sudo privileges:
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
Output should be: stack ALL=(ALL) NOPASSWD: ALL
3. Switch to stack user:
sudo su - stack
4. Install git:
sudo apt-get install git
5. Clone the Devstack repository, cd into it and change to the latest stable version. Currently (28/Feb/2018) the latest stable release is stable/pike however stable/queens will be released shortly:
git clone http://github.com/openstack-dev/devstack
git checkout stable/pike
6. Find your virtual machine IP address. It might be worth considering setting up a static IP but that process is not documented here:
7. Create or edit your local.conf to look similar to the following. Make sure to edit HOST_IP to your virtual machine IP address as above. Your local.conf can be edited and configured to your exact requirements (see https://docs.openstack.org/devstack/latest/configuration.html) but this will set you up for a basic deployment:
8. At this point I highly recommend creating a snapshot of the vm that you have set up ready to stack so that you can revert to this point if stack fails for any reason or if you need to run everything again later in time. It is a helpful point to revert to, make necessary changes, and re-run. Following this you are now ready to run the stack.sh file to start the build process:
9. After it is done it will return a URL for horizon. Open that link in your browser and you should then be able to access the OpenStack Dashboard from inside your virtual machine. The IP in the URL will also be the IP of the virtual machine which you will use in the next section to setup the OpenStack host IP. To clarify this you might want to run ifconfig from the terminal which will return your IP.
Known errors and workarounds
- Permission denied: ‘/home/stack/.cache/pip/wheels/
Run the following command and re-run ./stack.sh:
sudo chown -R stack:stack /opt/stack
2. Failure retrieving project_id for demo or when creating initial neutron network elements — ensure that the vm memory is large enough (I recommend 4096mb) and that you have added your HOST_IP to local.conf.
Installing Horizon outside of the virtual machine
1. Clone the Horizon git repository from OpenStack to your main working environment (i.e. outside of your virtual machine):
2. Under horizon/openstack_dashboard/local replicate and then rename the file local_settings.py.example to local_settings.py:
cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py
3. Open up the local_settings.py file in your preferred text editor. Change the OPENSTACK_HOST to match the hostname of your OpenStack server — i.e. the IP of your devstack virtual machine. This should be at about line 149 of the code.
4. Horizon now uses tox to manage virtual environments for testing and other development tasks:
pip install tox
5. Boot up Horizon by running the following from the root of the Horizon repository. The default port for runserver is 8000 which might be already consumed by heat-api-cfn in DevStack, therefore I recommend adding ‘localhost:9000’ to the command as below to start the test server at http://localhost:9000 :
tox -e runserver -- localhost:9000
6. Login to the horizon dashboard using the username: admin and password: as set in stack.sh build of devstack.
Installing the Ironic UI plugin for bare metal provisioning
Intro to the Ironic UI: The Ironic UI is a Horizon plugin that will allow users to view and manage bare metal nodes, ports and drivers.
1. Clone the Ironic UI repository:
2. Change into your local Horizon repository and run the venv. NOTE: this has been preinstalled when horizon was setup with ./run_tests.sh — do not reinstall venv
3. Copy the enabled file from ironic-ui/enabled to horizon/openstack_dashboard/enabled
4. Change into the ironic-ui repository and package the plugin:
pip install -e .
This will create a python egg in the dist folder and will install the plugin into horizon’s python virtual environment
5. Change back into the horizon repository and bring up your environment:
The Ironic Bare Metal Provisioning plugin should now be visible in the Horizon navigation.
To uninstall, use pip uninstall (find the name of the package to uninstall by running pip list from inside the horizon .venv). You will also need to remove the enabled file from the openstack_dashboard/enabled folder.