Search in sources :

Example 1 with SetMultipathPolicy

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));
        }
    }
}
Also used : FindHostScsiDiskForLun(com.emc.sa.service.vmware.block.tasks.FindHostScsiDiskForLun) SetMultipathPolicy(com.emc.sa.service.vmware.block.tasks.SetMultipathPolicy) HostSystem(com.vmware.vim25.mo.HostSystem) HostScsiDisk(com.vmware.vim25.HostScsiDisk) ExecutionException(com.emc.sa.engine.ExecutionException) VMWareException(com.iwave.ext.vmware.VMWareException)

Aggregations

ExecutionException (com.emc.sa.engine.ExecutionException)1 FindHostScsiDiskForLun (com.emc.sa.service.vmware.block.tasks.FindHostScsiDiskForLun)1 SetMultipathPolicy (com.emc.sa.service.vmware.block.tasks.SetMultipathPolicy)1 VMWareException (com.iwave.ext.vmware.VMWareException)1 HostScsiDisk (com.vmware.vim25.HostScsiDisk)1 HostSystem (com.vmware.vim25.mo.HostSystem)1