Hello Guys
In VRA 7.4 have blueprint where the user select cluster, vlan, storage and now need enter the hostname manually.
The problem that arises is that they have entered VM names that exist in vCenter and the process fails, so I need to know if there is a form or a workflow that allows me to validate if the hostname entered exists before sending the request. Example, if you enter as hostname vmtest01, validate that no vm with that name is created.
I appreciate your help to know if there is a way to validate the above.
Thank you
Sebastian Antunez N.
You'll have to write your own vRO action that takes this name and validates it against vCenter's inventory.
I created a custom action to find the vm
if(!vmName)
{
return "";
}
var vms = VcPlugin.getAllVirtualMachines();
for each (var vm in vms) {
if (vm.name == vmName) {
return vmName+" is already in use";
}
}
return "";
(Might not be "pro" code but it works )
Hello Lie
Sorry for my little knowledge
In VCO create a Workflow called ValidateName and the input add the value
Parameters:
Name Type Description
vmName VC:VirtualMachine Validate VM Hostname
In Schema Tab where IN Module add
local Parameter Source Parameter Type
vmName vmName [in Parameter] VC:VirtualMachine
And Scripting add your script
if(!vmName)
{
return "";
}
var vms = VcPlugin.getAllVirtualMachines();
for each (var vm in vms) {
if (vm.name == vmName) {
return vmName+" is already in use";
}
}
return "";
When save the workflow show me error
Invalid Return and mark the line
return "";
I do not know if I'm missing something to add, could you tell me if what I've done is correct?
Thanks
Sebastian
This should be done in an action not a workflow
An action is basically a function packed up. Return in JavaScript cannot be in any script block rather only in a function.