Back for 2020

It’s been a hot minute since I’ve concentrated on writing blog posts, after getting vExpert recognition I’ve let the content slide into non existence.

A busy work and family schedule meant I didn’t have the time but I’m hitting 2020 with renewed vigour and I hope these pages will again be filled with useful content.

Since the last posts (the majority of which were written at the beginning 2017!!) allot has changed, I’ve moved from the realm of infrastructure into infrastructure engineering and I’ve been exclusively working on vRealize Automation and Orchestrator and I’ve clocked up a ton of enterprise miles using the product on multiple projects.

I had a whole blog series written around how to “cloudify” vRealize 7.* including how to work CI/CD pipelines into your environment, coding practices, VM mobility and all that lovely stuff but with the release of vRA8 and the completely new design and extensibility engine I thought I’d start a fresh, the further I dive into infrastructure engineering the more I enjoy it and the more I drift into other product sets that are not VMware centric.

So going forward this blog will have a wider scope, it will likely have VMware product’s at its core but will branch off to look at alternatives, as the industry changes I want to fully transfer from being an “Infrastructure/VMware engineer” into being an automation engineer (DevOps engineer if you like)

With vRA8s new extensibility engine and native integration with Ansible, Azure, AWS etc this seems like the perfect time to do that.

With the above in mind, the first post will be about my new (ish) lab.

vRO convert objects from string to object type

This code can be used to convert a vDS portgroup name in type string to a vDS portgroup object in type VC:DistrubutedVirtualPortgroup

You can use this to convert anything by calling the appropriate methods and querying the appropriate value.

Here we call the getAllDistributedVirtualPortgroups() method to get all vDS portgroups but you could call the getAllVirtualMachines() or getAllDatastores() method.

Set an input parameter of pgName in type string and the output Parameter as nicnetwork of type VC:DistrubutedVirtualPortgroup

The vDS portgroup .name value will have the vDS name in brackets after the portgroup in a similar format to “MyPortgroup (myVDS)”

So the input string would have to be represented in this way to work or you’d need to elaborate on the java script.

var portgroups = VcPlugin.getAllDistributedVirtualPortgroups();

var arraylength = portgroups.length;
var i = 0;

while (i < arraylength){ if (portgroups[i].name == pgName){ nicnetwork = portgroups[i]; }



vRO Return Datastores over a specified TB size

This code will return only the datastores over a specified Terabyte size.

Set two input parameters

inputTB as type number, this will be the TB size that will determine the Datastores to return.

set another input parameter as inDS as array type VC:Datastore

Set the output parameter as outDS as array type VC:Datastore

var tbSize = inputTB * 1073741824;

System.log("Variable tbSize is "+tbSize);

var ds = new Array();

for each (d in inDS){ if (d.summary.capacity >= tbSize){ ds.push(d);} System.log("name: " + +" Size: "+ d.summary.capacity);}

outDS = ds;

vRO vMotion VM to SDRS Datastore cluster and inflate disk

The following can be used to vMotion a machine to an SDRS Datastore Cluster, inflating the disk to Lazy Zero at the same time (done by VcVirtualMachineRelocateTransformation.flat)

Create two input parameters. vMotionVM of type VC:VirtualMachine & a parameter name SDRSCL of type VC:StoragePod

The output parameter will be myVcTask of type VC:Task

var storageSpec = new VcStoragePlacementSpec();
var StorageResourceManager = vMotionVM.sdkConnection.storageResourceManager;
var myStoragePlacementResult = VcStoragePlacementResult();
var myKey = new Array();
var podSelectionSpec = new VcStorageDrsPodSelectionSpec();
var relocateSpec = new VcVirtualMachineRelocateSpec();
relocateSpec.transform = VcVirtualMachineRelocateTransformation.flat;

podSelectionSpec.storagePod = SDRSCL;

storageSpec.type = "relocate";
storageSpec.vm = vMotionVM;
storageSpec.podSelectionSpec = podSelectionSpec;
storageSpec.relocateSpec = relocateSpec

myStoragePlacementResult = StorageResourceManager.recommendDatastores(storageSpec);

myKey[0] = myStoragePlacementResult.recommendations[0].key
myVcTask = StorageResourceManager.applyStorageDrsRecommendation_Task(myKey);

vRO Remove CD ROM Workflow

The following can be used to remove a CDROM drive from a powered on Virtual Machine using vRO, vRealize Orchestrator.

Paste the following into a Scriptable task and create an input Parameter of type VC:VirtualMachine called workflowVM


var configSpec = new VcVirtualMachineConfigSpec();
var deviceConfigSpecs = new Array();
var deviceConfigSpec = new VcVirtualDeviceConfigSpec();
var devices = workflowVM.config.hardware.device;

for ( var ii in devices) {
var device = devices[ii];
if ( device instanceof VcVirtualCdrom) {
deviceConfigSpec.device = device;
deviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.remove;
deviceConfigSpecs.push (deviceConfigSpec);
configSpec.deviceChange = deviceConfigSpecs