Category: Xenserver

Scripts, notes, builds and tweaks.


Recovery of VMs to new CloudStack instance

This blog post was originally posted on the ShapeBlue website:

We recently came across a very unusual issue where a client had a major security breach on their network. As well as lots of other damage their CloudStack infrastructure was maliciously damaged beyond recovery. Luckily the hackers hadn’t manage to damage the backend XenServer hypervisors so they were quite happily still running user VMs and Virtual Routers, just not under CloudStack control. Read More

CloudStackDevOps and AutomationXenserver

Virtualisation user group talk 26/Feb – CloudStack, automated builds and Ansible

I recently did a talk on CloudStack / CloudPlatform, zero touch VMware ESXi / Citrix XenServer builds and Ansible automation at the Glasgow Virtualisation User Group meeting. Great day, lots of useful information from end users and vendors, as well as some interesting cloud and virtualisation discussions. Thanks to Mike, Brendon and Gavin for the invite, was good to catch up.

Slide deck up on Slideshare:

CloudStackDevOps and AutomationXenserver

Cloudmonkey Ansible playbook

Cloudmonkey is distributed with Apache CloudStack, and allows for command line configuration of CloudStack resources – i.e. configuration of zones, networks, pods, clusters as well as adding hypervisors, primary and secondary storage.

Using an Ansible playbook to run CloudMonkey isn’t necessarily a good idea – writing a proper shell script with it’s own variable input will allow for much more dynamic configuration – Ansible doesn’t offer proper scripting capabilities after all.

Anyway, the following playbook will configure a CloudStack zone, adding pod, cluster, hypervisors and storage.

Pre-reqs as follows:
Read More

CloudStackDevOps and AutomationXenserver

Apache CloudStack Ansible playbook


As with any Ansible playbook the CloudStack playbook is fairly self explanatory and self-documenting. In short the following will install Apache CloudStack version 4.3 or 4.4 with all required components as well as CloudMonkey for later configuration.

The playbook is written for CentOS base OS for all roles, with CloudStack using XenServer hypervisors and NFS storage.

The playbook relies on tags to separate the various tasks and roles, these are as follows:
Read More


Host config file export VBA script

Quick followup on the previous build script posts. In short the following will write host specific config files based on spreadsheet data, writing to files based on hostname in column 1 – in the following example “xs62cn1.cfg”.  

So, in short, a spreadsheet with the following entries:


will result in a new config file xs62cn1.cfg with the following entries:


VBA script:

Sub CreateHostConfigFiles()
'Exports spreadsheet data to config files

Dim intCol, intRow, arrHeaders(), intMaxcols, strOutputbuffer, objFSO, strFilename, arrFilename, objFile
    intRow = 2
    intCol = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Find headings
    ReDim arrHeaders(0)
    While Cells(1, intCol) <> ""
        ReDim Preserve arrHeaders(UBound(arrHeaders) + 1)
        arrHeaders(intCol - 1) = Cells(1, intCol)
        intCol = intCol + 1
    intCol = intCol - 1
    intMaxcols = intCol
    'Write config
    While Cells(intRow, 1) <> ""
        strFilename = Left(Cells(intRow, 1), InStr(Cells(intRow, 1), ".") - 1) & ".cfg"
        Set objFile = objFSO.CreateTextFile(strFilename, True)
        For intCol = 1 To intMaxcols
            strOutputbuffer = strOutputbuffer & arrHeaders(intCol - 1) & "=" & Chr(34) & Cells(intRow, intCol) & Chr(34) & ";" & Chr(10)
        objFile.write strOutputbuffer
        strOutputbuffer = ""
        intRow = intRow + 1
MsgBox "All done"
End Sub

Citrix Xenserver 6.2 zero touch build scripts


Scripted builds for Xenserver 6.2 is outlined in Xenserver build scripts run in the bash shell so are a bit more flexible than in ESXi. The following scripts allow for host specific dynamic zero touch builds – mainly for larger environments but can be used for any number of hosts.

All files discussed in this post can be found on

PXE boot process

The PXE boot process for Xenserver builds is as follows:

  1. Host is PXE booted from pxelinux.cfg menu, each host specific menu entry specifies host specific  XML answer file.
  2. Host specific XML answer file specifies hostname and post build script.
  3. Post build script preloads actual build script, patches and drivers as well as host specific configuration file.
  4. Upon reboot build script configures host.

I.e. for each host we require a XML answer file and a host configuration file.

The menu config for Xenserver 6.2 is as follows:

LABEL XS62CN1 Xen 6.2
kernel mboot.c32
append xenserver62/xen.gz dom0_max_vcpus=1-2 dom0_mem=752M,max:752M \
com1=115200,8n1 console=com1,vga --- xenserver62/vmlinuz xencons=hvc \
console=hvc0 console=tty0 answerfile= \
-answerfile install --- xenserver62/install.img

Answer file

The answer file specifies (see install guide for all options):

  • Install location
  • Keyboard mapping
  • Install file location
  • Root password
  • Post install script
  • NIC used during installation
  • Timezone
  • Hostname

Read More