VMware Cloud Community
aenagy
Hot Shot
Hot Shot
Jump to solution

How to construct a query for Server.findAllForType( type(string) , query(string) ) [vRO 7.6]

Most code I have seen that uses 'Server.findAllForType( type(string) , query(string) )' simply leave out the query and then iterate over the return to find the desired value(s). The built-in documentation for query states:

- query (string)

  (Optional) Custom query depending on plug-in implementation

(1) Where do I find the query specifications for the Orchestrator plugin? For example, if I want to find an Orchestrator Workflow by name how do I construct the query string?

(2) Where do I find the plug-in implementation specifications for the query if it's not already in the IDE help? The vRA and vSphere plug-ins come to mind but this is meant to be more general.

Thanks in advance for any help.

1 Solution

Accepted Solutions
inevp
Enthusiast
Enthusiast
Jump to solution

The code you are looking for is:

var workflow = Server.findAllForType("Workflow", "name = 'workflow name'")[0];

Keep in mind that there can be more than one workflow with the same name. If you have the workflow ID in you script and want greater precision you can do the following to search by ID:

var workflow = Server.findForType("Workflow", "workflow-id");

I'm afraid I can't really help you out with any additional documentation. If you want to search for system objects (like workflows, configurations, resources) - they are internal to the vRO, not part of any plug-in and queries should be similar to the one I provided above. The queries for plug-in objects on the other hand, as stated in the docs you cited, are implementation specific.

View solution in original post

Reply
0 Kudos
6 Replies
inevp
Enthusiast
Enthusiast
Jump to solution

The code you are looking for is:

var workflow = Server.findAllForType("Workflow", "name = 'workflow name'")[0];

Keep in mind that there can be more than one workflow with the same name. If you have the workflow ID in you script and want greater precision you can do the following to search by ID:

var workflow = Server.findForType("Workflow", "workflow-id");

I'm afraid I can't really help you out with any additional documentation. If you want to search for system objects (like workflows, configurations, resources) - they are internal to the vRO, not part of any plug-in and queries should be similar to the one I provided above. The queries for plug-in objects on the other hand, as stated in the docs you cited, are implementation specific.

Reply
0 Kudos
stevedrummond
Hot Shot
Hot Shot
Jump to solution

For question 2, you can't.

Unless they've documented it, someone's blogged/posted about it, or the source code is public, all you can do is try different things.

It's really down to how they implemented the ​Finder​ methods in their plugin.

Reply
0 Kudos
aenagy
Hot Shot
Hot Shot
Jump to solution

inevp:

Keep in mind that there can be more than one workflow with the same name.

This is a given. If there are more than one returned then I have a bigger problem of multiple workflows with the same name which needs to be fixed.

If you have the workflow ID

This is my use case. I know the name of the workflow but need to find the ID.

I was able to try your code snippet and it worked as I needed.

Thank-you.

Reply
0 Kudos
aenagy
Hot Shot
Hot Shot
Jump to solution

stevedrummond:

I was afraid of that. The helpful suggestions for this thread included another thread that gets deeper into this:

Server.findAllForType query parameter mystery solved (sorta)

This is something that VMware and the Orchestrator ecosystem should address starting with including the query specifications in the documentation, both within the IDE and standard documentation. With environments getting bigger all the time assuming that iterating over a large return set is going to scale seems overly optimistic.

Thank-you for your response.

Reply
0 Kudos
aenagy
Hot Shot
Hot Shot
Jump to solution

Unfortunately I can mark only one reply as the Answer.

This question is somewhat inspired by my experience using Get-View and PowerCLI to more efficiently query for results by returning only the desired results. It seemed only logical that Orchestrator would have the same capability. I am hoping this has been addressed in vRA 8 + vRO 8.

Reply
0 Kudos
stevedrummond
Hot Shot
Hot Shot
Jump to solution

It hasn't.

Reply
0 Kudos