use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method getRPBookmarksForCG.
/**
* Find the bookmarks associated with a consistency group
*
* @param impl - RP handle to use for RP operations
* @param cgUID - The CG to look for bookmarks
*
* @return A set of RP bookmarks found on the CG
*
* @throws RecoverPointException
*/
public List<RPBookmark> getRPBookmarksForCG(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID) throws RecoverPointException {
List<RPBookmark> returnBookmarkSet = null;
try {
logger.debug("Getting list of snapshots for CG: " + cgUID.getId());
List<ConsistencyGroupCopySnapshots> cgCopySnapList = impl.getGroupSnapshots(cgUID).getCopiesSnapshots();
for (ConsistencyGroupCopySnapshots cgCopySnap : cgCopySnapList) {
ConsistencyGroupCopyUID copyUID = cgCopySnap.getCopyUID();
logger.debug("Found " + cgCopySnap.getSnapshots().size() + " snapshots on copy: " + copyUID.getGlobalCopyUID().getCopyUID());
for (Snapshot snapItem : cgCopySnap.getSnapshots()) {
// We're not interested in bookmarks without names
if (snapItem.getDescription() != null && !snapItem.getDescription().isEmpty()) {
RPBookmark bookmark = new RPBookmark();
bookmark.setBookmarkTime(snapItem.getClosingTimeStamp());
bookmark.setCGGroupCopyUID(cgCopySnap.getCopyUID());
bookmark.setBookmarkName(snapItem.getDescription());
if (returnBookmarkSet == null) {
returnBookmarkSet = new ArrayList<RPBookmark>();
}
returnBookmarkSet.add(bookmark);
logger.debug("Recording bookmark: " + bookmark.getBookmarkName());
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.exceptionLookingForBookmarks(e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.exceptionLookingForBookmarks(e);
}
logger.debug("Return set has " + ((returnBookmarkSet != null) ? returnBookmarkSet.size() : 0) + " items");
return ((returnBookmarkSet != null) ? returnBookmarkSet : null);
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method enableCopyImage.
/**
* Perform an enable image on a CG copy
*
* @param impl - RP handle to use for RP operations
* @param copyToEnableTo - CG to enable, as well as the bookmark and APIT
* @param failover - whether this operation is a failover or not. Affects current copy check.
* @return void
*
* @throws RecoverPointException
*/
public void enableCopyImage(FunctionalAPIImpl impl, RPCopyRequestParams copyToEnableTo, boolean failover) throws RecoverPointException {
// Check the params
// If bookmark != null, enable the bookmark on the copy, and failover to that copy
// If APITTime != null, enable the specified APIT on the copy, and failover to that copy
// If both are null, enable the most recent imagem, and failover to that copy
String bookmarkName = copyToEnableTo.getBookmarkName();
Date apitTime = copyToEnableTo.getApitTime();
// FunctionalAPIImpl impl = new RecoverPointConnection().connect(endpoint, username, password);
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToEnableTo.getCopyVolumeInfo());
if (bookmarkName != null) {
logger.info("Enable copy to bookmark : " + bookmarkName);
} else if (apitTime != null) {
logger.info("Enable copy to APIT : " + apitTime.toString());
} else {
logger.info("Enable copy to most recent image");
}
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
// Will throw an exception if it's not in the right state
if (!imageManager.verifyCopyCapableOfEnableImageAccess(impl, cgCopyUID, copyToEnableTo.getBookmarkName(), failover)) {
try {
String cgCopyName = impl.getGroupCopyName(cgCopyUID);
String cgName = impl.getGroupName(cgCopyUID.getGroupUID());
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);
}
}
boolean waitForLinkState = false;
imageManager.enableCGCopy(impl, cgCopyUID, waitForLinkState, ImageAccessMode.LOGGED_ACCESS, bookmarkName, apitTime);
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method waitForCGCopyLinkState.
/**
* Wait for CG copy links to become ACTIVE
*
* @param impl access to RP
* @param copyUID copy ID
* @param desiredPipeState - Desired state of the pipe
*
* @return void
*
* @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
* InterruptedException
*/
public void waitForCGCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyUID, PipeState... desiredPipeState) throws RecoverPointException {
int numRetries = 0;
String cgName = null;
try {
cgName = impl.getGroupName(copyUID.getGroupUID());
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
}
List<String> desiredPipeStates = new ArrayList<String>();
if (desiredPipeState != null) {
// build the list of desired pipe states
for (PipeState pipeState : desiredPipeState) {
desiredPipeStates.add(pipeState.name());
}
}
while (numRetries++ < MAX_RETRIES) {
ConsistencyGroupState cgState = null;
try {
cgState = impl.getGroupState(copyUID.getGroupUID());
for (ConsistencyGroupLinkState linkstate : cgState.getLinksStates()) {
// The copy we're interested in may be in the FirstCopy or SecondCopy, so we need to find the link
// state where our copy is the first or second copy and the other copy is a production. There may be
// multiple production copies, so account for that, too. (you can assume there aren't multiple productions
// going to the same target. We used to assume that the targets are "second copy", but that is not true.
boolean found = false;
// Loop through production copies
if (!cgState.getSourceCopiesUIDs().isEmpty()) {
for (ConsistencyGroupCopyUID groupCopyUID : cgState.getSourceCopiesUIDs()) {
if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
found = true;
}
if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), groupCopyUID.getGlobalCopyUID()) && RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID())) {
found = true;
}
}
} else {
// the link source and copy. Just find our copy in the link and go with it.
if (RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getFirstCopy(), copyUID.getGlobalCopyUID()) || RecoverPointUtils.copiesEqual(linkstate.getGroupLinkUID().getSecondCopy(), copyUID.getGlobalCopyUID())) {
found = true;
}
}
if (!found) {
continue;
}
if (desiredPipeStates.contains(PipeState.ACTIVE.name())) {
// Treat SNAP_IDLE as ACTIVE
if (linkstate.getPipeState().equals(PipeState.SNAP_IDLE)) {
linkstate.setPipeState(PipeState.ACTIVE);
}
}
PipeState pipeState = linkstate.getPipeState();
logger.info("Copy link state is " + pipeState.toString() + "; desired states are: " + desiredPipeStates.toString());
if (desiredPipeStates.contains(pipeState.name())) {
logger.info("Copy link state matches the desired state.");
return;
} else {
// This makes sure that if you wanted to act on the entire CG, but there's still a copy
// in the undesired state, we still need to wait for it.
logger.info("Copy link state is not in desired state. It is: " + pipeState.toString());
break;
}
}
logger.info("Copy link not in desired state. Sleep 15 seconds and retry");
Thread.sleep(WAIT_FOR_LINKS_SLEEP_INTERVAL);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
} catch (InterruptedException e) {
throw RecoverPointException.exceptions.cantCheckLinkState(cgName, e);
}
}
throw RecoverPointException.exceptions.cgLinksFailedToBecomeActive(cgName);
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointUtils method enableNewConsistencyGroup.
/**
* @param impl - RP handle to use for RP operations
* @param cgUID - Consistency Group UID
* @param localCopyUID
* @param remoteCopiesUID
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
* @throws RecoverPointException
* @throws FunctionalAPIValidationException_Exception
*/
public static void enableNewConsistencyGroup(FunctionalAPIImpl impl, ConsistencyGroupUID cgUID, List<ConsistencyGroupCopyUID> localCopiesUID, List<ConsistencyGroupCopyUID> remoteCopiesUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, RecoverPointException, FunctionalAPIValidationException_Exception {
logger.info("Start enableNewConsistencyGroup...");
if (remoteCopiesUID != null && !remoteCopiesUID.isEmpty()) {
for (ConsistencyGroupCopyUID remoteCopyUID : remoteCopiesUID) {
try {
logger.info("Validate Remote copy...");
// CG validation warnings will be caught, logged, and
// processing will continue
impl.validateEnableConsistencyGroupCopy(remoteCopyUID, true);
} catch (FunctionalAPIValidationException_Exception e) {
logger.warn(e.getMessage(), e);
}
}
}
if (localCopiesUID != null && !localCopiesUID.isEmpty()) {
for (ConsistencyGroupCopyUID localCopyUID : localCopiesUID) {
try {
logger.info("Validate Local copy...");
// CG validation warnings will be caught, logged, and
// processing will continue
impl.validateEnableConsistencyGroupCopy(localCopyUID, true);
} catch (FunctionalAPIValidationException_Exception e) {
logger.warn(e.getMessage(), e);
}
}
}
// Last thing to do is enable the CG
logger.info("Enable Consistency Group and all copies");
try {
// CG validation warnings will be caught, logged, and
// processing will continue
impl.validateEnableConsistencyGroup(cgUID, true);
} catch (FunctionalAPIValidationException_Exception e) {
logger.warn(e.getMessage(), e);
}
impl.enableConsistencyGroup(cgUID, true);
// Make sure the CG is ready
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGLinkState(impl, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgUID));
logger.info("End enableNewConsistencyGroup.");
}
Aggregations