VMware Cloud Community
mcssschaefer
Enthusiast
Enthusiast
Jump to solution

Passing self created objects between workflow elements

Hi,

is it possible to pass self created objects between workflow elements? And when it's possible, how can it be accomplished?

In example:

var myVlans = [];

myVlans.push( {vlanid: 100, found: false, type="local", Network: PortGroup_100} )

myVlans.push( {vlanid: 101, found: false, type="distributed", Network: dvpg_100} )

I tried to define myVlans as an Array of Any (Workflow attribute) to get access in an other worfklow element.

Failure: Workflow:initializeWorkflowVariables / Find Host (item13) : ch.dunes.model.type.ConvertorException: Unable to serialize object of class : org.mozilla.javascript.NativeObject

Thanks in advance,

Stephan

http://blog.mightycare.de http://www.mightycare.de
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

vCO saves all outputs to its databse between each boxes to make sure the workflow can be resumed. It does it only with the objects it knows (not the custom ones you create in javascript). For example you can use the Properties object to pass your vlan properties from one box to another one.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

0 Kudos
8 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

vCO saves all outputs to its databse between each boxes to make sure the workflow can be resumed. It does it only with the objects it knows (not the custom ones you create in javascript). For example you can use the Properties object to pass your vlan properties from one box to another one.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
admin
Immortal
Immortal
Jump to solution

Hi Stephan,

had the same problem these days also for using it inside the worklfows. You can use JSON or serialize it in a way you want or write an specific action like "serialize" to build the objects. The best way in my opinion are Array/string for the "transport", they look similar to key paired values.

http://mighty-virtualization.blogspot.com/2011/07/vco-out-parameter-serialization-with.html

best regards

Christian

admin
Immortal
Immortal
Jump to solution

@Christophe: Damn, you win the speed contest again Smiley Happy

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

At least we did not answer the same thing. More options is better.

I like the properties because you can set and get any objects type without converting them back and forth.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
mcssschaefer
Enthusiast
Enthusiast
Jump to solution

Hi guys,

the "Properties"-Solution ismore straightforward to me, so I will stuck with it. Hopefully you understand it Christian :smileylaugh:

Here is a little example (Don't ask for the sense, it's just a test.)

Workflow element A)

for ( var i in clusterHost ) {
vlan[i] = new Properties();
vlan[i].put("host", clusterhost[i]);
vlan[i].put("networkName",clusterHost[i].config.network.portgroup[0].spec.name);
vlan[i].put("vlanId", clusterHost[i].config.network.portgroup[0].spec.vlanId);
vlan[i].put("vcNetwork",System.getModule("com.vmware.library.vc.network").getNetworksForLabel(clusterHost[i].config.network.portgroup[0].spec.name))
vlan[i].put("type", "local");
}

Workflow element B)

for ( var i in vlan ) {

System.debug("Name: " +vlan[i].get("name"));

System.debug("ID: " +vlan[i].get("id"));

System.debug("VcNetwork: " +vlan[i].get("vcNetwork"));

}

Works like a champ.

Thanks,

Stephan

http://blog.mightycare.de http://www.mightycare.de
0 Kudos
ullbergm
Enthusiast
Enthusiast
Jump to solution

Just wanted to say thanks, I was looking to pass things between workflows and the Properties object was exactly what i was looking for.

Check out my orchestration blog here: http://ullberg.us/orchestrate/
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

in 5.1 there is an improvement for reliablility on this:

you can define custom "strongly typed" so called Compositions.

They are used comparable to properties, but have type-safety even at development time.

Cheers,

Joerg

0 Kudos
ullbergm
Enthusiast
Enthusiast
Jump to solution

Even better, I'll take a look at that.

Thanks,

Magnus

Check out my orchestration blog here: http://ullberg.us/orchestrate/
0 Kudos