Requesting Machines with vmware vRealize Automation is not very complicated, but sometimes we want to make it even more simple. We could for example  let the user choose only if the size of the machine is small, medium or large instead of decide exact memory or cpu values.

We could do this by changing the BuildingMachine Workflow of vRA with the vcac Designer, but I like the vRO very much, so let’s try it with that.

 

First we have to create a new properties dictionary for the user in vRA under „Infrastructure->Blueprints“. For this example we build a dropdownlist with the values “small, medium, large”. Let’s give it an unique name, like “virtualMachine.custom.size”.

Next we add it to a property profile and add this to our target blueprint. When we test it, we should see the dropdownlist now in the Request screen, but of course it doesn’t do anything yet.

Now we continue with the orchestrator. There is a built in workflow called “workflow template” under “Library->vCloud Automation Center->Infrastructure Administration->Extensibility”. (Make sure, you registered vRA with your Orchestrator.) This template simply gets all custom properties from vRa, so we make a duplicate of it as starting point for our workflow.

For now, in this workflow there is only an scriptable task. Let’s modify it to get our property:

var size = "medium";
for each (var key in vCACVmProperties.keys) {
switch(key)
{
case " virtualMachine.custom.size " :
size = vCACVmProperties.get(key);
System.log("Found virtualMachine.custom.size: " + size);
break;
}
}

Now we can set our environment:

if (size != "")
{
switch(size)
{
case "small" :
memory = "512";
cpu = "1";
break;
case "medium" :
memory = "1024";
cpu = "2";
break;
case "large" :
memory = "2048";
cpu = "4";
break;
}
}

The variables “memory” and “cpu” in this case are output parameter. For now they are hardcoded, of course you could get them elsewhere.

In the next step, we need to set existing custom properties in our future virtual machine. Let’s get a workflow element from the toolbox and look for the workflow “Create/update property on virtualMachine Entity” under “Library->vCloud Automation Center->Infrastructure Administration->Extensibility->Helpers”. Then set the input parameter:

“Host” and “virtualMachine entity” we can simply set our existing ones. For all the Boolean values we set “false” and now we can set “PropertyName” to “VirtualMachine.Memory.Size” and “PropertyValue” to our “memory” variable from above”.

The same again for cpu with the “PropertyName”: “VirtualMachine.CPU.Count” and our “cpu” variable.

Our example workflow is now done, we can save and close it. The last task to do is to register it at our blueprint. For that, we look for the workflow “Assign a state change workflow to a blueprint and its virtual machines” again in the “Extensibility” folder. Start it an choose your vRA instance and the workflow stub “BuildingMachine”, then your blueprint and last our just built workflow.

Back in vRA you can test it now. If you get a machine from your blueprint, you should see our workflow working in vRO. If you look at the details of your new machine, you will not see the new values, because vRA doesn’t realize them, but if you check the machine itself, you should see the updated values.