use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method enableProtection.
/**
* Enable (start) the consistency group protection specified by the input volume info
* Requires a full sweep.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to enable
*
* @return void
*
* @throws RecoverPointException
*/
public void enableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
try {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(volumeInfo.getRpVolumeGroupID());
ConsistencyGroupCopyUID cgCopyUID = null;
cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
String cgName = functionalAPI.getGroupName(cgUID);
if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
// Enable the whole CG.
logger.info("Enabling consistency group " + cgName);
functionalAPI.enableConsistencyGroup(cgUID, true);
// Make sure the CG is ready
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
logger.info("Protection enabled on CG " + cgName);
} else {
// Enable the CG copy associated with the target
logger.info("Enabling CG copy " + cgCopyName + " on CG " + cgName);
functionalAPI.enableConsistencyGroupCopy(cgCopyUID, true);
// Make sure the CG copy is stopped
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.ACTIVE);
logger.info("Protection enabled on CG copy " + cgCopyName + " on CG " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID 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.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method waitForCGCopyState.
/**
* Wait for a CG copy to change state
*
* @param port - RP handle to use for RP operations
* @param groupCopy - RP group copy we are looking at
* @param expectRollComplete - true or false we are expecting the state to be LOGGED_ACCESS_WITH_ROLL, and the roll is complete
* @param accessMode - Access modes we are waiting for. Optional
*
* @return void
*
* @throws RecoverPointException, FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception,
* InterruptedException
*/
public void waitForCGCopyState(FunctionalAPIImpl port, ConsistencyGroupCopyUID groupCopy, boolean expectRollComplete, ImageAccessMode... accessMode) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, InterruptedException, RecoverPointException {
ConsistencyGroupUID groupUID = groupCopy.getGroupUID();
List<ConsistencyGroupCopyState> groupCopyStateList;
// groupCopyStateList = groupState.getGroupCopiesState();
String cgName = port.getGroupName(groupCopy.getGroupUID());
String cgCopyName = port.getGroupCopyName(groupCopy);
final int maxMinutes = 30;
// seconds
final int sleepTimeSeconds = 15;
final int secondsPerMin = 60;
final int numItersPerMin = secondsPerMin / sleepTimeSeconds;
List<ImageAccessMode> accessModes = new ArrayList<ImageAccessMode>();
if (accessMode != null) {
accessModes = Arrays.asList(accessMode);
}
logger.info("waitForCGCopyState called for copy " + cgCopyName + " of group " + cgName);
if (!accessModes.isEmpty()) {
logger.info("Waiting up to " + maxMinutes + " minutes for state to change to: " + accessModes.toString());
} else {
logger.info("Waiting up to " + maxMinutes + " minutes for state to change to: DIRECT_ACCESS or NO_ACCESS");
}
for (int minIter = 0; minIter < maxMinutes; minIter++) {
for (int perMinIter = 0; perMinIter < numItersPerMin; perMinIter++) {
groupCopyStateList = port.getGroupState(groupUID).getGroupCopiesStates();
for (ConsistencyGroupCopyState groupCopyState : groupCopyStateList) {
if (RecoverPointUtils.copiesEqual(groupCopyState.getCopyUID(), groupCopy)) {
StorageAccessState copyAccessState = groupCopyState.getStorageAccessState();
logger.info("Current Copy Access State: " + copyAccessState);
if (accessModes.contains(ImageAccessMode.LOGGED_ACCESS)) {
// HACK HACK HACK WJE had to add check for no access journal preserved, otherwise my restore wouldn't continue
if (copyAccessState == StorageAccessState.LOGGED_ACCESS || copyAccessState == StorageAccessState.NO_ACCESS_JOURNAL_PRESERVED) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is in logged access. Enable has completed");
return;
}
} else if (accessModes.contains(ImageAccessMode.VIRTUAL_ACCESS)) {
if (copyAccessState == StorageAccessState.VIRTUAL_ACCESS) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is in virtual access. Enable has completed");
return;
}
} else if (accessModes.contains(ImageAccessMode.VIRTUAL_ACCESS_WITH_ROLL)) {
if (expectRollComplete) {
if (copyAccessState == StorageAccessState.LOGGED_ACCESS_ROLL_COMPLETE) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is in virtual access with roll complete. Enable has completed");
return;
}
} else {
if ((copyAccessState == StorageAccessState.VIRTUAL_ACCESS_ROLLING_IMAGE) || (copyAccessState == StorageAccessState.LOGGED_ACCESS_ROLL_COMPLETE)) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is in virtual access with roll or roll complete. Enable has completed");
return;
}
}
} else {
// Wait for NO_ACCESS or DIRECT_ACCESS
if (copyAccessState == StorageAccessState.DIRECT_ACCESS) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is DIRECT_ACCESS mode");
return;
}
if (copyAccessState == StorageAccessState.NO_ACCESS) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is NO_ACCESS mode");
return;
}
}
}
}
logger.info("Copy image " + cgCopyName + " of group " + cgName + " not in correct state. Sleeping " + sleepTimeSeconds + " seconds");
Thread.sleep(Long.valueOf(sleepTimeSeconds * numMillisInSecond));
}
}
throw RecoverPointException.exceptions.stateChangeNeverCompleted();
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method getCopyLinkState.
/**
* Get the link state of a copy
*
* @param impl - RP handle
* @param cgCopy - CG Copy, contains CG
* @throws RecoverPointException
*/
public ConsistencyGroupLinkState getCopyLinkState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID cgCopy) throws RecoverPointException {
String cgCopyName = NAME_UNKNOWN;
String cgName = NAME_UNKNOWN;
try {
cgCopyName = impl.getGroupCopyName(cgCopy);
cgName = impl.getGroupName(cgCopy.getGroupUID());
ConsistencyGroupUID groupUID = cgCopy.getGroupUID();
ConsistencyGroupState groupState = impl.getGroupState(groupUID);
List<ConsistencyGroupLinkState> linkStates = groupState.getLinksStates();
for (ConsistencyGroupLinkState cgLinkState : linkStates) {
if ((RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getSecondCopy(), cgCopy.getGlobalCopyUID()) || (RecoverPointUtils.copiesEqual(cgLinkState.getGroupLinkUID().getFirstCopy(), cgCopy.getGlobalCopyUID())))) {
return cgLinkState;
}
}
return null;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupUID in project coprhd-controller by CoprHD.
the class RecoverPointImageManagementUtils method getCopyState.
/**
* Verify that a copy is capable of being enabled.
*
* @param impl - RP handle
* @param copyId - CG Copy, contains CG
* @param cgCopyName - copy name
* @param cgName - CG name
* @throws RecoverPointException
*/
public ConsistencyGroupCopyState getCopyState(FunctionalAPIImpl impl, ConsistencyGroupCopyUID copyId, String cgCopyName, String cgName) throws RecoverPointException {
try {
ConsistencyGroupUID groupUID = copyId.getGroupUID();
ConsistencyGroupState groupState;
List<ConsistencyGroupCopyState> cgCopyStateList;
groupState = impl.getGroupState(groupUID);
cgCopyStateList = groupState.getGroupCopiesStates();
for (ConsistencyGroupCopyState cgCopyState : cgCopyStateList) {
if (RecoverPointUtils.copiesEqual(cgCopyState.getCopyUID(), copyId)) {
return cgCopyState;
}
}
return null;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToEnableCopy(cgCopyName, cgName, e);
}
}
Aggregations