VMware {code} Community
nishtek
Contributor
Contributor
Jump to solution

how to get objectID from ManagedObjectReference

hi All,

i want to use object id of vmware object,(host , vm, clusters etc). i saw the sample codes and i am aware of getting it from web_platform.

but in my condition i am working in generic workspace(not in that object's context) so i cant use web_platform.

can some one help me how to generate objectId using ManagedObject Reference of that object.

i want to use it for sendNavigationRequest

Thanks in advance

Nishchay

Reply
0 Kudos
1 Solution

Accepted Solutions
laurentsd
VMware Employee
VMware Employee
Jump to solution

I don't have ready-made code but I can explain how to construct an objectId from a ManagedObjectReference on the Java side:

- get the type, value and serverGuid of the ManagedObjectReference

- first construct the string objectId = "urn:vmomi:{0}:{1}:{2}"  where {0} is the type, {1} the value and {2} the serverGuid

- then apply the following transformation necessary to encode any "/" character

      objectId = objectId.replace("/", "%252F")

View solution in original post

Reply
0 Kudos
9 Replies
laurentsd
VMware Employee
VMware Employee
Jump to solution

hi Nishchay,

Please be more specific in your question so that I can answer it correctly.  For instance provide a code snippet showing where you get the ManageObjectReference and explain your use case. Thanks.

Reply
0 Kudos
nishtek
Contributor
Contributor
Jump to solution

Hi Laurent,

1. i have created a simple Html Page.  and i am loading it on the click of a shortcut button.

2. i have created an extension on extension point vsphere.core.cluster.manageViews . the Extension id of my extension is, lets say com.mycompany.cluster.setting

3. i have listed all the clusters on that page. now i want to navigate to the above mentioned extension for that cluster(context) using sendNavigationRequest("com.mycompany.cluster.setting", ObjectId) where Object id is the object id of that cluster

4. since i dont have the object id , i cant navigate to this page.

5. for the cluster list , i have parsed the root folder > datacenter> clusters for the cluster,'s list . i have the ManagedObjectReference for all the clusters in the javaService

>>>>My Problem is how do i get this object id for all the cluster (by any mean, given i have the MORef to the cluster in Java Service) 

 

hope this my description is clear enough. please let me know i you need more clarification.

thanks,

Nishchay

Reply
0 Kudos
laurentsd
VMware Employee
VMware Employee
Jump to solution

Thanks for the detailed description.  This kind of transformation from IResourceReference to objectId is indeed missing.  Let me think about it, I should be able to provide some code snippet to help you out.

Reply
0 Kudos
nishtek
Contributor
Contributor
Jump to solution

Hi Laurent ,

that will be very helpful of you . 

Just to let you know i am building a html plugin. and i am not much aware of flex code.

i am being mean but it will be great if you can help me with java script code or java service code.

 

thanks

Nishchay

Reply
0 Kudos
nishtek
Contributor
Contributor
Jump to solution

One more thing , i tried to hardcode the objectID  in the sendNavigationRequest call , but its not working.

i tried the same thing from a page in the Cluster's workspace, and it was working. so, is there any dependency for using sendNavigationRequest API

Reply
0 Kudos
laurentsd
VMware Employee
VMware Employee
Jump to solution

I don't have ready-made code but I can explain how to construct an objectId from a ManagedObjectReference on the Java side:

- get the type, value and serverGuid of the ManagedObjectReference

- first construct the string objectId = "urn:vmomi:{0}:{1}:{2}"  where {0} is the type, {1} the value and {2} the serverGuid

- then apply the following transformation necessary to encode any "/" character

      objectId = objectId.replace("/", "%252F")

Reply
0 Kudos
nishtek
Contributor
Contributor
Jump to solution

thanks Laurent,

i was exactly following the same method till now as a work around. will continue with it.

Regarding my other query (comment 5 of this thread) , you have any idea why my sendNavigationRequest() is not working.

i am just simply executing WEB_PLATFORM.sendNavigationRequest(extensionID , objectID) from a HTML Page.

Thanks again

Reply
0 Kudos
laurentsd
VMware Employee
VMware Employee
Jump to solution

There is a known bug in sendNavigationRequest in SDK 6.0 which is fixed in 6.0.1

See Re: NavigationRequest to "vsphere.vco.workflowItem.monitor"

Reply
0 Kudos
nishtek
Contributor
Contributor
Jump to solution

thanks Mr. Laurent , that helped
Reply
0 Kudos