Search in sources :

Example 1 with ConsistencyGroupCopySettingsParam

use of com.emc.fapiclient.ws.ConsistencyGroupCopySettingsParam in project coprhd-controller by CoprHD.

the class RecoverPointClient method addCopyToCG.

/**
 * adds one copy to an existing CG
 *
 * @param cgUID CG uid where new copy should be added
 * @param allSites list of sites that see journal and copy file WWN's
 * @param copyParams the copy to be added
 * @param rSets replication set to which the user volumes have to be added
 * @param copyType either production, local or remote
 * @param linkSettings for the copy being added
 * @param copyUid of the copy being added
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIValidationException_Exception
 */
private void addCopyToCG(ConsistencyGroupUID cgUID, Set<RPSite> allSites, CreateCopyParams copyParams, List<CreateRSetParams> rSets, RecoverPointCGCopyType copyType, List<ConsistencyGroupLinkSettings> linkSettings, ConsistencyGroupCopyUID copyUid) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
    boolean isProduction = copyType == RecoverPointCGCopyType.PRODUCTION;
    String copyTypeStr = copyType.toString();
    logger.info(String.format("Adding new copy %s to cg", copyParams.getName()));
    ConsistencyGroupCopySettingsParam copySettingsParam = new ConsistencyGroupCopySettingsParam();
    copySettingsParam.setCopyName(copyParams.getName());
    copySettingsParam.setCopyPolicy(null);
    copySettingsParam.setEnabled(false);
    copySettingsParam.setGroupCopy(copyUid);
    copySettingsParam.setProductionCopy(isProduction);
    copySettingsParam.setTransferEnabled(false);
    copySettingsParam.getGroupLinksSettings().addAll(linkSettings);
    // we can't call validateAddConsistencyGroupCopy here because during a swap operation, it throws an exception
    // which is just a warning that a full sweep will be required. There didn't seem to be a way to catch
    // just the warning and let other errors propagate as errors.
    logger.info(String.format("Add Production copy %s (no validation): ", copyParams.getName(), copyParams.toString()));
    functionalAPI.addConsistencyGroupCopy(copySettingsParam);
    // add journals
    for (CreateVolumeParams journalVolume : copyParams.getJournals()) {
        logger.info(String.format("Adding Journal for Production copy %s : %s", copyParams.getName(), journalVolume.toString()));
        functionalAPI.addJournalVolume(copyUid, RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
    }
    if (rSets != null) {
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgUID);
        // Keep track of volumes added so we don't add the same one again. Prevents an exception from being thrown.
        List<String> volumesAdded = new ArrayList<String>();
        for (CreateRSetParams rSet : rSets) {
            ReplicationSetUID rSetUid = null;
            if (rSet != null && rSet.getName() != null && !rSet.getName().isEmpty()) {
                for (ReplicationSetSettings rSetSetting : groupSettings.getReplicationSetsSettings()) {
                    if (rSetSetting.getReplicationSetName().equalsIgnoreCase(rSet.getName())) {
                        rSetUid = rSetSetting.getReplicationSetUID();
                        break;
                    }
                }
            }
            if (rSetUid != null) {
                for (CreateVolumeParams volume : rSet.getVolumes()) {
                    if ((isProduction && volume.isProduction()) || (!isProduction && !volume.isProduction()) && !volumesAdded.contains(volume.getWwn())) {
                        logger.info(String.format("Adding %s copy volume : %s", copyTypeStr, volume.toString()));
                        functionalAPI.addUserVolume(copyUid, rSetUid, RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
                        volumesAdded.add(volume.getWwn());
                    }
                }
            }
        }
    }
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) ReplicationSetUID(com.emc.fapiclient.ws.ReplicationSetUID) ArrayList(java.util.ArrayList) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupCopySettingsParam(com.emc.fapiclient.ws.ConsistencyGroupCopySettingsParam) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams)

Aggregations

ConsistencyGroupCopySettingsParam (com.emc.fapiclient.ws.ConsistencyGroupCopySettingsParam)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)1 ReplicationSetUID (com.emc.fapiclient.ws.ReplicationSetUID)1 CreateRSetParams (com.emc.storageos.recoverpoint.requests.CreateRSetParams)1 CreateVolumeParams (com.emc.storageos.recoverpoint.requests.CreateVolumeParams)1 ArrayList (java.util.ArrayList)1