TIPS & TRICKS (New)
New items at the bottom of page
16) vRealize Automation 8.x Dynamic VM Placement using Resource Pools
Posted: 29th Mar 2021
Recently I was working with a customer and a requirement came up to allow the Provisioning of a VM into a specific Resource pool.
As I thought about it, targeting one resource pool would be fairly easy but extending this requirement a bit further I thought it would make sense to add the ability in the request form to be able to select the resource pool from a drop-down selection at provisioning time of where the VM needs to be deployed.
I therefore started looking into it and managed to create something that works, the process is listed below:
A) In Cloud Zone under Compute tag the resource pools that will be used for the selection
in the drop-down, Examples shown below:
Note:
Use the Tag Env:<res-pool-name>.
B) In the Blueprint, under the Inputs tab add the following Blueprint input:
C) In the Blueprint, under the Code tab the following will be added automatically:
Env:
type: string
enum:
- 'Env:Senthil-vc65-respool'
- 'Env:Irfan-vc65-respool'
D) The complete Blueprint code would look like the example shown below:
E) Version the Blueprint and Deploy it.
F) When deploying the Blueprint the following section is added for user input:
G) There is a drop-down to select the Resource Pool that the VM is to be provisioned in.
H) Select the Resource Pool required and DEPLOY the Blueprint.
I) I selected Env:Irfan-vc65-respool and in vCenter the VM was deployed in the correct
resource pool as shown below:
17) vRealize Automation 8.x Dynamically add Tags to Virtual Machines during Provisioning
Posted: 01st Apr 2021
Recently while working with a customer a requirement came up to Dynamically add a Tag to the Virtual Machine while Provisioning.
Thinking about it, there are two ways of achieving this as listed below:
a) Add a Tag in the Project under Provisioning.
b) Add an input to the Request form to capture the Tag and add it to the VM using a vRO
workflow.
I therefore started looking into it and managed to create the following two methods:
Method 1: Add a Tag in the Project under Provisioning
A) In Cloud Assembly under Projects, Create/Edit the Project and under the Provisioning
tab add the Tag required as shown below:
Note:
Created the Tag Silver-Backup-Policy.
B) Deploy a Blueprint, from the Project in A) above.
C) In vCenter after the VM is provisioned, the Tag Silver-Backup-Policy will also be
created as shown below:
B) The complete script code is listed below:
var tags = inputProperties.tags || new Properties();
var customProperties = inputProperties.customProperties || new Properties();
//Use workflow metadata to set tags and properties
var userName = System.getContext().getParameter("__metadata_userName");
var ProjectCode = customProperties.ProjectCode;
tags.put("UserName",userName);
tags.put("ProjectCode",ProjectCode);
customProperties.put("UserName",userName);
customProperties.put("ProjectCode",ProjectCode);
C) In Cloud Assembly, Under Extensibility – Subscriptions create a new Subscription
called Custom Tags with the following details:
D) In the Blueprint, under the Inputs tab add the following Blueprint input:
E) In the Blueprint, under the Code tab the following will be added automatically:
Project_Code:
type: string
default: '1234'
title: Project Code
minLength: 4
maxLength: 6
F) The complete Blueprint code would look like the example shown below:
G) Version the Blueprint and Deploy it.
H) When deploying the Blueprint the following section is added for user input in the
request form:
I) There is a Text Field for entering the Project Code. This is the value that is to be
assigned to the Tag. Default value is 1234.
J) Enter the Project Code required and DEPLOY the Blueprint.
K) I entered 123456 and in vCenter after the VM was deployed the Tag ProjectCode was
also added with the value of 123456 as shown below:
L) Also note, The Tag UserName was added by the vRO Workflow with the correct value of
fritz. This was extracted from the Virtual Machine system properties.
M) That’s it, all done. Enjoy!
18) vRealize Automation 8.x Dynamically Add Virtual Machine to DRS group during Provisioning
Posted: 03 May 2022
Recently while working with a customer a requirement came up to Dynamically add the Virtual Machine to a DRS Group while Provisioning.
Thinking about it, the easiest way to achieve this was to add an input to the Request form to capture the VM DRS Group and then add the VM using a vRO workflow to it.
I therefore started looking into it and managed to create the following by modifying the Out-Of-The-Box vRO workflow Add virtual machines to DRS Group to work with vRA:
A) In vRealize Orchestrator create a workflow called Add Virtual Machine to DRS Group, with the following details:


Note:
Set the cluster variable to the desired VC cluster that is to be used. I set it to S360-Workload-Cluster.


i) Configuring Cluster VM group Task



The complete script code is listed below:
var customProps = inputProperties.customProperties || new Properties();
//Use workflow metadata to select VM Group
vm_group = customProps.VMGroup;
System.log("VM Group: " + vm_group);
//Use workflow metadata to select VM Name
var resourceNames = inputProperties.resourceNames;
System.log("Resource Names: " + resourceNames);
query = "xpath:name='" + resourceNames + "'";
vmnames = Server.findAllForType("VC:VirtualMachine", query);
System.log("VM Name: " + vmnames);
vms = vmnames;
System.log("VM: " + vms[0]);
// ------- ReconfigureCluster_Task -------
System.log("Creating reconfigure specification");
//Creating editing spec
var MyVCClusterDRSConfigExSpec = new VcClusterConfigSpecEx() ;
//Configuring VM group
//------------Finding Existing VM Group------------
System.log ("Finding VM group");
var existingClusterVmGroup = new VcClusterVmGroup();
System.log ("Cluster: " + cluster);
existingClusterVmGroup = System.getModule("com.vmware.library.vc.cluster").getDrsVmGroup(cluster,vm_group);
var newVcClusterVmGroup = existingClusterVmGroup;
System.log ("Found VM group: " + newVcClusterVmGroup);
if (existingClusterVmGroup.vm!= null) {
//Copying current VMs to the new group
var groupArray = new Array ();
if (vms != null) {
for (var i=0; i< vms.length; i++) {
groupArray.push(vms[i]);
}
}
//Adding chosen Vms to the new group
for (var i=0; i< newVcClusterVmGroup.vm.length; i++) {
groupArray.push(newVcClusterVmGroup.vm[i]);
}
newVcClusterVmGroup.vm = groupArray;
System.log ("New current VM group contains " + newVcClusterVmGroup.vm.length + "vms");
} else {
System.log ("Adding first Vms to the group");
newVcClusterVmGroup.name = vm_group;
if (vms != null) {
System.log("Adding VM array to VMGRoup");
newVcClusterVmGroup.vm = vms;
}
}
//Configuring the Cluster group
var newVcClusterGroupSpec= new Array();
System.log("Creating VC Vluster Group spec");
newVcClusterGroupSpec[0] = new VcClusterGroupSpec();
System.log("Initializeing group spec");
newVcClusterGroupSpec[0].operation = VcArrayUpdateOperation.add;
System.log("Applying add operation to the group spec");
newVcClusterGroupSpec[0].info = newVcClusterVmGroup;
System.log("Seeting info of the VC cluster group equal to the VMGroup");
//Configuring the spec with the above group
MyVCClusterDRSConfigExSpec.drsConfig = new VcClusterDrsConfigInfo();
MyVCClusterDRSConfigExSpec.drsConfig.enabled = true;
System.log("Setting DRS Enabled for the clusterSpecEx");
MyVCClusterDRSConfigExSpec.groupSpec = newVcClusterGroupSpec;
System.log("Trying to apply add operaiont");
MyVCClusterDRSConfigExSpec.groupSpec[0].operation = VcArrayUpdateOperation.edit;
System.log("Invoking reconfigurespec");
task = cluster.reconfigureComputeResource_Task(MyVCClusterDRSConfigExSpec , true);
ii) Configuring the Wait Task




The complete Action script code is listed below:
var taskEnd = false;
var error;
while (task != null) {
if (task.info == null) {
throw "VIM Task info is null";
}
if (task.info.state == null) {
throw "VIM Task state is null";
}
var state = task.info.state.value;
if (state == "success") {
break;
}
else if (state == "error") {
if (task.info.error.localizedMessage == null) {
throw "Task '" + task.info.name + "' has encountered an unknown error";
}
else {
throw "Task '" + task.info.name + "' error: "+task.info.error.localizedMessage;
}
}
else if ((progress) && (state == "running")) {
if (task.info.progress == null) {
System.log(task.info.name+" Queued or In Progress...");
}
else {
System.log(task.info.name+" "+task.info.progress+" %");
}
}
System.sleep(pollRate*1000);
}
if (task == null) {
throw "VIM Task is null";
}
else if (progress) {
System.log(task.info.name+" end");
}
System.sleep(2*1000);
// Return the Task Result
if (task != null && task.info != null && task.info.result != null) {
return VcPlugin.convertToVimManagedObject(task , task.info.result);
}
else {
return null;
}
B) In Cloud Assembly, Under Extensibility – Subscriptions create a new Subscription called Add VM to DRS Group with the following details:

C) In the Blueprint, under the Inputs tab add the following Blueprint input:

D) In the Blueprint, under the Code tab the following will be added automatically under inputs section:
VM_Group:
type: string
title: VM DRS Group
E) The complete Blueprint code would look like the example shown below:

F) Version the Blueprint and Deploy it.
G) When deploying the Blueprint the following request form will be displayed:

H) There is a Text Field for entering the VM DRS Group. This is the DRS group the VM will be added to.
I) Enter the existing VM DRS Group required (Note: this is case sensitive) and DEPLOY the Blueprint.
J) I entered TestVMGrp as shown below:

K) And in vCenter after the VM was deployed it was also added to the DRS Group TestVMGrp as shown below:

L) In vRO the workflow was executed and completed as shown below:


M) That’s it. Enjoy!
19) VMware Cloud Foundation on VxRail Upgrade from Version 4.0 to 4.1
Posted: 13 Feb 2023
Recently I worked on a Project to upgrade VMware Cloud Foundation on VxRail from version 4.0 to 4.1. This was a Dark Site and I used the Skip-level Off-line upgrade method to upgrade the platform.
It was quite challenging as I had to make sure all the required bundles were downloaded prior to initiating the upgrade process.
I have created the Powerpoint presentation below to show the steps taken to upgrade the environment from 4.0 to 4.1.
Enjoy!
20) VMware Cloud Foundation on VxRail Upgrade from Version 4.1 to 4.4
Posted: 13 Feb 2023
Working on the same Project above I then had to upgrade VMware Cloud Foundation on VxRail from version 4.1 to 4.4 using the Skip-level Off-line (For Dark Site) upgrade method to upgrade the platform.
This was even more challenging as I had to make sure all the required bundles and the vRealize components bundles and packages were downloaded prior to initiating the upgrade process.
I have created the Powerpoint presentation below to show the steps taken to upgrade the environment from 4.1 to 4.4.
Enjoy!