Search in sources :

Example 21 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method changeVolumeVirtualPool.

/**
 * {@inheritDoc}
 *
 * @throws InternalException
 */
@Override
public TaskList changeVolumeVirtualPool(URI systemURI, Volume volume, VirtualPool vpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    VirtualPool volumeVirtualPool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
    s_logger.info("Volume {} VirtualPool change.", volume.getId());
    TaskList taskList = createTasksForVolumes(vpool, Arrays.asList(volume), taskId);
    String transferSpeed = null;
    ArrayList<Volume> volumes = new ArrayList<Volume>();
    volumes.add(volume);
    if (checkCommonVpoolUpdates(volumes, vpool, taskId)) {
        return taskList;
    }
    // Get the storage system. This could be a vplex, vmax, or
    // vnxblock, or other block storage system.
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
    String systemType = storageSystem.getSystemType();
    if (!DiscoveredDataObject.Type.vplex.name().equals(systemType)) {
        // If it is not a VPLEX volume, then this must be an import to VPLEX.
        s_logger.info("High availability VirtualPool change for array volume, importing volume VPLEX: " + volume.getLabel());
        importVirtualVolume(systemURI, volume, vpool, taskId);
        // Check to see if the imported volume is an SRDF source volume.
        if (volume.getSrdfTargets() != null) {
            StringSet srdfTargets = volume.getSrdfTargets();
            for (String target : srdfTargets) {
                Volume targetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
                URI targetVarray = targetVolume.getVirtualArray();
                // Get the target virtual pool.
                Map<URI, VpoolRemoteCopyProtectionSettings> protectionSettingsMap = VirtualPool.getRemoteProtectionSettings(vpool, _dbClient);
                VpoolRemoteCopyProtectionSettings settings = protectionSettingsMap.get(targetVarray);
                if (settings != null) {
                    VirtualPool targetVpool = _dbClient.queryObject(VirtualPool.class, settings.getVirtualPool());
                    if (NullColumnValueGetter.isNotNullValue(targetVpool.getHighAvailability()) && targetVpool.getHighAvailability().equals(VirtualPool.HighAvailabilityType.vplex_local.name())) {
                        String subTaskId = UUID.randomUUID().toString();
                        s_logger.info("Importing SRDF target to VPLEX " + targetVolume.getLabel());
                        Operation op = new Operation();
                        op.setResourceType(ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL);
                        op.setDescription("Change vpool operation");
                        op = _dbClient.createTaskOpStatus(Volume.class, targetVolume.getId(), subTaskId, op);
                        taskList.addTask(toTask(targetVolume, subTaskId, op));
                        importVirtualVolume(targetVolume.getStorageController(), targetVolume, targetVpool, subTaskId);
                    }
                }
            }
        }
    } else {
        if (VirtualPoolChangeAnalyzer.isVPlexConvertToDistributed(volumeVirtualPool, vpool, new StringBuffer())) {
            if (!VirtualPoolUtil.checkMatchingRemoteCopyVarraysettings(volumeVirtualPool, vpool, _dbClient)) {
                s_logger.info("Incompatible Remote Copy Varray Settings");
                throw BadRequestException.badRequests.changeToVirtualPoolNotSupported(volumeVirtualPool.getLabel(), "Incompatible Remote Copy Varray Settings");
            }
            if (vpoolChangeParam.getTransferSpeedParam() != null) {
                transferSpeed = vpoolChangeParam.getTransferSpeedParam();
                s_logger.info("Coversion of volume from vplex local to distributed will use the provided transfer speed {}", transferSpeed);
            }
            // Convert vplex_local to vplex_distributed
            upgradeToDistributed(systemURI, volume, vpool, transferSpeed, taskId);
        } else if (!VirtualPool.vPoolSpecifiesMirrors(volumeVirtualPool, _dbClient) && (VirtualPool.vPoolSpecifiesMirrors(vpool, _dbClient)) && VirtualPoolChangeAnalyzer.isSupportedAddMirrorsVirtualPoolChange(volume, volumeVirtualPool, vpool, _dbClient, new StringBuffer())) {
            // Change Virtual pool to have continuous copies
            URI originalVirtualPool = volume.getVirtualPool();
            // Update the volume with the new virtual pool
            volume.setVirtualPool(vpool.getId());
            _dbClient.updateObject(volume);
            // Update the task
            String msg = format("VirtualPool changed from %s to %s for Volume %s", originalVirtualPool, vpool.getId(), volume.getId());
            s_logger.info(msg);
            _dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL);
            _dbClient.ready(Volume.class, volume.getId(), taskId, msg);
        } else {
            // Prepare for VPlex virtual volume VirtualPool change.
            // Get the varray for the virtual volume.
            s_logger.info("VirtualPool change for VPlex virtual volume.");
            ControllerOperationValuesWrapper operationsWrapper = new ControllerOperationValuesWrapper();
            operationsWrapper.put(ControllerOperationValuesWrapper.MIGRATION_SUSPEND_BEFORE_COMMIT, vpoolChangeParam.getMigrationSuspendBeforeCommit());
            operationsWrapper.put(ControllerOperationValuesWrapper.MIGRATION_SUSPEND_BEFORE_DELETE_SOURCE, vpoolChangeParam.getMigrationSuspendBeforeDeleteSource());
            List<VolumeDescriptor> descriptors = createChangeVirtualPoolDescriptors(storageSystem, volume, vpool, taskId, null, null, operationsWrapper, true);
            // Now we get the Orchestration controller and use it to change the virtual pool of the volumes.
            orchestrateVPoolChanges(Arrays.asList(volume), descriptors, taskId);
        }
    }
    return taskList;
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) ControllerOperationValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.ControllerOperationValuesWrapper) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 22 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method prepareRecommendedVolumes.

/**
 * Prepare Recommended Volumes for SRDF scenarios only.
 *
 * This method is responsible for acting the same as the unprotected "prepareRecommendedVolumes"
 * call, however it needs to create multiple volumes per single volume requests in order to
 * generate SRDF protection.
 *
 * Those most typical scenario is, that for any one volume requested in an SRDF configuration,
 * we create: 1. One Source Volume 3. One Target Volume on target varrays
 *
 * @param param
 *            volume create request
 * @param task
 *            task from request or generated
 * @param taskList
 *            task list
 * @param project
 *            project from request
 * @param varray
 *            varray from request
 * @param vpool
 *            vpool from request
 * @param volumeCount
 *            volume count from the request
 * @param recommendations
 *            list of resulting recommendations from placement
 * @param consistencyGroup
 *            consistency group ID
 * @return list of volume URIs created
 */
private List<URI> prepareRecommendedVolumes(final String task, final TaskList taskList, final Project project, final VirtualArray varray, final VirtualPool vpool, final Integer volumeCount, final List<Recommendation> recommendations, final BlockConsistencyGroup consistencyGroup, final String volumeLabel, final String size) {
    List<URI> volumeURIs = new ArrayList<URI>();
    try {
        // Create an entire Protection object for each recommendation result.
        Iterator<Recommendation> recommendationsIter = recommendations.iterator();
        while (recommendationsIter.hasNext()) {
            SRDFRecommendation recommendation = (SRDFRecommendation) recommendationsIter.next();
            // until we (later) fix creating volumes while in SWAPPED state.
            for (SRDFRecommendation.Target target : recommendation.getVirtualArrayTargetMap().values()) {
                if (target != null && SRDFScheduler.rdfGroupHasSwappedVolumes(_dbClient, project.getId(), target.getSourceRAGroup())) {
                    RemoteDirectorGroup rdg = _dbClient.queryObject(RemoteDirectorGroup.class, target.getSourceRAGroup());
                    throw BadRequestException.badRequests.cannotAddVolumesToSwappedReplicationGroup(rdg.getLabel());
                }
            }
            StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
            // operation for each volume to be created.
            for (int i = 0; i < volumeCount; i++) {
                // get generated volume name
                String newVolumeLabel = generateDefaultVolumeLabel(volumeLabel, i, volumeCount);
                // Grab the existing volume and task object from the incoming task list
                Volume srcVolume = StorageScheduler.getPrecreatedVolume(_dbClient, taskList, newVolumeLabel);
                boolean volumePrecreated = false;
                if (srcVolume != null) {
                    volumePrecreated = true;
                }
                // number of targets.
                if (recommendation.getVpoolChangeVolume() == null) {
                    srcVolume = prepareVolume(srcVolume, project, varray, vpool, size, recommendation, newVolumeLabel, consistencyGroup, task, false, Volume.PersonalityTypes.SOURCE, null, null, null);
                    volumeURIs.add(srcVolume.getId());
                    if (!volumePrecreated) {
                        taskList.getTaskList().add(toTask(srcVolume, task));
                    }
                } else {
                    srcVolume = _dbClient.queryObject(Volume.class, recommendation.getVpoolChangeVolume());
                    Operation op = _dbClient.createTaskOpStatus(Volume.class, srcVolume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
                    // Fill in additional information that prepare would've filled in that's specific to SRDF.
                    // Best to only fill in information here that isn't harmful if a rollback occurred,
                    // and the protection never got set up.
                    volumeURIs.add(srcVolume.getId());
                    taskList.getTaskList().add(toTask(srcVolume, task, op));
                }
                // Remove "-source" designation in the label if found
                if (newVolumeLabel.contains("-source")) {
                    newVolumeLabel = newVolumeLabel.replaceAll("-source", "");
                }
                Map<URI, VpoolRemoteCopyProtectionSettings> settingMap = VirtualPool.getRemoteProtectionSettings(vpool, _dbClient);
                for (VirtualArray protectionVirtualArray : SRDFScheduler.getTargetVirtualArraysForVirtualPool(project, vpool, _dbClient, _permissionsHelper)) {
                    VpoolRemoteCopyProtectionSettings settings = settingMap.get(protectionVirtualArray.getId());
                    // COP-16363 Create target BCG in controllersvc
                    // Prepare and populate CG request for the SRDF targets
                    volumeURIs.addAll(prepareTargetVolumes(project, vpool, recommendation, new StringBuilder(newVolumeLabel), protectionVirtualArray, settings, srcVolume, task, taskList, size));
                }
            }
        }
    } catch (InternalException e) {
        _log.error("Rolling back the created CGs if any.");
        throw e;
    } catch (BadRequestException e) {
        _log.info("Bad request exception: " + e.getMessage());
        throw e;
    } catch (Exception e) {
        _log.error("Rolling back the created CGs if any.");
        throw APIException.badRequests.srdfInternalError(e);
    }
    return volumeURIs;
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) Volume(com.emc.storageos.db.client.model.Volume) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 23 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method getVirtualPoolChangeAllowedOperations.

/**
 * {@inheritDoc}
 */
@Override
protected List<VirtualPoolChangeOperationEnum> getVirtualPoolChangeAllowedOperations(Volume volume, VirtualPool volumeVirtualPool, VirtualPool newVirtualPool, StringBuffer notSuppReasonBuff) {
    List<VirtualPoolChangeOperationEnum> allowedOperations = new ArrayList<VirtualPoolChangeOperationEnum>();
    if (VirtualPool.vPoolSpecifiesSRDF(newVirtualPool) && VirtualPoolChangeAnalyzer.isSupportedSRDFVolumeVirtualPoolChange(volume, volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
        allowedOperations.add(VirtualPoolChangeOperationEnum.SRDF_PROTECED);
    }
    // check if import into VPLEX is allowed.
    StringBuffer vplexImportChangeReasonBuff = new StringBuffer();
    if (VirtualPoolChangeAnalyzer.isVPlexImport(volume, volumeVirtualPool, newVirtualPool, vplexImportChangeReasonBuff)) {
        // Analyze the remote copy protection settings of each to see if they are compatible
        Map<URI, VpoolRemoteCopyProtectionSettings> volumeRemoteCopySettings = VirtualPool.getRemoteProtectionSettings(volumeVirtualPool, _dbClient);
        Map<URI, VpoolRemoteCopyProtectionSettings> newRemoteCopySettings = VirtualPool.getRemoteProtectionSettings(newVirtualPool, _dbClient);
        if (!volumeRemoteCopySettings.isEmpty() || !newRemoteCopySettings.isEmpty() && volumeRemoteCopySettings.size() == newRemoteCopySettings.size()) {
            boolean compatible = true;
            StringBuffer targetReasonBuff = new StringBuffer();
            // For each existing remote copy protection settings
            for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : volumeRemoteCopySettings.entrySet()) {
                // Fetch the equivalent one in new vpool, and check to see if it matches
                VpoolRemoteCopyProtectionSettings newSettings = newRemoteCopySettings.get(entry.getKey());
                if (newSettings == null || !entry.getValue().getVirtualArray().equals(newSettings.getVirtualArray())) {
                    compatible = false;
                    break;
                }
                if (entry.getValue().getVirtualPool().equals(newSettings.getVirtualPool())) {
                    // same virtual pool is compatible
                    continue;
                }
                // Check to see if virtual pools are such that target can be upgraded to vplex local
                VirtualPool volumeCopyVpool = _dbClient.queryObject(VirtualPool.class, entry.getValue().getVirtualPool());
                VirtualPool newCopyVpool = _dbClient.queryObject(VirtualPool.class, newSettings.getVirtualPool());
                if (newCopyVpool.getHighAvailability() != null && newCopyVpool.getHighAvailability().equals(VirtualPool.HighAvailabilityType.vplex_local.name())) {
                    StringSet targetVolumes = volume.getSrdfTargets();
                    for (String targetVolumeId : targetVolumes) {
                        Volume targetVolume = _dbClient.queryObject(Volume.class, URI.create(targetVolumeId));
                        if (targetVolume.getVirtualArray().equals(entry.getKey())) {
                            // The new target Vpool can be import-able from the old if high availability is set
                            if (!VirtualPoolChangeAnalyzer.isVPlexImport(targetVolume, volumeCopyVpool, newCopyVpool, targetReasonBuff)) {
                                compatible = false;
                                break;
                            }
                        }
                    }
                }
            }
            if (compatible) {
                allowedOperations.add(VirtualPoolChangeOperationEnum.NON_VPLEX_TO_VPLEX);
            } else {
                notSuppReasonBuff.append("Incompatible VpoolRemoteCopyProtectionSettings: " + targetReasonBuff);
            }
        }
    }
    return allowedOperations;
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) VirtualPoolChangeOperationEnum(com.emc.storageos.model.vpool.VirtualPoolChangeOperationEnum) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) Map(java.util.Map) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap)

Example 24 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings in project coprhd-controller by CoprHD.

the class FileVirtualPoolService method deleteRemoteCopies.

private void deleteRemoteCopies(VirtualPool virtualPool, FileVirtualPoolProtectionUpdateParam param) {
    // Remove all remote copy setttings, if any!!!
    StringMap remoteCopySettingsMap = virtualPool.getFileRemoteCopySettings();
    if (remoteCopySettingsMap != null && !remoteCopySettingsMap.isEmpty()) {
        for (String varray : remoteCopySettingsMap.keySet()) {
            String remoteCopySettingsUri = remoteCopySettingsMap.get(varray);
            remoteCopySettingsMap.remove(varray);
            VpoolRemoteCopyProtectionSettings remoteSettingsObj = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(remoteCopySettingsUri));
            remoteSettingsObj.setInactive(true);
            _dbClient.updateObject(remoteSettingsObj);
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)

Example 25 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings in project coprhd-controller by CoprHD.

the class VirtualPoolService method deleteFileVPoolRemoteCopyProtectionSettings.

/**
 * Deletes all File Replication VpoolRemoteCopyProtectionSettings objects associated with a VirtualPool.
 *
 * @param vpool the VirtualPool from which to delete the
 *            VpoolRemoteCopyProtectionSettings.
 */
protected void deleteFileVPoolRemoteCopyProtectionSettings(VirtualPool vpool) {
    // Delete all settings associated with the protection settings
    if (vpool.getFileRemoteCopySettings() != null && !vpool.getFileRemoteCopySettings().isEmpty()) {
        for (String protectionVirtualArray : vpool.getFileRemoteCopySettings().keySet()) {
            String strRemoteSettings = vpool.getFileRemoteCopySettings().get(protectionVirtualArray);
            URI uriRemoteSettings = URI.create(strRemoteSettings);
            VpoolRemoteCopyProtectionSettings remoteSettings = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, uriRemoteSettings);
            if (remoteSettings != null && !remoteSettings.getInactive()) {
                _dbClient.markForDeletion(remoteSettings);
            }
        }
        vpool.getFileRemoteCopySettings().clear();
    }
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) URI(java.net.URI)

Aggregations

VpoolRemoteCopyProtectionSettings (com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)32 URI (java.net.URI)29 ArrayList (java.util.ArrayList)21 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)20 StringSet (com.emc.storageos.db.client.model.StringSet)15 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 List (java.util.List)13 StringMap (com.emc.storageos.db.client.model.StringMap)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)11 StoragePool (com.emc.storageos.db.client.model.StoragePool)9 Volume (com.emc.storageos.db.client.model.Volume)8 Recommendation (com.emc.storageos.volumecontroller.Recommendation)8 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)6 Network (com.emc.storageos.db.client.model.Network)5