use of com.emc.sa.service.vmware.block.tasks.SetMultipathPolicy in project coprhd-controller by CoprHD.
the class VMwareSupport method setMultipathPolicy.
/**
* Sets the multipath policy on the disks for the given host/cluster
*
* @param host
* the host to which the volume is assigned.
* @param cluster
* the cluster to which the volume is associated (may be null if the storage is exclusive to the host)
* @param multipathPolicy
* the multipath policy to use.
* @param volume
* the volume with the created datastore.
*/
public void setMultipathPolicy(HostSystem host, ClusterComputeResource cluster, String multipathPolicy, BlockObjectRestRep volume) {
if (VMwareUtils.isValidMultipathPolicy(multipathPolicy)) {
Map<HostSystem, HostScsiDisk> hostDisks = Maps.newHashMap();
if (cluster != null) {
List<HostSystem> clusterHosts = Lists.newArrayList(cluster.getHosts());
for (HostSystem clusterHost : clusterHosts) {
if (isHostConnected(clusterHost)) {
try {
HostScsiDisk disk = execute(new FindHostScsiDiskForLun(clusterHost, volume));
hostDisks.put(clusterHost, disk);
} catch (Exception ex) {
logWarn("vmware.support.multipath.policy.volumenotfound", volume.getWwn(), clusterHost.getName());
}
}
}
} else if (host != null) {
try {
HostScsiDisk disk = execute(new FindHostScsiDiskForLun(host, volume));
hostDisks.put(host, disk);
} catch (Exception e) {
logWarn("vmware.support.multipath.policy.volumenotfound", volume.getWwn(), host.getName());
}
}
if (hostDisks.size() > 0) {
execute(new SetMultipathPolicy(hostDisks, multipathPolicy));
}
}
}
Aggregations