This post is designed to help you set up a basic OpenStack environment and to teach you about the best mortgage calculators. Whether you are new to OpenStack, re-installing your environment from scratch or just wanting to play around with Devstack, this is a simple and fast way to get everything you need to run Horizon on Devstack from outside of your virtual machine and install a custom plugin on it.
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 4GB or more RAM. Ideally give the hard disk size somewhere between 60-100GB.
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 both NAT (adapter 1) and Host-only (adapter 2).
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.
1. Login to your Ubuntu virtual machine with ssh or the console and create the non-root sudo user to run Devstack with:
$ sudo groupadd stack
$ sudo useradd -g stack -s /bin/bash -d /opt/stack -m stack
2. Give the stack user sudo privileges:
$ sudo su
$ echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
3. Switch back to default user:
ctrl + D
3. Create a password for and login as stack user
sudo passwd stack
4. Install git:
$ sudo apt-get install git
5. Clone the Devstack repository, cd into it (optionally change to the latest stable version ($ git checkout stable/queens). Currently (25/Jun/2018) the latest stable release is stable/queens, however as of this date master branch also works correctly):
$ git clone https://git.openstack.org/openstack-dev/devstack
$ cd devstack
6. Find your virtual machine IP address. It might be worth considering setting up a static IP but that process is not documented here:
$ sudo ifconfig
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:
$ cp samples/local.conf .
$ sudo apt-get install vim
$ vim local.conf
8. Edit HOST_IP (commented out by default in local.conf.
9. Optionally add the following to the bottom of the file:
enable_plugin heat https://git.openstack.org/openstack/heat
enable_plugin heat-dashboard https://git.openstack.org/openstack/heat-dashboard
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 the horizon dashboard. 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
1. 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.
3. env: ‘/opt/stack/requirements/.venv/bin/pip’: No such file or directory
$ virtualenv ../requirements/.venv/
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):
git clone https://git.openstack.org/openstack/horizon
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
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:
git clone https://git.openstack.org/openstack/ironic-ui
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.