Package org.rhq.plugins.augeas.helper

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


    @Override
    protected String getResourceConfigurationRootPath() {
        Configuration pluginConfig = getResourceContext().getPluginConfiguration();
        String targetName = pluginConfig.getSimple(TARGET_NAME_PROP).getStringValue();
        String targetPath = "/files/etc/samba/smb.conf/target[.='" + targetName + "']";
        AugeasNode targetNode = new AugeasNode(targetPath);
        Augeas augeas = getAugeas();

        List<String> matches = augeas.match(targetNode.getPath());
        return matches.get(0);
    }
View Full Code Here


*/
public class PostfixAccessComponent extends AugeasConfigurationComponent {
    @Override
    protected AugeasNode getNewListMemberNode(AugeasNode listNode, PropertyDefinitionMap listMemberPropDefMap,
        int listIndex) {
        AugeasNode node = new AugeasNode(listNode, "0" + listIndex);
        return node;
    }
View Full Code Here

        if (namePaths == null || namePaths.isEmpty()) {
            return null;
        }

        AugeasNode node = new AugeasNode(namePaths.get(0));
        return node.getParent();
    }
View Full Code Here

        String specFilter = parentNode.getPath() + "/spec";
        List<String> userPaths = augeas.match(String.format(specFilter + "/user[.='%s']", userName));
        if (userPaths == null || userPaths.isEmpty()) {
            return null;
        }
        AugeasNode node = new AugeasNode(userPaths.get(0));
        return node.getParent();
    }
View Full Code Here

      return super.createResource(report);
    }

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

        if (namePaths == null || namePaths.isEmpty()) {
            return null;
        }

        AugeasNode node = new AugeasNode(namePaths.get(0));
        return node.getParent();
    }
View Full Code Here

        // First insert the root node corresponding to the new child Resource.
        String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(),
            report.getResourceConfiguration());
        initAugeas();
        try {
            AugeasNode rootNode = new AugeasNode(rootPath);
            if (this.augeas.exists(rootNode.getPath())) {
                report.setStatus(CreateResourceStatus.FAILURE);
                report.setErrorMessage("An Augeas node already exists with path " + rootPath);
                return report;
            }
            String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(),
                report.getResourceConfiguration());
            this.augeas.set(rootNode.getPath(), rootLabel);

            // Then set all its child nodes.
            Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
            for (PropertyDefinition propDef : propDefs) {
                setNode(propDef, resourceConfig, this.augeas, rootNode);
View Full Code Here

    protected AugeasNode getExistingChildNodeForListMemberPropertyMap(AugeasNode parentNode,
        PropertyDefinitionList propDefList, PropertyMap propMap) {
        String mapKey = getListMemberMapKey(propDefList);
        if (mapKey != null) {
            String existingChildNodeName = propMap.getSimple(mapKey).getStringValue();
            AugeasNode existingChildNode = new AugeasNode(parentNode, existingChildNodeName);
            return (this.augeas.exists(existingChildNode.getPath())) ? existingChildNode : null;
        } else {
            return null;
        }
    }
View Full Code Here

    }

    protected void loadProperty(PropertyDefinition propDef, AbstractPropertyMap parentPropMap, Augeas augeas,
        AugeasNode parentNode) {
        String propName = getAugeasPathRelativeToParent(propDef, parentNode, augeas);
        AugeasNode node = (propName.equals(".")) ? parentNode : new AugeasNode(parentNode, propName);
        Property prop;
        if (propDef instanceof PropertyDefinitionSimple) {
            prop = createPropertySimple((PropertyDefinitionSimple) propDef, augeas, node);
        } else if (propDef instanceof PropertyDefinitionMap) {
            prop = createPropertyMap((PropertyDefinitionMap) propDef, augeas, node);
View Full Code Here

        String mapKey = getListMemberMapKey(propDefList);
        String mapPath = getAugeasPathRelativeToParent(listMemberPropDefMap, node, augeas);
        String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + mapPath;
        List<String> listMemberPaths = augeas.match(listMemberPathsExpression);
        for (String listMemberPath : listMemberPaths) {
            AugeasNode listMemberNode = new AugeasNode(listMemberPath);
            PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName());
            propList.add(listMemberPropMap);

            // Add the "key" prop, if defined, to the map.
            if (mapKey != null) {
                PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName());
                listMemberPropMap.put(keyProp);
            }

            // Populate the rest of the map child properties.
            populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode);
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.