Search in sources :

Example 1 with ClusterIpInfo

use of com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo in project coprhd-controller by CoprHD.

the class ClusterInfo method ipReconfig.

/**
 * Submit cluster IPs reconfiguration requests.
 *
 * @param ipReconfigForm
 */
public static void ipReconfig(final ClusterIpInfoForm ipReconfigForm) {
    ipReconfigForm.validate();
    if (Validation.hasErrors()) {
        params.flash();
        Validation.keep();
        clusterIpInfo(ipReconfigForm);
    }
    final ViPRSystemClient client = BourneUtil.getSysClient();
    final ClusterIpInfo clusterIpInfo = ipReconfigForm.getClusterIpInfo();
    try {
        boolean isAccepted = client.control().reconfigClusterIps(clusterIpInfo, ipReconfigForm.powerOff);
        if (isAccepted) {
            flash.put("info", MessagesUtils.get(SUCCESS_KEY));
        } else {
            flash.error(MessagesUtils.get(ERROR_KEY));
        }
    } catch (Exception e) {
        flash.error(MessagesUtils.get(EXCEPTION_KEY, e.getMessage()));
        Logger.error(e, e.getMessage());
    }
    clusterIpInfo(ipReconfigForm);
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo) ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) FlashException(controllers.util.FlashException)

Example 2 with ClusterIpInfo

use of com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo in project coprhd-controller by CoprHD.

the class ClusterInfo method clusterIpInfo.

/**
 * loads cluster ip configuration details
 */
public static void clusterIpInfo(ClusterIpInfoForm ipReconfigForm) {
    if (ipReconfigForm == null) {
        ViPRSystemClient client = BourneUtil.getSysClient();
        ClusterIpInfo clusterIpInfo = client.control().getClusterIpinfo();
        ipReconfigForm = new ClusterIpInfoForm();
        ipReconfigForm.load(clusterIpInfo);
        ClusterNetworkReconfigStatus ipReconfigStatus = client.control().getClusterIpReconfigStatus();
        if (ipReconfigStatus != null && ipReconfigStatus.getStatus() != null) {
            if (ipReconfigStatus.getStatus().equals(ClusterNetworkReconfigStatus.Status.FAILED)) {
                flash.error(MessagesUtils.get(RECONFIGURATION_STATUS_ERROR, ipReconfigStatus.getMessage()));
            } else if (ipReconfigStatus.getStatus().equals(ClusterNetworkReconfigStatus.Status.SUCCEED)) {
                if (ipReconfigStatus.isRecentlyReconfigured()) {
                    flash.put("info", MessagesUtils.get(RECONFIGURATION_STATUS_SUCCESS));
                }
            }
        }
    }
    // NOSONAR
    vip = ipReconfigForm.selectVipforStatusQuery();
    // ("Suppressing Sonar violation of Lazy initialization of static fields should be synchronized for vip. vip only fetches network info. Sync not needed.")
    loadRenderArgs();
    render(ipReconfigForm);
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo) ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterNetworkReconfigStatus(com.emc.vipr.model.sys.ipreconfig.ClusterNetworkReconfigStatus)

Example 3 with ClusterIpInfo

use of com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo in project coprhd-controller by CoprHD.

the class Main method rollbackToOldIP.

private static void rollbackToOldIP() throws Exception {
    if (!FileUtils.exists(IpReconfigConstants.OLDIP_PATH)) {
        log.info("No old ip file {} for rollback. Exit...", IpReconfigConstants.OLDIP_PATH);
        return;
    }
    // 1. get current ip info from ovfenv device
    Map<String, String> ovfenvprop = PlatformUtils.getOvfenvProperties();
    String node_id = ovfenvprop.get(PropertyConstants.NODE_ID_KEY);
    int node_count = Integer.valueOf(ovfenvprop.get(PropertyConstants.NODE_COUNT_KEY));
    // 2. get old ip info from local file
    ClusterIpInfo oldIpinfo = IpReconfigUtil.readIpinfoFile(IpReconfigConstants.OLDIP_PATH);
    // 3. apply old ipinfo
    applyIpinfo(oldIpinfo, node_id, node_count, false);
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo)

Example 4 with ClusterIpInfo

use of com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo in project coprhd-controller by CoprHD.

the class Main method commitNewIP.

private static void commitNewIP() throws Exception {
    if (!FileUtils.exists(IpReconfigConstants.NEWIP_PATH)) {
        log.info("No new ip file {} for applying. Exit...", IpReconfigConstants.NEWIP_PATH);
        return;
    }
    String strExpirationTime = (String) FileUtils.readObjectFromFile(IpReconfigConstants.NEWIP_EXPIRATION);
    if (System.currentTimeMillis() >= Long.valueOf(strExpirationTime)) {
        log.info("Ip reconfiguration procedure has expired.  Will not applying new IPs info. Exit...");
        return;
    }
    // 1. get current ip info from ovfenv device
    Map<String, String> ovfenvprop = PlatformUtils.getOvfenvProperties();
    String node_id = ovfenvprop.get(PropertyConstants.NODE_ID_KEY);
    int node_count = Integer.valueOf(ovfenvprop.get(PropertyConstants.NODE_COUNT_KEY));
    // 2. get new ip info from local file
    ClusterIpInfo newIpinfo = IpReconfigUtil.readIpinfoFile(IpReconfigConstants.NEWIP_PATH);
    // 3. load node status from local file
    IpReconfigConstants.NodeStatus localnode_status = IpReconfigConstants.NodeStatus.valueOf(IpReconfigUtil.readNodeStatusFile());
    log.info("Local node's status is {}.", localnode_status);
    switch(localnode_status) {
        case None:
        case LOCALAWARE_LOCALPERSISTENT:
            log.info("NewIP exists, but should not be commited. Exiting...", localnode_status);
            return;
        case LOCALAWARE_CLUSTERPERSISTENT:
            log.info("Trying to connect with new cluster ...", localnode_status);
            handlePossibleJump(newIpinfo, node_id, node_count);
            break;
        case CLUSTERACK_CLUSTERPERSISTENT:
            log.info("Trying to commit new IPs directly ...", localnode_status);
            applyIpinfo(newIpinfo, node_id, node_count, true);
            break;
        default:
            log.info("No need to handle status {}...", localnode_status);
            return;
    }
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo) IpReconfigConstants(com.emc.storageos.systemservices.impl.ipreconfig.IpReconfigConstants)

Aggregations

ClusterIpInfo (com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo)4 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)2 IpReconfigConstants (com.emc.storageos.systemservices.impl.ipreconfig.IpReconfigConstants)1 ClusterNetworkReconfigStatus (com.emc.vipr.model.sys.ipreconfig.ClusterNetworkReconfigStatus)1 FlashException (controllers.util.FlashException)1