Prerequisites

  • XCP/Xenserver

 

Creating a template

The following is how to create new custom templates based on existing templates in Xen Cloud Platform. 

1. Get the template UUID that we want to use as our base. As usual just copy and paste the line in yellow into a root terminal on your XCP host.

xe template-list | grep -B1 name-label | awk -F: '{print $2}'

The output should look like this..

 

 688c625b-93b8-8e66-62e5-4542eca1e597

 Red Hat Enterprise Linux 6 (32-bit)

 

 c4e28252-030f-524a-c5d8-7da85df3ccf5

Windows Server 2003 (64-bit)

......

 

Scroll through the list and find the template you want to clone then copy and past it's UUID number ie.  688c625b-93b8-8e66-62e5-4542eca1e597. Choose a new name for your custom template and enter the following line with the UUID of the template you want to clone and the name you want it to have.

 

xe vm-clone uuid=<UUID> new-name-label="<NAME>"
xe template-param-set uuid=<UUID> other-config:install-methods=http,ftp,nfs other-config:default_template=true

Now you should have a new template of your own that you can customize. More after the jump.

 

Modifying a template

You can set template parameters using the following syntax. 

 

xe template-param-set uuid=<UUID> other-config:default_template=false
xe template-param-set uuid=<UUID> memory-static-max=1024MiB

 

To get a list of parameters that you can change on your template 

xe template-param-list uuid=<UUID> 

 

Deleting a template

To delete a template you need to set default_template to false first, then you can delete it. This will free any Virtual Disk Interfaces that are associated with it as well.

xe template-param-set other-config:default_template=false uuid=<UUID>
xe template-uninstall template-uuid=<UUID>

 

You could also just use my shell script for creating templates as well mktemplate.sh. Future versions of the script will ask for values associated with common parameters with defaults.