public String getHostSystemForVM(final String vmName) throws VMWareException {

        ServiceInstance si = null;

        try {

            si = this.getServerInstance();
            boolean found = false;
            HostSystem hostSystem = null;
            ManagedEntity[] hostsystems = new InventoryNavigator(si.getRootFolder()).searchManagedEntities("HostSystem");
            for (ManagedEntity hostsystem : hostsystems) {
                HostSystem host = (HostSystem) hostsystem;

                VirtualMachine[] vms = host.getVms();

                for (VirtualMachine vm : vms) {
                    if (vm.getName().equals(vmName)) {
                        hostSystem = host;
                        found = true;
                        break;
                    }
                }

                if (found)
                    break;
            }

            return hostSystem.getName();
        } catch (PlatformConfigFault f) {
            throw new VMWareException(f);
        } catch (RemoteException exc) {
            throw new VMWareException(exc);
        } catch (Exception exc) {
            throw new VMWareException(exc);
        }
    }