Search in sources :

Example 1 with GetBlockVolumeByWWN

use of com.emc.sa.service.vipr.block.tasks.GetBlockVolumeByWWN in project coprhd-controller by CoprHD.

the class VMwareSupport method verifyVolumesBackingDatastore.

/**
 * Finds the volumes backing the datastore.
 *
 * @param host
 *            the actual host system
 * @param hostId
 *            host ID
 * @param datastore
 *            the datastore.
 * @return the volumes backing the host system.
 */
public List<VolumeRestRep> verifyVolumesBackingDatastore(HostSystem host, URI hostId, Datastore datastore) {
    Set<String> luns = execute(new FindLunsBackingDatastore(host, datastore));
    List<VolumeRestRep> volumes = Lists.newArrayList();
    for (String lun : luns) {
        VolumeRestRep volume = execute(new GetBlockVolumeByWWN(lun));
        if (volume != null) {
            // VBDU: Check to ensure the correct datastore tag is in the volume returned
            String tagValue = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
            if (tagValue == null || !tagValue.equalsIgnoreCase(datastore.getName())) {
                String viprcliCommand = BlockStorageUtils.getVolumeTagCommand(volume.getId(), KnownMachineTags.getVMFSDatastoreTagName(hostId), datastore.getName());
                throw new IllegalStateException(ExecutionUtils.getMessage("vmware.support.datastore.doesntmatchvolume", volume.getName(), volume.getWwn(), datastore.getName(), viprcliCommand));
            }
            volumes.add(volume);
        } else {
            throw new IllegalStateException(ExecutionUtils.getMessage("vmware.support.datastore.volumenotfound", lun, datastore.getName()));
        }
    }
    return volumes;
}
Also used : FindLunsBackingDatastore(com.emc.sa.service.vmware.block.tasks.FindLunsBackingDatastore) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) GetBlockVolumeByWWN(com.emc.sa.service.vipr.block.tasks.GetBlockVolumeByWWN)

Aggregations

GetBlockVolumeByWWN (com.emc.sa.service.vipr.block.tasks.GetBlockVolumeByWWN)1 FindLunsBackingDatastore (com.emc.sa.service.vmware.block.tasks.FindLunsBackingDatastore)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1