Package lcmc.drbd.domain

Examples of lcmc.drbd.domain.DrbdXml$HostProxy


                             final int leftWidth,
                             final int rightWidth,
                             final boolean wizard,
                             final Map<Host, Widget> newInsideIpComboBoxHash,
                             final Map<Host, Widget> newOutsideIpComboBoxHash) {
        final DrbdXml dxml = getBrowser().getDrbdXml();
        for (final Host pHost : new HashSet<Host>(getCluster().getProxyHosts())) {
            final String section = Tools.getString("ResourceInfo.Proxy") + pHost.getName();
            final JPanel sectionPanel = getParamPanel(section);
            addSectionPanel(section, wizard, sectionPanel);
            enableSection(section, !DrbdProxy.PROXY, wizard);
            sectionPanel.setBackground(AppDefaults.LIGHT_ORANGE);
            final Value[] proxyNetInterfaces = getNetInterfaces(pHost.getBrowser());
            /* inside ip */
            if (proxyNetInterfaces == null) {
                //TODO: just textfield
            }
            final Widget iIpWi = widgetFactory.createInstance(
                                        Widget.Type.COMBOBOX,
                                        Widget.NO_DEFAULT,
                                        proxyNetInterfaces,
                                        Widget.NO_REGEXP,
                                        rightWidth,
                                        Widget.NO_ABBRV,
                                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                        Widget.NO_BUTTON);
            iIpWi.setAlwaysEditable(!pHost.isConnected());
            newInsideIpComboBoxHash.put(pHost, iIpWi);

            final JLabel insideIpLabel = new JLabel(Tools.getString("ResourceInfo.ProxyInsideIp"));
            iIpWi.setLabel(insideIpLabel, Tools.getString("ResourceInfo.ProxyInsideIp.ToolTip"));
            final JPanel panel = new JPanel();
            addField(panel, insideIpLabel, iIpWi.getComponent(), leftWidth, rightWidth, 0);
            panel.setBackground(AppDefaults.LIGHT_ORANGE);
            panel.setLayout(new SpringLayout());
            sectionPanel.add(panel);

            /* outside ip */
            final Widget oIpWi = widgetFactory.createInstance(
                                                    Widget.Type.COMBOBOX,
                                                    Widget.NO_DEFAULT,
                                                    proxyNetInterfaces,
                                                    Widget.NO_REGEXP,
                                                    rightWidth,
                                                    Widget.NO_ABBRV,
                                                    new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                                                    Widget.NO_BUTTON);
            oIpWi.setAlwaysEditable(!pHost.isConnected());
            newOutsideIpComboBoxHash.put(pHost, oIpWi);

            final JLabel outsideIpLabel = new JLabel(Tools.getString("ResourceInfo.ProxyOutsideIp"));
            oIpWi.setLabel(outsideIpLabel, Tools.getString("ResourceInfo.ProxyOutsideIp.ToolTip"));
            addField(panel, outsideIpLabel, oIpWi.getComponent(), leftWidth, rightWidth, 0);
            SpringUtilities.makeCompactGrid(panel, 2, 2, /* rows, cols */
                                            1, 1,           /* initX, initY */
                                            1, 1);          /* xPad, yPad */
            optionsPanel.add(sectionPanel);
        }

        for (final Host host : getHosts()) {
            final HostProxy hostProxy = dxml.getHostProxy(host.getName(), getName());
            Value insideIpSaved = null;
            Value outsideIpSaved = null;
            final Host proxyHost;
            if (hostProxy != null) {
                insideIpSaved = hostProxy.getInsideIp();
View Full Code Here


        if (outsidePortComboBox != null && !Tools.areEqual(savedOutsidePort, outsidePortComboBox.getValue())) {
            changed = true;
        }

        /* ips */
        final DrbdXml dxml = getBrowser().getDrbdXml();
        for (final Host host : getHosts()) {
            final Host proxyHost = getProxyHost(host, !WIZARD);
            if (proxyHost == null) {
                continue;
            }
            final Widget wi = insideIpComboBoxHash.get(proxyHost);
            if (wi == null) {
                continue;
            }
            Value ipSaved = savedInsideIps.get(proxyHost);
            final Value defaultInsideIp = getDefaultInsideIp(proxyHost);
            if (ipSaved == null) {
                ipSaved = defaultInsideIp;
            }
            final Value value = wi.getValue();
            if (!Tools.areEqual(ipSaved, value)) {
                changed = true;
            }
        }

        for (final Host host : getHosts()) {
            final HostProxy hostProxy = dxml.getHostProxy(host.getName(), getName());
            final Host proxyHost;
            if (hostProxy != null) {
                proxyHost = getCluster().getProxyHostByName(hostProxy.getProxyHostName());
            } else {
                proxyHost = host;
View Full Code Here

            portLabel = Tools.getString("ResourceInfo.NetInterfacePort");
        }
        portCB.getLabel().setText(portLabel);
        final Widget protocolWi = getWidget(DrbdXml.PROTOCOL_PARAM, Widget.WIZARD_PREFIX);
        final Widget pingTimeoutWi = getWidget(DrbdXml.PING_TIMEOUT_PARAM, Widget.WIZARD_PREFIX);
        final DrbdXml dxml = getBrowser().getDrbdXml();
        if (protocolWi != null && getResource().isNew()) {
            if (isProxy) {
                protocolWi.setValue(PROXY_DEFAULT_PROTOCOL);
                pingTimeoutWi.setValue(PROXY_DEFAULT_PING_TIMEOUT);
            } else {
                protocolWi.setValue(dxml.getParamPreferred(DrbdXml.PROTOCOL_PARAM));
                pingTimeoutWi.setValue(dxml.getParamDefault(DrbdXml.PING_TIMEOUT_PARAM));
            }
        }
    }
View Full Code Here

        super.init(name, browser);
        setResource(new Resource(name));
    }

    public void setParameters() {
        final DrbdXml dxml = getBrowser().getDrbdXml();
        final Cluster cluster = getCluster();
        for (final String hostName : dxml.getProxyHostNames()) {
            final Host proxyHost = cluster.getProxyHostByName(hostName);
            if (proxyHost == null) {
                final Host hp = hostFactory.createInstance();
                hp.setHostname(hostName);
                cluster.addProxyHost(hp);
                addProxyHostNode(hp);
            } else {
                if (proxyHostInfo != null && proxyHostInfo.getNode() == null) {
                    addProxyHostNode(proxyHost);
                }
            }
        }
        for (final String param : getParametersFromXML()) {
            final String sectionString = dxml.getSection(param);
            /* remove -options */
            final String section = sectionString.replaceAll("-options$", "");
            Value value;
            final Value defaultValue = getParamDefault(param);
            if (DrbdXml.GLOBAL_SECTION.equals(section)) {
                value = dxml.getGlobalConfigValue(param);
                if (value == null) {
                    value = defaultValue;
                }
            } else {
                value = dxml.getCommonConfigValue(section, param);
                if (value == null || value.isNothingSelected()) {
                    value = defaultValue;
                }
            }
            if ("usage-count".equals(param)) {
View Full Code Here

    }

    /** Returns lsit of all parameters as an array. */
    @Override
    public String[] getParametersFromXML() {
        final DrbdXml drbdXml = getBrowser().getDrbdXml();
        if (drbdXml == null) {
            return null;
        }
        return getEnabledSectionParams(drbdXml.getGlobalParams());
    }
View Full Code Here

        getBrowser().resetFilesystems();
    }

    /** Adds existing drbd resource to the GUI. */
    public ResourceInfo addDrbdResource(final String name, final Set<Host> hosts, final Application.RunMode runMode) {
        final DrbdXml dxml = getBrowser().getDrbdXml();
        final ResourceInfo resourceInfo = resourceInfoProvider.get();
        resourceInfo.init(name, hosts, getBrowser());
        final String[] sections = dxml.getSections();
        for (final String sectionString : sections) {
            /* remove -options */
            final String section = sectionString.replaceAll("-options$", "");
            final String[] params = dxml.getSectionParams(sectionString);
            for (final String param : params) {
                Value value = dxml.getConfigValue(name, section, param);
                if (value == null || value.isNothingSelected()) {
                    value = dxml.getParamDefault(param);
                }
                resourceInfo.getDrbdResource().setValue(param, value);
            }
        }
        resourceInfo.getDrbdResource().setCommited(true);
View Full Code Here

            incorrect.add("no resources inside");
        } else {
            getBrowser().putDrbdResHash();
        }

        final DrbdXml dxml = getBrowser().getDrbdXml();
        if (dxml != null && dxml.isDrbdDisabled()) {
            incorrect.add("DRBD is disabled");
        }

        check.addCheck(super.checkResourceFields(param, params));
        return check;
View Full Code Here

        super.resetInfoPanel();
        infoPanel = null;
    }

    public void updateDrbdInfo() {
        final DrbdXml newDrbdXml = drbdXmlProvider.get();
        newDrbdXml.init(getCluster().getHostsArray(), getBrowser().getHostDrbdParameters());
        for (final Host host : getCluster().getHosts()) {
            final String configString = newDrbdXml.getConfig(host);
            if (configString != null) {
                newDrbdXml.update(configString);
            }
        }
        getBrowser().setDrbdXml(newDrbdXml);
        getBrowser().resetFilesystems();
    }
View Full Code Here

        for (final Host host : hosts) {
            final StringBuilder globalConfig = new StringBuilder(160);
            globalConfig.append("## generated by drbd-gui\n\n");

            final StringBuilder global = new StringBuilder(80);
            final DrbdXml dxml = getBrowser().getDrbdXml();
            /* global options */
            final String[] params = dxml.getSectionParams(DrbdXml.GLOBAL_SECTION);
            global.append("global {\n");
            final boolean volumesAvailable = host.hasVolumes();
            for (final String param : params) {
                Value value = getComboBoxValue(param);
                if (value == null || value.isNothingSelected()) {
                    if ("usage-count".equals(param)) {
                        value = DrbdXml.CONFIG_YES;
                    } else {
                        continue;
                    }
                }
                if (!value.equals(dxml.getParamDefault(param))) {
                    if ("disable-ip-verification".equals(param)
                        || (!volumesAvailable && (isCheckBox(param) || "booleanhandler".equals(getParamType(param))))) {
                        if (value.equals(DrbdXml.CONFIG_YES)) {
                            /* boolean parameter */
                            global.append("\t\t").append(param).append(";\n");
View Full Code Here

     * Creates drbd config for sections and returns it. Removes 'drbd: '
     * from the 'after' parameter.
     */
    protected String drbdSectionsConfig(final Host host) throws Exceptions.DrbdConfigException {
        final StringBuilder config = new StringBuilder("");
        final DrbdXml dxml = getBrowser().getDrbdXml();
        final String[] sections = dxml.getSections();
        final boolean volumesAvailable = host.hasVolumes();
        for (final String sectionString : sections) {
            if (!isSectionEnabled(sectionString)) {
                continue;
            }
            /* remove -options */
            final String section = sectionString.replaceAll("-options$", "");
            if ("resource".equals(section) || DrbdXml.GLOBAL_SECTION.equals(section)) {
                continue;
            }
            final String[] params = dxml.getSectionParams(sectionString);

            if (params.length != 0) {
                final StringBuilder sectionConfig = new StringBuilder("");
                boolean inPlugin = false;
                for (final String param : params) {
View Full Code Here

TOP

Related Classes of lcmc.drbd.domain.DrbdXml$HostProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.