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;
}
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);
}
}
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);
}
}
}
}
}
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);
}
}
}
}
}
}
}
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;
}
Aggregations