Hyper-V Drivers for OpenNebula 3.2
The Hyper-V Drivers enable the management of an OpenNebula cloud based on the Windows Server Hyper-V hypervisor.
Acknowledgments: These new components have been developed with the support of Microsoft. We also want to give thanks to VrStorm for trying the driver while it was in development.
These drivers can access directly to each of Hyper-V hosts or use a Windows Front-end acting as proxy to access the Windows Hosts. This last configuration is useful to manage standalone Hyper-V installations.
An OpenNebula/Hyper-V cloud requires the following minimal components:
Hyper-V drivers can coexist with Xen, KVM or VMWare drivers.
hdc is reserved to contextualization iso. Take this into account when assigning disk targets.The prefered method to set the network configuration is using the context parameter. Right now the context image is seen in hdc. The provided ttylinux image in the files section (ttylinux) comes prepared to use it. (DHCP)
CONTEXT = [ hostname = "$NAME", ip_public = "$NIC[IP, NETWORK=\"<NETWORK NAME>\"]", files = "<PATH TO>/init.sh" ]
init.sh file:#!/bin/bash if [ -f /mnt/context/context.sh ]; then . /mnt/context/context.sh fi hostname $HOSTNAME ifconfig eth0 $IP_PUBLIC
NETWORK NAME to the name of your network and PATH TO to the place where init.sh is located.There are two ways to communicate with HyperV hosts. One is using a machine that serves as proxy and has the WinRM service configured. This is the preferred method to connect to standalone HyperV hypervisors. The other one is connecting directly to each of the machines, they will need to have installed and configured the WinRM service and some other software usually installed in the frontend.
Follow these configuration guides in order to configure the machines.
C:\Program Files\Modules
> Set-ExecutionPolicy Unrestricted CurrentUser
C:\Users\<user>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 file and add at the end:import-module 'C:\Program Files\Modules\HyperV'
* Create an administrative user called 'oneadmin', it will be used to connect using winrm into the FRONTEND and also for file copying.
> winrm quickconfig
> winrm set winrm/config/service @{AllowUnencrypted="true"}
> winrm set winrm/config/service/auth @{Basic="true"}
icacls <local folder> /grant "NT Virtual Machine\Virtual Machines":f
hvremote /add:<domain>/ssh hvremote /mmc:enable hvremote /AnonDCOM:grant
The shared storage from the Windows server must be mounted in the server that executes OpenNebula so it can put there the images for running VMS. It must be mounted in a way so oneadmin user has permissions to access it. This can be donde adding uid=oneadmin to the mount options:
smbmount <WINDOWS SHARE> <YOUR MOUNT POINT> -ouser=<WINDOWS USER>,pass=<PASSWORD>,dom=<DOMAIN>,uid=oneadmin
<>You can download the code from the file section of this project. one-hyperv-3.2.0.tar.gz
To install the drivers there's a install.sh script. It takes one parameter if your installation is self contained and is the ONE_LOCATION path. If your OpenNebula installation is system wide execute it without parameters.
To activate the drivers we should add this to oned.conf:
IM_MAD = [ name = "im_hyperv", executable = "one_im_sh", arguments = "-r 0 -t 15 hyperv" ] VM_MAD = [ name = "vmm_hyperv", executable = "one_vmm_sh", arguments = "-t 15 -r 0 hyperv", default = "vmm_exec/vmm_exec_kvm.conf", type = "xml" ] TM_MAD = [ name = "tm_hyperv", executable = "one_tm", arguments = "tm_hyperv/tm_hyperv.conf" ]
We will also need to configure the TM so it knows where the share storage is mounted in /etc/one/tm_hyperv/tm_hypervrc:
SMB_MOUNT=<MOUNT POINT>
Change <MOUNT POINT> to the path previously used to mount the Windows shared directory.
We will also need to edit /etc/one/hyperv.conf:
:proxy: <PROXY> :vmdir: <WINDOWS SHARE> :local_vmdir: <LOCAL FOLDER> :user: <USER> :password: <PASSWORD>
PROXY: this is the name of the Windows frontend sever that will serve as proxy. Commenting this parameter will make the driver connect to each of the hosts directly. (Can be commented prepending a #)WINDOWS SHARE: the windows path to access the shared storageLOCAL DIR: directory that will hold the images for VMs in each machineUSER: windows oneadmin user namePASSWORD: windows oneadmin user passwordFor example, if our server is called FRONTEND and the share is called vms the configuration will be:
:proxy: "FRONTEND" :vmdir: "\\\\FRONTEND\\vms" :local_vmdir: "C:\\localvms" :user: "oneadmin" :password: "password"
You will add the hosts with the name known to the windows server and the newly installed drivers:
$ onehost create host01 im_hyperv vmm_hyperv tm_hyperv dummy
We will create the networks that will match the networks we previously created in the nodes. The networks will be created as any other OpenNebula network but we will use the Hyper-V network name as the bridge. For example for the networks created before we can use these both templates to create them. Feel free to change the IP ranges:
$ cat internal.one NAME = "Internal" TYPE = RANGED BRIDGE = internal NETWORK_SIZE = C NETWORK_ADDRESS = 192.168.48.0 $ cat external.one NAME = "External" TYPE = RANGED BRIDGE = external NETWORK_SIZE = C NETWORK_ADDRESS = 192.168.100.0 $ onevnet create internal.one $ onevnet create external.one
To test the installation you can use the ttylinux image. Put it in a OpenNebula server path and create a VM using this template:
NAME=ttylinux MEMORY=64 CPU=1 VCPU=1 DISK=[ SOURCE=<PATH TO>/ttylinux.vhd, TARGET=hda ]
Now you should be able to create the VM using the standard OpenNebula CLI:
$ onevm create template.one
After a while the VM should be able to be seen from the Hyper-V management console:
Alternatively you can create and manage the VM's with Sunstone.