modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
| 11 +++++++++-
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
| 3 +-
modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml
| 6 +++--
3 files changed, 16 insertions(+), 4 deletions(-)
New commits:
commit 3145a6481b06ea4984212c5f89452c2cc28fe9c3
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Oct 27 14:57:02 2009 -0400
Got the add functionality working with sudoers
diff --git
a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 0bfcef0..803804d 100644
---
a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++
b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -72,6 +72,7 @@ public class AugeasConfigurationComponent<T extends
ResourceComponent> implement
public static final String EXCLUDE_GLOBS_PROP =
"configurationFilesExclusionPatterns";
public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP =
"resourceConfigurationRootNode";
public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
+ public static final String NEW_NODE_EXPRESSION = "newNodeExpression";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/share/augeas/lenses";
@@ -468,6 +469,9 @@ public class AugeasConfigurationComponent<T extends
ResourceComponent> implement
protected void setNodeFromPropertyList(PropertyDefinitionList propDefList,
PropertyList propList, Augeas augeas,
AugeasNode listNode) {
PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition();
+
+ PropertySimple newNodeExpression =
resourceContext.getPluginConfiguration().getSimple(NEW_NODE_EXPRESSION);
+
if (!(listMemberPropDef instanceof PropertyDefinitionMap)) {
throw new IllegalArgumentException(
"Invalid Resource ConfigurationDefinition - only lists of maps are
supported.");
@@ -490,10 +494,15 @@ public class AugeasConfigurationComponent<T extends
ResourceComponent> implement
// Keep track of the existing nodes that we'll be updating, so that
we can remove all other existing
// nodes.
updatedListMemberNodes.add(memberNodeToUpdate);
+ } else if (newNodeExpression != null) {
+ String var = "var" + listIndex;
+ augeas.defineNode(var, newNodeExpression.getStringValue(), null);
+ memberNodeToUpdate = new AugeasNode("$" + var);
} 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.
- memberNodeToUpdate = new AugeasNode(listNode, "0" +
(listIndex++));
+ memberNodeToUpdate = new AugeasNode(listNode, "0" +
(listIndex));
+ listIndex++;
}
// Update the node's children.
diff --git
a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
index 7c01a14..cc62907 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java
@@ -25,6 +25,7 @@ package org.rhq.plugins.augeas.helper;
*/
public class AugeasNode {
public static final char SEPARATOR_CHAR = '/';
+ public static final char VARIABLE_CHAR = '$';
public static final String SEPARATOR = new String(new char[] { SEPARATOR_CHAR });
private String path;
@@ -33,7 +34,7 @@ public class AugeasNode {
if (path == null) {
throw new IllegalArgumentException("'path' parameter must not be
null.");
}
- if (path.charAt(0) != SEPARATOR_CHAR) {
+ if (path.charAt(0) != SEPARATOR_CHAR && path.charAt(0) != VARIABLE_CHAR)
{
throw new IllegalArgumentException("Specified path (" + path +
") is not absolute.");
}
diff --git a/modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml
index fda6e03..828878d 100644
--- a/modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml
@@ -32,13 +32,15 @@
<c:simple-property name="configurationFilesInclusionPatterns"
displayName="Sudoers File Path" required="true"
readOnly="true"
default="/etc/sudoers"
description="Location of the sudoers file."/>
<c:simple-property name="resourceConfigurationRootNode"
required="true" readOnly="true"
- default="/files/etc/sudoers"/>
+ default="/files/etc/sudoers"/>
+ <c:simple-property name="newNodeExpression"
required="true" readOnly="true"
+ default="/files/etc/sudoers/spec[last()+1]"/>
</plugin-configuration>
<resource-configuration>
<c:list-property name="." displayName="Entries">
<c:map-property name="spec[*]">
- <c:simple-property name="user"
displayName="User/Group" type="string" required="true"
activationPolicy="immediate"
+ <c:simple-property name="user"
displayName="User/Group" type="string" required="true"
readOnly="true" activationPolicy="immediate"
description="The User/User Alias/Group/Group Alias
who needs to be given access to run a command. Alternatively you can specify aliases
defined using User_Alias. Eg: if you had this defined previously User_Alias OPERATORS =
joe, mike, jude - You could enter OPERATORS for the user"/>
<c:simple-property name="host_group/host"
displayName="Host Alias" type="string" required="true"
activationPolicy="immediate"
description="The Host alias of the terminal from
which the above user can run the given command. Set it to ALL if the user is allowed to
execute from any host. Alternatively if you have a Host_Alias defined you can use that
here. Eg: if you defined Host_Alias OFNET = 10.1.2.0/255.255.255.0 - you could use
"OFNET'" here"/>
Show replies by date