Java 类com.vmware.vim25.DatastoreHostMount 实例源码

项目:cloudstack    文件:VmwareStorageProcessor.java   
private boolean verifyAllHostsSeeDatastore(List<Pair<ManagedObjectReference, String>> lstHosts, DatastoreMO dsMO) throws Exception {
    int numHostsChecked = 0;

    for (Pair<ManagedObjectReference, String> host: lstHosts) {
        ManagedObjectReference morHostToMatch = host.first();
        HostMO hostToMatchMO = new HostMO(dsMO.getContext(), morHostToMatch);

        List<DatastoreHostMount> datastoreHostMounts = dsMO.getHostMounts();

        for (DatastoreHostMount datastoreHostMount : datastoreHostMounts) {
            ManagedObjectReference morHost = datastoreHostMount.getKey();
            HostMO hostMO = new HostMO(dsMO.getContext(), morHost);

            if (hostMO.getHostName().equals(hostToMatchMO.getHostName())) {
                numHostsChecked++;
            }
        }
    }

    return lstHosts.size() == numHostsChecked;
}
项目:cloudstack    文件:VmwareStorageProcessor.java   
private boolean verifyAllHostsMountedDatastore(List<Pair<ManagedObjectReference, String>> lstHosts, DatastoreMO dsMO) throws Exception {
    int numHostsChecked = 0;

    for (Pair<ManagedObjectReference, String> host: lstHosts) {
        ManagedObjectReference morHostToMatch = host.first();
        HostMO hostToMatchMO = new HostMO(dsMO.getContext(), morHostToMatch);

        List<DatastoreHostMount> datastoreHostMounts = dsMO.getHostMounts();

        for (DatastoreHostMount datastoreHostMount : datastoreHostMounts) {
            ManagedObjectReference morHost = datastoreHostMount.getKey();
            HostMO hostMO = new HostMO(dsMO.getContext(), morHost);

            if (hostMO.getHostName().equals(hostToMatchMO.getHostName())) {
                if (datastoreHostMount.getMountInfo().isMounted() && datastoreHostMount.getMountInfo().isAccessible()) {
                    numHostsChecked++;
                }
                else {
                    return false;
                }
            }
        }
    }

    return lstHosts.size() == numHostsChecked;
}
项目:cloudstack    文件:VmwareStorageProcessor.java   
private String getDatastoreUuid(DatastoreMO dsMO, HostMO hostToMatchMO) throws Exception {
    List<DatastoreHostMount> datastoreHostMounts = dsMO.getHostMounts();

    for (DatastoreHostMount datastoreHostMount : datastoreHostMounts) {
        ManagedObjectReference morHost = datastoreHostMount.getKey();
        HostMO hostMO = new HostMO(dsMO.getContext(), morHost);

        if (hostMO.getHostName().equals(hostToMatchMO.getHostName())) {
            String path = datastoreHostMount.getMountInfo().getPath();

            String searchStr = "/vmfs/volumes/";
            int index = path.indexOf(searchStr);

            if (index == -1) {
                throw new CloudRuntimeException("Unable to find the following search string: " + searchStr);
            }

            return path.substring(index + searchStr.length());
        }
    }

    throw new CloudRuntimeException("Unable to locate the UUID of the datastore");
}
项目:cloudstack    文件:DatastoreMO.java   
public boolean isAccessibleToHost(String hostValue) throws Exception {
    boolean isAccessible = true;
    List<DatastoreHostMount> hostMounts = getHostMounts();
    for (DatastoreHostMount hostMount : hostMounts) {
        String hostMountValue = hostMount.getKey().getValue();
        if (hostMountValue.equalsIgnoreCase(hostValue)) {
            HostMountInfo mountInfo = hostMount.getMountInfo();
            isAccessible = mountInfo.isAccessible();
            break;
        }
    }
    return isAccessible;
}
项目:cloudstack    文件:VmwareStorageProcessor.java   
private boolean isDatastoreMounted(DatastoreMO dsMO, HostMO hostToMatchMO) throws Exception {
    List<DatastoreHostMount> datastoreHostMounts = dsMO.getHostMounts();

    for (DatastoreHostMount datastoreHostMount : datastoreHostMounts) {
        ManagedObjectReference morHost = datastoreHostMount.getKey();
        HostMO hostMO = new HostMO(dsMO.getContext(), morHost);

        if (hostMO.getHostName().equals(hostToMatchMO.getHostName())) {
            return datastoreHostMount.getMountInfo().isMounted();
        }
    }

    throw new CloudRuntimeException("Unable to locate the applicable host");
}
项目:cloudstack    文件:DatastoreMO.java   
public List<DatastoreHostMount> getHostMounts() throws Exception {
    return _context.getVimClient().getDynamicProperty(_mor, "host");
}