Search in sources :

Example 6 with ExportMaskCreateCompleter

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);
}
Also used : StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) ExportMaskCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams)

Example 7 with ExportMaskCreateCompleter

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);
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ExportMaskCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Initiator(com.emc.storageos.db.client.model.Initiator) Test(org.junit.Test)

Aggregations

ExportMaskCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 ExportMask (com.emc.storageos.db.client.model.ExportMask)6 Initiator (com.emc.storageos.db.client.model.Initiator)6 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 BlockStorageDevice (com.emc.storageos.volumecontroller.BlockStorageDevice)3 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 Workflow (com.emc.storageos.workflow.Workflow)2 HashMap (java.util.HashMap)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)1 StoragePortGroup (com.emc.storageos.db.client.model.StoragePortGroup)1 Volume (com.emc.storageos.db.client.model.Volume)1