Quantcast
Channel: Cloudbase Solutions
Viewing all articles
Browse latest Browse all 83

DevStack on Hyper-V

$
0
0

DevStack is without any doubt one of the easiest ways to set up an OpenStack environment for testing or development purposes (no production!!).
It’s also a great way to test the Hyper-V Nova Compute and Quantum Grizzly beta versions that we are releasing these days! :-)

Hyper-V Server 2012 is free and can be downloaded from here . The installation is very simple and straightforward as with any Windows Server solution. You can use of course also the full Windows Server 2012 , but unless you are really missing the GUI features, there’s no need for it.

Another great option for development consists in enabling the Hyper-V role on Windows 8 (Pro or Enterprise). If you have a Mac, Linux or Windows 7 you can run both Hyper-V and DevStack virtualized on VMWare Fusion 5 / Workstation 9.

To make things even easier, in this guide we’ll run DevStack in a VM on top of the Hyper-V compute node. Hyper-V is not particularly picky about hardware, which means that there’s no need for expensive servers to be used for test and development.

The DevStack VM

Let’s start by downloading an Ubuntu Server 12.04 ISO image and create a VM on Hyper-V. Since Hyper-V Server does not provide a GUI, you can do that from a separate host (Windows 8 / Windows Server 2012) or you can issue some simple Powershell commands.
Here’s how to download the Ubuntu ISO image via Powershell:

 

$isourl = "http://releases.ubuntu.com/12.04/ubuntu-12.04.1-server-amd64.iso"
$isopath = "C:\ISO\ubuntu-12.04.1-server-amd64.iso"
Invoke-WebRequest -uri $isourl -OutFile $isopath

 

You will need an external virtual switch, in order for the VMs to communicate with the external world (including Internet for our DevStack VM). You can of course skip this step if you already created one.

 

$net = Get-NetAdapter
$vmswitch = new-vmswitch External -NetAdapterName $net[0].Name -AllowManagementOS $True

 

Finally here’s how to create and start the DevStack VM, with 1 GB RAM and 15 GB HDD, a virtual network adapter attached to the external switch and the Ubuntu ISO attached to the DVD for the installation.

 

$vm = new-VM "DevStack" -MemoryStartupBytes (1024*1024*1024) -NewVHDPath "C:\VHD\DevStack.vhdx" -NewVHDSizeBytes (15*1024*1024*1024)
Set-VMDvdDrive $vm.Name -Path $isopath
Connect-VMNetworkAdapter $vm.Name -SwitchName $vmswitch.Name
Start-VM $vm

 

Now it’s time to connect to the VM console and install Ubuntu. All we need is a basic installation with SSH. DevStack will take care of the rest.

 

Console access

The free Hyper-V Server does not provide a console UI application, so we have two options:

  1. Access the server from another host using Hyper-V Manager on Windows 8 or Windows Server 2012
  2. Using our free FreeRDP based solution directly from the Hyper-V server

We’ll choose the latter in this guide as we simply love it. :-)

In Powershell from the directory in which you unzipped FreerDP run:

 

Set-ExecutionPolicy RemoteSigned
Import-Module .\PSFreeRDP.ps1

 

And now we can finally access the console of our new VM:

 

Get-VMConsole DevStack

 

Once you are done with the Ubuntu setup, we can go on and deploy DevStack. My suggestion is to connect to the Ubuntu VM via SSH, as it’s way easier especially for pasting commands. In case you should need an SSH client for Windows, Putty is a great (and free) option.
Let’s  start by adding an NTP daemon as time synchronization issues are a typical source of headaches in OpenStack:

 

sudo apt-get install ntp
sudo service ntp start

 

We need Git to download DevStack:

sudo apt-get install git

 

Installing and running DevStack is easy:

 

git clone git://github.com/openstack-dev/devstack.git
cd devstack
./stack.sh

 

The script will ask you for a few passwords. You will find them in the “devstack/localrc” file afterwards.
In case you should prefer to run a specific version of the OpenStack components instead of the latest Grizzly bits, just add the branch name to the git clone command, e.g.:

 

git clone git://github.com/openstack-dev/devstack.git -b stable/folsom

 

Now edit your ~/.bashrc file and add the following lines at the end, in order to have your environment ready whenever you log in:

 

export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=yourpassword
export OS_AUTH_URL="http://localhost:5000/v2.0/"

 

And reload it with:

source ~/.bashrc

 

It’s time to add an image to Glance in order to spawn VMs on Hyper-V. To save you some time we prepared a ready made Ubuntu VM image. When you create your own, remember to use the VHD format and not VHDX.

 

wget http://www.cloudbase.it/downloads/UbuntuServer1204_cloudinit.zip
unzip UbuntuServer1204_cloudinit.zip
glance image-create --name "Ubuntu Server 12.04" --property hypervisor_type=hyperv --container-format bare --disk-format vhd < UbuntuServer1204.vhd

 

Note the hypervisor_type property. By specifying it, we are asking Nova Scheduler to use this image on Hyper-V compute nodes only, which means that you can have a mix of KVM, Xen or Hyper-V nodes in your stack, letting Nova Scheduler taking care of it any time you boot a new image, a great feature IMO!
We are almost done. Let’s create a new keypair and save the private key in your user’s home:

 

test -d ~/.ssh || mkdir ~/.ssh
nova keypair-add key1 >> ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

 

Ok, we are done with DevStack so far. We need to setup our Hyper-V Nova Compute node, which is even easier thanks to the installer that we released :-) . Let’s go back to the Powershell:

 

$src = "http://www.cloudbase.it/downloads/HyperVNovaCompute_Beta.msi"
$dest = "$env:temp\HyperVNovaCompute_Folsom.msi"
Invoke-WebRequest -uri $src -OutFile $dest
Unblock-File $dest
Start-Process $dest

 

The installation is very easy, just follow the steps available here!
Remember to specify the IP address of your DevStack VM for Glance and RabbitMQ. As Nova database connection string you can simply use: mysql://root:YourDevStackPassword@YourDevstackIP/nova

(Note: never use “root” in a production environment!)

Now let’s go back to DevStack and check that all the services are up and running:

 

nova-manage service list

 

You should see a smile “:-)” close to each service and no “XXX”.

Now it’s time to boot our first OpenStack VM:

 

nova boot --flavor 1 --image "Ubuntu Server 12.04" --key-name key1 vm1

 

You can check the progress and status of your VM with:

 

nova list

 

The first time that you boot an instance it will take a few minutes, depending on the size of your Glance image, as the image itself gets cached on the compute node. Subsequent image boots will be very fast.

 

Some useful tips

How to delete all the VM at once from the command line

During testing you’ll need to cleanup all the instances quite often. Here’s a simple script to do that on Linux without issuing single “nova delete” commands for every instance:

 

nova list | awk '{if (NR > 3 && $2 != "") {system("nova delete " $2);}}'

 

How to update DevStack

I typically run the following script from the DevStack folder after a reboot to update the OpenStack components (Nova, Glance, etc) and the DevStack scripts, just before running stack.sh

git pull
pushd .
cd /opt/stack/nova
git pull
cd /opt/stack/glance
git pull
cd /opt/stack/cinder
git pull
cd /opt/stack/keystone
git pull
cd /opt/stack/horizon
git pull
cd /opt/stack/python-glanceclient
git pull
python setup.py build
sudo python setup.py install --force 
cd /opt/stack/python-novaclient
git pull
python setup.py build
sudo python setup.py install --force
cd /opt/stack/python-cinderclient
git pull
python setup.py build
sudo python setup.py install --force
cd /opt/stack/python-keystoneclient
git pull
python setup.py build
sudo python setup.py install --force
popd

 

How to check your OpenStack versions

All the components in your stack need to share the same OpenStack version. Don’t mix Grizzly and Folsom components!! Here’s how to check what Nova version you are running:

 

python -c "from nova import version; print version.NOVA_VERSION"

 

For Grizzly you will get: ['2013, '1', '0']  (the last number might also be “None”).

 

The post DevStack on Hyper-V appeared first on Cloudbase Solutions.


Viewing all articles
Browse latest Browse all 83

Trending Articles