Setting Disk and Memory properties of VMs using vRA custom forms – Part 2


As outlined in Part 1, my customer asked to be able to remove or reconfigure the basic disks table that vRA provides on custom forms, such that users could change the entered disk sizes without having to see or change the other disk related properties. This scenerio was for a SQL Server catalog item, where the underlying vSphere template was shared between a Windows catalog item and a SQL Server catalog item. This meant it was not possible to specify the additional disks needed for SQL within the vSphere template. Also company policy was to allow different sizes of SQL Servers to be provisioned, there was no enforced standard disk sizes only a standard disk layout. This meant the disk sizes needed to be specified as part of the request, and could vary for all drives other than the standard C and D drives provided by the template.

By default the disk information is displayed in a Data Grid parameter on the custom form. Whilst it is possible to change the visibility of each column within the table, when a user wants to edit a disk entry within the table vRA displays a form showing all disk properties.

This extra form was the part that my customer did not like, since the user is presented with a number of other properties which they may find confusing and could potentially alter the values for.

My customer only wanted to be able to change the Capacity value for the disks, every other value could remain unchanged and was known in advance. Unfortunately the Data Grid used on the custom form does not allow the individual properties for a disk to be configured separately. It is only possible to change the source for the values at the overall Data Grid level, i.e. all disks are treated as a single entity on the custom form.

Disk Properties Solution

Looking at the Data Grid configuration on the custom form there is a clue as to the solution. Expanding the Default Value section on the Values tab there is a csv section shown, with a comma separated list of disk properties. The first line contains the headers for the grid, followed by a separate line for each disk that is listed in the grid.

Therefore if all the disks required for a request can be listed in this format, it should also be possible to update the values using a vRO action to change just the capacity value.

Generating the disk properties CSV data

In order to generate the CSV data needed to create all disks required for the VM the IaaS blueprint in vRA was updated to include all of the disks required for the SQL server. The capacity of each disk was set to the default value that would be used within the request form. Once the disks were added the custom form automatically populated the csv value for the disks Data Grid, allowing the values to be copied into the vRO action.

vRO Action configuration

In vRO the equivalent parameter type to a Data Grid is an Array of Properties. Each disk entry in the grid is a Properties object where the name of the key is the column heading, and the key value is the value listed in that column.

A new vRO action named setDiskCapacities was created, and the return type set to Array/Properties. Input parameters were added for each of the disks whose capacity users would be able to set at request time, each parameter was set to type integer.

The code needed for the action was fairly simple for this scenario, it just needed to take the input parameter values and enter them into the correct place within the individual disk properties. The format used to declare the disk properties needed to be slightly different compared to the csv section on the custom form, since Properties objects do not use a comma separated format. Instead the format column heading:column value was used to specify the values in a json style format.

var disks = new Array();
 disks.push({"is_clone":true,"initial_location":"E","volumeId":0,"id":"1550828485000","label":"Hard disk 1","custom_properties":"","userCreated":false,"storage_reservation_policy":"","capacity":eDriveCapacity});
 disks.push({"is_clone":true,"initial_location":"F","volumeId":0,"id":"1563358141307","label":"Hard disk 2","custom_properties":"","userCreated":false,"storage_reservation_policy":"","capacity":fDriveCapacity});
return disks;

All disks used by the blueprint must also be included in the vRO action, even if their values will not change. If they are omitted the custom form will not load and provisioning would fail.

The final action looks like the screenshot below:

Custom Form configuration

The next step was to add new Integer input fields onto the custom form for each of the drive sizes users could change. Each parameter was configured with a default, minimum and maximum value inline with the IaaS blueprint limits.

Finally the disks Data Grid was configured to use an external source for its value, and the inputs for the action mapped to the fields added to the custom form for the individual disk sizes.

When the form loads the vRO action is executed, and the disks Data Grid populated using the default values for the disk capacities.

When the user changes any of the capacity values the Data Grid is updated to show the new capacity values.

Once tested the disks Data Grid visibility setting can be configured as No, to hide the table from the end users, leaving just the new input fields. vRA will automatically populate the disks values and provision the VM with the requested disks, including the capacity.

The values contained within the disk properties in the vRO action which have been hardcoded can also be replaced with input parameters in the same way the capacity values are updated. It is also possible to loop through the entries in the array and update other values, such as the reservation policy. Since it is an array of JSON objects each value can be accessed by evaluating the correct entry in the array and then using the dot notation to access the correct property e.g. disks[1].capacity to retrieve the capacity value of the second disk in the array.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close