Search in sources :

Example 1 with ClusterRPAsState

use of com.emc.fapiclient.ws.ClusterRPAsState 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

ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ClusterRPAsState (com.emc.fapiclient.ws.ClusterRPAsState)1 FiberChannelInitiatorInformation (com.emc.fapiclient.ws.FiberChannelInitiatorInformation)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 InitiatorInformation (com.emc.fapiclient.ws.InitiatorInformation)1 RpaState (com.emc.fapiclient.ws.RpaState)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1