Creating a sandbox environment using VMware Workstation and Vagrant allows us to discover and experiment with the OpenStack services. VMware Workstation gives us the ability to spin up virtual machines and networks without affecting the rest of our working environment. VMware Workstation is available for Windows and Linux. Vagrant allows us to automate this task, meaning we can spend less time creating our test environments and more time using OpenStack. This test environment can then be used for the rest of the OpenStack Cloud Computing Cookbook.

It is assumed that the computer you will be using to run your test environment in has enough processing power that has hardware virtualization support (for example, Intel VT-X and AMD-V support) with at least 8 GB RAM. Remember we’re creating a virtual machine that itself will be used to spin up virtual machines, so the more RAM you have, the better.

Getting ready

To begin with, we must have purchased VMware Workstation from http://www.vmware.com/ and then follow the installation procedure once this has been downloaded.

We also need to download and install Vagrant, which will be covered in the later part.

The steps throughout the book assume the underlying operating system that will be used to install OpenStack on will be Ubuntu 14.04 LTS release.

We don’t need to download a Ubuntu 14.04 ISO as we use our Vagrant environment do this for us.

Once set up, we need to create the Networks that we will use for our OpenStack environment. From the Virtual Network Editor, create the following networks:

Here we are creating 3 “host-only” networks that will map to our eth1, eth2 and eth3 interfaces under our Linux guests (as vmnet8 will consume eth0).

Once this has been done, we need to ensure we are able to change our interfaces in our guests to Promiscuous mode, and we can only do that if we are able to write to the interface on our host. On our host running VMware Workstation, run the following (if running under Linux):

How to do it…

To create our sandbox environment within VMware Workstation we will use Vagrant to define a number of virtual machines that allows us to run all of the OpenStack services used in the OpenStack Cloud Computing Cookbook.

These virtual machines will be configured with at an appropriate amount of RAM, CPU and Disk, and have a total of four network interfaces. Vagrant automatically setups an interface on our virtual machine that will NAT (Network Address Translate) traffic out, allowing our virtual machine to connect to the network outside of VMware Workstation to download packages. This NAT interface is not mentioned in our Vagrantfile but will be visible on our virtual machine as eth0. A Vagrantfile, which is found in the working directory of our virtual machine sandbox environment, is a simple file that describes our virtual machines and how VMware Workstation will create them. We configure our first interface for use in our OpenStack environment, which will be the host network interface of our OpenStack virtual machines (the interface a client will connect to Horizon, or use the API), a second interface will be for our private network that OpenStack Compute uses for internal communication between different OpenStack Compute hosts and a third which will be used when we look at Neutron networking as an external provider network. When these virtual machines become available after starting them up, you will see the four interfaces that are explained below:

Once installed, we can define our virtual machine and networking in a file called Vagrantfile. To do this, create a working directory (for example, “~/cookbook” and edit a file in here called Vagrantfileas shown in the following command snippet:

mkdir ~/cookbook
cd ~/cookbook
vim Vagrantfile

We can now proceed to configure Vagrant by editing the ~/cookbook/Vagrantfile file with the following code:

We are now ready to power on our controller node. We do this by simply running the following command:

vagrant up

Congratulations! We have successfully created the VMware Workstation virtual machines running on Ubuntu 14.04 which is able to run OpenStack services.

How it works…

What we have done is defined a number of virtual machines within VirtualBox, VMware Fusion/Workstation by defining it in Vagrant. Vagrant then configures these virtual machines, based on the settings given in Vagrantfile in the directory where we want to store and run our VirtualBox or VMware Fusion/Workstation virtual machines from. This file is based on Ruby syntax, but the lines are relatively self-explanatory. We have specified some of the following:

The hostnames are called controller, network, compute, swift and cinder and have a corresponding 4th octet IP assigned to them that i is appended to the networks given further into the file.

The VM is based on Ubuntu Trusty Tahr, an alias for Ubuntu 14.04 LTS 64-bit

We configure some optimizations and specific configurations for VMware and VirtualBox

The file has been written as a series of nested loops, iterating over the “nodes” array set at the top of the file.

In each iteration, the corresponding configuration of the virtual machine is made, and then the configured virtual machine is then brought up.

We then launch this virtual machines using Vagrant with the help of the following simple command:

vagrant up

This will launch all VMs listed in the Vagrantfile.

To see the status of the virtual machines we use the following command:

vagrant status

To log into any of the machines we use the following command:

vagrant ssh controller

replace “controller” with the name of the virtual machine you want to use.