VMware Cloud Community
qc4vmware
Virtuoso
Virtuoso
Jump to solution

properties variable type and scriptable object type

Can anyone point me in the right direction for using the "Properties" scriptable object type.  Any sort of documentation on how it works exactly.  It seems like it holds a list of keys and values but I can't seem to get it it to work for me.  I want to load it up with list of keys and string values.  I was hoping to do this for some scripting instead of creating a bunch of string attributes in the workflow.  This or any other similar functionality alternative I would appreciate input on. I guess I could also use an array of strings where I know the index of the item I want to retrieve but I like the idea of being able to retrieve the value with variable.get(key)

Paul

1 Solution

Accepted Solutions
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

In the official documentation there's also a small example similar to the one from Christophe:

http://pubs.vmware.com/vsphere-50/topic/com.vmware.vsphere.vco_dev.doc_42/GUID4660AD05-E4C1-44A9-900...

See "Setting and Obtaining Properties from a Hashtable".

I hope it helps.

Sergio

View solution in original post

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

Hi Paul,

The Properties object work as follows:

Screen shot 2012-04-19 at 9.23.25 AM.png

var myProp = new Properties();

prop.put("key1", value1);

prop.put("key2", value2);

var value1 = prop.get("key1");

The value can be any of the objects. You can use properties as an input of a subworkflow (there is a vlone from properties example in the library) but not have an end user fill them as an input.

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
sanchezs
VMware Employee
VMware Employee
Jump to solution

Hi Paul,

In the official documentation there's also a small example similar to the one from Christophe:

http://pubs.vmware.com/vsphere-50/topic/com.vmware.vsphere.vco_dev.doc_42/GUID4660AD05-E4C1-44A9-900...

See "Setting and Obtaining Properties from a Hashtable".

I hope it helps.

Sergio

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Thanks guys... I gave the correct answer points to Sergio since Christophe already has such a high count Smiley Happy.  I was too lazy to RTFM so I really appreciate not being ridiculed.  So the problem I was running into doesn't seem to have anything to do with my usage of the scriptable object.  It must have something to do with the scope of the properties variable.  I had set an attribute in the workflow to the properties type.  I set that as an input to a scriptable object.  I then tried doint the put at that point and I kept getting an error saying something about a null value.  i guess I need to declare the properties type inside of the scriptable object then set it as an output to the workflow attribute?  I am off to give this a try.

Reply
0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Yes the object need to be declared (meaning doing the object = new Properties()). Creating the object does nto declare it. With an array you have an option to set it as an empty array but not with the Properties type.

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
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Is there anyway to save a predefined set of properties to a configuration?

Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

Hi!

I guess that should be possible via some scripting again.

See an example in this great post: http://blogs.vmware.com/orchestrator/2012/02/configuration-elements-revisited.html

Cheers,

Joerg

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Sometimes I wonder why I don't think of these things myself.  Thanks for the link to the awesome article!

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

One more question to throw out there.  If instead of using the "Properties" type variable I wanted to use XML is there a way to pass this variable type out from an action?  Do I just use a "String" type and the xml related commands will recognize it as a variable of type XML?

Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

For xml you should use a string.

Than you can use either the XML-Plugin (bundled with vCO) for a DOM-style xml-handling, or the (shorter) E4X way...

For examples: google! 🙂 There should be some blog entries out there...., like

http://www.vcoportal.de/2011/03/xml-handling-the-e4x-way/

also interesting: http://communities.vmware.com/message/1731950?tstart=0

Be aware: I eventually got in the situation that the conversion between a string-typed workflow attribute in scriptable task to XML and back did not always work. It's a good idea to create an empty string with var mystring = new String() as recommended for the properties before...

Cheers,

Joerg

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso
Jump to solution

Thanks for the hints... I have things working with XML for the moment.  As I expand what I am doing I think I get a lot more portability and functionality than using the Properties type.  One last thing I needed to do was convert the string to xml which I did with:

var newXml = new XML(stringVariableFromActionOutput);

Reply
0 Kudos