VMware Cloud Community
pizzle85
Expert
Expert
Jump to solution

Get and Set Dynamic Type Output via Script

I am running vRO 6.0.1. I have built a dynamic type for Veeam. I can see the objects in the inventory and can select them as attributes in workflows. I'm attempting to get the Dynamic Type Object through a script and set it as an output variable of the script but its not working. I have created the dynamic type using the Dynamic Types Plug-In Generator v2.

I have the namespace "Veeam" with the types:

VeeamHost

     jobFolder

          job

I set an output attribute with the type "DynamicTypes:Veeam.job" and name jobOut

My script is just:

jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

System.log("Found Job: " + jobOut); 

After execution the jobOut variable is blank. In the logs i see:

Found Job: DynamicWrapper (Instance) : [DynamicTypesDynamicObject]-[class com.vmware.o11n.plugin.dynamictypes.model.DynamicObject] -- VALUE : dynobj:[ __ns:Veeam __tp:DynamicTypes:Veeam.job __id:29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae]

Does anyone have an idea of how to populate the DynamicTypes:Veeam.job output with the actual veeam job i got via the script?

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Could you check what happens if you replace the line

  jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

with

  jobOut = DynamicTypesManager.getObject("Veeam", "job", "29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

View solution in original post

0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Could you check what happens if you replace the line

  jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

with

  jobOut = DynamicTypesManager.getObject("Veeam", "job", "29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

0 Kudos
pizzle85
Expert
Expert
Jump to solution

That did it.

I thought i could use the "Object" or "Any" return types to populate their real types. While this works and im going to use it from now on, should my original code have worked?

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

If I understand it correctly, the question if whether System.findForType(...) should work if the jobOut type is changed from concrete dynamic type Veeam.job to generic DynamicObject or Any? If so, the answer is no - it shouldn't matter what is the type of the output parameter as long as it is compatible with the type of the actual value. In your case, most probably you won't see the correct value in 'Variables' table when you use Server.findForType() no matter what is the type of jobOut - Veeam.job, DynamicObject or Any, and when you use DynamicTypesManager.getObject(), you should see the correct value in 'Variables' table if you use Veeam.job or DynamicObject types for jobOut.

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

I made the same mistake using Server.findForType() since this is the universal method I use for any vCO object.

Would it make sense or even be possible to have it working as DynamicTypesManager.getObject() ?


While we do have the solution to make it work I am sure several people will have the same issue.

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