Package org.rhq.modules.plugins.jbossas7.helper

Examples of org.rhq.modules.plugins.jbossas7.helper.HostConfiguration


            result.setErrorMessage("'" + ServerPluginConfiguration.Property.BASE_DIR
                + "' plugin config prop is not set.");
            return result;
        }

        HostConfiguration hostConfig = getHostConfig();
        String realm = pluginConfig.getSimpleValue("realm", "ManagementRealm");
        File propertiesFile = hostConfig.getSecurityPropertyFile(serverPluginConfig, realm);
        if (!propertiesFile.canWrite()) {
            result.setErrorMessage("Management users properties file [" + propertiesFile + "] is not writable.");
            return result;
        }
View Full Code Here


        return null;
    }

    private HostConfiguration getHostConfig() {
        File configFile;
        HostConfiguration hostConfig;
        try {
            String config = readAttribute(getEnvironmentAddress(), getMode().getHostConfigAttributeName());
            configFile = new File(config);
        } catch (Exception e) {
            // This probably means the server is not running and/or authentication is not set up. Fallback to the
            // host config file set in the plugin config during discovery.
            // TODO (ips, 05/05/12): This is not ideal, because the user could have restarted the server with a
            //                       different config file, since the time it was imported into inventory. The better
            //                       thing to do here is to find the current server process and parse its command line
            //                       to find the current config file name.
            configFile = serverPluginConfig.getHostConfigFile();
            if (configFile == null) {
                throw new RuntimeException("Failed to determine config file path.", e);
            }
        }
        try {
            hostConfig = new HostConfiguration(configFile);
        } catch (Exception e) {
            throw new RuntimeException("Failed to parse configuration file [" + configFile + "].", e);
        }
        return hostConfig;
    }
View Full Code Here

@Test(groups = "unit")
public class XmlFileReadingTest {

    public void hostPort70() throws Exception {
        URL url = getClass().getClassLoader().getResource("standalone70.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
        HostPort hp = hostConfig.getManagementHostPort(
                new AS7CommandLine(new String [] {"java", "foo.Main", "org.jboss.as.standalone"}), AS7Mode.STANDALONE);
        System.out.println(hp);
        assert hp.host.equals("127.0.0.70") : "Host is " + hp.host;
        assert hp.port==19990 : "Port is " + hp.port;
    }
View Full Code Here

        assert hp.port==19990 : "Port is " + hp.port;
    }

    public void hostPort71() throws Exception {
        URL url = getClass().getClassLoader().getResource("standalone71.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
        HostPort hp = hostConfig.getManagementHostPort(
                new AS7CommandLine(new String[] {"java", "foo.Main", "org.jboss.as.standalone"}), AS7Mode.STANDALONE);
        System.out.println(hp);
        // hp : HostPort{host='localhost', port=9990, isLocal=true}
        assert hp.host.equals("127.0.0.71") : "Host is " + hp.host;
        assert hp.port==29990 : "Port is " + hp.port;
View Full Code Here

        assert hp.port==29990 : "Port is " + hp.port;
    }

    public void domainController1() throws Exception {
        URL url = getClass().getClassLoader().getResource("host1.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
        HostPort hp = hostConfig.getDomainControllerHostPort(new AS7CommandLine(new String[]{"java", "foo.Main",
                "org.jboss.as.host-controller"}));
        assert hp.isLocal : "DC is not local as expected: " + hp;
    }
View Full Code Here

        assert hp.isLocal : "DC is not local as expected: " + hp;
    }

    public void domainController2() throws Exception {
        URL url = getClass().getClassLoader().getResource("host2.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
        HostPort hp = hostConfig.getDomainControllerHostPort(new AS7CommandLine(new String[]{"java", "foo.Main",
                "org.jboss.as.host-controller"}));
        assert "192.168.100.1".equals(hp.host) : "DC is at " + hp.host;
        assert hp.port == 9559 : "DC port is at " + hp.port;
    }
View Full Code Here

        assert hp.port == 9559 : "DC port is at " + hp.port;
    }

    public void domainController3() throws Exception {
        URL url = getClass().getClassLoader().getResource("host3.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
        HostPort hp = hostConfig.getDomainControllerHostPort(new AS7CommandLine(new String[]{"java", "foo.Main",
                "org.jboss.as.host-controller", "--master-address=192.168.123.123"}));
        assert "192.168.123.123".equals(hp.host) : "DC is at " + hp.host;
        assert hp.port == 1234 : "DC port is at " + hp.port;
    }
View Full Code Here

    }


    public void testXpath70() throws Exception {
        URL url = getClass().getClassLoader().getResource("standalone70.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));
/*
        String realm = bd.obtainXmlPropertyViaXPath("/management/management-interfaces/http-interface/@security-realm");
        assert "ManagementRealm".equals(realm) : "Realm was " + realm;
*/
        String pathExpr = "//management/management-interfaces/http-interface/@port";
        String port = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "19990".equals(port) : "Port was [" + port + "]";

        pathExpr = "//management/management-interfaces/http-interface/@interface";
        String interfName = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "management".equals(interfName) : "Interface was " + interfName;

        pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value";
        String interfElem = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "${jboss.bind.address.management:127.0.0.70}".equals(interfElem) : "InterfElem was " + interfElem;
    }
View Full Code Here

    }


    public void testXpath71() throws Exception {
        URL url = getClass().getClassLoader().getResource("standalone71.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));

        String realm = hostConfig.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm");
        assert "ManagementRealm".equals(realm) : "Realm was " + realm;
        String sbindingRef = hostConfig.obtainXmlPropertyViaXPath(
                ("//management/management-interfaces/http-interface/socket-binding/@http"));
        assert "management-http".equals(sbindingRef): "Socketbinding was " + sbindingRef;

        String pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@port";
        String port = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "29990".equals(port) : "Port was [" + port + "]";

        pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@interface";
        String interfName = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "management".equals(interfName) : "Interface was " + interfName;

        pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value";
        String interfElem = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "${jboss.bind.address.management:127.0.0.71}".equals(interfElem) : "InterfElem was " + interfElem;
    }
View Full Code Here

        assert "${jboss.bind.address.management:127.0.0.71}".equals(interfElem) : "InterfElem was " + interfElem;
    }

    public void testXpath711() throws Exception {
        URL url = getClass().getClassLoader().getResource("standalone711.xml");
        HostConfiguration hostConfig = new HostConfiguration(new File(url.getPath()));

        String realm = hostConfig.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm");
        assert "ManagementRealm".equals(realm) : "Realm was " + realm;
        String sbindingRef = hostConfig.obtainXmlPropertyViaXPath(
                ("//management/management-interfaces/http-interface/socket-binding/@http"));
        assert "management-http".equals(sbindingRef): "Socketbinding was " + sbindingRef;

        String pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@port";
        String port = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "${jboss.management.http.port:9990}".equals(port) : "Port was [" + port + "]";

        pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@interface";
        String interfName = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "management".equals(interfName) : "Interface was " + interfName;

        pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value";
        String interfElem = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "${jboss.bind.address.management:127.0.0.71}".equals(interfElem) : "InterfElem was " + interfElem;

        String socketBindingGroupName = "standard-sockets";
        pathExpr = "/server/socket-binding-group[@name='" + socketBindingGroupName + "']/@port-offset";
        String offsetAttr = hostConfig.obtainXmlPropertyViaXPath(pathExpr);
        assert "${jboss.socket.binding.port-offset:123}".equals(offsetAttr) : "Port-Offset was " + offsetAttr;
    }
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.helper.HostConfiguration

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.