Search in sources :

Example 26 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method deleteCG.

/**
 * Delete the consistency group specified by the input volume info.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to delete
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void deleteCG(RecoverPointVolumeProtectionInfo cgToDelete) throws RecoverPointException {
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(cgToDelete);
    String cgName = null;
    try {
        cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID());
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
        for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
            if (!cgToDelete.isMetroPoint() && !RecoverPointUtils.copiesEqual(productionCopyUID, cgCopyUID)) {
                // Can't call delete CG using anything but the production CG copy
                throw RecoverPointException.exceptions.cantCallDeleteCGUsingProductionCGCopy(cgName);
            }
        }
        // First disable the CG before removing it, this buys RP a bit of time
        // to clean it up.
        disableConsistencyGroup(cgCopyUID.getGroupUID());
        // Delete the CG, async call to RP
        functionalAPI.removeConsistencyGroup(cgCopyUID.getGroupUID());
        // Verify the CG has been removed
        validateCGRemoved(cgCopyUID.getGroupUID(), cgName);
        logger.info("Deleted consistency group " + cgName);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 27 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method disableProtection.

/**
 * Disable (stop) the consistency group protection specified by the input volume info.
 * If a target volume is specified, disable the copy associated with the target.
 * Disable requires a full sweep when enabled.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to disable
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void disableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
    try {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(volumeInfo.getRpVolumeGroupID());
        if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
            // Disable the whole CG
            disableConsistencyGroup(cgUID);
        } else {
            // Disable the CG copy associated with the target.
            ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
            functionalAPI.disableConsistencyGroupCopy(cgCopyUID);
            String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
            String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
            logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
            // Make sure the CG copy is stopped
            RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
            imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.UNKNOWN);
            logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 28 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method createCG.

/**
 * Creates a consistency group
 *
 * @param request - contains all the information required to create the consistency group
 *
 * @param attachAsClean attach as clean can be true if source and target are guaranteed to be the same (as in create
 *            new volume). for change vpool, attach as clean should be false
 *
 * @return CreateCGResponse - response as to success or fail of creating the consistency group
 *
 * @throws RecoverPointException
 */
public RecoverPointCGResponse createCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
    if (null == _endpoint.toASCIIString()) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    RecoverPointCGResponse response = new RecoverPointCGResponse();
    ConsistencyGroupUID cgUID = null;
    try {
        // Make sure the CG name is unique.
        int cgSuffix = 0;
        String cgName = request.getCgName();
        while (doesCgExist(request.getCgName())) {
            request.setCgName(String.format("%s-%d", cgName, ++cgSuffix));
        }
        // caches site names to cluster id's to reduce calls to fapi for the same information
        Map<String, ClusterUID> clusterIdCache = new HashMap<String, ClusterUID>();
        // prodSites is used for logging and to determine if a non-production copy is local or remote
        List<ClusterUID> prodSites = getProdSites(request, clusterIdCache);
        StringBuffer sb = new StringBuffer();
        for (ClusterUID prodSite : prodSites) {
            sb.append(prodSite.getId());
            sb.append(" ");
        }
        logger.info("RecoverPointClient: Creating recoverPoint consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
        // used to set the copy uid on the rset volume when adding rsets
        Map<Long, ConsistencyGroupCopyUID> productionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
        Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
        Map<ConsistencyGroupCopyUID, String> cgCopyNames = new HashMap<ConsistencyGroupCopyUID, String>();
        FullConsistencyGroupPolicy fullConsistencyGroupPolicy = configureCGPolicy(request, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
        // create the CG with copies
        logger.info("Adding cg, copies and links for CG: " + request.getCgName());
        functionalAPI.validateAddConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
        cgUID = functionalAPI.addConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
        response.setCgId(cgUID.getId());
        ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
        logger.info("Adding journals and rsets for CG " + request.getCgName());
        functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
        RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
        logger.info("Waiting for links to become active for CG " + request.getCgName());
        rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
        logger.info(String.format("Consistency group %s has been created.", request.getCgName()));
        response.setReturnCode(RecoverPointReturnCode.SUCCESS);
        return response;
    } catch (Exception e) {
        if (cgUID != null) {
            try {
                RecoverPointUtils.cleanupCG(functionalAPI, cgUID);
            } catch (Exception e1) {
                logger.error("Error removing CG " + request.getCgName() + " after create CG failure");
                logger.error(e1.getMessage(), e1);
            }
        }
        throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(request.getCgName(), getCause(e));
    }
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) HashMap(java.util.HashMap) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID)

Example 29 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method pauseTransfer.

/**
 * Pause (suspend) the consistency group protection specified by the input volume info.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to pause
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void pauseTransfer(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
    try {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(volumeInfo.getRpVolumeGroupID());
        if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
            // Pause the whole CG
            functionalAPI.pauseGroupTransfer(cgUID);
            String cgName = functionalAPI.getGroupName(cgUID);
            logger.info("Protection paused on CG " + cgName);
        } else {
            // Pause the CG copy associated with the target
            ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
            functionalAPI.pauseGroupCopyTransfer(cgCopyUID);
            String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
            String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
            logger.info("Protection paused on CG copy " + cgCopyName + " on CG " + cgName);
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToPauseProtection(volumeInfo.getRpVolumeGroupID(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToPauseProtection(volumeInfo.getRpVolumeGroupID(), e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 30 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method getReplicationSet.

/**
 * Get the replication set information associated with this volume. This is important when assembling a workflow to
 * recreate the replication set for the purpose of expanding volumes.
 *
 * Steps are as follows:
 * This method: Get the state information associated with the replication set
 * Delete method below: Delete the replication set
 * RP Controller: Expand volumes
 * Recreate method below: Perform a rescan_san
 * Recreate method below: Create the replication set
 *
 * @param RecoverPointVolumeProtectionInfo volume - Volume info for the CG to remove the replication set from
 * @return void
 *
 * @throws RecoverPointException
 */
public RecreateReplicationSetRequestParams getReplicationSet(RecoverPointVolumeProtectionInfo volume) throws RecoverPointException {
    ReplicationSetSettings rsetSettings = null;
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ReplicationSetUID repSetUID = new ReplicationSetUID();
        repSetUID.setId(volume.getRpVolumeRSetID());
        rsetSettings = getReplicationSetSettings(functionalAPI, rsetSettings, cgID, repSetUID);
        if (rsetSettings == null) {
            throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN());
        }
        RecreateReplicationSetRequestParams response = new RecreateReplicationSetRequestParams();
        response.setCgName(volume.getRpProtectionName());
        response.setName(rsetSettings.getReplicationSetName());
        response.setConsistencyGroupUID(cgID);
        response.setVolumes(new ArrayList<CreateRSetVolumeParams>());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        // Get the standby production copy (if one exists). In the case of MetroPoint,
        // we must ignore the standby copy device when getting the replication set. Including
        // the standby copy during replication set re-creation will throw an exception
        // because it has the same device ID as the active copy device.
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        for (UserVolumeSettings volumeSettings : rsetSettings.getVolumes()) {
            if (standbyProdCopy != null && RecoverPointUtils.copiesEqual(volumeSettings.getGroupCopyUID(), standbyProdCopy)) {
                // This is the standby production copy so ignore it.
                String standyCopyName = functionalAPI.getGroupCopyName(volumeSettings.getGroupCopyUID());
                logger.info(String.format("Ignoring volume %s at standby copy %s to avoid duplicate device IDs in replication set reconstruction for MetroPoint.", volumeSettings.getVolumeInfo().getVolumeName(), standyCopyName));
                continue;
            }
            CreateRSetVolumeParams volumeParams = new CreateRSetVolumeParams();
            volumeParams.setDeviceUID(volumeSettings.getVolumeInfo().getVolumeID());
            volumeParams.setConsistencyGroupCopyUID(volumeSettings.getGroupCopyUID());
            response.getVolumes().add(volumeParams);
        }
        return response;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    }
}
Also used : UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) RecreateReplicationSetRequestParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) CreateRSetVolumeParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams.CreateRSetVolumeParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ReplicationSetUID(com.emc.fapiclient.ws.ReplicationSetUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Aggregations

ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)34 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)24 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)24 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)14 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)9 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)9 ClusterUID (com.emc.fapiclient.ws.ClusterUID)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 HashMap (java.util.HashMap)6 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)5 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)4 HashSet (java.util.HashSet)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)3