Package org.rhq.augeas.node

Examples of org.rhq.augeas.node.AugeasNode


        List<AugeasNode> searchedNodes = AugeasNodeSearch.searchNode(NESTED_DIRECTIVES, nodeName, parentNode);
        List<AugeasNode> results = new ArrayList<AugeasNode>();

        for (AugeasNode node : searchedNodes) {
            AugeasNode tempNode = node;
            boolean match = true;
            int i = 0;

            while (match && i < nodeParams.size() && tempNode != parentNode) {
                List<AugeasNode> childNodes = tempNode.getChildByLabel("param");
                if (childNodes.size() > 0) {
                    if (!nodeParams.get(i).equals(childNodes.get(0).getValue()))
                        match = false;
                } else
                    match = false;
                i = i + 1;
                tempNode = tempNode.getParentNode();
            }

            if (match == true)
                results.add(node);
        }
View Full Code Here


    }

    public static List<String> getParams(AugeasNode node, AugeasNode parentNode) {
        List<String> res = new ArrayList<String>();

        AugeasNode pNode = node;
        while (!pNode.equals(parentNode)) {
            List<AugeasNode> paramNodes = pNode.getChildByLabel("param");
            for (AugeasNode param : paramNodes) {
                res.add(param.getValue());
            }
            pNode = pNode.getParentNode();
        }
        return res;
    }
View Full Code Here

     * @param node
     * @param parentNode
     * @return
     */
    public static String getNodeKey(AugeasNode node, AugeasNode parentNode) {
        AugeasNode pNode = node;
        StringBuilder str = new StringBuilder();
        while (pNode != null && !pNode.equals(parentNode)) {
            str.append(getNodeKeyFromParent(pNode));
            pNode = pNode.getParentNode();
        }
        return str.toString();
    }
View Full Code Here

        return str.toString();
    }

    public static AugeasNode findNodeById(AugeasNode parentNode, String params) {

        AugeasNode tempNode = parentNode;
        String[] ids = params.split(";");
        for (int i = ids.length - 1; i >= 0; i--) {
            tempNode = getNodeFromParentById(tempNode, ids[i]);
        }
        return tempNode;
View Full Code Here

        if (startNode == null)
            return null;

        Configuration resourceConfig = new Configuration();
        String nodeName = startNode.getLabel();
        AugeasNode parentNode = getParentName(startNode);
        List<String> params = AugeasNodeSearch.getParams(startNode, parentNode);

        if (nodeName.equals("<Directory"))
            if (params.size() > 0)
                params.remove(0);
View Full Code Here

        return resourceConfig;
    }

    private AugeasNode getParentName(AugeasNode node) {

        AugeasNode tempNode = node.getParentNode();

        while (!tempNode.equals(tree.getRootNode())) {
            if (tempNode.getLabel().equals("<Directory"))
                return tempNode;

            if (tempNode.getLabel().equals("<VirtualHost"))
                return tempNode;

            tempNode = tempNode.getParentNode();
        }

        return tree.getRootNode();
    }
View Full Code Here

                Configuration pluginConfig = resourceContext.getPluginConfiguration();
                String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
                    PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);

                AugeasNode vhost = null;

                String vhostFile = comp.getConfiguration().getModules().get(0).getConfigFiles().get(0);

                if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
                    vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
                } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
                    String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
                    if (mask == null) {
                        report.setErrorMessage("No virtual host file mask configured.");
                    } else {
                        vhostFile = getNewVhostFileName(addr, mask);
                        File vhostFileFile = new File(vhostFile);

                        //we're creating a new file here, so we must ensure that Augeas does have this file
                        //on its load path, otherwise it will refuse to create it.
                        AugeasConfigurationApache config = (AugeasConfigurationApache) comp.getConfiguration();
                        AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
                        boolean willPersist = false;
                        for (String glob : moduleConfig.getIncludedGlobs()) {
                            if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
                                willPersist = true;
                                break;
                            }
                        }

                        if (!willPersist) {
                            //the file wouldn't be loaded by augeas
                            moduleConfig.addIncludedGlob(vhostFile);
                            //this also means that there was no include
                            //that would load the file, so we have to
                            //add the include directive to the main conf.
                            List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
                            AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null,
                                includes.size() + 1);
                            tree.createNode(include, "param", vhostFile, 0);
                            tree.save();
                        }
View Full Code Here

        ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
        AugeasComponent comp = parentComponent.getAugeas();
        AugeasTree tree = null;
        try {
            tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
            AugeasNode directoryNode = parentComponent.getNode(tree);

            ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
            return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
        } finally {
            comp.close();
View Full Code Here

        AugeasTree tree = null;
        try {
            tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
            ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
            ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
            AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
            mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
            tree.save();

            report.setStatus(ConfigurationUpdateStatus.SUCCESS);
            log.info("Apache configuration was updated");
View Full Code Here

            comp.close();
        }
    }

    private AugeasNode getNode(AugeasNode virtualHost) {
        AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
        return directory;
    }
View Full Code Here

TOP

Related Classes of org.rhq.augeas.node.AugeasNode

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.