VMware Cloud Community
goldeneyez
Contributor
Contributor

VcSdkConnection and getAllManagedObjects method

Hi everyone

I have a variable that contain VcSdkConnection object

when I am executing the method getAllManagedObjects then I get an error.

probably I am not executing correctly the method and thus I need assistance with this.

here is the code that I am using:

System.log("with Properties: displayName");

var XPath_query = "xpath:displayName[contains(.,'lab-vc01')]";

System.log(XPath_query);

var VcSdkConnection_Array = Server.findAllForType("VC:SdkConnection",XPath_query);

System.log(VcSdkConnection_Array.length);

System.log("with Properties: displayName"+" "+"getAllManagedObjects()");

var allManagedObjects = VcSdkConnection_Array[0].getAllManagedObjects("","","");

so what you need to focus his the following:

*******************************

var allManagedObjects = VcSdkConnection_Array[0].getAllManagedObjects("","","");

*******************************

you can read the document about VcSdkConnection.allManagedObjects() in the following URL:

vRO API Explorer by Dr Ruurd and Flores of ITQ

https://www.vmware.com/support/orchestrator/doc/vro-vsphere60-api/html/VcSdkConnection.html#getAllMa...

the Parameters that getAllManagedObjects expect to get are the following:

sdkType

additionalPropertyFilters

query

sdkType which is type of String and it is VI type

additionalPropertyFilters which is type of string[] and it is Top level property filters

query which is type of string and it is XPath query

my target is to retrieve from vCenter MOB the following fields:

the 1st is:

***********************************

Data Object Type: OptionValue

Parent Managed Object ID: VpxSettings

Property Path: setting["VirtualCenter.FQDN"]

the value field

***********************************

and you can see the following image that I took from vCenter MOB:

1st.jpg

the 2nd is:

***********************************

Data Object Type: OptionValue

Parent Managed Object ID: VpxSettings

Property Path: setting["VirtualCenter.InstanceName"]

the value field

***********************************

and you can see the following image that I took from vCenter MOB:

2nd.jpg

my 1st question is:

how to retrieve this through sdkconnection object ?

what I should retrieve ?  which type of object ?  is it Managed Object ? or this is Managed Object Reference ?

also , you can read above that one of the parameters which I need to provide is: sdkType

how can I know the list of all sdkType values that exist ? I couldn't find this.

I will be glad if someone can assist me in understanding how to retrieve Managed Object and how to retrieve Managed Object Reference.

I am sure that there are many users that willing to understand this subject. so it will be big contribution for the vRealize Orchestrator users that develop automation implementation

thanks.

Reply
0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

These two settings can be retrieved via VcOptionManager, which is accessible via setting property of VcSdkConnection.

Here is a sample demonstrating how to retrieve VirtualCenter.FQDN setting; similar code for VirtualCenter.InstanceName: (variable sdkConn is your input VcSdkConnection instance)

var options = sdkConn.setting.queryOptions("VirtualCenter.FQDN"); 

if (options != null && options.length > 0) { 

    var fqdn = options[0].value; 

    System.log("vCenter FQDN : " + fqdn); 

} else { 

    System.log("Unable to determine vCenter FQDN"); 

The list of managed object types can be found in vSphere documentation; for example here - https://pubs.vmware.com/vsphere-6-5/index.jsp?topic=%2Fcom.vmware.eam.apiref.doc%2Fmo-types-landing....

Reply
0 Kudos
goldeneyez
Contributor
Contributor

Hi Ilian Iliev

1st I would like to say thank you that you suggested another way to implement the query.

2nd , because it will good for understanding for me and also for all audience in this forum.

can you please expose the usage of:

*******************************

var allManagedObjects = VcSdkConnection_Array[0].getAllManagedObjects("","","");

*******************************

as it shows in the following URL:

https://www.vmware.com/support/orchestrator/doc/vro-vsphere60-api/html/VcSdkConnection.html#getAllMa...

I am using vCenter Server version 6.0

and I am querying the vCenter and not the ESXi

thx

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

First, your code does not call getAllMAnagedObjects with proper parameters. According to documentation, the second parameter is of type array of strings, and you passing a single string. Also, the first parameter should be a name of some managed object type instead of empty string. So, a proper call should look something like the following (which will retrieve all datastore instances from your vCenter / VcSdkConnection

var allDatastores = VcSdkConnection_Array[0].getAllManagedObjects("Datastore",[],null);

The second parameter is a string array containing property names for the fetched objects to be retrieved from vCenter property collector and cached. It is fine for this parameter to be empty array; you're still be able to access all the properties of the fetched objects, but access to them will be a bit slower.

The third parameter is probably a XPath query to further filter the list of fetched objects. I'm not sure what exactly can be provided here as I'm not very familiar with property collector and vCenter plug-in implementation.

Reply
0 Kudos