I'm working on a vCO workflow that will enable members of my team to set up new teams in vCAC..
I can't seem to workout how to map the output of "Create a Machine Prefix" , which is vCAC:Entity to the Machine Prefix Input (defaultMachinePrefix) which is vCACCAFE:MachinePrefix.
When I try to pass the entity ID to defaultMachine prefix I get the following error: Cannot convert undefined to java.util.UUID (Workflow:Set up new vCAC User / Create a Business Group (item6)#4)
Has anyone had any success or am I trying to do something that can't be done?
Cheers
OK finally managed to do this...
vCACCAFEEntitiesFinder is the way to go for this sort of stuff.
Here is what I did to get from Machine Prefix vCACEntity to vCAC:MachinePrefix:
Inputs:
mp_new MachinePrefix (vCAC:Entity output from New machine prefix OU)
vCACCAFEHost (vCACCAFE:VCACHost)
Outputs:
mp_defaultMachinePrefix (vCACCAFE:MachinePrefix)
function getMachinePrefix() {
var vCACCAFEMachinePrefix;
var array = new Array();
array = vCACCAFEEntitiesFinder.getMachinePrefixes(vCACCAFEHost);
var machinePrefix = mp_newMachinePrefix.getProperty("MachinePrefix");
System.log("Searching for machine prefix..");
for (var i = 0; i < array.length; i++) {
if (array[i].name.toLowerCase() == machinePrefix.toLowerCase()){
System.log("Found MachinePrefix : " + array[i].name);
vCACCAFEMachinePrefix = array[i];
}
}
return vCACCAFEMachinePrefix;
//Set default prefix mp_defaultMachinePrefix = getMachinePrefix();
if(!mp_defaultMachinePrefix){
throw "Could not find machine prefix entity";
}
Hmm,
Thought i'd found the answer:
var myvCACCAFEMachinePrefixesService = new vCACCAFEMachinePrefixesService();
var array = new Array();
array = myvCACCAFEMachinePrefixesService.getAll()
Then loop through the array until MachinePrifix.name == the user input for machine prefix
But no.. java.lang.NullPointerException (Workflow:test43 / Scriptable task (item2)#1)
OK finally managed to do this...
vCACCAFEEntitiesFinder is the way to go for this sort of stuff.
Here is what I did to get from Machine Prefix vCACEntity to vCAC:MachinePrefix:
Inputs:
mp_new MachinePrefix (vCAC:Entity output from New machine prefix OU)
vCACCAFEHost (vCACCAFE:VCACHost)
Outputs:
mp_defaultMachinePrefix (vCACCAFE:MachinePrefix)
function getMachinePrefix() {
var vCACCAFEMachinePrefix;
var array = new Array();
array = vCACCAFEEntitiesFinder.getMachinePrefixes(vCACCAFEHost);
var machinePrefix = mp_newMachinePrefix.getProperty("MachinePrefix");
System.log("Searching for machine prefix..");
for (var i = 0; i < array.length; i++) {
if (array[i].name.toLowerCase() == machinePrefix.toLowerCase()){
System.log("Found MachinePrefix : " + array[i].name);
vCACCAFEMachinePrefix = array[i];
}
}
return vCACCAFEMachinePrefix;
//Set default prefix mp_defaultMachinePrefix = getMachinePrefix();
if(!mp_defaultMachinePrefix){
throw "Could not find machine prefix entity";
}
Thanks for posting back how you sorted this, very helpful right now
This script is not working for me.
Getting the error: Unable to create object: _vCACCAFEEntitiesFinder: Class ch.dunes.vso.sdk.DynamicWrapper cannot access a member of class com.vmware.011n.plugin.vcac.model.inventory.EntitiesFinder with modifiers "private"
or this error: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING
Check this out..
And see here for more conversion: vCACCAFEEntitiesFinder.getMachinePrefixes(vCACCafeHost) only returns 25 results
thanks a lot.. working now
It's not working now with the solution mentioned in the given link:
[
/*
input: vCACMachinePrefixEntity [vCAC:Entity
input: vCACCAFEHost [vCACCAFE:vCACHost]
output: vCACCAFEMachinePrefixObject [vCACCAFE:MachinePrefix]
Description: Maps a vCAC:Entity machine prefix to a vCACCAFEMahcinePrefix object
*/
var vCACCAFEMachinePrefixEntityName = vCACMachinePrefixEntity.getProperty('MachinePrefix');
var vCACCAFEMachinePrefixArray = vCACCAFEEntitiesFinder.findMachinePrefixes(vCACCAFEHost,vCACCAFEMachinePrefixEntityName);
vCACCAFEMachinePrefixObject = vCACCAFEMachinePrefixArray[0];
]
Getting the error : [null] java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING
Unable to resolve this error. Thanks.
Interesting..
Are you sure you are passing it a vCAC:Entity?
I've just done a quick test and worked.
Can you provide more info?
Looking at the first screenshot.. it appears that the newMachinePrefix attribute is not set.. This should be set after create a machine prefix completes.
newMachinePrefix is bound to vCACCAFEMachinePrefix in machine prefix modifications.
Are you sure that the machine prefix is being created?
Thanks
newMachinePrefix attribute is set as can be seen in the screenshot
newMachinePrefix is then bound to vCACCAFEMachinePrefix in machine prefix modifications (Screenshot attached)
Yes, machine prefix is being created. I checked it. (Also attached screenshot for this)
Unable to resolve the error yet
This is weird.
I'm begining to wonder if this is something to do with IaaS?
I can't reproduce your error.
Can you tailf /var/log/vco/app-server/catalina.out and /var/log/vco/app-server/server.log when you run the workflow that fails and post any errors that you may see?
Cheers