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