use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportRemoveVolume.
@Test
public void testExportRemoveVolume() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Volume> volumes = getVolumes(_storageSystem);
Volume volume = volumes.get(0);
List<URI> volumeURIs = new ArrayList<URI>(1);
volumeURIs.add(volume.getId());
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportRemoveVolumeCompleter(exportGroup.getId(), volumeURIs, token);
_deviceController.doExportRemoveVolume(_storageSystem, exportMask, volume.getId(), null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportAddInitiators.
@Test
public void testExportAddInitiators() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Initiator> initiators = getInitiators();
List<URI> initiatorURIs = new ArrayList<URI>();
List<Initiator> initiatorArgs = new ArrayList<Initiator>();
for (Initiator initiator : initiators) {
if (initiator.getInitiatorPort().endsWith("2")) {
initiatorURIs.add(initiator.getId());
initiatorArgs.add(initiator);
}
}
List<URI> targets = new ArrayList<URI>();
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportAddInitiatorCompleter(exportGroup.getId(), initiatorURIs, token);
_deviceController.doExportAddInitiators(_storageSystem, exportMask, null, initiatorArgs, targets, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportGroupCreation.
@Test
public void testExportGroupCreation() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
int lun = 1;
Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
for (Volume volume : getVolumes(_storageSystem)) {
volumeMap.put(volume.getId(), lun++);
break;
}
List<Initiator> initiatorList = getInitiators();
List<URI> initiatorURIs = new ArrayList<URI>();
for (Initiator initiator : initiatorList) {
initiatorURIs.add(initiator.getId());
}
String maskingStep = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportMaskCreateCompleter(exportGroup.getId(), exportMask.getId(), initiatorURIs, volumeMap, maskingStep);
_deviceController.doExportCreate(_storageSystem, exportMask, volumeMap, initiatorList, null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceExportController method exportGroupDelete.
/**
* Delete the export.
*
* @param export URI of ExportGroup
* @param opId Operation ID
* @throws com.emc.storageos.volumecontroller.ControllerException
*/
@Override
public void exportGroupDelete(URI export, String opId) throws ControllerException {
ExportTaskCompleter taskCompleter = new ExportDeleteCompleter(export, false, opId);
Workflow workflow = null;
try {
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, export);
if (exportGroup != null && exportGroup.getExportMasks() != null) {
workflow = _wfUtils.newWorkflow("exportGroupDelete", false, opId);
if (NullColumnValueGetter.isNullValue(exportGroup.getType())) {
// (VPLEX backend groups have a null export group type, for instance)
throw DeviceControllerException.exceptions.exportGroupDeleteUnsupported(exportGroup.forDisplay());
}
Set<URI> storageSystemURIs = new HashSet<URI>();
// Use temp set to prevent ConcurrentModificationException
List<ExportMask> tempExportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup);
for (ExportMask tempExportMask : tempExportMasks) {
List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroup.ExportGroupType.valueOf(exportGroup.getType()), StringSetUtil.stringSetToUriList(exportGroup.getInitiators()), tempExportMask.getStorageDevice());
boolean acquiredLocks = _wfUtils.getWorkflowService().acquireWorkflowLocks(workflow, lockKeys, LockTimeoutValue.get(LockType.EXPORT_GROUP_OPS));
if (!acquiredLocks) {
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), "ExportGroupDelete: " + exportGroup.getLabel());
}
if (tempExportMask != null && tempExportMask.getVolumes() != null) {
List<URI> uriList = getExportRemovableObjects(exportGroup, tempExportMask);
Map<URI, List<URI>> storageToVolumes = getStorageToVolumes(uriList);
for (URI storageURI : storageToVolumes.keySet()) {
if (!storageSystemURIs.contains(storageURI)) {
storageSystemURIs.add(storageURI);
_wfUtils.generateExportGroupDeleteWorkflow(workflow, null, null, storageURI, export);
}
}
} else {
exportGroup.removeExportMask(tempExportMask.getId());
_dbClient.updateObject(exportGroup);
}
}
workflow.executePlan(taskCompleter, "Removed export from all devices.");
} else {
taskCompleter.ready(_dbClient);
}
} catch (Exception ex) {
String message = "exportGroupDelete caught an exception.";
_log.error(message, ex);
if (workflow != null) {
_wfUtils.getWorkflowService().releaseAllWorkflowLocks(workflow);
}
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceExportController method exportGroupCreate.
/**
* Export one or more volumes. The volumeToExports parameter has
* all the information required to do the add volumes operation.
*
* @param export URI of ExportMask
* @param volumeMap Volume-lun map to be part of the export mask
* @param initiatorURIs List of URIs for the initiators to be added to the export mask
* @param opId Operation ID
* @throws com.emc.storageos.volumecontroller.ControllerException
*/
@Override
public void exportGroupCreate(URI export, Map<URI, Integer> volumeMap, List<URI> initiatorURIs, String opId) throws ControllerException {
ExportTaskCompleter taskCompleter = new ExportCreateCompleter(export, volumeMap, opId);
Workflow workflow = null;
try {
// Do some initial sanitizing of the export parameters
StringSetUtil.removeDuplicates(initiatorURIs);
workflow = _wfUtils.newWorkflow("exportGroupCreate", false, opId);
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, export);
Map<URI, Map<URI, Integer>> storageToVolumes = getStorageToVolumeMap(volumeMap);
for (Map.Entry<URI, Map<URI, Integer>> entry : storageToVolumes.entrySet()) {
List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroup.ExportGroupType.valueOf(exportGroup.getType()), initiatorURIs, entry.getKey());
boolean acquiredLocks = _wfUtils.getWorkflowService().acquireWorkflowLocks(workflow, lockKeys, LockTimeoutValue.get(LockType.EXPORT_GROUP_OPS));
if (!acquiredLocks) {
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), "ExportGroupCreate: " + exportGroup.getLabel());
}
// Initialize the Map of objects to export with all objects.
Map<URI, Integer> objectsToAdd = new HashMap<URI, Integer>(entry.getValue());
String waitFor = null;
ProtectionExportController protectionController = getProtectionExportController();
waitFor = protectionController.addStepsForExportGroupCreate(workflow, null, waitFor, export, objectsToAdd, entry.getKey(), initiatorURIs);
if (!objectsToAdd.isEmpty()) {
// There are no export BlockObjects tied to the current storage system that have an associated protection
// system. We can just create a step to call the block controller directly for export group create.
_log.info(String.format("Generating exportGroupCreates steps for objects %s associated with storage system [%s]", objectsToAdd, entry.getKey()));
_wfUtils.generateExportGroupCreateWorkflow(workflow, null, waitFor, entry.getKey(), export, objectsToAdd, initiatorURIs);
}
}
workflow.executePlan(taskCompleter, "Exported to all devices successfully.");
} catch (Exception ex) {
String message = "exportGroupCreate caught an exception.";
_log.error(message, ex);
_wfUtils.getWorkflowService().releaseAllWorkflowLocks(workflow);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
taskCompleter.error(_dbClient, serviceError);
}
}
Aggregations