Search in sources :

Example 56 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class FailoverBlockVolumeService method precheck.

@Override
public void precheck() {
    String sourceId = "";
    String targetId = "";
    String targetName = "";
    String sourceName = "";
    if (ConsistencyUtils.isVolumeStorageType(storageType)) {
        // The type selected is volume
        BlockObjectRestRep targetVolume = BlockStorageUtils.getVolume(protectionTarget);
        BlockObjectRestRep sourceVolume = BlockStorageUtils.getVolume(protectionSource);
        type = BlockStorageUtils.getFailoverType(targetVolume);
        targetId = stringId(targetVolume);
        targetName = targetVolume.getName();
        sourceId = stringId(sourceVolume);
        sourceName = sourceVolume.getName();
    } else {
        // The type selected is consistency group
        BlockConsistencyGroupRestRep cg = BlockStorageUtils.getBlockConsistencyGroup(protectionSource);
        VirtualArrayRestRep virtualArray = BlockStorageUtils.getVirtualArray(protectionTarget);
        type = ConsistencyUtils.getFailoverType(cg);
        targetId = stringId(virtualArray);
        targetName = virtualArray.getName();
        sourceId = stringId(cg);
        sourceName = cg.getName();
    }
    if (type == null) {
        ExecutionUtils.fail("failTask.FailoverBlockVolumeService", args(sourceId, targetId), args());
    }
    if (type.equals(RECOVER_POINT) && BlockProvider.PIT_IMAGE_OPTION_KEY.equals(imageToAccess) && pointInTime == null) {
        ExecutionUtils.fail("failTask.FailoverBlockVolumeService.pit", new Object[] {}, new Object[] {});
    }
    // TODO: Add new fields
    logInfo("fail.over.block.volume.service", type.toUpperCase(), sourceName, targetName);
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 57 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class SwapContinuousCopiesService method precheck.

@Override
public void precheck() throws Exception {
    super.precheck();
    String sourceId = "";
    String targetId = "";
    String targetName = "";
    String sourceName = "";
    if (ConsistencyUtils.isVolumeStorageType(storageType)) {
        // The type selected is volume
        BlockObjectRestRep targetVolume = BlockStorageUtils.getVolume(protectionTarget);
        BlockObjectRestRep sourceVolume = BlockStorageUtils.getVolume(protectionSource);
        type = BlockStorageUtils.getFailoverType(targetVolume);
        targetId = stringId(targetVolume);
        targetName = targetVolume.getName();
        sourceId = stringId(sourceVolume);
        sourceName = sourceVolume.getName();
    } else {
        // The type selected is consistency group
        BlockConsistencyGroupRestRep cg = BlockStorageUtils.getBlockConsistencyGroup(protectionSource);
        VirtualArrayRestRep virtualArray = BlockStorageUtils.getVirtualArray(protectionTarget);
        type = ConsistencyUtils.getFailoverType(cg);
        targetId = stringId(virtualArray);
        targetName = virtualArray.getName();
        sourceId = stringId(cg);
        sourceName = cg.getName();
    }
    if (type == null) {
        ExecutionUtils.fail("failTask.SwapContinuousCopiesService", args(sourceId, targetId), args());
    }
    logInfo("swap.continuous.copies.service.precheck", type.toUpperCase(), sourceName, targetName);
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 58 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class UnexportHostService method precheck.

@Override
public void precheck() {
    host = BlockStorageUtils.getHost(hostId);
    String hostName = host.getLabel();
    exports = BlockStorageUtils.findExportsContainingHost(hostId, null, null);
    if (exports.isEmpty()) {
        ExecutionUtils.fail("failTask.UnexportHostService.export", args(), args(hostName));
    }
    volumes = BlockStorageUtils.getBlockResources(uris(volumeIds));
    if (volumes.isEmpty()) {
        ExecutionUtils.fail("failTask.UnexportHostService.volumes", args(), args());
    }
    if (volumes.size() < volumeIds.size()) {
        logWarn("unexport.host.service.not.found", volumeIds.size(), volumes.size());
    }
    for (ExportGroupRestRep export : exports) {
        for (BlockObjectRestRep volume : volumes) {
            URI volumeId = ResourceUtils.id(volume);
            if (BlockStorageUtils.isVolumeInExportGroup(export, volumeId) && StringUtils.equalsIgnoreCase(export.getType(), ExportGroupType.Cluster.name())) {
                ExecutionUtils.fail("failTask.UnexportHostService.clusterExport", args(), args(export.getName()));
            }
        }
    }
    checkForBootVolumes(volumeIds);
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 59 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class UnexportHostService method execute.

@Override
public void execute() throws Exception {
    for (ExportGroupRestRep export : exports) {
        URI exportId = ResourceUtils.id(export);
        String exportName = ResourceUtils.name(export);
        // Check each volume to see if it is in this export
        Set<URI> exportedVolumeIds = Sets.newHashSet();
        for (BlockObjectRestRep volume : volumes) {
            URI volumeId = ResourceUtils.id(volume);
            String volumeName = ResourceUtils.name(volume);
            if (BlockStorageUtils.isVolumeInExportGroup(export, volumeId)) {
                logInfo("unexport.host.service.volume.in.export", volumeName, exportName);
                exportedVolumeIds.add(volumeId);
            }
        }
        if (!exportedVolumeIds.isEmpty()) {
            logInfo("unexport.host.service.volume.remove", exportedVolumeIds.size(), exportName);
            BlockStorageUtils.removeBlockResourcesFromExport(exportedVolumeIds, exportId);
        } else {
            logDebug("unexport.host.service.volume.skip", exportName);
        }
        String hostOrClusterId = BlockStorageUtils.getHostOrClusterId(hostId);
        if (hostOrClusterId != null) {
            ExecutionUtils.addAffectedResource(hostOrClusterId.toString());
        }
    }
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Aggregations

BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)59 URI (java.net.URI)29 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)8 Host (com.emc.storageos.db.client.model.Host)7 DiskDrive (com.iwave.ext.windows.model.wmi.DiskDrive)7 ArrayList (java.util.ArrayList)7 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 Datastore (com.vmware.vim25.mo.Datastore)5 Map (java.util.Map)5 ExecutionException (com.emc.sa.engine.ExecutionException)4 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)4 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)4 GetHost (com.emc.sa.service.vipr.tasks.GetHost)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)3 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)3 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 Disk (com.iwave.ext.windows.model.Disk)3 ResourceType (com.emc.sa.util.ResourceType)2