VMware Cloud Community
jinho10
Contributor
Contributor

Managed Object Reference to Managed Object (in the context of SRM)

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.

0 Kudos
4 Replies
scott28tt
VMware Employee
VMware Employee

Moderator note: Moved to the SRM forum area.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
jinho10
Contributor
Contributor

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

0 Kudos
vThinkBeyondVM
VMware Employee
VMware Employee

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.


----------------------------------------------------------------
Thanks & Regards
Vikas, VCP70, MCTS on AD, SCJP6.0, VCF, vSphere with Tanzu specialist.
https://vThinkBeyondVM.com/about
-----------------------------------------------------------------
Disclaimer: Any views or opinions expressed here are strictly my own. I am solely responsible for all content published here. Content published here is not read, reviewed or approved in advance by VMware and does not necessarily represent or reflect the views or opinions of VMware.

0 Kudos
basher
VMware Employee
VMware Employee

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

Director - VMware Site Recovery Manager
0 Kudos