Examples of ApacheDirectiveTree


Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

     * @param keepConditionalDirectives whether to keep conditional directives in the tree (true) or whether to
     *                                  transparently include/ignore their children based on runtime config info (false)
     * @throws IllegalStateException if none or more than one directives found
     */
    public ApacheDirective getDirective(boolean keepConditionalDirectives) {
        ApacheDirectiveTree tree = resourceContext.getParentResourceComponent().parseRuntimeConfiguration(true,
            keepConditionalDirectives);

        String resourceKey = resourceContext.getResourceKey();

        int snmpIdx = getWwwServiceIndex();

        if (snmpIdx < 1) {
            throw new IllegalStateException("Could not determine the index of the virtual host [" + resourceKey
                + "] in the runtime configuration. This is very strange.");
        }

        if (snmpIdx == 1) {
            return tree.getRootNode();
        }

        final List<ApacheDirective> allVhosts  = tree.findByName("<VirtualHost", true);
       
        //transform the SNMP index into the index of the vhost
        int idx = allVhosts.size() - snmpIdx + 1;

        return allVhosts.get(idx);
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

        int foundIdx = 0;

        //only look for the vhost entry if the vhost we're looking for isn't the main server
        if (!MAIN_SERVER_RESOURCE_KEY.equals(vhostAddressStrings[0])) {
            ApacheDirectiveTree tree = parent.parseRuntimeConfiguration(false);

            //find the vhost entry the resource key represents
            List<ApacheDirective> vhosts = tree.search("/<VirtualHost");
            for (ApacheDirective vhost : vhosts) {
                List<ApacheDirective> serverNames = vhost.getChildByName("ServerName");
                String serverName = serverNames.size() > 0 ? serverNames.get(0).getValuesAsString() : null;

                List<String> addrs = vhost.getValues();
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

            new PropertySimple(PluginDescriptorBasedAugeasConfiguration.INCLUDE_GLOBS_PROP, serverConfigFile);
        pluginConfig.put(inclusionGlobs);

        pluginConfig.put(new PropertyList(ApacheServerComponent.PLUGIN_CONFIG_CUSTOM_MODULE_NAMES));

        ApacheDirectiveTree serverConfig =
            parseRuntimeConfiguration(serverConfigFile.getAbsolutePath(), process.getProcessInfo(), binaryInfo);

        String serverUrl = null;
        String vhostsGlobInclude = null;

        //now check if the httpd.conf doesn't redefine the ServerRoot
        List<ApacheDirective> serverRoots = serverConfig.search("/ServerRoot");
        if (!serverRoots.isEmpty()) {
            serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
            serverRootProp.setValue(serverRoot);
        }
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

                + ApacheServerComponent.PLUGIN_CONFIG_PROP_HTTPD_CONF + "' connection property is set correctly.");
        }
    }

    public static ApacheDirectiveTree parseFullConfiguration(String path, String serverRoot) {
        ApacheDirectiveTree tree = new ApacheDirectiveTree();
        ApacheParser parser = new ApacheParserImpl(tree, serverRoot, null);
        ApacheConfigReader.buildTree(path, parser);
        return tree;
    }
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

        RuntimeApacheConfiguration.NodeInspector insp =
            RuntimeApacheConfiguration.getNodeInspector(processInfo, binaryInfo, moduleNames,
                suppressUnknownModuleWarnings, keepConditional);

        ApacheDirectiveTree tree = new ApacheDirectiveTree();
        ApacheParser parser = new ApacheParserImpl(tree, defaultServerRoot, insp);
        ApacheConfigReader.buildTree(path, parser);
        return tree;
    }
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

        binfo.setVersion("2.2.17");
        binfo.setRoot(new File(tmpDir, "snmp-mapping").getAbsolutePath());
        MockProcessInfo pinfo = new MockProcessInfo();
        pinfo.setCommandLine(new String[] { "blahblah" });

        ApacheDirectiveTree tree =
            ApacheServerDiscoveryComponent.parseRuntimeConfiguration(
                new File(tmpDir, "snmp-mapping/httpd.conf").getAbsolutePath(), pinfo, binfo);

        HttpdAddressUtility addrUtil = HttpdAddressUtility.get("2.2.17");
        List<ApacheDirective> vhosts = tree.search("/<VirtualHost");
        List<String> snmpNames = new ArrayList<String>(vhosts.size() + 1);
        snmpNames.add(addrUtil.getHttpdInternalMainServerAddressRepresentation(tree).toString(false, false));
        for (ApacheDirective vhost : vhosts) {
            String vhostDef = vhost.getValues().get(0);
            String serverName = null;
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

        binfo.setVersion("2.2.17");
        binfo.setRoot(new File(tmpDir, "runtime-config/conditional").getAbsolutePath());
        MockProcessInfo pinfo = new MockProcessInfo();
        pinfo.setCommandLine(new String[] { "blahblah", "-D", "DEFINED" });

        ApacheDirectiveTree tree =
            ApacheServerDiscoveryComponent.parseRuntimeConfiguration(new File(tmpDir,
                "runtime-config/conditional/httpd.conf").getAbsolutePath(), pinfo, binfo);

        List<VhostSpec> vhosts = VhostSpec.detect(tree);
View Full Code Here

Examples of org.rhq.plugins.apache.parser.ApacheDirectiveTree

        binfo.setVersion("2.2.17");
        binfo.setRoot(new File(tmpDir, "runtime-config/incl-order").getAbsolutePath());
        MockProcessInfo pinfo = new MockProcessInfo();
        pinfo.setCommandLine(new String[] { "blahblah" });

        ApacheDirectiveTree tree =
            ApacheServerDiscoveryComponent.parseRuntimeConfiguration(new File(tmpDir,
                "runtime-config/incl-order/httpd.conf").getAbsolutePath(), pinfo, binfo);

        List<ApacheDirective> listens = tree.search("/Listen");

        assertEquals(listens.size(), 3, "There should be 3 listen directives");

        assertEquals(listens.get(0).getValuesAsString(), "80");
        assertEquals(listens.get(1).getValuesAsString(), "81");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.