Search in sources :

Example 1 with ExportAddVolumeCompleter

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

Example 2 with ExportAddVolumeCompleter

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);
    }
}
Also used : 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) 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) ExportAddVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with ExportAddVolumeCompleter

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

Aggregations

ExportGroup (com.emc.storageos.db.client.model.ExportGroup)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 ExportAddVolumeCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter)3 URI (java.net.URI)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 Volume (com.emc.storageos.db.client.model.Volume)2 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)2 HashMap (java.util.HashMap)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