VMware {code} Community
druideinformati
Contributor
Contributor

Getting the details of a VM's host

Hi,

I'm trying to get the host details related to a VM, so that I can construct a link to the Web console. Code:

if (dp.getName().equals("runtime")) {

                VirtualMachineRuntimeInfo runtimeInfo = (VirtualMachineRuntimeInfo) dp.getVal();

                ManagedObjectReference hostInfo = runtimeInfo.getHost();

                getInfoHote(hostInfo);

  public String getInfoHote(ManagedObjectReference hostInfo) {

ManagedObjectReference propColl = serviceContent.getPropertyCollector();

    try {

      List<String> vmList = new ArrayList<String>();

      vmList.add("HostSystem");

      ManagedObjectReference cViewRef = vimPort.createContainerView(hostInfo,

          serviceContent.getRootFolder(),

          vmList,

          true);

     

      ObjectSpec oSpec = new ObjectSpec();

      oSpec.setObj(cViewRef);

      oSpec.setSkip(true);

      TraversalSpec tSpec = new TraversalSpec();

      tSpec.setName("traverseEntities");

      tSpec.setPath("view");

      tSpec.setSkip(false);

      tSpec.setType("ContainerView");

      oSpec.getSelectSet().add(tSpec);

      PropertySpec pSpec = new PropertySpec();

      pSpec.setType("HostSystem");

      pSpec.getPathSet().add("config");

      PropertyFilterSpec fSpec = new PropertyFilterSpec();

      fSpec.getObjectSet().add(oSpec);

      fSpec.getPropSet().add(pSpec);

      List<PropertyFilterSpec> fSpecList = new ArrayList<PropertyFilterSpec>();

      fSpecList.add(fSpec);

      RetrieveOptions ro = new RetrieveOptions();

      RetrieveResult props = vimPort.retrievePropertiesEx(propColl,fSpecList,ro);

But I'm getting:

com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: The request refers to an unexpected or unknown type. Please see the server log to find more detail regarding exact cause of the failure.

What I'm doing wrong?

Tags (1)
0 Kudos
0 Replies