VMware Cloud Community
Craig_G2
Hot Shot
Hot Shot
Jump to solution

Create new Business group with vCO workflow

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

1 Solution

Accepted Solutions
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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";

}

View solution in original post

0 Kudos
13 Replies
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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)

0 Kudos
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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";

}

0 Kudos
jmedd
Enthusiast
Enthusiast
Jump to solution

Thanks for posting back how you sorted this, very helpful right now Smiley Happy

Blog: http://jonathanmedd.net | Twitter: @jonathanmedd
0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

thanks a lot.. working now Smiley Happy

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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?

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

Yes, passing a vCAC:Entity.

Screenshots are attached.

0 Kudos
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

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


0 Kudos
Craig_G2
Hot Shot
Hot Shot
Jump to solution

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

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

Logs attached of catalina.out and server.log

0 Kudos