Search in sources :

Example 21 with FunctionalAPIActionFailedException_Exception

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);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SetVolumeParam(com.emc.fapiclient.ws.SetVolumeParam) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 22 with FunctionalAPIActionFailedException_Exception

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;
}
Also used : LicenseState(com.emc.fapiclient.ws.LicenseState) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) AccountState(com.emc.fapiclient.ws.AccountState) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

Example 23 with FunctionalAPIActionFailedException_Exception

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;
}
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)

Example 24 with FunctionalAPIActionFailedException_Exception

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));
    }
}
Also used : RpaConfiguration(com.emc.fapiclient.ws.RpaConfiguration) ClusterSettings(com.emc.fapiclient.ws.ClusterSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) TreeSet(java.util.TreeSet) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) HashSet(java.util.HashSet)

Example 25 with FunctionalAPIActionFailedException_Exception

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();
    }
}
Also used : HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RpaState(com.emc.fapiclient.ws.RpaState) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) ClusterRPAsState(com.emc.fapiclient.ws.ClusterRPAsState) FiberChannelInitiatorInformation(com.emc.fapiclient.ws.FiberChannelInitiatorInformation) InitiatorInformation(com.emc.fapiclient.ws.InitiatorInformation) FiberChannelInitiatorInformation(com.emc.fapiclient.ws.FiberChannelInitiatorInformation) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)42 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)42 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)21 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)15 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)11 HashSet (java.util.HashSet)10 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)7 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)7 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)5 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)5 HashMap (java.util.HashMap)5 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)3 ConsistencyGroupCopySnapshots (com.emc.fapiclient.ws.ConsistencyGroupCopySnapshots)3 DeviceUID (com.emc.fapiclient.ws.DeviceUID)3