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.