Deploy and reconfigure Instance from Template

This tutorial details how to deploy a virtual machine from a virtual machine template in the ITS Private Cloud and reconfigure the operating system (hostname, domain, gateway, dns, etc.) using the VSS CLI. It assumes you already have set up a VSS account with access to the REST API, a virtual machine with operating system and VMware Tools installed which will be marked as template.

If you do not have a virtual machine with operating system installed, please refer to Deploying a Development Environment.

As a best practice and to speed up deployment, a small sized virtual machine is recommended (1vCPU, 1GB memory, 1NIC and 1x10GB disk). A virtual machine template should hold operating system installation and configuration and resulting virtual machines will be modified as required.

Virtual Machine Template

Virtual Machine Templates are useful if you create a virtual machine that you want to clone frequently, offering a more secure way of preserving a virtual machine configuration, since they are more difficult to alter than ordinary virtual machine. Templates are commonly referred as Master Copy of certain virtual machine, thus any virtual machine can be marked as template.

Virtual machines with large disks will take longer to deploy.

Optional. In order to make a virtual machine a template, first obtain the moref of the virtual machine:

vss-cli compute vm ls -f name=Front moref name folder.path cpu_count memory_gb power_state ip_address ------- ---------------- ------------------------- ----------- ----------- ------------- ------------ vm-2182 2004T-Frontend-1 VSS > Development > Dev03 1 1 poweredOff

Save the moref in MOREF environment variable.

Then update the template state by running vss-cli compute vm set <name-or-vm_id> template --on:

vss-cli --wait compute vm set $MOREF template --on # or vss-cli --wait compute vm set Front template --on

Once the request has been processed, verify the template state:

vss-cli compute vm get Front template IsTemplate : True

Launch Instance

Launching an instance from-template is simpler than shell since the from-template command carbon copies the specs with just name and --description/-d to provide. However to make this example more realistic, a different logical folder is provided, otherwise the from-template command will use the source virtual machine template folder as default.

Run vss-cli compute vm mk from-template --help to obtain the list of arguments and options required:

Network

Run vss-cli compute net ls to list available network segments to your account. You must have at least VL-1584-VSS-PUBLIC which is the VSS public network.

Save dvportgroup-11052 in NET environment variable:

By default, the network adapter will use vmxnet3 which provides ideal performance, however a few legacy operating systems does not have the drivers. In such case, you can specify which adapter type between: e1000e*, e1000, vmxnet2 or vmxnet3. To do so, append the adapter type to the network adapter network as follows:

Folder

Logical folders can be listed by running vss-cli compute folder ls. Select the target moref folder to store the virtual machine on:

Set the FOLDER environment variable to the target folder (the folder moref may vary):

Before proceeding to deploy the virtual machine, a guest operating system customization specification needs to be created.

Customization Spec

Customizing a guest operating system is helpful to prevent conflicts if virtual machines are identical after deployed. To customize the guest operating system, VMware Tools and Perl must be installed in the source virtual machine.

The vss-cli compute vm mk from-template command provides the option -p/--custom-spec to pass the guest os customization spec, which is structured as follows:

Since we are running on a DHCP-enabled network, we will just update the hostname and domain. The customization spec added will be:

Serializing the above JSON structure would be something like:

Deployment

At this point, we have all requirements to run vss-cli compute vm mk from-template command to submit a deployment request. For this example, the request is made for 2GB of memory, 2 vCPU, 2x40GB disks and to reconfigure the hostname and domain.

Wait a few minutes until the virtual machine is deployed.

Wait a few minutes until the virtual machine is deployed.

Access Virtual Machine

Since we added the --power-on option, the virtual machine should have been powered on right after the Guest Operating System Customization task completed.

In a few minutes the virtual machine will show the hostname and ip configuration by running vss-cli compute vm get <name-or-vm-id> guest:

The Guest Host Name shows that the hostname has been changed, and now you will be able to access via either ssh or the virtual machine console:

University of Toronto - Since 1827