I am porting some legacy C# code that powers on and off a VM buy its uuid. I would like to use the findbyUUID to get me the VM. The document says that you do not need to provide the DataCenter. When I try the following code snipp it an error is thrown
ManagedObjectReference dc= null;
ManagedObjectReference vmMoRef = _service.FindByUuid(ServiceRef, dc ,vmGUID, true);
Just seeing If anyone has any ideas or a C# code sample using findBYUUID without a datacenter managed object reference
Thanks
Hi,
In the above code snippet, the parameter you pass in as datacenter is a MOR with null value. This is the reason for the error that you see. You would need to pass a null value for second parameter (datacenter) to search the entire inventory.
Replace it with the following code snippet and it should be working:
// Assuming "ServiceRef" holds a reference to the SearchIndex
ManagedObjectReference vmMoRef = _service.FindByUuid(ServiceRef, null, vmGUID, true);
Hope the above information helps.
Regards,
Neha
Nope I am still having problems. Do you have a full sample code?
Attached is a small C# sample for powering ON a virtual machine. This sample takes in the UUID of the VM as an input parameter that you wish to power ON. It then finds the MOR of this VM using the FindByUuid API and invokes the PowerOnVM_Task method. Hope this sample will help you in sorting out the issues.
Regards,
Neha