I recently setup a MAAS cluster on Ubuntu Linux in my home lab so that I could play around with Openstack and Juju. I wanted MAAS to be able to automatically power on and off my newly-provisioned vms, but I had a hard time finding an easy-to-follow set of instructions on how to get this working on VMware ESXi. I did eventually get it working and put together a procedure below. Hopefully it helps someone out.
- VMware ESXi (Standalone, no VirtualCenter server) version 5.5.0
- Ubuntu MAAS on VMware VMs (no physical servers)
- libvirt version 1.2.8
- Ubuntu Linux 14.04
Install and Build the libvirt 1.2.8
- First, download the latest (Currently 1.2.8) version source file at
- Untar the file
tar -xzf /tmp/libvirt-1.2.8.tar.gz -C /tmp/
- Uninstall any existing version of libvir
sudo apt-get remove libvirt-bin
- Install the prerequisites
sudo apt-get install gcc make libxml2-dev libgnutls-dev libdevmapper-dev libcurl4-gnutls-dev libpciaccess-dev libnl-dev
- Make and Install the new version
- Specify the /usr directory when calling the configure command to specify where the non-architecture specific stuff gets installed
./configure –prefix=/usr –with-esx
sudo make install
You have to setup the /etc/libvirt/auth.conf file with credentials in order to use virsh without entering a password. This is necessary for MAAS to power nodes up automatically.
sudo nano /etc/libvirt/auth.conf
- The credentials-esx block defines the credentials
- credentials-esx # The esx in this part defines the name of the credential set
- The second block defines the service and hostname
- auth-esx # This defines which credential block to use. In this case, the esx credentials
- auth-esx-hostname # This defines the host to use the esx credentials for
- Restart libvirt-bin
sudo service libvirt-bin restart
Test your Configuration
You can make a test connection to your ESXi host to test your virsh configuration with the command below:
virsh -c esx://root@esxhostname1?no_verify=1 list –all
This will prompt you for your root password and then list all VMs on the VM host.
3/25/2015 – UPDATE: I found that this will only work on the paid (non-evaulation) version of vSphere ESXi. If you have the eval version, it will work until your eval expires and reverts to the unpaid license. MAAS will silently fail to power on or off VMs when this happens. You will get this error when trying to run the command manually from the CLI:
virsh -c esx://root@esxhostname?no_verify=1 start –domain myvmname
error: Failed to start the domain myvmname
error: internal error: HTTP response code 500 for call to ‘PowerOnVM_Task’. Fault: ServerFaultCode – Current license or ESXi version prohibits executio nof the requested operation.
Pretty clear, I guess.
Configuring MAAS for Virsh
Now you have to configure your new MAAS nodes with virsh. To do this, we’ll simulate adding a new node to a MAAS cluster.
- First, use the VSphere client to connect to your ESXi host and create a new VM.
- Make sure and set the OS Type to Ubuntu Linux (I use 64-bit)
- Once the vm is created, right-click it and Edit Settings
- Make sure you go to the Boot tab and force it to the BIOS for the next boot.
- Start the new VM and go into the BIOS.
- Go to the boot tab in the BIOS and set the network card to be the first boot option (Use SHIFT plus to move it up)
- Go to the Exit menu and choose Save.
- Power off the VM.
- Edit the settings again
- Select the network card and copy the MAC address
- Log into your MAAS web interface (http://maas-cluster-controller/MAAS)
- Click the Nodes menu option.
- Click the Add Node button.
- Fill out the fields as specified:
- Power Type: Select virsh from the drop down
- Power Address: esx://root@esxhost1/system?no_verify=1
- Where esxhost1 is the name of your ESXi host
- Power ID: The name of the VM as displayed in the VM inventory in the vSphere client.
- Now click “Add an additional MAC address”
- Paste in the MAC address of the VMs virtual network card you got above.
Done! I’ve not found a way to get past manually booting the node for the first time. After you manually power it on once, it will enlist and shut itself off. From there on out, you can click the node in the MAAS web interface and click “Start Node” or “Stop Node” to power it on and off.