Package org.rhq.plugins.augeas.helper

Examples of org.rhq.plugins.augeas.helper.AugeasNode


    }

    protected void setNode(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
        AugeasNode parentNode) {
        String propName = getAugeasPathRelativeToParent(propDef, parentNode, augeas);
        AugeasNode node = (propName.equals(".")) ? parentNode : new AugeasNode(parentNode, propName);

        if (isPropertyDefined(propDef, parentPropMap)) {
            // The property *is* defined, which means we either need to add or update the corresponding node in the
            // Augeas tree.
            if (propDef instanceof PropertyDefinitionSimple) {
View Full Code Here


            + listMemberPropDefMapPath);

        // now turn paths into augeas nodes
        List<AugeasNode> existingListMemberNodes = new ArrayList<AugeasNode>();
        for (String existingListMemberPath : existingListMemberPaths) {
            existingListMemberNodes.add(new AugeasNode(existingListMemberPath));
        }

        Set<AugeasNode> updatedListMemberNodes = new HashSet<AugeasNode>();

        for (Property listMemberProp : propList.getList()) {
            PropertyMap listMemberPropMap = (PropertyMap) listMemberProp;
            AugeasNode memberNodeToUpdate = getExistingChildNodeForListMemberPropertyMap(listNode, propDefList,
                listMemberPropMap);
            if (memberNodeToUpdate != null) {
                // Keep track of the existing nodes that we'll be updating, so that we can remove all other existing
                // nodes.
                updatedListMemberNodes.add(memberNodeToUpdate);
            } else {
                // The maps in the list are non-keyed, or there is no map in the list with the same key as the map
                // being added, so create a new node for the map to add to the list.
                AugeasNode basePathNode = getNewListMemberNode(listNode, listMemberPropDefMap, listIndex);
                String var = "prop" + listIndex;
                String bpath = basePathNode.getPath();
                augeas.defineNode(var, bpath, null);
                memberNodeToUpdate = new AugeasNode("$" + var);
                listIndex++;
            }

            // Update the node's children.
            setNodeFromPropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, memberNodeToUpdate);
View Full Code Here

        }
    }

    protected AugeasNode getNewListMemberNode(AugeasNode listNode, PropertyDefinitionMap listMemberPropDefMap,
        int listIndex) {
        return new AugeasNode(listNode, getAugeasPathRelativeToParent(listMemberPropDefMap, listNode, getAugeas())
            + "[" + listIndex + "]");
    }
View Full Code Here

        String metadataNodePrefix = "/augeas/files";
        for (String glob : this.includeGlobs) {
            if (glob.startsWith(AugeasNode.SEPARATOR)) {
                glob = glob.substring(1);
            }
            AugeasNode metadataNode = new AugeasNode(metadataNodePrefix, glob);
            AugeasNode errorNode = new AugeasNode(metadataNode, "error");
            List<String> nodePaths = augeas.match(errorNode.getPath() + "/*");
            for (String path : nodePaths) {
                String error = augeas.get(path);
                summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length()))
                    .append("\":\n").append(error).append("\n");
            }
View Full Code Here

            this.augeas.load();
            checkModuleErrors(this.augeas);
            String resourceConfigRootPath = getResourceConfigurationRootPath();
            if (resourceConfigRootPath.indexOf(AugeasNode.SEPARATOR_CHAR) != 0) {
                // root path is relative - make it absolute
                this.resourceConfigRootNode = new AugeasNode("/files/", resourceConfigRootPath);
            } else {
                // root path is already absolute
                this.resourceConfigRootNode = new AugeasNode(resourceConfigRootPath);
            }
            log.debug("Resource Config Root Node = \"" + this.resourceConfigRootNode + "\"");
        }
    }
View Full Code Here

    private void checkModuleErrors(Augeas augeas) {
        List<String> errors = augeas.match("/augeas/load//error");
        if (errors != null && errors.size() > 0) {
            StringBuilder errorMessage = new StringBuilder();
            for (String nodePath : errors) {
                AugeasNode node = new AugeasNode(nodePath);
                String moduleName = node.getParent().getName();
                String errorText = augeas.get(nodePath);

                errorMessage.append("Module '").append(moduleName).append("' failed with the following errors:\n");
                errorMessage.append(errorText);
                errorMessage.append("\n\n");
View Full Code Here

    }

    @Override
    protected AugeasNode getNewListMemberNode(AugeasNode listNode, PropertyDefinitionMap listMemberPropDefMap,
        int listIndex) {
        return new AugeasNode(listNode, "0" + listIndex);
    }
View Full Code Here

        // Now see if there's at least one node in this list with an 'ipaddr' value with the same IP address version as
        // the PropertyMap.
        String ipaddr = propMap.getSimple("ipaddr").getStringValue();
        int ipAddressVersion = (ipaddr.indexOf(':') == -1) ? 4 : 6;
        for (String canonicalPath : canonicalPaths) {
            AugeasNode canonicalNode = new AugeasNode(canonicalPath);
            AugeasNode childNode = canonicalNode.getParent();
            AugeasNode ipaddrNode = new AugeasNode(childNode, "ipaddr");
            String existingIpaddr = augeas.get(ipaddrNode.getPath());
            int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
            if (existingIpAddressVersion == ipAddressVersion) {
                return childNode;
            }
        }
View Full Code Here

        try {
            augeas = getAugeas();

            File crontabFile = new File(crontabPath);
            String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
            AugeasNode baseNode = new AugeasNode(basePath);

            PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
            PropertyDefinitionList entriesDef = crontabConfigurationDefinition
                .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
            setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
View Full Code Here

            PropertyList ret = new PropertyList(propDefList.getName());
           
            for(String path : envSettings) {
                PropertyMap map = new PropertyMap(VAR_PROP);
                ret.add(map);
                String name = new AugeasNode(path).getName();
                String value = augeas.get(path);
                map.put(new PropertySimple(NAME_PROP, name));
                map.put(new PropertySimple(VALUE_PROP, value));
            }
           
View Full Code Here

TOP

Related Classes of org.rhq.plugins.augeas.helper.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.