Search in sources :

Example 16 with RecoverPointVolumeProtectionInfo

use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.

the class RecoverPointClient method deleteReplicationSets.

/**
 * Deletes one-to-many replication sets based on the volume information passed in.
 *
 * @param volumeInfoList the volume information that relates to one or more replication sets.
 * @throws RecoverPointException
 */
public void deleteReplicationSets(List<RecoverPointVolumeProtectionInfo> volumeInfoList) throws RecoverPointException {
    // Used to capture the volume WWNs associated with each replication set to remove.
    List<String> volumeWWNs = new ArrayList<String>();
    Map<Long, String> rsetNames = new HashMap<Long, String>();
    List<Long> rsetIDsToValidate = new ArrayList<Long>();
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volumeInfoList.get(0).getRpVolumeGroupID());
        ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
        cgSettingsParam.setGroupUID(cgID);
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgID);
        List<ReplicationSetSettings> replicationSetSettings = groupSettings.getReplicationSetsSettings();
        for (RecoverPointVolumeProtectionInfo volumeInfo : volumeInfoList) {
            boolean found = false;
            // Validate that the requested replication sets to delete actually exist.
            for (ReplicationSetSettings replicationSet : replicationSetSettings) {
                if (replicationSet.getReplicationSetUID().getId() == volumeInfo.getRpVolumeRSetID()) {
                    rsetNames.put(volumeInfo.getRpVolumeRSetID(), replicationSet.getReplicationSetName());
                    found = true;
                    break;
                }
            }
            if (!found) {
                logger.warn(String.format("No matching replication set for volume [%s] with replication set ID [%s] found." + " This will need to be checked on the RP System.", volumeInfo.getRpVolumeWWN(), volumeInfo.getRpVolumeRSetID()));
                continue;
            }
            ReplicationSetUID repSetUID = new ReplicationSetUID();
            repSetUID.setId(volumeInfo.getRpVolumeRSetID());
            repSetUID.setGroupUID(cgID);
            if (!containsRepSetUID(cgSettingsParam.getRemovedReplicationSets(), repSetUID)) {
                cgSettingsParam.getRemovedReplicationSets().add(repSetUID);
                rsetIDsToValidate.add(repSetUID.getId());
            }
            volumeWWNs.add(volumeInfo.getRpVolumeWWN());
            logger.info(String.format("Adding replication set [%s] (%d) to be removed from RP CG [%s] (%d)", rsetNames.get(volumeInfo.getRpVolumeRSetID()), volumeInfo.getRpVolumeRSetID(), groupSettings.getName(), cgID.getId()));
        }
        // to remove.
        if (cgSettingsParam.getRemovedReplicationSets() != null && !cgSettingsParam.getRemovedReplicationSets().isEmpty()) {
            if (replicationSetSettings.size() == cgSettingsParam.getRemovedReplicationSets().size()) {
                // We are removing all the replication sets in the CG so we need to disable
                // the entire CG.
                disableConsistencyGroup(cgID);
            }
            // Remove the replication sets
            functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
            // Validate that the RSets have been removed
            validateRSetsRemoved(rsetIDsToValidate, cgID, volumeWWNs);
            logger.info("Request to delete replication sets " + rsetNames.toString() + " from RP CG " + groupSettings.getName() + " completed.");
        } else {
            logger.warn(String.format("No replication sets found to be deleted from RP CG [%s] (%d)", groupSettings.getName(), cgID.getId()));
        }
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), e);
    }
}
Also used : ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) 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) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ReplicationSetUID(com.emc.fapiclient.ws.ReplicationSetUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 17 with RecoverPointVolumeProtectionInfo

use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method testExceptionUseCases.

// @Test
public void testExceptionUseCases() throws InterruptedException {
    boolean foundError = false;
    logger.info("Testing RecoverPoint Exception Use Cases");
    try {
        // RecreateCGAndBookmark();
        logger.info("Pause Pause Resume on a CG Copy");
        RecoverPointVolumeProtectionInfo protectionInfo = null;
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
        rpClient.pauseTransfer(protectionInfo);
        rpClient.pauseTransfer(protectionInfo);
        rpClient.resumeTransfer(protectionInfo);
        logger.info("Pause Pause Resume on a CG Copy PASSED");
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    try {
        logger.info("Disable Disable Enable on a CG Copy");
        RecoverPointVolumeProtectionInfo protectionInfo = null;
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
        rpClient.disableProtection(protectionInfo);
        rpClient.disableProtection(protectionInfo);
        rpClient.enableProtection(protectionInfo);
        logger.info("Disable Disable Enable on a CG Copy PASSED");
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    try {
        logger.info("Enable Most Recent Image, Enable Bookmark (should fail)");
        CreateBookmarkRequestParams params = new CreateBookmarkRequestParams();
        Bookmarkname = "BourneBookmark_";
        Random randomnumber = new Random();
        Bookmarkname += Math.abs(randomnumber.nextInt());
        params.setBookmark(Bookmarkname);
        Set<String> WWNSetToBookmark = new HashSet<String>();
        WWNSetToBookmark.add(BourneRPTestCRRLUN1WWN);
        WWNSetToBookmark.add(BourneRPTestCRRLUN2WWN);
        params.setVolumeWWNSet(WWNSetToBookmark);
        rpClient.createBookmarks(params);
        MultiCopyEnableImageRequestParams enableParams = new MultiCopyEnableImageRequestParams();
        MultiCopyEnableImageRequestParams enableParams1 = new MultiCopyEnableImageRequestParams();
        MultiCopyDisableImageRequestParams disableParams = new MultiCopyDisableImageRequestParams();
        Set<String> WWNSetForTest = new HashSet<String>();
        WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
        WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
        enableParams.setVolumeWWNSet(WWNSetForTest);
        enableParams1.setVolumeWWNSet(WWNSetForTest);
        disableParams.setVolumeWWNSet(WWNSetForTest);
        disableParams.setEmName(Bookmarkname);
        rpClient.enableImageCopies(enableParams1);
        try {
            rpClient.enableImageCopies(enableParams);
            foundError = true;
        } catch (RecoverPointException e) {
            logger.info("Enable Most Recent Image, Enable Bookmark PASSED");
        }
        logger.info("Sleep 15 seconds before disable of image");
        Thread.sleep(15000);
        rpClient.disableImageCopies(disableParams);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (!foundError) {
        logger.info("TestExceptionUseCases PASSED");
    } else {
        fail("TestExceptionUseCases FAILED");
    }
}
Also used : CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Random(java.util.Random) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) MultiCopyDisableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams) MultiCopyEnableImageRequestParams(com.emc.storageos.recoverpoint.requests.MultiCopyEnableImageRequestParams) HashSet(java.util.HashSet)

Example 18 with RecoverPointVolumeProtectionInfo

use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method recreateCGCDPOnly.

public void recreateCGCDPOnly() throws RecoverPointException {
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    try {
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestProdLUN1WWN);
    } catch (RecoverPointException e) {
        logger.info("Ignore getProtectionInfoForVolume error");
    }
    if (protectionInfo != null) {
        logger.info("Delete previous CG (if it exists)");
        rpClient.deleteCG(protectionInfo);
    }
    logger.info("Create the CG with one replication set");
    // CreateCGRequestParams createCGParams = CreateCGParamsHelper(true, false, 2);
    CGRequestParams createCGParams = createCGParamsHelper(true, false, 1);
    rpClient.createCG(createCGParams, false, false);
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams)

Example 19 with RecoverPointVolumeProtectionInfo

use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.

the class RecoverPointClientIntegrationTest method testFailover.

// @Test
public void testFailover() {
    logger.info("Testing RecoverPoint Failover For Volume");
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    RecoverPointVolumeProtectionInfo failbackProtectionInfo = null;
    boolean foundError = false;
    try {
        recreateCGAndBookmark();
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
        failbackProtectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestProdLUN1WWN);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (protectionInfo == null) {
        foundError = true;
        fail("Failed to find protection info for WWN: " + BourneRPTestCRRLUN1WWN);
    }
    if (failbackProtectionInfo == null) {
        foundError = true;
        fail("Failed to find protection info for WWN: " + BourneRPTestProdLUN1WWN);
    }
    if (!foundError) {
        // Verify this is a source
        if (protectionInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET) {
            logger.info("RecoverPoint Get Protection Info For Volume PASSED");
            logger.info("Protected target volume " + BourneRPTestCRRLUN1WWN + " is on CG Name: " + protectionInfo.getRpProtectionName());
        } else {
            foundError = true;
            fail("Volume " + BourneRPTestCRRLUN1WWN + " did not map to a protected source target");
        }
    }
    RPCopyRequestParams failoverRequest = new RPCopyRequestParams();
    RPCopyRequestParams failbackRequest = new RPCopyRequestParams();
    failoverRequest.setCopyVolumeInfo(protectionInfo);
    failbackRequest.setCopyVolumeInfo(failbackProtectionInfo);
    try {
        // try {
        // logger.info("Delete the CDP copy");
        // RecoverPointVolumeProtectionInfo deleteCopyInfo = null;
        // deleteCopyInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCDPLUN1WWN);
        // rpClient.deleteCopy(deleteCopyInfo);
        // } catch (Exception e) {
        // logger.info("Ignore error deleting CDP copy");
        // }
        logger.info("Failover start");
        rpClient.failoverCopy(failoverRequest);
        logger.info("Sleep 15 seconds before failback");
        Thread.sleep(15000);
        logger.info("Failback start");
        rpClient.failoverCopy(failbackRequest);
    } catch (RecoverPointException e) {
        foundError = true;
        fail(e.getMessage());
    } catch (InterruptedException e) {
        foundError = true;
        fail(e.getMessage());
    }
    if (!foundError) {
        logger.info("TestFailover PASSED");
    }
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) RPCopyRequestParams(com.emc.storageos.recoverpoint.requests.RPCopyRequestParams)

Example 20 with RecoverPointVolumeProtectionInfo

use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.

the class RPDeviceController method deleteRSetStep.

/**
 * Delete the replication set
 *
 * @param rpSystem
 *            RP system
 * @param params
 *            parameters needed to create the CG
 * @param token
 *            the task
 * @return
 * @throws InternalException
 */
public boolean deleteRSetStep(URI rpSystemId, List<URI> volumeIds, String token) throws InternalException {
    List<String> replicationSetNames = new ArrayList<String>();
    try {
        List<RecoverPointVolumeProtectionInfo> volumeProtectionInfoList = new ArrayList<RecoverPointVolumeProtectionInfo>();
        ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
        RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
        for (URI volumeId : volumeIds) {
            Volume volume = _dbClient.queryObject(Volume.class, volumeId);
            RecoverPointVolumeProtectionInfo volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(volume.getId(), _dbClient));
            // Get the volume's source volume in order to determine if we are dealing with a MetroPoint
            // configuration.
            Volume sourceVolume = RPHelper.getRPSourceVolume(_dbClient, volume);
            VirtualPool virtualPool = _dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
            // Set the MetroPoint flag
            volumeProtectionInfo.setMetroPoint(VirtualPool.vPoolSpecifiesMetroPoint(virtualPool));
            volumeProtectionInfoList.add(volumeProtectionInfo);
            replicationSetNames.add(volume.getRSetName());
        }
        if (!volumeProtectionInfoList.isEmpty()) {
            rp.deleteReplicationSets(volumeProtectionInfoList);
        }
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(token);
    } catch (Exception e) {
        _log.error(String.format("deleteRSetStep Failed - Replication Sets: %s", replicationSetNames.toString()));
        return stepFailed(token, e, "deleteRSetStep");
    }
    return true;
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) 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) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

Aggregations

RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)22 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)15 Volume (com.emc.storageos.db.client.model.Volume)7 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)7 ArrayList (java.util.ArrayList)7 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)5 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)5 RPCopyRequestParams (com.emc.storageos.recoverpoint.requests.RPCopyRequestParams)5 URISyntaxException (java.net.URISyntaxException)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)3 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 LockRetryException (com.emc.storageos.locking.LockRetryException)3 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 URI (java.net.URI)3 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)2