CloudStack uses virtual appliances as part of its orchestration. For example, it uses virtual routers for SDN, secondary storage vm for snapshots, templates etc. All these service appliances are created off a template called a systemvm template in CloudStack’s terminologies. This template appliance is patched to create secondary storage vm, console proxy vm or router vm. There was an old way of building systemvms in patches/systemvm/debian/buildsystemvm.sh which is no longer maintained and we wanted to have a way for hackers to just build systemvms on their own box.
Build your own systemvm template (BYO SystemVMs) allows anyone to customize and build their own systemvm template. SystemVM template is an appliance which gets patched by CloudStack's systemvm.iso on a host before it becomes one of the service VMs: ssvm, cpvm or rvm. To make it possible for anyone to BYO systemvm template, we researched and found that it was possible for everyone to install VirtualBox, create and setup a VM, install all the tools and export it. To automate the process we've used veewee, an opensource appliance building tool, that automates the process of appliance building on VirtualBox and we use some tools to export the disk image to various formats.
For latest update, follow the README and build script at:
https://github.com/apache/cloudstack/tree/master/tools/appliance
Veewee [3] uses some definition with which it would automatically download and install a Linux distro on VirtualBox. Since the previous systemvm templates provided by Citrix was based on Debian, we created veewee definitions that are based on Debian. The definitions are located in: tools/appliance/definitions/*
We implement two definitions;
systemvmtemplate: Based on Debian 7.0 Wheezy i386
systemvmtemplate64: Based on Debian 7.0 Wheezy x86_64
The specs for the systemvm templates are as follows:
Disk size: 2000MB
OS Type: Debian i386/amd64 Linux 3.2.x
RAM: As allocated by the host
Disk formats: qcow2 (KVM), vhd (Xen), vhd (HyperV), ova (VMWare)
The assumption is if anyone changes the base distro, they will also need to for the scripts as per their needs and Linux distro: patches/systemvm/debian/
There is a readme file: tools/appliance/README.md
Brief description is that we ask veewee to build a template from its definition, veewee reads a definitions.rb file, downloads an ISO, creates a VM on VirtualBox and using preseed.cfg automatically installs and configures a basic Linux box. Next, it would copy and run bunch of postinstallation scripts which configures a number of packages to be installed, copies scripts (like cloud-early-config) and cleans up. The VM is shutdown and the disk image is exported [1] [2] to various disk formats such as qcow2, vhd and ova.
Testing is difficult because we don't have any test suite to test systemvm templates. Since the new/default systemvm template definition is based on Debian (like the old ones) and we ported all the build steps from the old buildsystemvmtemplate.sh script, we assume that there should be minimal issues.
Testing can be done by running various tests in basic and advance zone, testing ssvm, cpvm and rvm. So, far Marcus and Rohit have successfully tested new systemvm templates for KVM and Xen.
The following daily jenkins build job [2] creates systemvms from master branch:
https://builds.cloudstack.org/view/master/job/build-master-systemvm/
To use these systemvm templates, download the template and use cloud-install-sys-tmplt to preseed systemvm templates as documented on the installation docs [4], or extract and copy the template to appropriate secondary storage path for ex. for Xen: template/tmpl/1/1/
The buildjob would create xen, kvm and hyperv appliance. For VMWare there is a non-automated workaround:
1. Download the vmdk
2. Using VMWare Fusion, create a VM with 256MB Ram but don't start the VM
3. Using ovftool, export VMWare compatible ova:
/Applications/VMware\ Fusion.app/Contents/Library/VMware\ OVF\ Tool/ovftool --compress=9 ~/Documents/Virtual\ Machines.localized/systemvmtemplate-vmware.vmwarevm/systemvmtemplate-vmware.vmx /Bhaisaab/systemvmtemplate-vmware.ova
4. If necessary install vmware-tools, else the opensource alternative open-vm-tools is preinstalled.
1. Conversion of raw disk image to Xen VHD: http://blogs.citrix.com/2012/10/04/convert-a-raw-image-to-xenserver-vhd/
2. Setting up a jenkins job for automating systemvm template building: http://rohit.yadav.xyz/logs/building-systemvms/
3. Veewee: https://github.com/jedi4ever/veewee/
4. Preparing/Preseeding systemvm template: http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.0.0-incubating/html/Installation_Guide/management-server-install-flow.html#prepare-system-vm-template