Package net.augeas

Examples of net.augeas.Augeas


        Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();

        SambaServerComponent serverComponent = discoveryContext.getParentResourceComponent();

        Augeas augeas = null;
        try {
            augeas = serverComponent.getAugeas();

            if (augeas!=null) {
                List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
                for (String match : matches) {
                    String name = augeas.get(match);
                    Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
                    pluginConfig.put(new PropertySimple("targetName", name));
                    DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
                        name, name + " share", null, "Samba Share [" + name + "]", pluginConfig, null);
                    details.add(detail);
View Full Code Here


    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 void deleteResource() throws Exception {
        initAugeas();
        String rootPath = getResourceConfigurationRootPath();
        try {
            Augeas augeas = getAugeas();
            augeas.remove(rootPath);
            augeas.save();
        } finally {
            close();
        }
    }
View Full Code Here

    }

    protected AugeasNode getExistingChildNodeForListMemberPropertyMap(AugeasNode parentNode,
        PropertyDefinitionList propDefList, PropertyMap propMap) {
        // First find all child nodes with the same 'pattern' value as the PropertyMap.
        Augeas augeas = getAugeas();

        String nameFilter = parentNode.getPath() + "/*/pattern";
        String canonical = propMap.getSimple("pattern").getStringValue();
        List<String> namePaths = AugeasUtility.matchFilter(augeas, nameFilter, canonical);

View Full Code Here

    }

    protected AugeasNode getExistingChildNodeForListMemberPropertyMap(AugeasNode parentNode,
        PropertyDefinitionList propDefList, PropertyMap propMap) {
        // First find all child nodes with the same 'spec' value as the PropertyMap.
        Augeas augeas = getAugeas();

        String userName = propMap.getSimple("user").getStringValue();
        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

        configuration.setNotes("Loaded from Augeas at " + new Date());

        // Load default properties
        String grubTreeNode = augeasTreeNodeProperty.getStringValue();

        Augeas augeas = new Augeas(rootPath, lensesPath, Augeas.NONE);
        try {
            return getConfig(configuration, grubTreeNode, augeas);
        } finally {
            augeas.close();
        }
    }
View Full Code Here

  private Augeas aug;
  private Node root;
  private  List<String> excludes = Collections.EMPTY_LIST;
  public AugeasTree(String rootLocation, String file,
      List<String> excludableKeys) {
    aug = new Augeas(rootLocation, "", Augeas.SAVE_NEWFILE)
    excludes = excludableKeys;
    root = new Node();
    root.setKey ("/files" + file);
  }
View Full Code Here

    root.setKey ("/files" + file);
  }
 
  public AugeasTree(String file,
      List<String> excludableKeys) {
    aug = new Augeas(Augeas.SAVE_NEWFILE)
    excludes = excludableKeys;
    root = new Node();
    root.setKey ("/files" + file);
 
View Full Code Here

        }

        String lensesPath = lensesPathProperty.getStringValue();
        String rootPath = rootPathProperty.getStringValue();

        Augeas augeas = new Augeas(rootPath, lensesPath, Augeas.NONE);

        // Find out where to look for the apt sources tree
        PropertySimple augeasTreeNodeProperty = pluginConfiguration.getSimple("augeas-apt-sources-path");

        if (augeasTreeNodeProperty == null) {
            throw new Exception("Augeas tree node not specified for apt sources, cannot retrive configuration");
        }

        String sourcesTreeNode = augeasTreeNodeProperty.getStringValue();

        // Request data from augeas
        List<String> matches = augeas.match(sourcesTreeNode);
        if (matches.size() == 0) {
            throw new Exception("Unable to load apt sources data from augeas");
        }

        // Parse out the properties
        Configuration configuration = new Configuration();
        configuration.setNotes("Loaded from Augeas at " + new Date());

        PropertyList entriesList = new PropertyList("aptEntries");
        configuration.put(entriesList);

        for (String entryNode : matches) {
            String type = augeas.get(entryNode + "/type");
            String uri = augeas.get(entryNode + "/uri");
            String distribution = augeas.get(entryNode + "/distribution");

            PropertyMap entry = new PropertyMap("aptEntry");
            entry.put(new PropertySimple("type", type));
            entry.put(new PropertySimple("uri", uri));
            entry.put(new PropertySimple("distribution", distribution));
View Full Code Here

        }

        String val = prop.getStringValue();

        if (val.equals("yes")) {
            Augeas ag = null;
            try {
                ag = new Augeas();
            } catch (Exception e) {
                logAugeasError(e);
                throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
            } catch (NoClassDefFoundError e) {
                logAugeasError(e);
                throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
            } catch (UnsatisfiedLinkError e) {
                logAugeasError(e);
                throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
            } finally {
                if (ag != null) {
                    try {
                        ag.close();
                    } catch (Exception e) {
                    }
                    ag = null;
                }
            }
View Full Code Here

TOP

Related Classes of net.augeas.Augeas

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.