use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportAddInitiator.
@Test
public void testExportAddInitiator() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
Initiator initiator = getInitiators().get(0);
List<URI> initiatorURIs = new ArrayList<URI>();
initiatorURIs.add(initiator.getId());
List<URI> targets = new ArrayList<URI>();
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportAddInitiatorCompleter(exportGroup.getId(), initiatorURIs, token);
_deviceController.doExportAddInitiator(_storageSystem, exportMask, null, initiator, targets, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method exportGroupAddInitiators.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.impl.vplex.VplexController#exportAddInitiator(java.net.URI, java.net.URI,
* java.net.URI,
* java.lang.String)
*/
@Override
public void exportGroupAddInitiators(URI vplexURI, URI exportURI, List<URI> initiatorURIs, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem vplex = getDataObject(StorageSystem.class, vplexURI, _dbClient);
ExportGroup exportGroup = getDataObject(ExportGroup.class, exportURI, _dbClient);
ExportAddInitiatorCompleter completer = new ExportAddInitiatorCompleter(exportURI, initiatorURIs, opId);
Workflow workflow = _workflowService.getNewWorkflow(this, "exportAddInitiator", true, opId);
boolean isRecoverPointExport = ExportUtils.checkIfInitiatorsForRP(_dbClient, exportGroup.getInitiators());
initiatorURIs = VPlexUtil.filterInitiatorsForVplex(_dbClient, initiatorURIs);
// get a map of host URI to a list of Initiators in that Host
Map<URI, List<Initiator>> hostInitiatorsMap = VPlexUtil.makeHostInitiatorsMap(initiatorURIs, _dbClient);
// Get the varrays involved.
List<URI> varrayList = new ArrayList<URI>();
varrayList.add(exportGroup.getVirtualArray());
// if already present, or create an altVirtualArray if there are distributed volumes.
if (!isRecoverPointExport) {
if ((exportGroup.getAltVirtualArrays() != null) && (exportGroup.getAltVirtualArrays().get(vplexURI.toString()) != null)) {
// If there is an alternate Varray entry for this Vplex, it indicates we have HA volumes.
varrayList.add(URI.create(exportGroup.getAltVirtualArrays().get(vplexURI.toString())));
} else {
// Check to see if there are distributed volumes. If so, maybe we
// could export to both varrays.
Map<URI, Integer> volumeMap = ExportUtils.getExportGroupVolumeMap(_dbClient, vplex, exportGroup);
Map<URI, Set<URI>> varrayToVolumes = VPlexUtil.mapBlockObjectsToVarrays(_dbClient, volumeMap.keySet(), vplexURI, exportGroup);
// Remove the local volumes
varrayToVolumes.remove(exportGroup.getVirtualArray());
if (!varrayToVolumes.isEmpty()) {
URI haVarray = VPlexUtil.pickHAVarray(varrayToVolumes);
exportGroup.putAltVirtualArray(vplex.toString(), haVarray.toString());
_dbClient.updateObject(exportGroup);
}
}
}
// Process each host separately.
String previousStep = null;
for (URI hostURI : hostInitiatorsMap.keySet()) {
List<URI> initURIs = new ArrayList<URI>();
for (Initiator initiator : hostInitiatorsMap.get(hostURI)) {
initURIs.add(initiator.getId());
}
// Partition the Initiators by Varray. We may need to do two different ExportMasks,
// one for each of the varrays.
Map<URI, List<URI>> varraysToInitiators = VPlexUtil.partitionInitiatorsByVarray(_dbClient, initURIs, varrayList, vplex);
if (varraysToInitiators.isEmpty()) {
throw VPlexApiException.exceptions.exportCreateNoinitiatorsHaveCorrectConnectivity(exportGroup.getInitiators().toString(), varrayList.toString());
}
// Now process the Initiators for a host and a given varray.
for (URI varrayURI : varraysToInitiators.keySet()) {
initURIs = varraysToInitiators.get(varrayURI);
List<Initiator> initiators = new ArrayList<Initiator>();
for (Initiator initiator : hostInitiatorsMap.get(hostURI)) {
if (initURIs.contains(initiator.getId())) {
initiators.add(initiator);
}
}
if (!initiators.isEmpty()) {
previousStep = addStepsForAddInitiators(workflow, vplex, exportGroup, varrayURI, initURIs, initiators, hostURI, previousStep, opId);
}
}
}
// Fire off the Workflow
String message = String.format("Successfully added initiators %s to ExportGroup %s", initiatorURIs.toString(), exportGroup.getLabel());
workflow.executePlan(completer, "Successfully added initiators: " + message);
} catch (VPlexApiException vae) {
_log.error("Exception adding initiators to Storage View: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(opId, vae);
} catch (Exception ex) {
_log.error("Exception adding initiators to Storage View: " + ex.getMessage(), ex);
String opName = ResourceOperationTypeEnum.ADD_EXPORT_INITIATOR.getName();
ServiceError serviceError = VPlexApiException.errors.exportGroupAddInitiatorsFailed(opName, ex);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter 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);
}
Aggregations