Search in sources :

Example 1 with ExportAddInitiatorCompleter

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

Example 2 with ExportAddInitiatorCompleter

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);
    }
}
Also used : ExportAddInitiatorCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with ExportAddInitiatorCompleter

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

Aggregations

ExportGroup (com.emc.storageos.db.client.model.ExportGroup)3 Initiator (com.emc.storageos.db.client.model.Initiator)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 ExportAddInitiatorCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)2 Test (org.junit.Test)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1