VMware {code} Community
S_COLA
Contributor
Contributor

Using ManagedObjectReference ?

Hello,

I already apologize for my question that sounds pretty dumb, but I'm trying to solve this problem for hours...

I'm using the currentSnapshot attribute from the VirtualMachineSnapshotInfo Class to get a ManagedObjectReference

to a VirtualMachineSnapshot.

It's working fine : the type attribute equals "VirtualMachineSnapshot", the _value equals "snapshot-62".

But, when I try to access the config property VirtualMachineSnapshot, I've got an error message "property names 'config' not found on object VimManagedObjectReference".

Could you help me, please ? Thank you in advance.

Reply
0 Kudos
3 Replies
dmhaynes
Enthusiast
Enthusiast

If I am reading this correctly, you have a MoRef to the snapshot but have not yet loaded the snapshot property 'config'.

Take a look at the getObjectProperties method in the service utilities object in the SDK samples to see how to get the properties of an object referenced by a MoRef.

Reply
0 Kudos
maciej_wos
Contributor
Contributor

ManagedObjectReference is not the object itself.

Its just the "reference" to the objects that sits on the server side. So it has two properties only: type and Value.

To get the properties of the \*real* object you need to use some property collecting tool. There's property collector to do that, but it's a bit of a pain to use it (don't know about Perl, but in C# it definitely is!).

What you have to do is to create the PropertyFilterSpec object and set it's objectSet property to the array of ManagedObjectReferences to the objects you want to get properties of.

Next you need to prepare the PropertySpec object(s) to tell which propertis you want and set the propertySpec field of PropertyFilterSpec.

Then you put it all together and call something like:

vim_service.RetrieveProperties(service_content.propertyCollector, property_filter_spec)

and with a little bit of luck you should get what you need.

S_COLA
Contributor
Contributor

Thank you for your answer, I was able to get my needed attribute Smiley Happy

Thanx again.

Reply
0 Kudos