Search in sources :

Example 1 with RPConsistencyGroup

use of com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup in project coprhd-controller by CoprHD.

the class RPDeviceController method constructSnapshotObjectFromBookmark.

/**
 * Amend the BlockSnapshot object based on the results of the Bookmark creation operation
 *
 * @param result
 *            result from the snapshot creation command
 * @param system
 *            protection system
 * @param snapshotList
 *            snapshot list generated
 * @param name
 *            emName
 * @param opId
 *            operation ID for task completer
 * @throws InternalException
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private void constructSnapshotObjectFromBookmark(CreateBookmarkResponse response, ProtectionSystem system, List<URI> snapshotList, String name, String opId) throws InternalException {
    ProtectionSet protectionSet = null;
    RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
    // Update each snapshot object with the respective information.
    for (URI snapshotID : snapshotList) {
        // Get the snapshot and the associated volume
        BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
        Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
        // Fetch the VPLEX volume that is created with this volume as the back-end volume.
        if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
            volume = Volume.fetchVplexVolume(_dbClient, volume);
        }
        if (protectionSet == null || !protectionSet.getId().equals(volume.getProtectionSet().getURI())) {
            protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
        }
        // Gather the bookmark date, which is different than the snapshot date
        Date bookmarkDate = new Date();
        if (response.getVolumeWWNBookmarkDateMap() != null) {
            bookmarkDate = response.getVolumeWWNBookmarkDateMap().get(RPHelper.getRPWWn(volume.getId(), _dbClient));
        } else {
            _log.warn("Bookmark date was not filled-in.  Will use current date/time.");
        }
        snapshot.setEmName(name);
        snapshot.setInactive(false);
        snapshot.setEmBookmarkTime("" + bookmarkDate.getTime());
        snapshot.setCreationTime(Calendar.getInstance());
        snapshot.setTechnologyType(TechnologyType.RP.toString());
        Volume targetVolume = RPHelper.getRPTargetVolumeFromSource(_dbClient, volume, snapshot.getVirtualArray());
        // This section will identify and store the COPY ID associated with the bookmarks created.
        // It is critical to store this information so we can later determine which bookmarks have
        // been deleted from the RPA.
        // 
        // May be able to remove this if the protection set object is more detailed (for instance, if
        // we store the copy id with the volume)
        RecoverPointVolumeProtectionInfo protectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
        for (RPConsistencyGroup rpcg : response.getCgBookmarkMap().keySet()) {
            if (rpcg.getCGUID().getId() == protectionInfo.getRpVolumeGroupID()) {
                for (RPBookmark bookmark : response.getCgBookmarkMap().get(rpcg)) {
                    if (bookmark.getBookmarkName() != null && bookmark.getBookmarkName().equalsIgnoreCase(name) && bookmark.getCGGroupCopyUID().getGlobalCopyUID().getCopyUID() == protectionInfo.getRpVolumeGroupCopyID()) {
                        snapshot.setEmCGGroupCopyId(protectionInfo.getRpVolumeGroupCopyID());
                        break;
                    }
                }
            }
        }
        if (targetVolume.getId().equals(volume.getId())) {
            _log.error("The source and the target volumes are the same");
            throw DeviceControllerExceptions.recoverpoint.cannotActivateSnapshotNoTargetVolume();
        }
        snapshot.setDeviceLabel(targetVolume.getDeviceLabel());
        snapshot.setStorageController(targetVolume.getStorageController());
        snapshot.setSystemType(targetVolume.getSystemType());
        snapshot.setVirtualArray(targetVolume.getVirtualArray());
        snapshot.setNativeId(targetVolume.getNativeId());
        snapshot.setAlternateName(targetVolume.getAlternateName());
        snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
        snapshot.setIsSyncActive(false);
        // Setting the WWN of the bookmark to the WWN of the volume, no functional reason for now.
        snapshot.setWWN(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
        snapshot.setProtectionController(system.getId());
        snapshot.setProtectionSet(volume.getProtectionSet().getURI());
        _log.info(String.format("Updated bookmark %1$s associated with block volume %2$s on site %3$s.", name, volume.getDeviceLabel(), snapshot.getEmInternalSiteName()));
        _dbClient.updateObject(snapshot);
        List<URI> taskSnapshotURIList = new ArrayList<URI>();
        taskSnapshotURIList.add(snapshot.getId());
        TaskCompleter completer = new BlockSnapshotCreateCompleter(taskSnapshotURIList, opId);
        completer.ready(_dbClient);
    }
    // Get information about the bookmarks created so we can get to them later.
    _log.info("Bookmark(s) created for snapshot operation");
    return;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) Date(java.util.Date) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) VolumeVpoolChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVpoolChangeTaskCompleter) RPCGProtectionTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter) RPBookmark(com.emc.storageos.recoverpoint.objectmodel.RPBookmark)

Example 2 with RPConsistencyGroup

use of com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup in project coprhd-controller by CoprHD.

the class RecoverPointClient method createBookmarks.

/**
 * Creates a bookmark against one or more consistency group
 *
 * @param CreateBookmarkRequestParams request - contains the information about which CGs to create bookmarks on
 *
 * @return CreateBookmarkResponse - response as to success or fail of creating the bookmarks
 *
 * @throws RecoverPointException
 */
public CreateBookmarkResponse createBookmarks(CreateBookmarkRequestParams request) throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, request, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    return bookmarkManager.createCGBookmarks(functionalAPI, rpCGMap, request);
}
Also used : RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) HashSet(java.util.HashSet)

Example 3 with RPConsistencyGroup

use of com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup in project coprhd-controller by CoprHD.

the class RecoverPointClient method disableImageCopies.

/**
 * Disables copy images for one or more consistency group copies
 *
 * @param MultiCopyDisableImageRequestParams request - contains the information about which CG copies to disable
 *
 * @return MultiCopyDisableImageResponse - response as to success or fail of disabling the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyDisableImageResponse disableImageCopies(MultiCopyDisableImageRequestParams request) throws RecoverPointException {
    MultiCopyDisableImageResponse response = new MultiCopyDisableImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToDisable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        cgSetToDisable.add(rpCGMap.get(volume));
    }
    for (RPConsistencyGroup rpcg : cgSetToDisable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, copy.getCGGroupCopyUID());
            if (request.getEmName() == null || request.getEmName().isEmpty() || (copyState != null && copyState.getAccessedImage() != null && copyState.getAccessedImage().getDescription() != null && copyState.getAccessedImage().getDescription().equals(request.getEmName()))) {
                imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
            }
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) MultiCopyDisableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyDisableImageResponse) HashSet(java.util.HashSet)

Example 4 with RPConsistencyGroup

use of com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup in project coprhd-controller by CoprHD.

the class RecoverPointBookmarkManagementUtils method mapCGsForWWNs.

/**
 * Take a list of WWNs for a RecoverPoint appliance and return consistency group information for the WWNs
 *
 * @param impl - RP handle to perform RP operations
 * @param request - Input request of WWNs
 * @param unmappedWWNs - WWNs that could not be mapped to a consistency group
 *
 * @return WWN to consistency group mappings
 *
 * @throws RecoverPointException
 */
public Map<String, RPConsistencyGroup> mapCGsForWWNs(FunctionalAPIImpl impl, CreateBookmarkRequestParams request, Set<String> unmappedWWNs) throws RecoverPointException {
    try {
        Set<String> wwnList = request.getVolumeWWNSet();
        if (wwnList.isEmpty()) {
            logger.error("Input WWN list size is 0");
            return null;
        }
        Map<String, RPConsistencyGroup> returnMap = new HashMap<String, RPConsistencyGroup>();
        Set<String> wwnListCopy = new HashSet<String>();
        for (String wwn : wwnList) {
            wwnListCopy.add(wwn.toLowerCase(Locale.ENGLISH));
            logger.info("Mapping source WWN " + wwn.toLowerCase(Locale.ENGLISH) + " to RecoverPoint CG");
        }
        List<ConsistencyGroupSettings> cgSettings = impl.getAllGroupsSettings();
        RPConsistencyGroup rpCG = null;
        for (ConsistencyGroupSettings cgSetting : cgSettings) {
            for (ReplicationSetSettings rsSetting : cgSetting.getReplicationSetsSettings()) {
                // Only get the unique volumes from a replication set. In MetroPoint, a replication set will list the source volume
                // twice. This is because in MetroPoint each VPLEX leg is considered a copy but the WWN/volume is the same.
                Set<UserVolumeSettings> uvSettings = new HashSet<UserVolumeSettings>();
                uvSettings.addAll(rsSetting.getVolumes());
                for (UserVolumeSettings uvSetting : uvSettings) {
                    String volUID = RecoverPointUtils.getGuidBufferAsString(uvSetting.getVolumeInfo().getRawUids(), false);
                    if (wwnListCopy.contains(volUID.toLowerCase(Locale.ENGLISH))) {
                        // Remove the volUID from the list
                        wwnListCopy.remove(volUID.toLowerCase(Locale.ENGLISH));
                        // We are getting the index of the first production copy because we only need to
                        // get the cluster ID of the source. All source copies in a CG, across different Rsets, are on the same cluster.
                        // Hence we are ok fetching the first one and getting its cluster id and using it.
                        ConsistencyGroupCopyUID productionCopyUID = cgSetting.getProductionCopiesUIDs().get(0);
                        // Get the RecoverPoint CG name and ID
                        String cgName = cgSetting.getName();
                        ConsistencyGroupUID cgUID = cgSetting.getGroupUID();
                        // Get the Copy information
                        RPCopy rpCopy = new RPCopy();
                        rpCopy.setCGGroupCopyUID(uvSetting.getGroupCopyUID());
                        Set<RPCopy> copies = new HashSet<RPCopy>();
                        copies.add(rpCopy);
                        logger.info("Source WWN: " + volUID + " is on RecoverPoint CG " + cgName + " with RecoverPoint CGID " + cgUID.getId());
                        rpCG = new RPConsistencyGroup();
                        rpCG.setName(cgName);
                        rpCG.setCGUID(cgUID);
                        rpCG.setClusterUID(productionCopyUID.getGlobalCopyUID().getClusterUID());
                        rpCG.setSiteToArrayIDsMap(mapCGToStorageArraysNoConnection(cgSetting));
                        rpCG.setCopies(copies);
                        returnMap.put(volUID, rpCG);
                        break;
                    }
                }
            }
            if (wwnListCopy.isEmpty()) {
                break;
            }
        }
        for (String wwnMissing : wwnListCopy) {
            logger.error("Could not map WWN: " + wwnMissing);
            unmappedWWNs.add(wwnMissing);
        }
        return returnMap;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage());
        return null;
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage());
        return null;
    }
}
Also used : UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet)

Example 5 with RPConsistencyGroup

use of com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup in project coprhd-controller by CoprHD.

the class RecoverPointClient method enableImageCopies.

/**
 * Enables copy images for one or more consistency group copies
 *
 * @param MultiCopyEnableImageRequestParams request - contains the information about which CG copies to enable
 *
 * @return MultiCopyEnableImageResponse - response as to success or fail of enabling the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyEnableImageResponse enableImageCopies(MultiCopyEnableImageRequestParams request) throws RecoverPointException {
    MultiCopyEnableImageResponse response = new MultiCopyEnableImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setBookmark(request.getBookmark());
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        // logger.info("Get RPCG for volume: " + volume);
        cgSetToEnable.add(rpCGMap.get(volume));
    }
    // Make sure your copies are OK to enable.
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            try {
                String cgCopyName = functionalAPI.getGroupCopyName(copy.getCGGroupCopyUID());
                String cgName = functionalAPI.getGroupName(copy.getCGGroupCopyUID().getGroupUID());
                if (!imageManager.verifyCopyCapableOfEnableImageAccess(functionalAPI, copy.getCGGroupCopyUID(), request.getBookmark(), false)) {
                    logger.info("Copy " + cgCopyName + " of group " + cgName + " is in a mode that disallows enabling the CG copy.");
                    throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCG(cgName, cgCopyName);
                }
            } catch (FunctionalAPIActionFailedException_Exception e) {
                throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
            } catch (FunctionalAPIInternalError_Exception e) {
                throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
            }
        }
    }
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            boolean waitForLinkState = true;
            imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : MultiCopyEnableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) HashSet(java.util.HashSet)

Aggregations

RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)8 HashSet (java.util.HashSet)7 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)4 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)4 RPCopy (com.emc.storageos.recoverpoint.objectmodel.RPCopy)4 RecoverPointBookmarkManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils)4 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)3 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)3 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)2 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)2 RPBookmark (com.emc.storageos.recoverpoint.objectmodel.RPBookmark)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)1 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1