use of com.emc.storageos.recoverpoint.objectmodel.RPCopy 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;
}
use of com.emc.storageos.recoverpoint.objectmodel.RPCopy 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;
}
}
use of com.emc.storageos.recoverpoint.objectmodel.RPCopy 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;
}
use of com.emc.storageos.recoverpoint.objectmodel.RPCopy in project coprhd-controller by CoprHD.
the class RecoverPointClient method restoreImageCopies.
/**
* Restore copy images for one or more consistency group copies
*
* @param MultiCopyRestoreImageRequestParams request - contains the information about which CG copies to restore
*
* @return MultiCopyRestoreImageResponse - response as to success or fail of restoring the image copies
*
* @throws RecoverPointException
*/
public MultiCopyRestoreImageResponse restoreImageCopies(MultiCopyRestoreImageRequestParams request) throws RecoverPointException {
MultiCopyRestoreImageResponse response = new MultiCopyRestoreImageResponse();
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));
}
ClusterUID siteToRestore = null;
// Verify that we are not restoring from different sites
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
if (siteToRestore == null) {
siteToRestore = copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID();
} else if (siteToRestore.getId() != copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID().getId()) {
throw RecoverPointException.exceptions.cannotRestoreVolumesFromDifferentSites(wwnSet);
}
try {
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(copy.getCGGroupCopyUID().getGroupUID()).getProductionCopiesUIDs();
for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
if (RecoverPointUtils.copiesEqual(productionCopyUID, copy.getCGGroupCopyUID())) {
throw RecoverPointException.exceptions.cannotRestoreVolumesInConsistencyGroup(wwnSet);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
}
}
}
try {
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
boolean waitForLinkState = false;
imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
}
}
} catch (RecoverPointException e) {
logger.error("Caught exception while enabling CG copies for restore. Return copies to previous state");
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
throw e;
}
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.restoreEnabledCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
Aggregations