VMware Cloud Community
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

properties as loops

cdecanini_ mentioned yesterday to use properties objects instead of config objects due to performance related issues. After switching I have run into a number of issues relating to looping workflows.

I am having issues working out how to use workflow loop through a properties object . The only way I can see to iterate properties is using the properties.keys method.

how does one assign this in the form of a workflow loop and use a descrease counter to select the next record?

I can see its pretty easy if I house properties objects inside arrays. but our discussion was housing properties objects inside properties objects.

then I can use the array length to iterate the objects.

Reply
0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I think I was the one to misunderstand. I thought you wanted to go from XML to serializable object and back to XML. The most important is that you achieved what you wanted to know and learned different ways to do it.

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

Reply
0 Kudos
3 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Maybe I have misunderstood what you are doing in details. If the goal is to have a way to convert XML to a serailizable object properties of properties allows you to go through your XML and to add nodes as new Properties object and leaf as string.

To iterate through keys you can use:

for each (var key in prop.keys) {

     var object = prop.get(key);

}

You can then test if the object is type is string or properties. Usualy this is a recursive function (except is your XML is fixed / flat).

If the order of the element is important use an arry since properties are not ordered (it is a hasmap).

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
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

perhaps it was I who was unclear.

Essentially I was trying to send the xml objects across to the next action for use within a workflow loop.

I am clear on how to iterate .keys of a properties object. I am also clear on how to use a property to hold another property containing the data I need.

What I am unclear of or perhaps I didnt elude to what I was trying to do well enough, was that once I have these objects within the properties was to create the workflow loop with them.

I have it working using both arrays containing properties and config elements containing properties.

but you mentioned yesterday to use properties containing properties. In that context I cannot work out how to loop through them with workflow. As I have been using array.lenth and configelement.length as the counter for the workflow loops.

I am unsure how I could achieve the same with properties as there is no length property nor can you retrieve a property based on its position in the hashmap.

perhaps I misunderstood you previously.

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I think I was the one to misunderstand. I thought you wanted to go from XML to serializable object and back to XML. The most important is that you achieved what you wanted to know and learned different ways to do it.

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
Reply
0 Kudos