I am trying to implement a controller for the site recovery manager to partially automate some steps. VMware provides some APIs to control protection group and recovery group---check status, (un) associate VMs, initiate recovery.
The problem that I have is after I get VM list MOR (managed object reference) via listAssociatedVM API... there are no ways for me to get the real information from server using MOR. SRM API does not provide this API so I had to go to generic vSphere API to achieve this. Does anyone know that I can get VM information (like name, size...) using MOR?
The following is my function:
public void listProtectedVMs() throws Exception {
List<ManagedObjectReference> plans = srmPort.listProtectionGroups(srm_serviceContent.getProtection());
if (plans != null && plans.size() > 0) {
for(int i = 0; i < plans.size(); i++) {
List<ManagedObjectReference> associatedVMs = srmPort.listAssociatedVms(plans.get(i));
for(int j = 0; j < associatedVMs.size(); j++) {
// how to get virtual machine name???
System.out.println("type: " + associatedVMs.get(j).getType());
System.out.println("value: " + associatedVMs.get(j).getValue());
}
}
}
}
Thank you.
Moderator note: Moved to the SRM forum area.
Respond to myself:
After all, I used a mix of VI API (VMware Infrastructure (vSphere) Java API) and SRM API. Bad thing is that I have to connect vCenter server twice.
Jinho
In the context of SRM I am not much aware but in the context of vCenter. We can get VM related info by using its MOR.
Hi Jinho,
Detailed VM info has to be collected from vCenter server by passing it the MOR you get from SRM. The idea is that SRM does not keep a full copy of the VM object.
Best regards
Stefan Tsonev