VMware {code} Community
kumar_t
Enthusiast
Enthusiast

How to retrieve list of vCenters with FQDN and GUID in a Enhanced linked mode using web services sdk

How to retrieve list of vCenters with FQDN and GUID in a Enhanced linked mode using web services sdk?

0 Kudos
1 Reply
doskiran
Enthusiast
Enthusiast

Rest APIs:

1)  GET:  https://{vcenter}/api/vcenter/topology/nodes

2)  GET: https://{vcenter}/api/vcenter/topology/replication-status

Web Service sample java code:

Here is the sample code to get all linked vCenters by using userAgent , here userAgent is the name of user agent or application. In my case I opened my linked VC atleast onetime with web client, so userAgent comparing with "web-client" in the code.

Set<String> vcList = new HashSet<String>();
System.out.println(serviceInstance.getAboutInfo().getInstanceUuid());
SessionManager sessionMgr = serviceInstance.getSessionManager();
UserSession[] userSessions = sessionMgr.getSessionList();
for (UserSession userSession:userSessions) {
      if (userSession.getUserName().contains("vsphere-webclient")) {
          vcList.add(userSession.getIpAddress());
      }
}

 

0 Kudos