Search in sources :

Example 71 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class ReplicaDeviceController method addStepsForDeleteVolumes.

@Override
public String addStepsForDeleteVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> volumes, String taskId) throws InternalException {
    // Get the list of descriptors which represent source volumes to be deleted
    List<VolumeDescriptor> volumeDescriptors = VolumeDescriptor.filterByType(volumes, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.SRDF_SOURCE, VolumeDescriptor.Type.SRDF_EXISTING_SOURCE, VolumeDescriptor.Type.SRDF_TARGET }, null);
    // If no source volumes, just return
    if (volumeDescriptors.isEmpty()) {
        log.info("No replica steps required");
        return waitFor;
    }
    List<URI> volumeDescriptorURIs = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
    List<Volume> unfilteredVolumes = _dbClient.queryObject(Volume.class, volumeDescriptorURIs);
    // Filter Volume list, returning if no volumes passed.
    Collection<Volume> filteredVolumes = filter(unfilteredVolumes, deleteVolumeFilterPredicate());
    if (filteredVolumes.isEmpty()) {
        return waitFor;
    }
    Map<String, Set<URI>> rgVolsMap = sortVolumesBySystemAndReplicationGroup(filteredVolumes);
    for (Set<URI> volumeURIs : rgVolsMap.values()) {
        // find member volumes in the group
        List<Volume> volumeList = getVolumes(filteredVolumes, volumeURIs);
        if (volumeList.isEmpty()) {
            continue;
        }
        Volume firstVol = volumeList.get(0);
        String rpName = firstVol.getReplicationGroupInstance();
        URI storage = firstVol.getStorageController();
        boolean isRemoveAllFromRG = ControllerUtils.replicationGroupHasNoOtherVolume(_dbClient, rpName, volumeURIs, storage);
        log.info("isRemoveAllFromRG {}", isRemoveAllFromRG);
        if (checkIfCGHasCloneReplica(volumeList)) {
            log.info("Adding clone steps for deleting volumes");
            waitFor = detachCloneSteps(workflow, waitFor, volumeURIs, volumeList, isRemoveAllFromRG);
        }
        if (checkIfCGHasMirrorReplica(volumeList)) {
            log.info("Adding mirror steps for deleting volumes");
            // delete mirrors for the to be deleted volumes
            waitFor = deleteMirrorSteps(workflow, waitFor, volumeURIs, volumeList, isRemoveAllFromRG);
        }
        if (checkIfCGHasSnapshotReplica(volumeList)) {
            log.info("Adding snapshot steps for deleting volumes");
            // delete snapshots for the to be deleted volumes
            waitFor = deleteSnapshotSteps(workflow, waitFor, volumeURIs, volumeList, isRemoveAllFromRG);
        }
        if (checkIfCGHasSnapshotSessions(volumeList)) {
            log.info("Adding snapshot session steps for deleting volumes");
            waitFor = deleteSnapshotSessionSteps(workflow, waitFor, volumeList, isRemoveAllFromRG);
        }
    }
    return waitFor;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 72 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class VolumeCreateWorkflowCompleter method handleVplexVolumeErrors.

private void handleVplexVolumeErrors(DbClient dbClient) {
    List<String> finalMessages = new ArrayList<String>();
    for (VolumeDescriptor volumeDescriptor : VolumeDescriptor.getDescriptors(_volumeDescriptors, VolumeDescriptor.Type.VPLEX_VIRT_VOLUME)) {
        Volume volume = dbClient.queryObject(Volume.class, volumeDescriptor.getVolumeURI());
        _log.info("Looking at VPLEX virtual volume {}", volume.getLabel());
        boolean deactivateVirtualVolume = true;
        List<String> livingVolumeNames = new ArrayList<String>();
        _log.info("Its associated volumes are: " + volume.getAssociatedVolumes());
        if (null != volume.getAssociatedVolumes()) {
            for (String associatedVolumeUri : volume.getAssociatedVolumes()) {
                Volume associatedVolume = dbClient.queryObject(Volume.class, URI.create(associatedVolumeUri));
                if (associatedVolume != null && !associatedVolume.getInactive()) {
                    _log.warn("VPLEX virtual volume {} has active associated volume {}", volume.getLabel(), associatedVolume.getLabel());
                    livingVolumeNames.add(associatedVolume.getLabel());
                    deactivateVirtualVolume = false;
                }
            }
        }
        if (deactivateVirtualVolume) {
            _log.info("VPLEX virtual volume {} has no active associated volumes, marking for deletion", volume.getLabel());
            dbClient.markForDeletion(volume);
        } else {
            String message = "VPLEX virtual volume " + volume.getLabel() + " will not be marked for deletion " + "because it still has active associated volumes (";
            message += Joiner.on(",").join(livingVolumeNames) + ")";
            finalMessages.add(message);
            _log.warn(message);
        }
    }
    if (!finalMessages.isEmpty()) {
        String finalMessage = Joiner.on("; ").join(finalMessages) + ".";
        _log.error(finalMessage);
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList)

Example 73 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class VplexDBCkr method cleanupForViPROnlyDelete.

public void cleanupForViPROnlyDelete(List<VolumeDescriptor> volumeDescriptors) {
    // Remove volumes from ExportGroup(s) and ExportMask(s).
    List<URI> volumeURIs = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
    for (URI volumeURI : volumeURIs) {
        cleanBlockObjectFromExports(volumeURI, true);
    }
    // Clean up the relationship between vplex volumes that are full
    // copies and and their source vplex volumes.
    List<VolumeDescriptor> vplexVolumeDescriptors = VolumeDescriptor.getDescriptors(volumeDescriptors, VolumeDescriptor.Type.VPLEX_VIRT_VOLUME);
    List<URI> vplexvolumeURIs = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
    for (URI volumeURI : vplexvolumeURIs) {
        Volume volume = dbClient.queryObject(Volume.class, volumeURI);
        URI sourceVolumeURI = volume.getAssociatedSourceVolume();
        if (!NullColumnValueGetter.isNullURI(sourceVolumeURI)) {
            // The volume being removed is a full copy. Make sure the copies
            // list of the source no longer references this volume. Note
            // that it is possible that the source was already deleted but
            // we left the source URI set in the copy, so one could always
            // know the source of the copy. So, check for a null source
            // volume.
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeURI);
            if (sourceVolume != null) {
                StringSet fullCopyIds = sourceVolume.getFullCopies();
                if (fullCopyIds.contains(volumeURI.toString())) {
                    fullCopyIds.remove(volumeURI.toString());
                    dbClient.updateObject(sourceVolume);
                }
            }
        }
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI)

Example 74 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class VplexDBCkr method addDescriptorsForVplexMirrors.

public void addDescriptorsForVplexMirrors(List<VolumeDescriptor> descriptors, Volume vplexVolume) {
    if (vplexVolume.getMirrors() != null && vplexVolume.getMirrors().isEmpty() == false) {
        for (String mirrorId : vplexVolume.getMirrors()) {
            VplexMirror mirror = dbClient.queryObject(VplexMirror.class, URI.create(mirrorId));
            if (mirror != null && !mirror.getInactive()) {
                if (null != mirror.getAssociatedVolumes()) {
                    for (String assocVolumeId : mirror.getAssociatedVolumes()) {
                        Volume volume = dbClient.queryObject(Volume.class, URI.create(assocVolumeId));
                        if (volume != null && !volume.getInactive()) {
                            VolumeDescriptor volDesc = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, volume.getStorageController(), URI.create(assocVolumeId), null, null);
                            descriptors.add(volDesc);
                        }
                    }
                }
            }
        }
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) VplexMirror(com.emc.storageos.db.client.model.VplexMirror)

Example 75 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method getBootVolumeIdFromDescriptors.

/**
 * Given a list of volume descriptors, get the boot volume URI.  If the host and its boot volume
 * ID are filled-in, verify that as well.  Since the Host's boot volume ID gets cleared out, this
 * step is not required.
 *
 * The goal of this method is to first search for any VPLEX volume(s).  Failing finding any of those,
 * get the backing volumes.  The key is to get the host-facing volume.
 *
 * @param volumeDescriptors volume descriptors, could be a mix of vplex and backing volumes
 * @param host host for debug and validation
 * @return the boot volume ID from the volume descriptors
 */
private static URI getBootVolumeIdFromDescriptors(List<VolumeDescriptor> volumeDescriptors, Host host) {
    // Get only the VPLEX volume(s) from the descriptors.
    List<VolumeDescriptor> bootVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.VPLEX_VIRT_VOLUME }, new VolumeDescriptor.Type[] {});
    // If there are no VPlex volumes, grab the block volumes
    if (bootVolumeDescriptors.isEmpty()) {
        bootVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA }, new VolumeDescriptor.Type[] {});
    }
    // Ensure there is one and only one volume descriptor.
    if (bootVolumeDescriptors == null || bootVolumeDescriptors.size() != 1) {
        throw new IllegalStateException("Could not locate VolumeDescriptor(s) for boot volume " + host.getLabel());
    }
    // Ensure if there is a host boot volume ID that they match up.
    URI bootVolumeURI = bootVolumeDescriptors.get(0).getVolumeURI();
    if (host != null && !NullColumnValueGetter.isNullURI(host.getBootVolumeId()) && !host.getBootVolumeId().equals(bootVolumeURI)) {
        throw new IllegalStateException("Boot volume requested for deletion is different than host's marked boot volume " + host.getLabel());
    }
    return bootVolumeURI;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) URI(java.net.URI)

Aggregations

VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)117 Volume (com.emc.storageos.db.client.model.Volume)98 URI (java.net.URI)86 NamedURI (com.emc.storageos.db.client.model.NamedURI)77 ArrayList (java.util.ArrayList)77 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)38 HashMap (java.util.HashMap)38 StringSet (com.emc.storageos.db.client.model.StringSet)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)27 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)18 Workflow (com.emc.storageos.workflow.Workflow)18 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)17 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 List (java.util.List)17 BlockOrchestrationController (com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController)16 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)16 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 URISyntaxException (java.net.URISyntaxException)16 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)15