This blog demonstrates how to perform a scripted install of a XenServer inside a XenServer. This gives a flexibile virtual environment for development or experimenting with cloud setups.

The official way of automating XenServer installation, is to use PXE boot.

This guide assumes that you don’t have DHCP/PXE services running on your isolated network, so it will re-master the XenServer install media, thus, the only dependency is to be able to boot from an iso file.

Network setup

In this example, the physical XenServer host’s eth0 interface is connected to the corporate network, which is providing DNS and DHCP services. The corporate network is:

[[code]]czoyNjpcIjEwLjIxOS4wLjAvMjU1LjI1NS4xOTIuMA0KXCI7e1smKiZdfQ==[[/code]]

and the physical XenServer’s address is: 10.219.10.25

In order to separate the virtual hypervisor from these networks, and emulate a network environment without DHCP, a new network has been created by issuing the following command on the physical hypervisor:

[[code]]czozOTpcInhlIG5ldHdvcmstY3JlYXRlIG5hbWUtbGFiZWw9aXNvbGF0ZWQNClwiO3tbJiomXX0=[[/code]]

This will be a separated network. I also set up an Ubuntu VM with two network interfaces: one plugged to the corporate network, one to the newly created isolated network. This VM has shorewall and dnsmasq installed and configured, so that it will act as a default gateway, and as a DNS proxy for the isolated network. I will call this machine toolbox throughout this documentation. The network address for toolbox is 192.168.32.1, so the isolated network’s IP configuration is:

[[code]]czoyODpcIjE5Mi4xNjguMzIuMC8yNTUuMjU1LjI1NS4wDQpcIjt7WyYqJl19[[/code]]

I will install the Virtual Hypervisor, connected to the isolated network, with a static IP configuration:

[[code]]czoxMDU6XCIgICBhZGRyZXNzOiAxOTIuMTY4LjMyLjINCiAgIG5ldG1hc2s6IDI1NS4yNTUuMjU1LjANCmRlZmF1bHQgZ3c6IDE5Mi57WyYqJl19MTY4LjMyLjENCiAgICAgICBETlM6IDE5Mi4xNjguMzIuMQ0KXCI7e1smKiZdfQ==[[/code]]

Installing the Virtual Hypervisor

To install the virtual hypervisor, log in to the toolbox vm. First, check out the tools that will be used to remaster an official XenServer iso for scripted install.

[[code]]czoxMDY6XCJnaXQgY2xvbmUgaHR0cHM6Ly9naXRodWIuY29tL21hdGVsYWthdC92aXJ0dWFsLWh5cGVydmlzb3IuZ2l0DQpjZCB2aXJ7WyYqJl19dHVhbC1oeXBlcnZpc29yLw0KZ2l0IGNoZWNrb3V0IHYxLjANClwiO3tbJiomXX0=[[/code]]

Please note, that the v1.0 branch is used during this guide, to avoid the effect of further changes in master.

After this step, download the XenServer iso image as xenserver.iso.

Generate an answer file

The next step is to generate a XenServer answer file. This file contains the Virtual Hypervisor’s root user’s crendentials, the hostname, and the network configuration:

[[code]]czoxNjI6XCIuL3NjcmlwdHMvZ2VuZXJhdGVfYW5zd2VyZmlsZS5zaCBzdGF0aWMgXFwNCi1oIHZoMC5sYWIgXFwNCi1pIDE5Mi4xNjguM3tbJiomXX0yLjIgXFwNCi1tIDI1NS4yNTUuMjU1LjAgXFwNCi1nIDE5Mi4xNjguMzIuMSBcXA0KLXAgdmhwYXNzIFxcDQotbiAxOTIuMTY4LjMyLjEgJntbJiomXX1ndDsgdmgwLmFuc3dlcnMNClwiO3tbJiomXX0=[[/code]]

You could further customise the answer file vh0.answers. Please note, that the answer file contains a post install script:

[[code]]czo5MDpcIiZsdDtzY3JpcHQgc3RhZ2U9XCJmaWxlc3lzdGVtLXBvcHVsYXRlZFwiIHR5cGU9XCJ1cmxcIiZndDtmaWxlOi8vL3Bvc3RpbnN0e1smKiZdfS5zaCZsdDsvc2NyaXB0Jmd0Ow0KXCI7e1smKiZdfQ==[[/code]]

This file will be copied from the data directory. The purpose of this script is to install a firstboot script, firstboot.sh, which will be started only once. This firstboot script simply halts the machine. See data/firstboot.sh. This is required, so that the machine-installer script will know, that the installation is finished.

Create a Remastered ISO

The next step, is to inject the created answer file together with the post-installation and first-boot scripts to a remastered, custom XenServer iso file:

[[code]]czo3MDpcInNjcmlwdHMvY3JlYXRlX2N1c3RvbXhzX2lzby5zaCB4ZW5zZXJ2ZXIuaXNvIHZoMC5sYWIuaXNvIHZoMC5hbnN3ZXJzDQp7WyYqJl19XCI7e1smKiZdfQ==[[/code]]

The following output should appear on the screen:

[[code]]czoxODM6XCJFeHRyYWN0aW5nIHhlbnNlcnZlci5pc28gdG8gL3RtcC90bXAuUkc4cVJhc3ljSA0KUmVtYXN0ZXJpbmcgL3RtcC90bXB7WyYqJl19LlJHOHFSYXN5Y0gvaW5zdGFsbC5pbWcNClJlbW92aW5nIC90bXAvdG1wLlFIRGRwRHRkWUMNCkNyZWF0ZSBuZXcgaXNvOiB2aDAubHtbJiomXX1hYi5pc28NClJlbW92aW5nIC90bXAvdG1wLlJHOHFSYXN5Y0gNClwiO3tbJiomXX0=[[/code]]

Install the Virtual Hypervisor

The next step is to install an HVM virtual machine with the remastered ISO. This could be done by executing:

[[code]]czo4NDpcInNjcmlwdHMveHNfc3RhcnRfY3JlYXRlX3ZtX3dpdGhfY2Ryb20uc2ggdmgwLmxhYi5pc28gMTAuMjE5LjEwLjI1IGlzb2x7WyYqJl19YXRlZCB2aDAubGFiDQpcIjt7WyYqJl19[[/code]]

This script will ask for the physical hypervisor’s password, copy the iso file to the hypervisor, and block, until the installation is finished. You can use XenCenter to follow the events, or simply issue:

[[code]]czoxMjpcInhlIHZtLWxpc3QNClwiO3tbJiomXX0=[[/code]]

on the hypervisor. The VM’s label will show the state of the installation: – created (Step 1 of 3)
booted from iso (Step 2 of 3)
first boot (Step 3 of 3)

As the script finished, you should end up having a Virtual Hypervisor:

[[code]]czoxMjpcInhlIHZtLWxpc3QNClwiO3tbJiomXX0=[[/code]]

Should contain something like:

[[code]]czoxMjQ6XCJ1dWlkICggUk8pICAgICAgICAgICA6IDQyM2JmYTA4LWZjMjktYzc4My0yMWNjLTk5NzBiOGQwNjc2Zg0KICAgICBuYW17WyYqJl19ZS1sYWJlbCAoIFJXKTogdmgwLmxhYg0KICAgIHBvd2VyLXN0YXRlICggUk8pOiBoYWx0ZWQNClwiO3tbJiomXX0=[[/code]]

Start the Virtual Hypervisor

You can start the Virtual Hypervisor by logging in to the physical one, and issuing:

[[code]]czoyNDpcInhlIHZtLXN0YXJ0IHZtPXZoMC5sYWINClwiO3tbJiomXX0=[[/code]]

Log in

After you started the virtual hypervisor, use:

[[code]]czoyMzpcInNzaCByb290QDE5Mi4xNjguMzIuMg0KXCI7e1smKiZdfQ==[[/code]]

to log in. The password is vhpass, as specified during the answer file generation step.

Look at the Console

To get a console for the Virtual Hypervisor, first you have to find out the vncserver’s port:

[[code]]czoxMDM6XCJ4ZW5zdG9yZS1yZWFkIC9sb2NhbC9kb21haW4vJCh4ZSB2bS1saXN0IG5hbWUtbGFiZWw9dmgwLmxhYiBwYXJhbXM9ZG97WyYqJl19bS1pZCAtLW1pbmltYWwpL2NvbnNvbGUvdm5jLXBvcnQNClwiO3tbJiomXX0=[[/code]]

Subtract 5900 from the result, and use that with vncviewer from your workstation (In this example, the result was 5902):

[[code]]czo0NjpcInZuY3ZpZXdlciAtdmlhIHJvb3RAMTAuMjE5LjEwLjI1IGxvY2FsaG9zdDoyDQpcIjt7WyYqJl19[[/code]]

Where to go now?

You can now set up your OpenStack test setups in a fully virtualised environment, decoupled from all the corporate networking services, properly isolated.