Examples of AugeasModuleConfig


Examples of org.rhq.augeas.config.AugeasModuleConfig

                        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();
                        }

                        try {
                            vhostFileFile.createNewFile();
                        } catch (IOException e) {
                            LOG.error("Failed to create a new vhost file: " + vhostFile, e);
                        }

                        comp.close();
                        comp = getAugeas();
                        tree = comp.getAugeasTree(moduleConfig.getModuletName());

                        vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
                        ((ApacheAugeasNode) vhost).setParentNode(tree.getRootNode());

                    }
View Full Code Here

Examples of org.rhq.augeas.config.AugeasModuleConfig

        throws AugeasRhqException {

        this.ag = component.getAugeas();

        AugeasConfigurationApache apacheConfig = (AugeasConfigurationApache) config;
        AugeasModuleConfig module = config.getModuleByName(name);

        ApacheAugeasTree tree = new ApacheAugeasTree(apacheConfig.getServerRootPath(), component.getAugeas(), module);

        List<String> incld = module.getConfigFiles();

        if (incld.isEmpty())
            throw new AugeasRhqException("No configuration provided.");

        String rootPath = incld.get(0);

        AugeasNode rootNode = new ApacheAugeasNode(ApacheAugeasTree.AUGEAS_DATA_PATH + rootPath, tree);
        tree.setRootNode(rootNode);
        // we need to know which files are related to each glob

        for (String inclName : module.getIncludedGlobs()) {

            List<File> files = new ArrayList<File>();

            File check = new File(inclName);
            File root = new File(check.isAbsolute() ? Glob.rootPortion(inclName) : apacheConfig.getServerRootPath());
            files.addAll(Glob.match(root, inclName, Glob.ALPHABETICAL_COMPARATOR));

            if (module.getExcludedGlobs() != null)
                Glob.excludeAll(files, module.getExcludedGlobs());

            if (!includes.containsKey(inclName))
                includes.put(inclName, files);
        }
View Full Code Here

Examples of org.rhq.augeas.config.AugeasModuleConfig

          loadPath = pluginConfiguration.getSimpleValue(AUGEAS_LOAD_PATH, "");
           if (loadPath.equals("")){
             loadPath = path;
             }
      
        AugeasModuleConfig config = new AugeasModuleConfig();
          config.setIncludedGlobs(includes);
          config.setExcludedGlobs(excludes);         
          config.setLensPath(getAugeasModuleName(pluginConfiguration) + ".lns");
          config.setModuletName(getAugeasModuleName(pluginConfiguration));
        modules.add(config);
       
        }catch(Exception e){
          log.error("Creation of temporary Directory for augeas lens failed.");
          throw new AugeasRhqException("Creation of temporary Directory for augeas lens failed.",e);
View Full Code Here

Examples of org.rhq.augeas.config.AugeasModuleConfig

    }

    public Configuration updateConfiguration(Configuration configuration) throws AugeasRhqException {
        if (modules.isEmpty())
            throw new AugeasRhqException("Error in augeas Configuration.");
        AugeasModuleConfig tempModule = modules.get(0);

        PropertySimple includeProps = getGlobList(INCLUDE_GLOBS_PROP, tempModule.getIncludedGlobs());
        PropertySimple excludeProps = getGlobList(EXCLUDE_GLOBS_PROP, tempModule.getExcludedGlobs());
        configuration.put(includeProps);
        configuration.put(excludeProps);

        return configuration;
    }
View Full Code Here

Examples of org.rhq.augeas.config.AugeasModuleConfig

    public AugeasTree buildTree(AugeasProxy component, AugeasConfiguration moduleConfig, String name, boolean lazy)
        throws AugeasTreeException {

        AugeasTree tree;
        AugeasModuleConfig module = moduleConfig.getModuleByName(name);
        if (lazy)
            tree = new AugeasTreeLazy(component.getAugeas(), module);
        else
            tree = new AugeasTreeReal(component.getAugeas(), module);

        AugeasNode rootNode = new AugeasRootNode();

        for (String fileName : module.getConfigFiles()) {
            rootNode.addChildNode(tree.createNode(AUGEAS_DATA_PATH + File.separatorChar + fileName));
        }

        tree.setRootNode(rootNode);
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.