use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter in project coprhd-controller by CoprHD.
the class AbstractDefaultMaskingOrchestrator method generateExportMaskCreateWorkflow.
/**
* Creates an ExportMask Workflow that generates a new ExportMask in an existing ExportGroup.
*
* @param workflow
* workflow to add steps to
* @param previousStep
* previous step before these steps
* @param storage
* storage system
* @param exportGroup
* export group
* @param initiatorURIs
* initiators impacted by this operation
* @param volumeMap
* volumes
* @param token
* step ID
* @return URI of the new ExportMask
* @throws Exception
*/
public GenExportMaskCreateWorkflowResult generateExportMaskCreateWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, List<URI> initiatorURIs, Map<URI, Integer> volumeMap, String token) throws Exception {
URI exportGroupURI = exportGroup.getId();
URI storageURI = storage.getId();
List<Initiator> initiators = null;
if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
} else {
_log.error("Internal Error: Need to add the initiatorURIs to the call that assembles this step.");
}
// Create and initialize the Export Mask. This involves assigning and
// allocating the Storage Ports (targets).
ExportPathParams pathParams = _blockScheduler.calculateExportPathParamForVolumes(volumeMap.keySet(), exportGroup.getNumPaths(), storage.getId(), exportGroup.getId());
if (exportGroup.getType() != null) {
pathParams.setExportGroupType(exportGroup.getType());
}
if (exportGroup.getZoneAllInitiators()) {
pathParams.setAllowFewerPorts(true);
}
URI portGroupURI = null;
if (pathParams.getPortGroup() != null) {
portGroupURI = pathParams.getPortGroup();
StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, portGroupURI);
_log.info(String.format("port group is %s", portGroup.getLabel()));
List<URI> storagePorts = StringSetUtil.stringSetToUriList(portGroup.getStoragePorts());
if (!CollectionUtils.isEmpty(storagePorts)) {
pathParams.setStoragePorts(StringSetUtil.uriListToStringSet(storagePorts));
} else {
_log.error(String.format("The port group %s does not have any port members", portGroup));
throw DeviceControllerException.exceptions.noPortMembersInPortGroupError(portGroup.getLabel());
}
}
Map<URI, List<URI>> assignments = _blockScheduler.assignStoragePorts(storage, exportGroup, initiators, null, pathParams, volumeMap.keySet(), _networkDeviceController, exportGroup.getVirtualArray(), token);
List<URI> targets = BlockStorageScheduler.getTargetURIsFromAssignments(assignments);
String maskName = useComputedMaskName() ? getComputedExportMaskName(storage, exportGroup, initiators) : null;
// can be done differently
if (exportGroup.checkInternalFlags(Flag.RECOVERPOINT_JOURNAL)) {
maskName += "_journal";
}
ExportMask exportMask = ExportMaskUtils.initializeExportMask(storage, exportGroup, initiators, volumeMap, targets, assignments, maskName, _dbClient);
if (portGroupURI != null) {
exportMask.setPortGroup(portGroupURI);
}
List<BlockObject> vols = new ArrayList<BlockObject>();
for (URI boURI : volumeMap.keySet()) {
BlockObject bo = BlockObject.fetch(_dbClient, boURI);
vols.add(bo);
}
exportMask.addToUserCreatedVolumes(vols);
_dbClient.updateObject(exportMask);
// Make a new TaskCompleter for the exportStep. It has only one subtask.
// This is due to existing requirements in the doExportGroupCreate completion
// logic.
String maskingStep = workflow.createStepId();
ExportTaskCompleter exportTaskCompleter = new ExportMaskCreateCompleter(exportGroupURI, exportMask.getId(), initiatorURIs, volumeMap, maskingStep);
Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupCreate", storageURI, exportGroupURI, exportMask.getId(), volumeMap, initiatorURIs, targets, exportTaskCompleter);
Workflow.Method maskingRollbackMethod = new Workflow.Method("rollbackExportGroupCreate", storageURI, exportGroupURI, exportMask.getId(), maskingStep);
maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Creating mask %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, maskingRollbackMethod, maskingStep);
return new GenExportMaskCreateWorkflowResult(exportMask.getId(), maskingStep);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter 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);
}
Aggregations