Introduction

vRealize Automation relies on a blueprint concept for offering catalog services. This means that the service is widely defined in the catalog and users just request the pre-defined services. Although there’s options for parametrization and deployment type (template, unattended installation …) some users still might want to do their custom installation of a VM. To do this they need a way to attach an ISO to a VM provisioned by vRA as well as there needs to be a method to upload an ISO of their choice. Both is not available out-of-the-box in vRA but can be implemented with small customizations.

 

This article describes how to

  • Leverage a central ISO storage
  • Provide upload web page for ISOs
  • Integrate mount and unmount day-2 operations
  • Create example blueprint with day-2 operations entitled

 

image002.png

 

 

Disclaimer

This article just gives an example and starting point on how this requirement can be achieved. It’s not intended to provide a “water-proof” solution nor it leverages all capabilities PHP technology provides.

 

 

Preparation of central ISO storage

 

vSphere typically uses a central shared datastore as ISO repository. This can be of any supported type like iSCSI, Fibre Channel or NFS. For this use case the best way to go is leveraging an NFS share. While mounting and ISO browsing would work for any datastore, it’s much easier to upload files to a file service rather than block storage.

Therefor as first step you should provide an NFS share which has write permissions from the web server we will discuss later and appropriate permissions from the ESX hosts.

This NFS share must to be added as datastore to all ESX hosts where VMs with mounted ISOs should be used.

 

At this point I won’t go into details on how this is done. Please refer to vSphere documentation.

 

  image003.png

 

 

 

Create upload server for ISOs

 

Now we need to set up an upload server which hosts the web page where image upload can be invoked by the user. vRealize Automation itself does not provide this capability. Also, it’s hard to use vRealize Orchestrator workflows directly for this task as Orchestrator expects the source files to be hosted on the Orchestrator VM itself rather than on a directory on the client PC.

 

The easiest way to create an upload server is by leveraging a linux web server for this task. In this example I am using a CentOS 7 based VM, but the procedure in general should work for any linux running apache and PHP.

 

Setting up web server on linux

 

The basic procedure for the upload server setup is described here: https://www.w3schools.com/php/php_file_upload.asp

 

In this example slight modifications are used. The configuration below e.g. checks if files have been uploaded before and only accepts iso files.

 

Following steps must be performed:

 

Install apache on linux

 

yum install httpd

 

Make sure apache starts on VM start

 

chkconfig httpd on

 

Install PHP (might be more packages than actually needed)

 

yum install php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml

 

Modify /etc/php.ini

 

The values are self-explaining and can be modified to individual needs.

 

memory_limit = 64M

upload_max_filesize = 8000M

post_max_size = 8000M

file_uploads = On

 

Create file /var/www/html/index.html

 

<!DOCTYPE html>

<html>

<body>

 

<title>VMware vRealize Automation ISO Upload</title>

<h1>VMware vRealize Automation ISO Upload</h1>

 

<form action="upload.php" method="post" enctype="multipart/form-data">

    Select ISO image to upload:

    <input type="file" name="fileToUpload" id="fileToUpload">

    <input type="submit" value="Upload Image" name="submit">

</form>

<style>

body {

    background-color: #3989C7;

    background-repeat: no-repeat;

    background-position: center top;

    color: white;

    font-size: 150%;

}

</style>

 

Create file /var/www/html/upload.php

 

<?php

$target_dir = "uploads/";

$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

$uploadOk = 1;

$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

// Check if file already exists

if (file_exists($target_file)) {

    echo "Sorry, file already exists.";

    $uploadOk = 0;

}

// Allow certain file formats

if($imageFileType != "iso") {

    echo "Sorry, only ISO files are allowed.";

    $uploadOk = 0;

}

// Check if $uploadOk is set to 0 by an error

if ($uploadOk == 0) {

    echo "Sorry, your file was not uploaded.";

// if everything is ok, try to upload file

} else {

    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {

        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";

    } else {

        echo "Sorry, there was an error uploading your file.";

    }

}

?>

 

 

Create uploads folder and set proper permissions

 

mkdir /var/www/html/uploads

chown apache:apache /var/www/html/uploads

 

 

Mount ISO NFS share to uploads folder

 

mount -t nfs <server IP or hostname>:/<path-to-iso-folder> /var/www/html/uploads

 

 

Restart apache services after changes

 

service httpd restart

 

 

After all required steps have been performed, the upload page as below screenshot shows should appear when pointing your browser to the web server.

 

  image004.png

 

 

When a local file has been selected for upload it will first be loaded into the linux OS memory and then stored in the uploads folder on the NFS server. To optimize performance, it might be required to tune the memory_limit parameter in /etc/php.ini.

 

 

 

Create Day-2 operations

 

The actual mount and unmount tasks are performed by related Orchestrator workflows to be invoked by day-2 operations.

As pre-requisite in Orchestrator the vCenter plugin must be configured properly allowing the workflows to scan the datastores.

 

Following steps must be done to get the workflows configured.

 

Import Orchestrator package

 

Import Orchestrator package com.vmware.custom.isomount.package (attached to this blog)

 

Modify workflow “Mount ISO”

 

Edit Workflow and select the NFS datastore added previously through vCenter plugin.

 

  image005.png

 

Set datastorepath attribute. If root folder of NFS share is used, insert the datastore name into the field.

 

  image006.png

 

Save workflow

 

Add custom resources in vRA

 

Go to Design --> XaaS --> Resource Actions and create a new one.

 

Select “Mount ISO” workflow from proper folder.

image007.png

 

 

Keep defaults in next page

 

image008.png

 

 

In next page remove description and keep other values.

 

image009.png

 

 

In Form tab drag a new field of type “Link” from left to right and place it above the “select ISO file to mount” field.

 

  image010.png

 

Modify field constraints to define Value --> Constant --> <URL of the web server>

Click “Apply” and “Finish”

 

Publish the new resource action

 

Do same steps for the Unmount ISO resource action, however no modification of form page is required.

 

 

Create example blueprint

 

The above-mentioned day-2 operations for mount and unmount can be used for any entitled blueprint. Depending on the VM configuration however it might be required to modify the workflows as CD-ROMs to add ISO reference might be identified differently (different identifier numbers or types) depending on VM configuration.

In this example we use an empty VM blueprint which expects VM installation to happen based on the ISO mounted.

 

Create empty VM blueprint

 

Create new blueprint in vRA through design tab.

 

image015.png

 

Specify “create” action and “BasicVmWorkflow” in build information tab.

 

image016.png

 

Specify desired VM parameters and in specific disk size. Storage maximum must be at least the desired disk size.

 

image017.png

 

Add disk with proper size on Storage tab

 

image018.png

 

 

Specify custom property with operating system type

 

image019.png

 

In vSphere it’s required to specify the OS type of a VM during VM creation. To do this you have to set the mentioned custom property in vRA. Find a list of guest os identifiers here: http://www.fatpacket.com/blog/2016/12/vm-guestos-identifiers/

 

In this example we are using a Windows 2012 server guest. For production use of this configuration it might be required to define an OS selection for the user on request page or choose a generic OS type and hard code it into the blueprint.

 

As last step you need to publish the blueprint and create a proper entitlement.

 

image020.png

 

It’s recommended to use VMRC console for full VM installation purpose. VMRC is much easier to handle for this use case compared to web remote console. This especially translates to better keyboard mapping for non-US keyboards.

 

 

Final test

 

After proper entitlement a new catalog item should appear in the catalog of the entitled user. On request the virtual machine is provisioned. When the provisioning process has finished, the defined day-2 operations are available on the VM object.

 

image021.png

 

The “mount ISO” operation provides a link to the upload page and shows all available ISOs in a dropdown field. On selection of an ISO and click on submit button, the iso will be mounted automatically to the VM.

 

image022.png

 

Users must wait until the mount process is finished until they can carry out other day-2 operations. After that they can use the VMRC day-2 operation to manage and install the VM based on the ISO. If VMRC is not installed on the client, users can use the link that is presented to download VMRC and install it. The VM must be power cycled to start the ISO boot process.

 

image023.png