use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointUtils method verifyCGVolumesAttachedToSplitter.
/**
* verify that the volumes in a consistency group are connected to a splitter
*
* @param impl - handle for FAPI
* @param groupUID - consistency group to examine volumes on
* @throws - RecoverPointException
*/
public static void verifyCGVolumesAttachedToSplitter(FunctionalAPIImpl impl, ConsistencyGroupUID groupUID) throws RecoverPointException {
ConsistencyGroupSettings groupSettings;
try {
groupSettings = impl.getGroupSettings(groupUID);
// Get the consistency group settings
for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
// Run over all replication sets
for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
logger.info("Volume : " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is of type " + userVolume.getVolumeType());
if (userVolume.getAttachedSplitters().isEmpty()) {
String volumeWWN = RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false);
logger.warn("Volume " + volumeWWN + " is not attached to any splitters");
Set<SplitterUID> splittersToAttachTo = getSplittersToAttachToForVolume(impl, userVolume.getClusterUID(), userVolume.getVolumeInfo().getVolumeID());
for (SplitterUID splitterUID : splittersToAttachTo) {
SetVolumeParam volumeParam = new SetVolumeParam();
volumeParam.setShouldAttachAsClean(false);
volumeParam.setVolumeID(userVolume.getVolumeInfo().getVolumeID());
logger.info("Attaching volume " + volumeWWN + " to splitter" + impl.getSplitterName(splitterUID));
impl.attachVolumeToSplitter(splitterUID, volumeParam);
}
} else {
for (SplitterUID splitterUID : userVolume.getAttachedSplitters()) {
logger.info("Volume " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is attached to splitter " + impl.getSplitterName(splitterUID));
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointUtils method isSiteLicensed.
/**
* Returns true if the specified RecoverPoint site is licensed.
*
* @param impl
* @return boolean
* @throws Exception
*/
public static boolean isSiteLicensed(FunctionalAPIImpl impl) throws Exception {
// A bad license will be caught hear 99% of the time.
try {
AccountState accountState = impl.getAccountState();
List<LicenseState> licenseStates = accountState.getLicensesStates();
for (LicenseState licenseState : licenseStates) {
if (licenseState.getLicenseStatus().equals(LicenseStatus.ACTIVE)) {
logger.info("Found an active license");
return true;
}
}
logger.error("RecoverPoint licenses do not exist, are invalid, or have expired. Check your RP configuration");
} catch (FunctionalAPIActionFailedException_Exception e) {
return false;
} catch (FunctionalAPIInternalError_Exception e) {
;
return false;
} catch (Exception f) {
throw f;
}
return false;
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception 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.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getAssociatedRPSites.
/**
* Returns a list of sites associated with any given site (or RPA). The user can/should enter a site mgmt IP addr, but they can also
* support the mgmt IP addr of an RPA. This method will return sites, not RPAs
*
* @return set of discovered RP sites
*
* @throws RecoverPointException
*/
public Set<RPSite> getAssociatedRPSites() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
try {
logger.info("RecoverPoint service: Returning all RP Sites associated with endpoint: " + _endpoint);
Set<RPSite> returnSiteSet = new HashSet<RPSite>();
RPSite discoveredSite = null;
ClusterUID localClusterUID = functionalAPI.getLocalCluster();
String localSiteName = "unknown";
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
SortedSet<String> siteNames = new TreeSet<String>();
for (ClusterSettings siteSettings : fullRecoverPointSettings.getSystemSettings().getClustersSettings()) {
String siteName = siteSettings.getClusterName();
siteNames.add(siteName);
}
Iterator<String> iter = siteNames.iterator();
String installationId = "";
while (iter.hasNext()) {
installationId += iter.next();
if (iter.hasNext()) {
installationId += "_";
}
}
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
try {
// TODO: Support multiple management IPs per site
String siteIP = siteSettings.getManagementIPs().get(0).getIp();
String siteName = siteSettings.getClusterName();
if (siteIP == null) {
throw RecoverPointException.exceptions.cannotDetermineMgmtIPSite(siteName);
}
List<RpaConfiguration> rpaList = siteSettings.getRpasConfigurations();
discoveredSite = new RPSite();
discoveredSite.setSiteName(siteName);
discoveredSite.setSiteManagementIPv4(siteIP);
discoveredSite.setSiteVersion(functionalAPI.getRecoverPointVersion().getVersion());
discoveredSite.setSiteVolumes(functionalAPI.getClusterSANVolumes(siteSettings.getCluster(), true));
discoveredSite.setInternalSiteName(siteSettings.getInternalClusterName());
discoveredSite.setSiteUID(siteSettings.getCluster().getId());
if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
localSiteName = siteName;
}
discoveredSite.setNumRPAs(rpaList.size());
String siteGUID = installationId + ":" + siteSettings.getCluster().getId();
logger.info("SITE GUID: " + siteGUID);
discoveredSite.setSiteGUID(siteGUID);
if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
logger.info("Discovered local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
} else {
logger.info("Discovered non-local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
}
returnSiteSet.add(discoveredSite);
} catch (FunctionalAPIInternalError_Exception | FunctionalAPIActionFailedException_Exception fe) {
StringBuffer buf = new StringBuffer();
buf.append(String.format("Internal Error during discover of RP Cluster %s, Skipping discovery of this site.", localSiteName));
if (fe != null) {
buf.append('\n');
buf.append(String.format("Exception returned : %s", fe.getMessage()));
}
logger.warn(buf.toString());
}
}
// 99% of unlicensed RP system errors will be caught here
if (!RecoverPointUtils.isSiteLicensed(functionalAPI)) {
throw RecoverPointException.exceptions.siteNotLicensed(localSiteName);
}
return returnSiteSet;
} catch (RecoverPointException e) {
throw e;
} catch (Exception e) {
logger.error(e.getMessage());
throw RecoverPointException.exceptions.failedToPingMgmtIP(mgmtIPAddress, getCause(e));
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getInitiatorWWNs.
/**
* Given an RP site, return a map of all the RP initiator WWNs for each RPA in that site.
*
* @param internalSiteName - RP internal site name
* @return Map of RPA number to Map with portWWN being the key and nodeWWN the value.
* @throws RecoverPointException
*/
public Map<String, Map<String, String>> getInitiatorWWNs(String internalSiteName) throws RecoverPointException {
Map<String, Map<String, String>> rpaWWNs = new HashMap<String, Map<String, String>>();
try {
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
if (!siteSettings.getInternalClusterName().equals(internalSiteName)) {
continue;
}
ClusterRPAsState clusterRPAState = functionalAPI.getRPAsStateFromCluster(siteSettings.getCluster());
for (RpaState rpaState : clusterRPAState.getRpasStates()) {
for (InitiatorInformation rpaPortState : rpaState.getInitiatorsStates()) {
if (rpaPortState instanceof FiberChannelInitiatorInformation) {
FiberChannelInitiatorInformation initiator = (FiberChannelInitiatorInformation) rpaPortState;
String nodeWWN = WwnUtils.convertWWN(initiator.getNodeWWN(), WwnUtils.FORMAT.COLON);
String portWWN = WwnUtils.convertWWN(initiator.getPortWWN(), WwnUtils.FORMAT.COLON);
String rpaId = String.valueOf(rpaState.getRpaUID().getRpaNumber());
logger.info(String.format("RPA ID: %s - RPA Port WWN : %s, NodeWWN : %s", rpaId, portWWN, nodeWWN));
if (!rpaWWNs.containsKey(rpaId)) {
rpaWWNs.put(rpaId, new HashMap<String, String>());
}
rpaWWNs.get(rpaId).put(portWWN, nodeWWN);
}
}
}
}
return rpaWWNs;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get port information");
throw RecoverPointException.exceptions.failureGettingInitiatorWWNs();
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIInternalError_Exception. Get port information");
throw RecoverPointException.exceptions.failureGettingInitiatorWWNs();
}
}
Aggregations