use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportAddVolume.
@Test
public void testExportAddVolume() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Volume> volumes = getVolumes(_storageSystem);
Volume volume = volumes.get(0);
Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
int lun = 1;
volumeMap.put(volume.getId(), lun);
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportAddVolumeCompleter(exportGroup.getId(), volumeMap, token);
_deviceController.doExportAddVolume(_storageSystem, exportMask, volume.getId(), lun, null, taskCompleter);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method exportGroupAddVolumes.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.impl.vplex.VplexController#exportAddVolume(java.net.URI, java.net.URI,
* java.net.URI,
* java.lang.Integer, java.lang.String)
*/
@Override
public void exportGroupAddVolumes(URI vplexURI, URI exportURI, Map<URI, Integer> volumeMap, String opId) throws ControllerException {
String volListStr = "";
ExportAddVolumeCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
completer = new ExportAddVolumeCompleter(exportURI, volumeMap, opId);
volListStr = Joiner.on(',').join(volumeMap.keySet());
Workflow workflow = _workflowService.getNewWorkflow(this, "exportGroupAddVolumes", true, opId);
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportURI);
StorageSystem vplexSystem = _dbClient.queryObject(StorageSystem.class, vplexURI);
URI srcVarray = exportGroup.getVirtualArray();
boolean isRecoverPointExport = ExportUtils.checkIfInitiatorsForRP(_dbClient, exportGroup.getInitiators());
if (!exportGroup.hasInitiators()) {
// VPLEX API restricts adding volumes before initiators
VPlexApiException.exceptions.cannotAddVolumesToExportGroupWithoutInitiators(exportGroup.forDisplay());
}
// Determine whether this export will be done across both VPLEX clusters,
// or just the src or ha varray.
// We get a map of varray to the volumes that can be exported in each varray.
Map<URI, Set<URI>> varrayToVolumes = VPlexUtil.mapBlockObjectsToVarrays(_dbClient, volumeMap.keySet(), vplexURI, exportGroup);
// Put the srcVolumes in their own set, and remove the src varray from the varrayToVolumes map.
Set<URI> srcVolumes = varrayToVolumes.get(srcVarray);
varrayToVolumes.remove(srcVarray);
URI haVarray = null;
// and we're not exporting to recover point initiators
if (!varrayToVolumes.isEmpty() && !isRecoverPointExport) {
if (exportGroup.hasAltVirtualArray(vplexURI.toString())) {
// If we've already chosen an haVarray, go with with the choice
haVarray = URI.create(exportGroup.getAltVirtualArrays().get(vplexURI.toString()));
} else {
// Otherwise we will make sure there is only one HA varray and persist it.
haVarray = VPlexUtil.pickHAVarray(varrayToVolumes);
}
}
// Partition the initiators by varray into varrayToInitiators map.
List<URI> varrayURIs = new ArrayList<URI>();
varrayURIs.add(exportGroup.getVirtualArray());
if (haVarray != null) {
varrayURIs.add(haVarray);
}
List<URI> exportGroupInitiatorList = StringSetUtil.stringSetToUriList(exportGroup.getInitiators());
Map<URI, List<URI>> varrayToInitiators = VPlexUtil.partitionInitiatorsByVarray(_dbClient, exportGroupInitiatorList, varrayURIs, vplexSystem);
if (varrayToInitiators.isEmpty()) {
throw VPlexApiException.exceptions.exportCreateNoinitiatorsHaveCorrectConnectivity(exportGroup.getInitiators().toString(), varrayURIs.toString());
}
findAndUpdateFreeHLUsForClusterExport(vplexSystem, exportGroup, exportGroupInitiatorList, volumeMap);
// Check if Zoning needs to be checked from system config
// call the doZoneExportMasksCreate to check/create/remove zones with the flag
String addZoneWhileAddingVolume = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ZONE_ADD_VOLUME, CustomConfigConstants.GLOBAL_KEY, null);
// Default behavior is we allow zoning checks against the Network System
Boolean addZoneOnDeviceOperation = true;
_log.info("zoneExportAddVolumes checking for custom config value {} to skip zoning checks : (Default) : {}", addZoneWhileAddingVolume, addZoneOnDeviceOperation);
if (addZoneWhileAddingVolume != null) {
addZoneOnDeviceOperation = Boolean.valueOf(addZoneWhileAddingVolume);
_log.info("Boolean convereted of : {} : returned by Config handler as : {} ", addZoneWhileAddingVolume, addZoneOnDeviceOperation);
} else {
_log.info("Config handler returned null for value so going by default value {}", addZoneOnDeviceOperation);
}
_log.info("zoneExportAddVolumes checking for custom config value {} to skip zoning checks : (Custom Config) : {}", addZoneWhileAddingVolume, addZoneOnDeviceOperation);
// Add all the volumes to the SRC varray if there are src side volumes and
// initiators that have connectivity to the source side.
String srcExportStepId = null;
if (varrayToInitiators.get(srcVarray) != null && srcVolumes != null) {
srcExportStepId = assembleExportMasksWorkflow(vplexURI, exportURI, srcVarray, varrayToInitiators.get(srcVarray), ExportMaskUtils.filterVolumeMap(volumeMap, srcVolumes), addZoneOnDeviceOperation, workflow, null, opId);
}
// and there are volumes to be added to the ha varray, do so.
if (haVarray != null && varrayToInitiators.get(haVarray) != null && varrayToVolumes.get(haVarray) != null) {
exportGroup.putAltVirtualArray(vplexURI.toString(), haVarray.toString());
_dbClient.updateObject(exportGroup);
assembleExportMasksWorkflow(vplexURI, exportURI, haVarray, varrayToInitiators.get(haVarray), ExportMaskUtils.filterVolumeMap(volumeMap, varrayToVolumes.get(haVarray)), addZoneOnDeviceOperation, workflow, srcExportStepId, opId);
}
// Initiate the workflow.
String message = String.format("VPLEX ExportGroup Add Volumes (%s) for export %s completed successfully", volListStr, exportURI);
workflow.executePlan(completer, message);
} catch (VPlexApiException vae) {
String message = String.format("Failed to add Volumes %s to ExportGroup %s", volListStr, exportURI);
_log.error(message, vae);
failStep(completer, opId, vae);
} catch (Exception ex) {
String message = String.format("Failed to add Volumes %s to ExportGroup %s", volListStr, exportURI);
_log.error(message, ex);
String opName = ResourceOperationTypeEnum.ADD_EXPORT_VOLUME.getName();
ServiceError serviceError = VPlexApiException.errors.exportGroupAddVolumesFailed(volListStr, exportURI.toString(), opName, ex);
failStep(completer, opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method testExportAddVolumes.
@Test
public void testExportAddVolumes() {
ExportGroup exportGroup = getExportGroup();
ExportMask exportMask = getExportMask();
List<Volume> volumes = getVolumes(_storageSystem);
Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
int lun = 1;
for (Volume volume : volumes) {
volumeMap.put(volume.getId(), lun++);
}
String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
ExportTaskCompleter taskCompleter = new ExportAddVolumeCompleter(exportGroup.getId(), volumeMap, token);
_deviceController.doExportAddVolumes(_storageSystem, exportMask, null, volumeMap, taskCompleter);
}
Aggregations