Update on Hyper-V plugin work (2013-08-30):

A working plugin is available in a fork of Apache CloudStack on GitHub at https://github.com/lafferty/cloudstack/tree/hyperv_plugin

The plugin is implemented in two parts: Java classes that are loaded into the management server, and an Agent written in C# that runs on Hyper-V. Both portions can be compiled using open source tools.

The plugin has been tested with QuickCloud. QuickCloud provides services normally attached to SystemVMs. Proper system VM support should be available shortly.

Architecture Overview

Management Server / Agent Communications

Messages are sent from the management server to the agent using JSON over HTTP to avoid having to write the agent in Java. Other agents use the CloudStack Message bus for communicating between the management server and agent. However, this forces the agent to be written in Java. Specifically, the client for the CloudStack message bus relies on the Java NIO API, which is peculiar to Java. Porting the client to even similar languages such as C# is difficult. In contrast, JSON over HTTP passes kernel commands as JSON in the body of an HTTP POST, which removes the dependency on Java's NIO. HTTP stacks themselves are easy to come by regardless of the language or platform.

JSON over HTTP is RPC-like and not RESTful. Each destination URI corresponds to a command (an action) and not the resource being manipulated.

Using an RPC approach avoids undertaking design work to translate incoming kernel commands to a suitable RESTful equivalent. This is because the management server commands look more like method calls than manipulates the cloud using operations and not resource property changes. Therefore, JSON over HTTP minimises the coding effort by avoiding RPC to RESTful translation.

Agent Implementation

The agent is written in C# to simplify coding. C# libraries can directly interact with WMI APIs exposed by Hyper-V. Code generation tools use these libraries to generate wrappers that expose the API as C# classes. In contrast, Java makes no provision for WMI. With Java API calls would probably have to be written in terms of SQL-like queries. Therefore, a C# agent offers easier access to Hyper-V APIs.

The agent is written to be executed as a Windows Service. The agent exposes special hooks that allow the Windows Service Control Manager (SCM) to execute the agent as if it were a daemon.

The agent is configuration is delivered over HTTP after startup. An agent must be told about its zone, pod, and cluster location before it can join itself to the cloud. For example, the KVM server component uses SSH to launch the remote agent with configuration data passed as command line parameters. Therefore, no additional daemons are required to configure the Hyper-V agent.

The agent can be compiled in Mono. Mono is an OpenSource equivalent of the .NET Framwork. The ability to compile with Mono decouples the agent from Microsoft's proprietary development environment.

The remote agent hosts its own HTTP stack to avoid any dependency of Microsoft’s Internet Information Services (IIS) web server.

Building the Agent

Source plugin is available in a fork of Apache CloudStack on GitHub (https://github.com/lafferty/cloudstack/tree/hyperv_plugin)

Java code for the plugin is built by default. E.g.

mvn clean install

C# code for the plugin is built using the hyperv-agent provide. E.g.

mvn clean install -P hyperv-agent

If you do not have Visual Studio 2012 SP1 or later, use Mono. Install details at http://dlafferty.blogspot.com/2013/08/building-your-microsoft-solution-with.html

To trigger the C#-based unit tests, use -DskipTests=false. E.g.

mvn clean install -P hyperv-agent -DskipTests=false

To trigger the Java-based functional tests, use -DskipFunctionalTests=false. E.g.

mvn clean install -P hyperv-agent -DskipFunctionalTests=false

The functional tests require you build on the parent partition (aka Dom0) of a Hyper-V 2012 hypervisor. Otherwise, you will not have access to the necessary Hyper-V APIs.

In addition, you will have to customise settings in the agent.properties file in the conf folder of the plugin’s root. Changes the samples properties in the default file to match your system. E.g.

Administrator@cc-svr10 ~/github/cifs/cloudstack/plugins/hypervisors/hyperv
$ more conf/agent.properties
#Storage
#Tue Feb 12 10:08:17 GMT 2013
local.storage.path=E\:\\Disks
Disks
cpus=8
resource=com.cloud.hypervisor.hyperv.resource.HypervResource
type=Routing
ipaddress=10.1.1.1
private.mac.address=DEADBEEFC0DE

If localhost is used, mac address is blank.
#private.ip.address=127.0.0.1
#private.mac.address=
local.storage.uuid=5fe2bad3-d785-394e-9949-89786b8a63d2
capabilities=hvm
cpuspeed=2130
port=8250
hyperv.python.module.script=cloudstackcmds.py
memory=34359738368
host=hypervfun.citrite.net
pod=1
gateway.ip.address=10.1.1.1
guid=16f85622-4508-415e-b13a-49a39bb14e4d
#guid=generate_from_private.ip.address
cluster=2
zone=1
local.secondary.storage.path=c\:
Secondary
workers=5
agent.executable=C\:\\cygwin\\home\\Administrator\\github\\cshv3\\plugins\\hypervisors\\hyperv\\DotNET\\ServerResource\\AgentShell\\bin\\Debug
AgentShell.exe
private.ip.netmask=255.255.240.0
HypervResource.id=5
hyperv.python.module.dir=C\:\\cygwin\\home\\Administrator\\github\\cshv3\\plugins\\hypervisors\\hyperv\\scripts\\hyperv
DefaultVirtualDiskFolder=E\:\\Disks
TestCoreCount=8
TestCoreMhz=2133
TestMemoryMb=34350288896
TestDom0MinMemoryMb=21474836488

System VMs

The plugin uses QuickCloud instead of System VMs. QuickCloud runs services as daemons on the management instead of on a separate VM created by CloudStack. For Hyper-V, the QuickCloud secondary storage service is used. Console access is available nor is a virtual router available.

This will soon change: ISO attach and the ability to pass information to a guest VM will enable full support for System VM services.

For Secondary Storage, provide a CIFS URL. See https://cwiki.apache.org/confluence/display/CLOUDSTACK/CIFS+Support NFS is not supported at this point, because an NFS client is not available on all Hyper-V 2012 SKUs.

IP Dependencies

The C# source code and configuration files that are input for code generate should be contain the Apache header (http://www.apache.org/legal/src-headers.html#headers) to indicate that Apache CloudStack holds the copyright.

Besides some referenced code snippets from stackoverflow.com, the only third party input are binaries. These are from the Microsoft .NET Framework 4.5 and NuGet packages.

The background to NuGet is that it is akin to a Maven repo, but each packages has a corresponding web page that includes details of the license for use of the package.

NuGet packages are downloaded at build time. These packages provide logging, JSON serialisation, AWS S3 access, a decompression library and a light weight HTTP stack.

Licenses for the NuGet packages are enumerated below. I do not have the .NET Framework 4.5 EULA to hand.

Apache License, Version 2.0 (http://logging.apache.org/log4net/license.html):

AWS .NET SDK (http://aws.amazon.com/sdkfornet/faqs/#13)
Log4net 2.0.0 (http://nuget.org/packages/log4net/)

The MIT License (MIT):

Newtonsoft.Json 4.5.11 http://json.codeplex.com/license

Microsoft Public License (http://en.wikipedia.org/wiki/Shared_source#Microsoft_Public_License_.28Ms-PL.29):

DotNetZip 1.9.1.8 http://dotnetzip.codeplex.com/license

MICROSOFT ASP.NET MODEL VIEW CONTROLLER 4 EULA (http://www.microsoft.com/web/webpi/eula/mvc_4_eula_enu.htm

Microsoft ASP.NET Web API Core Libraries 4.0.20710.0 http://nuget.org/packages/Microsoft.AspNet.WebApi.Core/4.0.20710.0 NuGet id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0"
Microsoft ASP.NET Web API Client Libraries 4.0.20710.0 http://nuget.org/packages/Microsoft.AspNet.WebApi.Client/4.0.20710.0 NuGet id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0"
Microsoft .NET Framework 4 HTTP Client Libraries 2.0.20710.0 http://nuget.org/packages/Microsoft.Net.Http/2.0.20710.0 NuGet id="Microsoft.Net.Http" version="2.0.20710.0"
Microsoft ASP.NET Web API Self Host 4.0.20918.0 http://nuget.org/packages/Microsoft.AspNet.WebApi.SelfHost/4.0.20918.0 NuGet id="Microsoft.AspNet.WebApi.SelfHost" version="4.0.20918.0"

  • No labels