[rhq] Branch 'raw-config' - 30 commits - .classpath modules/core modules/enterprise modules/helpers modules/plugins
by Adam Young
.classpath | 2
modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java | 4
modules/core/dbutils/src/test/java/org/rhq/core/db/DatabaseTest.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 10
modules/enterprise/gui/installer-war/pom.xml | 5
modules/enterprise/gui/portal-war/pom.xml | 9
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/EditGeneralPropertiesUIBean.java | 6
modules/enterprise/server/ear/pom.xml | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 22
modules/helpers/pluginAnnotations/pom.xml | 4
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java | 39
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java | 39
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java | 38
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java | 43
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java | 38
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java | 41
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java | 35
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java | 34
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java | 38
modules/helpers/pluginGen/pom.xml | 9
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java | 786 ++++++----
modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java | 11
modules/helpers/pluginGen/src/main/resources/component.ftl | 16
modules/helpers/pluginGen/src/main/resources/descriptor.ftl | 27
modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl | 78
modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java | 106 +
modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/tokens/Ordered.java | 57
modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Ordered.g | 45
modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g | 45
modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Skip.g | 46
modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Transparent.g | 50
modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Unordered.g | 43
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java | 102 +
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java | 307 +++
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java | 310 ---
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SkipTest.java | 144 +
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/TransparentTest.java | 93 +
modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java | 256 +++
modules/plugins/antlr-config/src/test/resources/ordered | 5
modules/plugins/antlr-config/src/test/resources/simple | 7
modules/plugins/antlr-config/src/test/resources/skip | 14
modules/plugins/antlr-config/src/test/resources/transparent | 11
modules/plugins/antlr-config/src/test/resources/unordered | 5
modules/plugins/augeas/pom.xml | 6
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 23
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java | 2
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasPluginLifecycleListener.java | 2
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasNode.java | 24
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasUtility.java | 16
modules/plugins/augeas/src/main/resources/META-INF/rhq-plugin.xml | 2
modules/plugins/hosts/pom.xml | 6
modules/plugins/jboss-cache-v3/pom.xml | 2
modules/plugins/sudoers/src/main/resources/META-INF/rhq-plugin.xml | 4
53 files changed, 2227 insertions(+), 846 deletions(-)
New commits:
commit 0d0de279c89011acbfce6592ea1fb63825de4c30
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Oct 19 17:16:02 2009 -0400
Updated the rhq sudoer's plugin in to correctly map to the updated Augeas plugin
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 9118cf1..6bff878 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
@@ -39,7 +39,7 @@ public class AugeasNode {
}
// Remove redundant "." and ".." components and redundant slashes.
- this.path = normalize(path);
+ this.path = path;
}
public AugeasNode(AugeasNode parent, String name) {
commit 283ef316f24bef58b176ca367129632a4c413cd8
Merge: 4ad17fb... 59cad4f...
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Oct 26 14:12:14 2009 -0400
merged from master, minus two conflicts
diff --cc .classpath
index 63f9e6f,222ef84..c11b92f
--- a/.classpath
+++ b/.classpath
@@@ -1,8 -1,7 +1,9 @@@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/>
+ <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/>
<classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/>
commit 59cad4fcb211675be4167f684664deab5f1db696
Merge: cb30db0... bacd1ba...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:15:21 2009 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit cb30db0ea4dea73a4de3d9003c07d5033df000ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:11:39 2009 -0400
upping jsp precompiler since the previous version seems gone from the central repo. may want to up again when a non RC is available.
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 896dd3c..0d35569 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -27,6 +27,7 @@
<!-- dependency versions -->
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -307,8 +308,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 4f38976..dd751d3 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -26,6 +26,7 @@
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
<seam.version>2.1.0.SP1</seam.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -367,8 +368,8 @@
<!-- new jetty based jsp compiler -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.5</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<scope>provided</scope>
</dependency>
@@ -556,8 +557,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
commit bacd1ba678d44af463226cc1a7102212b35faa09
Merge: 9dba749... 4422052...
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:38:17 2009 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9dba7497582b27dd7b2a547a3d43f3183dc224bf
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:35:05 2009 +0100
Change the group of the helper artifacts to 'org.rhq.helpers' so that they end up in a subgroup
on their own. This gives less clutter to the repo.
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index 3e73c16..a3dc269 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<packaging>jar</packaging>
@@ -50,4 +50,4 @@
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index e58e36d..0fd3ff7 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginGen</artifactId>
<packaging>jar</packaging>
@@ -86,9 +86,9 @@
<version>2.3.11</version>
</dependency>
<dependency>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
commit 4422052c4b3f2a882d650303cc462e2ce9492b7d
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Oct 23 10:35:27 2009 -0700
adding helpers src dir
diff --git a/.classpath b/.classpath
index 4186c24..222ef84 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/>
+ <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/>
<classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/>
@@ -74,7 +75,7 @@
<classpathentry kind="src" path="modules/plugins/netservices/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/target/generated-sources/xjc"/>
- <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apt/src/test/java"/>
@@ -83,9 +84,9 @@
<classpathentry kind="src" path="modules/plugins/hardware/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/oracle/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/grub/src/test/java"/>
- <classpathentry kind="src" path="modules/plugins/grub/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/grub/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/samba/src/test/java"/>
- <classpathentry kind="src" path="modules/plugins/samba/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/samba/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/sudoers/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/sudoers/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/>
commit fdd23ec2bb428e6bde53e70d9b31c6ae22465da0
Author: Ian P. Springer <ips(a)jetengine.springer.net>
Date: Wed Oct 21 12:37:01 2009 -0400
mtime also needs to be set on Resources when inventoryStatus is updated (this is the rest of the fix for http://jira.rhq-project.org/browse/RHQ-1996)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 2b1b330..55c0693 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -479,26 +479,20 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
long now = System.currentTimeMillis();
-
- resource.setInventoryStatus(newStatus);
- resource.setItime(now);
-
+ updateInventoryStatus(resource, newStatus, now);
resource = entityManager.merge(resource);
+
if (setDescendents) {
for (Resource childResource : resource.getChildResources()) {
- childResource.setInventoryStatus(newStatus);
- childResource.setItime(now);
-
+ updateInventoryStatus(childResource, newStatus, now);
childResource = entityManager.merge(childResource);
setResourceStatus(user, childResource, newStatus, setDescendents);
}
} else if (resource.getResourceType().getCategory() == ResourceCategory.PLATFORM) {
- // Commit platform services when the platform is committed
+ // Commit platform services when the platform is committed.
for (Resource childResource : resource.getChildResources()) {
if (childResource.getResourceType().getCategory() == ResourceCategory.SERVICE) {
- childResource.setInventoryStatus(newStatus);
- childResource.setItime(now);
-
+ updateInventoryStatus(childResource, newStatus, now);
childResource = entityManager.merge(childResource);
setResourceStatus(user, childResource, newStatus, setDescendents);
}
@@ -508,6 +502,12 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return resource;
}
+ private void updateInventoryStatus(Resource resource, InventoryStatus newStatus, long now) {
+ resource.setInventoryStatus(newStatus);
+ resource.setItime(now);
+ resource.setMtime(now);
+ }
+
@SuppressWarnings("unchecked")
public Resource getResourceById(Subject user, int resourceId) {
Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_ID);
commit a2d134f41f2fa7e3d25d8e317ae19cef790c9e7a
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 17:38:39 2009 +0200
More changes to the plugin generator to allow for annotation processing and thus automatic descriptor creation.
Thanks to Galder Zamarreño
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
index 770278d..a416079 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
@@ -23,14 +23,14 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqDataType.
- *
+ * DataType.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
public enum DataType {
MEASUREMENT, TRAIT, CALLTIME;
-
+
@Override
public String toString() {
return super.toString().toLowerCase();
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
index 7d4c1cb..49551ef 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
@@ -23,8 +23,8 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqDisplayType.
- *
+ * DisplayType.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
index b63d957..0ae4011 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -23,14 +23,14 @@
package org.rhq.helpers.pluginAnnotations.agent;
/**
- * RhqUnits.
- *
+ * Metric Units.
+ *
* @author Galder Zamarreño
* @since 4.0
*/
public enum Units {
NONE, MILLISECONDS, SECONDS, PERCENTAGE;
-
+
@Override
public String toString() {
return super.toString().toLowerCase();
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index a38edcc..e58e36d 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -85,5 +85,10 @@
<artifactId>freemarker</artifactId>
<version>2.3.11</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-pluginAnnotations</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
index c39f3a1..76b374b 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Props.java
@@ -19,8 +19,15 @@
package org.rhq.helpers.pluginGen;
import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
+import org.rhq.helpers.pluginAnnotations.agent.DataType;
+import org.rhq.helpers.pluginAnnotations.agent.DisplayType;
+import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Units;
+
/**
* The properties needed to generate a new plugin skeleton
*
@@ -28,266 +35,525 @@ import java.util.Set;
*/
public class Props {
- /** What category is this ? */
- private ResourceCategory category;
- /** The name of this item */
- private String name;
- /** A description of the plugin */
- private String description;
- /** Package name prefix */
- private String packagePrefix;
- /** String package */
- private String pkg;
- /** The name of the DiscoveryClass */
- private String discoveryClass;
- /** The name of the Component class */
- private String componentClass;
- /** The type of the parent we run in */
- private String parentType;
- /** Filesytem root */
- private String fileSystemRoot;
- /** Should this service do monitoring ? */
- private boolean monitoring;
- /** Should this service do operations ? */
- private boolean operations;
- /** Is this service a singleton (e.g. a XYZ subsystem) */
- private boolean singleton;
- /** Does the service support configuration ? */
- private boolean resourceConfiguration;
- /** Does the service support events */
- private boolean events;
- /** Does the service support the support facet? */
- private boolean supportFacet;
- /** Can the service create children ? */
- private boolean createChildren;
- /** Can the service delete children ? */
- private boolean deleteChildren;
- /** Use externals chars in the plugin jar ? */
- private boolean usesExternalJarsInPlugin;
- /** Does it support manuall add of children ? */
- private boolean manualAddOfResourceType;
- /** Does it use the PluginLifecycleListener api ? */
- private boolean usePluginLifecycleListenerApi;
- /** Depends on JMX plugin ? */
- private boolean dependsOnJmxPlugin;
- /** What version of RHQ should this plugin's pom use ? */
- private String rhqVersion = "1.4.0-SNAPSHOT";
-
- /** Embedded children */
- private Set<Props> children = new HashSet<Props>();
+ /** What category is this ? */
+ private ResourceCategory category;
+ /** The name of this item */
+ private String name;
+ /** A description of the plugin */
+ private String description;
+ /** Package name prefix */
+ private String packagePrefix;
+ /** String package */
+ private String pkg;
+ /** The name of the DiscoveryClass */
+ private String discoveryClass;
+ /** The name of the Component class */
+ private String componentClass;
+ /** The type of the parent we run in */
+ private String parentType;
+ /** Filesytem root */
+ private String fileSystemRoot;
+ /** Should this service do monitoring ? */
+ private boolean hasMetrics;
+ /** Should this service do operations ? */
+ private boolean hasOperations;
+ /** Is this service a singleton (e.g. a XYZ subsystem) */
+ private boolean singleton;
+ /** Does the service support configuration ? */
+ private boolean resourceConfiguration;
+ /** Does the service support events */
+ private boolean events;
+ /** Does the service support the support facet? */
+ private boolean supportFacet;
+ /** Can the service create children ? */
+ private boolean createChildren;
+ /** Can the service delete children ? */
+ private boolean deleteChildren;
+ /** Use externals chars in the plugin jar ? */
+ private boolean usesExternalJarsInPlugin;
+ /** Does it support manuall add of children ? */
+ private boolean manualAddOfResourceType;
+ /** Does it use the PluginLifecycleListener api ? */
+ private boolean usePluginLifecycleListenerApi;
+ /** Depends on JMX plugin ? */
+ private boolean dependsOnJmxPlugin;
+ /** What version of RHQ should this plugin's pom use ? */
+ private String rhqVersion = "1.4.0-SNAPSHOT";
+
+ /** Embedded children */
+ private Set<Props> children = new HashSet<Props>();
+
+ private Set<SimpleProperty> simpleProps = new LinkedHashSet<SimpleProperty>();
+
+ private Set<Template> templates = new HashSet<Template>();
+
+ private Set<MetricProps> metrics = new LinkedHashSet<MetricProps>();;
+
+ private Set<OperationProps> operations = new LinkedHashSet<OperationProps>();;
+
+ private String pluginName;
+ private String pluginDescription;
public ResourceCategory getCategory() {
- return category;
- }
-
- public void setCategory(ResourceCategory category) {
- this.category = category;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDiscoveryClass() {
- return discoveryClass;
- }
-
- public void setDiscoveryClass(String discoveryClass) {
- this.discoveryClass = discoveryClass;
- }
-
- public String getComponentClass() {
- return componentClass;
- }
-
- public void setComponentClass(String componentClass) {
- this.componentClass = componentClass;
- }
-
- public String getParentType() {
- return parentType;
- }
-
- public void setParentType(String parentType) {
- this.parentType = parentType;
- }
-
- public boolean isMonitoring() {
- return monitoring;
- }
-
- public void setMonitoring(boolean monitoring) {
- this.monitoring = monitoring;
- }
-
- public boolean isOperations() {
- return operations;
- }
-
- public void setOperations(boolean operations) {
- this.operations = operations;
- }
-
- public boolean isSingleton() {
- return singleton;
- }
-
- public void setSingleton(boolean singleton) {
- this.singleton = singleton;
- }
-
- public boolean isResourceConfiguration() {
- return resourceConfiguration;
- }
-
- public void setResourceConfiguration(boolean resourceConfiguration) {
- this.resourceConfiguration = resourceConfiguration;
- }
-
- public boolean isEvents() {
- return events;
- }
-
- public void setEvents(boolean events) {
- this.events = events;
- }
-
- public boolean isSupportFacet() {
- return supportFacet;
- }
-
- public void setSupportFacet(boolean supportFacet) {
- this.supportFacet = supportFacet;
- }
-
- public boolean isCreateChildren() {
- return createChildren;
- }
-
- public void setCreateChildren(boolean createChildren) {
- this.createChildren = createChildren;
- }
-
- public Set<Props> getChildren() {
- return children;
- }
-
- public void setChildren(Set<Props> children) {
- this.children = children;
- }
-
- public String getPackagePrefix() {
- return packagePrefix;
- }
-
- public void setPackagePrefix(String packagePrefix) {
- this.packagePrefix = packagePrefix;
- }
-
- public String getFileSystemRoot() {
- return fileSystemRoot;
- }
-
- public void setFileSystemRoot(String fileSystemRoot) {
- this.fileSystemRoot = fileSystemRoot;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isUsesExternalJarsInPlugin() {
- return usesExternalJarsInPlugin;
- }
-
- public void setUsesExternalJarsInPlugin(boolean usesExternalJarsInPlugin) {
- this.usesExternalJarsInPlugin = usesExternalJarsInPlugin;
- }
-
- public boolean isDeleteChildren() {
- return deleteChildren;
- }
-
- public void setDeleteChildren(boolean deleteChildren) {
- this.deleteChildren = deleteChildren;
- }
-
- public boolean isManualAddOfResourceType() {
- return manualAddOfResourceType;
- }
-
- public void setManualAddOfResourceType(boolean manualAddOfResourceType) {
- this.manualAddOfResourceType = manualAddOfResourceType;
- }
-
- public void setPkg(String pkg) {
- this.pkg = pkg;
- }
-
- public String getPkg() {
- return this.pkg;
- }
-
- public boolean isUsePluginLifecycleListenerApi() {
- return usePluginLifecycleListenerApi;
- }
-
- public void setUsePluginLifecycleListenerApi(boolean usePluginLifecycleListenerApi) {
- this.usePluginLifecycleListenerApi = usePluginLifecycleListenerApi;
- }
-
- public boolean isDependsOnJmxPlugin() {
- return dependsOnJmxPlugin;
- }
-
- public void setDependsOnJmxPlugin(boolean dependsOnJmxPlugin) {
- this.dependsOnJmxPlugin = dependsOnJmxPlugin;
- }
-
- public String getRhqVersion() {
- return rhqVersion;
- }
-
- public void setRhqVersion(String rhqVersion) {
- this.rhqVersion = rhqVersion;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Props");
- sb.append("{category=").append(category);
- sb.append(", name='").append(name).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", packagePrefix='").append(packagePrefix).append('\'');
- sb.append(", pkg='").append(pkg).append('\'');
- sb.append(", discoveryClass='").append(discoveryClass).append('\'');
- sb.append(", componentClass='").append(componentClass).append('\'');
- sb.append(", parentType='").append(parentType).append('\'');
- sb.append(", fileSystemRoot='").append(fileSystemRoot).append('\'');
- sb.append(", monitoring=").append(monitoring);
- sb.append(", operations=").append(operations);
- sb.append(", singleton=").append(singleton);
- sb.append(", resourceConfiguration=").append(resourceConfiguration);
- sb.append(", events=").append(events);
- sb.append(", supportFacet=").append(supportFacet);
- sb.append(", createChildren=").append(createChildren);
- sb.append(", deleteChildren=").append(deleteChildren);
- sb.append(", usesExternalJarsInPlugin=").append(usesExternalJarsInPlugin);
- sb.append(", manualAddOfResourceType=").append(manualAddOfResourceType);
- sb.append(", usePluginLifecycleListenerApi=").append(usePluginLifecycleListenerApi);
- sb.append(", dependsOnJmxPlugin=").append(dependsOnJmxPlugin);
- sb.append(", rhqVersion='").append(rhqVersion).append('\'');
- sb.append(", children=").append(children);
- sb.append('}');
- return sb.toString();
- }
+ return category;
+ }
+
+ public void setCategory(ResourceCategory category) {
+ this.category = category;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDiscoveryClass() {
+ return discoveryClass;
+ }
+
+ public void setDiscoveryClass(String discoveryClass) {
+ this.discoveryClass = discoveryClass;
+ }
+
+ public String getComponentClass() {
+ return componentClass;
+ }
+
+ public void setComponentClass(String componentClass) {
+ this.componentClass = componentClass;
+ }
+
+ public String getParentType() {
+ return parentType;
+ }
+
+ public void setParentType(String parentType) {
+ this.parentType = parentType;
+ }
+
+ public boolean isHasMetrics() {
+ return hasMetrics;
+ }
+
+ public void setHasMetrics(boolean hasMetrics) {
+ this.hasMetrics = hasMetrics;
+ }
+
+ public boolean isHasOperations() {
+ return hasOperations;
+ }
+
+ public void setHasOperations(boolean hasOperations) {
+ this.hasOperations = hasOperations;
+ }
+
+ public boolean isSingleton() {
+ return singleton;
+ }
+
+ public void setSingleton(boolean singleton) {
+ this.singleton = singleton;
+ }
+
+ public boolean isResourceConfiguration() {
+ return resourceConfiguration;
+ }
+
+ public void setResourceConfiguration(boolean resourceConfiguration) {
+ this.resourceConfiguration = resourceConfiguration;
+ }
+
+ public boolean isEvents() {
+ return events;
+ }
+
+ public void setEvents(boolean events) {
+ this.events = events;
+ }
+
+ public boolean isSupportFacet() {
+ return supportFacet;
+ }
+
+ public void setSupportFacet(boolean supportFacet) {
+ this.supportFacet = supportFacet;
+ }
+
+ public boolean isCreateChildren() {
+ return createChildren;
+ }
+
+ public void setCreateChildren(boolean createChildren) {
+ this.createChildren = createChildren;
+ }
+
+ public Set<Props> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set<Props> children) {
+ this.children = children;
+ }
+
+ public String getPackagePrefix() {
+ return packagePrefix;
+ }
+
+ public void setPackagePrefix(String packagePrefix) {
+ this.packagePrefix = packagePrefix;
+ }
+
+ public String getFileSystemRoot() {
+ return fileSystemRoot;
+ }
+
+ public void setFileSystemRoot(String fileSystemRoot) {
+ this.fileSystemRoot = fileSystemRoot;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isUsesExternalJarsInPlugin() {
+ return usesExternalJarsInPlugin;
+ }
+
+ public void setUsesExternalJarsInPlugin(boolean usesExternalJarsInPlugin) {
+ this.usesExternalJarsInPlugin = usesExternalJarsInPlugin;
+ }
+
+ public boolean isDeleteChildren() {
+ return deleteChildren;
+ }
+
+ public void setDeleteChildren(boolean deleteChildren) {
+ this.deleteChildren = deleteChildren;
+ }
+
+ public boolean isManualAddOfResourceType() {
+ return manualAddOfResourceType;
+ }
+
+ public void setManualAddOfResourceType(boolean manualAddOfResourceType) {
+ this.manualAddOfResourceType = manualAddOfResourceType;
+ }
+
+ public void setPkg(String pkg) {
+ this.pkg = pkg;
+ }
+
+ public String getPkg() {
+ return this.pkg;
+ }
+
+ public boolean isUsePluginLifecycleListenerApi() {
+ return usePluginLifecycleListenerApi;
+ }
+
+ public void setUsePluginLifecycleListenerApi(boolean usePluginLifecycleListenerApi) {
+ this.usePluginLifecycleListenerApi = usePluginLifecycleListenerApi;
+ }
+
+ public boolean isDependsOnJmxPlugin() {
+ return dependsOnJmxPlugin;
+ }
+
+ public void setDependsOnJmxPlugin(boolean dependsOnJmxPlugin) {
+ this.dependsOnJmxPlugin = dependsOnJmxPlugin;
+ }
+
+ public String getRhqVersion() {
+ return rhqVersion;
+ }
+
+ public void setRhqVersion(String rhqVersion) {
+ this.rhqVersion = rhqVersion;
+ }
+
+ public Set<SimpleProperty> getSimpleProps() {
+ return simpleProps;
+ }
+
+ public void setSimpleProps(Set<SimpleProperty> simpleProps) {
+ this.simpleProps = simpleProps;
+ }
+
+ public Set<Template> getTemplates() {
+ return templates;
+ }
+
+ public void setTemplates(Set<Template> templates) {
+ this.templates = templates;
+ }
+
+ public Set<MetricProps> getMetrics() {
+ return metrics;
+ }
+
+ public void setMetrics(Set<MetricProps> metricProps) {
+ this.metrics = metricProps;
+ }
+
+ public Set<OperationProps> getOperations() {
+ return operations;
+ }
+
+ public void setOperations(Set<OperationProps> opProps) {
+ this.operations = opProps;
+ }
+
+ public String getPluginName() {
+ return pluginName;
+ }
+
+ public void setPluginName(String pluginName) {
+ this.pluginName = pluginName;
+ }
+
+ public String getPluginDescription() {
+ return pluginDescription;
+ }
+
+ public void setPluginDescription(String pluginDescription) {
+ this.pluginDescription = pluginDescription;
+ }
+
+ public void populateMetrics(List<Class> classes) {
+ for (Class<?> clazz : classes) {
+ Metric metricAnnot = clazz.getAnnotation(Metric.class);
+ if (metricAnnot != null) {
+ MetricProps metric = new MetricProps(metricAnnot.property());
+ metric.setDisplayName(metricAnnot.displayName());
+ metric.setDisplayType(metricAnnot.displayType());
+ metric.setDataType(metricAnnot.dataType());
+ metric.setDescription(metricAnnot.description());
+ metrics.add(metric);
+ }
+
+ }
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Props");
+ sb.append("{category=").append(category);
+ sb.append(", name='").append(name).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", packagePrefix='").append(packagePrefix).append('\'');
+ sb.append(", pkg='").append(pkg).append('\'');
+ sb.append(", discoveryClass='").append(discoveryClass).append('\'');
+ sb.append(", componentClass='").append(componentClass).append('\'');
+ sb.append(", parentType='").append(parentType).append('\'');
+ sb.append(", fileSystemRoot='").append(fileSystemRoot).append('\'');
+ sb.append(", monitoring=").append(hasMetrics);
+ sb.append(", operations=").append(hasOperations);
+ sb.append(", metricProps=").append(metrics);
+ sb.append(", operationProps=").append(operations);
+ sb.append(", singleton=").append(singleton);
+ sb.append(", resourceConfiguration=").append(resourceConfiguration);
+ sb.append(", events=").append(events);
+ sb.append(", supportFacet=").append(supportFacet);
+ sb.append(", createChildren=").append(createChildren);
+ sb.append(", deleteChildren=").append(deleteChildren);
+ sb.append(", usesExternalJarsInPlugin=").append(usesExternalJarsInPlugin);
+ sb.append(", manualAddOfResourceType=").append(manualAddOfResourceType);
+ sb.append(", usePluginLifecycleListenerApi=").append(usePluginLifecycleListenerApi);
+ sb.append(", dependsOnJmxPlugin=").append(dependsOnJmxPlugin);
+ sb.append(", rhqVersion='").append(rhqVersion).append('\'');
+ sb.append(", children=").append(children);
+ sb.append(", simpleProps=").append(simpleProps);
+ sb.append(", templates=").append(templates);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class SimpleProperty {
+ private final String name;
+ private String description;
+ private String type;
+ private boolean readOnly;
+ private String displayName;
+ private String defaultValue;
+
+ public SimpleProperty(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ }
+
+ public static class Template {
+ private final String name;
+ private String description;
+ private Set<SimpleProperty> simpleProps = new HashSet<SimpleProperty>();
+
+ public Template(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Set<SimpleProperty> getSimpleProps() {
+ return simpleProps;
+ }
+
+ public void setSimpleProps(Set<SimpleProperty> simpleProps) {
+ this.simpleProps = simpleProps;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+ public static class MetricProps {
+ private final String property;
+ private String displayName;
+ private String description;
+ private DisplayType displayType;
+ private DataType dataType;
+ private Units units;
+
+ public MetricProps(String property) {
+ this.property = property;
+ }
+
+ public DataType getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(DataType dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public DisplayType getDisplayType() {
+ return displayType;
+ }
+
+ public void setDisplayType(DisplayType displayType) {
+ this.displayType = displayType;
+ }
+
+ public Units getUnits() {
+ return units;
+ }
+
+ public void setUnits(Units units) {
+ this.units = units;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ }
+
+ public static class OperationProps {
+ private final String name;
+ private String displayName;
+ private String description;
+ private Set<SimpleProperty> params = new LinkedHashSet<SimpleProperty>();
+
+ public OperationProps(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Set<SimpleProperty> getParams() {
+ return params;
+ }
+ }
}
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
index 46362af..3c4c48e 100644
--- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
+++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/pluginGen/Test.java
@@ -34,19 +34,23 @@ public class Test {
Props p = new Props();
p.setName("foo");
+ p.setPluginName("fooPlugin");
+ p.setPluginDescription("fooDescription");
+ p.setPkg("a.package");
p.setCategory(ResourceCategory.SERVER);
p.setPackagePrefix("com.acme.plugin");
p.setDiscoveryClass("FooDiscovery");
p.setComponentClass("FooComponent");
p.setResourceConfiguration(true);
- p.setMonitoring(true);
- p.setOperations(true);
+ p.setHasMetrics(true);
+ p.setHasOperations(true);
p.setEvents(true);
p.setCreateChildren(true);
p.setSingleton(true);
Props child = new Props();
child.setName("FooChild1");
+ child.setPkg("child.package1");
child.setCategory(ResourceCategory.SERVICE);
child.setPackagePrefix(p.getPackagePrefix());
child.setDiscoveryClass("ChildDiscovery1");
@@ -58,12 +62,15 @@ public class Test {
child = new Props();
child.setName("FooChild2");
+ child.setPkg("child.package2");
child.setCategory(ResourceCategory.SERVICE);
child.setParentType("FooComponent");
child.setPackagePrefix(p.getPackagePrefix());
child.setDiscoveryClass("ChildDiscovery2");
child.setComponentClass("ChildComponent2");
child.setEvents(true);
+ child.setHasMetrics(true);
+ child.setHasOperations(true);
p.getChildren().add(child);
diff --git a/modules/helpers/pluginGen/src/main/resources/component.ftl b/modules/helpers/pluginGen/src/main/resources/component.ftl
index 54776e8..e9961fc 100644
--- a/modules/helpers/pluginGen/src/main/resources/component.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/component.ftl
@@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.measurement.AvailabilityType;
-<#if props.monitoring>
+<#if props.metrics??>
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
@@ -49,13 +49,13 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
</#if>
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-<#if props.monitoring>
+<#if props.metrics??>
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
</#if>
<#if props.events>
import org.rhq.core.pluginapi.event.EventContext;
</#if>
-<#if props.operations>
+<#if props.operations??>
import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
@@ -72,10 +72,10 @@ import org.rhq.core.pluginapi.support.SupportFacet;
public class ${props.componentClass} implements ResourceComponent<#if props.parentType??><${props.parentType}></#if>
-<#if props.monitoring>
+<#if props.metrics??>
, MeasurementFacet
</#if>
-<#if props.operations>
+<#if props.operations??>
, OperationFacet
</#if>
<#if props.resourceConfiguration>
@@ -164,7 +164,7 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
}
-<#if props.monitoring>
+<#if props.metrics??>
/**
* Gather measurement data
@@ -182,7 +182,7 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
}
</#if>
-<#if props.operations>
+<#if props.operations??>
public void startOperationFacet(OperationContext context) {
@@ -271,4 +271,4 @@ public class ${props.componentClass} implements ResourceComponent<#if props.pare
return null;
}
</#if>
-}
\ No newline at end of file
+}
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
index b05e25c..a62af11 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptor.ftl
@@ -20,8 +20,9 @@
-->
<#-- @ftlvariable name="props" type="org.rhq.helpers.pluginGen.Props" -->
<?xml version="1.0"?>
-<plugin name="${props.name}"
- displayName="${props.name}Plugin"
+<plugin name="${props.pluginName}"
+ displayName="${props.pluginName}Plugin"
+ description="${props.pluginDescription}"
<#if props.usePluginLifecycleListenerApi>
pluginLifecycleListener="${props.componentClass}"
</#if>
@@ -31,20 +32,16 @@
xmlns:c="urn:xmlns:rhq-configuration">
<#if props.dependsOnJmxPlugin>
- <depends plugin="JMX" useClasses="true"/>
-</#if>
-
- <${props.category.lowerName}
- <#include "descriptorMain.ftl"/>
-
- <#-- Those are the embedded children -->
- <#list props.children as props>
- <${props.category.lowerName}
- <#include "./descriptorMain.ftl"/>
- </${props.category.lowerName}>
+ <depends plugin="JMX" useClasses="true"/>
+</#if>
- </#list>
- </${props.category.lowerName}>
+ <${props.category.lowerName} <#include "descriptorMain.ftl"/>
+ <#-- Those are the embedded children -->
+ <#list props.children as props>
+ <${props.category.lowerName} <#include "./descriptorMain.ftl"/>
+ </${props.category.lowerName}>
+ </#list>
+ </${props.category.lowerName}>
</plugin>
\ No newline at end of file
diff --git a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
index 41420ff..a148a61 100644
--- a/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
+++ b/modules/helpers/pluginGen/src/main/resources/descriptorMain.ftl
@@ -24,50 +24,68 @@
platform/server/service. It is called by descriptor.ftl
-->
- name="${props.name}" <#-- TODO separate out plugin name and service name -->
+name="${props.name}" <#-- TODO separate out plugin name and service name -->
discovery="${props.discoveryClass}"
class="${props.componentClass}"
- <#if props.singleton>
- singleton="true"
- </#if>
- <#if props.manualAddOfResourceType>
- supportsManualAdd="true"
- </#if>
- <#if props.createChildren && props.deleteChildren>
- createDeletePolicy="both"
- <#elseif props.createChildren && !props.deleteChildren>
- createDeletePolicy="create-only"
- <#elseif !props.createChildren && props.deleteChildren>
- createDeletePolicy="delete-only"
- <#else > <#-- Dont mention it, as 'neither' is default -->
- </#if>
- >
+ <#if props.singleton>singleton="true"</#if>
+ <#if props.manualAddOfResourceType>supportsManualAdd="true"</#if>
+ <#if props.createChildren && props.deleteChildren>createDeletePolicy="both"<#elseif props.createChildren && !props.deleteChildren>createDeletePolicy="create-only"<#elseif !props.createChildren && props.deleteChildren>createDeletePolicy="delete-only"<#else > <#-- Dont mention it, as 'neither' is default --></#if>
+ >
+ <#if props.simpleProps?has_content>
<plugin-configuration>
- <!-- TODO add your own here -->
- <c:simple-property name="dummy"/>
+ <#list props.simpleProps as simpleProps>
+ <c:simple-property name="${simpleProps.name}" description="${simpleProps.description}" <#if simpleProps.type??>type="${simpleProps.type}"</#if> <#if simpleProps.readOnly>readOnly="true"</#if>/>
+ </#list>
+ <!-- The template section is only for manual resource additions, and default parameters and the ones presented to the user. -->
+ <#list props.templates as templates>
+ <c:template name="${templates.name}" description="${templates.description}">
+ <#list templates.simpleProps as innerSimpleProps>
+ <c:simple-property name="${innerSimpleProps.name}" displayName="${innerSimpleProps.displayName}"
+ defaultValue="${innerSimpleProps.defaultValue}"/>
+ </#list>
+ </c:template>
+ </#list>
</plugin-configuration>
+ </#if>
- <!-- TODO process scans -->
-
- <#if props.operations>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
+ <#if props.hasOperations>
+ <#if props.operations?has_content>
+ <#list props.operations as operation>
+ <operation name="${operation.name}" displayName="${operation.displayName}" description="${operation.description}">
+ <#if operation.params?has_content>
+ <parameters>
+ <#list operation.params as param>
+ <c:simple-property name="${param.name}" <#if param.description??>description="${param.description}"</#if>/>
+ </#list>
+ </parameters>
+ </#if>
+ </operation>
+ </#list>
+ <#else>
+ <operation name="dummyOperation">
+ <!-- TODO supply parameters and return values -->
+ </operation>
</#if>
- <#if props.monitoring>
- <metric property="dummyMetric" displayName="Dummy display name"/>
+ </#if>
+ <#if props.hasMetrics>
+ <#if props.metrics?has_content>
+ <#list props.metrics as metric>
+ <metric property="${metric.property}" displayName="${metric.displayName}" displayType="${metric.displayType}" units="${metric.units}" dataType="${metric.dataType}"
+ description="${metric.description}" />
+ </#list>
+ <#else>
+ <metric property="dummyMetric" displayName="Dummy display name"/>
</#if>
+ </#if>
+
<#if props.events>
<event name="${props.name}DummyEvent"/>
-
</#if>
<#if props.resourceConfiguration>
<resource-configuration>
<!-- TODO supply your configuration parameters -->
<c:simple-property name="dummy"/>
</resource-configuration>
-
- </#if>
+ </#if>
\ No newline at end of file
commit 455c073b6bb2745c833db83e1213ef1e9dd36f6d
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 09:39:46 2009 +0200
Annotations to allow for (semi-)automatic descriptor generation.
Thanks Galder Zamareño.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
new file mode 100644
index 0000000..770278d
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DataType.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqDataType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum DataType {
+ MEASUREMENT, TRAIT, CALLTIME;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
new file mode 100644
index 0000000..7d4c1cb
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/DisplayType.java
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqDisplayType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum DisplayType {
+ SUMMARY, DETAIL;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
new file mode 100644
index 0000000..c797e81
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/MeasurementType.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * MeasurementType.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum MeasurementType {
+ DYNAMIC, TRENDSUP, TRENDSDOWN;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
new file mode 100644
index 0000000..c1482f1
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Metric.java
@@ -0,0 +1,43 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to denote a metric that should be measured
+ *
+ * @author Heiko W. Rupp
+ * @author Galder Zamarreo
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD })
+public @interface Metric {
+ String property() default "";
+ String displayName() default "";
+ String description() default "";
+ long defaultInterval() default 120000000L; // 20 min
+ DisplayType displayType() default DisplayType.DETAIL;
+ DataType dataType() default DataType.MEASUREMENT;
+ Units units() default Units.NONE;
+ MeasurementType measurementType() default MeasurementType.DYNAMIC;
+ }
\ No newline at end of file
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
new file mode 100644
index 0000000..ba60955
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Operation.java
@@ -0,0 +1,38 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that denotes an Operation that can be executed
+ *
+ * @author Heiko W. Rupp
+ * @author Galder Zamarreo
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface Operation {
+ String name() default "";
+ String displayName() default "";
+ String description() default "";
+}
\ No newline at end of file
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
new file mode 100644
index 0000000..4b82a13
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Parameter.java
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Parameter.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+(a)Target(ElementType.PARAMETER)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Parameter {
+ String name() default "";
+ String description() default "";
+}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
new file mode 100644
index 0000000..b63d957
--- /dev/null
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.rhq.helpers.pluginAnnotations.agent;
+
+/**
+ * RhqUnits.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public enum Units {
+ NONE, MILLISECONDS, SECONDS, PERCENTAGE;
+
+ @Override
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+}
commit 755916036ba1bf5ce6e715f2a898aa0b94c55528
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Wed Oct 21 09:38:14 2009 +0200
Annotations to allow for (semi-)automatic descriptor generation.
Thanks Galder Zamareño.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java
deleted file mode 100644
index 5397a85..0000000
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqMetric.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.helpers.pluginAnnotations.agent;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to denote a metric that should be measured
- * @author Heiko W. Rupp
- */
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target({ElementType.FIELD, ElementType.METHOD})
-public @interface RhqMetric {
- String name();
- long defaultInterval() default 120000000L; // 20 min
-}
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java
deleted file mode 100644
index bdcda47..0000000
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/RhqOperation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.helpers.pluginAnnotations.agent;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation that denotes an Operation that can be executed
- * @author Heiko W. Rupp
- */
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target(ElementType.METHOD)
-public @interface RhqOperation {
- String name();
-}
commit d6f2370fd84b6942ee68b22e2621b4c466144bfb
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Oct 20 14:15:17 2009 -0400
Revert "back out my augeas/hosts plugin changes from last Friday (6dc0d3ff445cb0e5fdd4957577327ccf24a15db6)"
This reverts commit 7beb55bb72dcc52bfd7d4ac6915efcb7c10b45af.
The last friday commit actually fixed a lot of issues.
It is essential that this fix be in master. This fix has already been
tested on raw-config branch and has been proved to work.
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 d51e43e..3ef73bd 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
@@ -19,6 +19,7 @@
package org.rhq.plugins.augeas;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -60,6 +61,8 @@ import org.rhq.plugins.platform.PlatformComponent;
*/
public class AugeasConfigurationComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet {
public static final String CONFIGURATION_FILE_PROP = "configurationFile";
+ public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
+ public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/local/share/augeas/lenses";
@@ -70,8 +73,8 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private ResourceContext resourceContext;
private File configFile;
private Augeas augeas;
- private AugeasNode augeasConfigFileNode;
private AugeasNode augeasConfigFileMetadataNode;
+ private AugeasNode resourceConfigRootNode;
public void start(ResourceContext<PlatformComponent> resourceContext) throws InvalidPluginConfigurationException,
Exception {
@@ -81,9 +84,21 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
this.configFile = new File(configFilePath);
this.augeas = createAugeas();
if (this.augeas != null) {
- this.augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ AugeasNode augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ // This is the metadata portion of the tree for this config file (e.g. /augeas/files/etc/hosts, where error
+ // messages are stored as node values.
this.augeasConfigFileMetadataNode = new AugeasNode("/augeas/files" + AugeasNode.SEPARATOR_CHAR
- + this.configFile.getPath());
+ + this.configFile.getPath());
+ String resourceConfigRootNodePath = pluginConfig.getSimpleValue(RESOURCE_CONFIGURATION_ROOT_NODE_PROP, null);
+ if (resourceConfigRootNodePath != null) {
+ if (resourceConfigRootNodePath.indexOf(AugeasNode.SEPARATOR_CHAR) == 0) {
+ this.resourceConfigRootNode = new AugeasNode(resourceConfigRootNodePath);
+ } else {
+ this.resourceConfigRootNode = new AugeasNode(augeasConfigFileNode, resourceConfigRootNodePath);
+ }
+ } else {
+ this.resourceConfigRootNode = augeasConfigFileNode;
+ }
}
}
@@ -119,7 +134,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
return resourceConfig;
@@ -127,16 +142,27 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
if (!validateResourceConfiguration(report)) {
+ log.debug("Validation of updated Resource configuration for "
+ + this.getResourceContext().getResourceType() + " Resource with key '"
+ + this.getResourceContext().getResourceKey() + "' failed with the following errors: "
+ + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
if (!this.configFile.canWrite()) {
- report.setErrorMessage("Configuration file '" + this.configFile + "' is not writeable.");
+ report.setErrorMessage("Configuration file '" + this.configFile + "' is not writable.");
return;
}
- // Load the config file from disk and build a tree representation of it.
+ File configFileParentDir = this.configFile.getParentFile();
+ if (!configFileParentDir.canWrite()) {
+ report.setErrorMessage("Configuration file parent directory '" + configFileParentDir
+ + "' is not writable.");
+ return;
+ }
+
+ // Load the config file from disk and build a tree representation of it in memory.
this.augeas.load();
ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
@@ -145,7 +171,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
// Write the updated tree out to the config file.
@@ -193,7 +219,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private Augeas createAugeas() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String augeasModuleName = pluginConfig.getSimpleValue("augeasModuleName", null);
+ String augeasModuleName = pluginConfig.getSimpleValue(AUGEAS_MODULE_NAME_PROP, null);
if (augeasModuleName == null) {
return null;
}
@@ -285,10 +311,10 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertyList propList = new PropertyList(propDefList.getName());
String mapKey = getListMemberMapKey(propDefList);
- List<String> listMemberPaths = augeas.match(node.getPath());
+ String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + listMemberPropDefMap.getName();
+ List<String> listMemberPaths = augeas.match(listMemberPathsExpression);
for (String listMemberPath : listMemberPaths) {
AugeasNode listMemberNode = new AugeasNode(listMemberPath);
-
PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName());
propList.add(listMemberPropMap);
@@ -297,6 +323,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName());
listMemberPropMap.put(keyProp);
}
+
// Populate the rest of the map child properties.
populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode);
}
@@ -379,11 +406,15 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
"Invalid Resource ConfigurationDefinition - only lists of maps are supported.");
}
PropertyDefinitionMap listMemberPropDefMap = (PropertyDefinitionMap) listMemberPropDef;
- String mapKey = getListMemberMapKey(propDefList);
- Set<String> keys = new HashSet<String>();
int listIndex = 0;
- Set<AugeasNode> updatedMemberNodes = new HashSet<AugeasNode>();
+ List<String> existingListMemberPaths = augeas.match(listNode.getPath() + AugeasNode.SEPARATOR_CHAR
+ + listMemberPropDefMap.getName());
+ 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,
@@ -391,11 +422,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
if (memberNodeToUpdate != null) {
// Keep track of the existing nodes that we'll be updating, so that we can remove all other existing
// nodes.
- updatedMemberNodes.add(memberNodeToUpdate);
+ 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.
- memberNodeToUpdate = new AugeasNode(listNode, "0" + listIndex);
+ memberNodeToUpdate = new AugeasNode(listNode, "0" + (listIndex++));
}
// Update the node's children.
@@ -403,11 +434,9 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
}
// Now remove any existing nodes that we did not update in the previous loop.
- List<String> existingListMemberPaths = augeas.match(listNode.getPath() + "/*");
- for (String existingListMemberPath : existingListMemberPaths) {
- AugeasNode existingListMemberNode = new AugeasNode(existingListMemberPath);
- if (!updatedMemberNodes.contains(existingListMemberNode)) {
- augeas.remove(existingListMemberPath);
+ for (AugeasNode existingListMemberNode : existingListMemberNodes) {
+ if (!updatedListMemberNodes.contains(existingListMemberNode)) {
+ augeas.remove(existingListMemberNode.getPath());
}
}
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index 875a4c1..8e944db 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -54,7 +54,6 @@ public class HostsComponent extends AugeasConfigurationComponent {
"(([a-zA-Z\\d]|[a-zA-Z\\d][a-zA-Z\\d\\-]*[a-zA-Z\\d])\\.)*([A-Za-z]|[A-Za-z][A-Za-z\\d\\-]*[A-Za-z\\d])";
private static final Pattern DOMAIN_NAME_PATTERN = Pattern.compile(DOMAIN_NAME_REGEX);
-
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
super.start(resourceContext);
}
@@ -188,7 +187,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
String existingIpaddr = augeas.get(ipaddrNode.getPath());
int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
if (existingIpAddressVersion == ipAddressVersion) {
- return ipaddrNode;
+ return childNode;
}
}
return null;
diff --git a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
index 07e30fb..326eec6 100644
--- a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
@@ -41,8 +41,8 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property name="/*" displayName="Entries">
- <c:map-property name="entry">
+ <c:list-property name="." displayName="Entries">
+ <c:map-property name="*[canonical]">
<c:simple-property name="ipaddr" displayName="IP Address" type="string" required="true" activationPolicy="immediate"
description="The IP address of the host entry. The address may be an IPv4 address (e.g., 192.168.1.10) or an IPv6 address (e.g., fec0:0:0:bebe::2)."/>
commit b8acc4e5a3faeba55e32cb6884d04d58d9081480
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Oct 20 10:50:24 2009 -0700
adding generated source for antlr plugin
diff --git a/.classpath b/.classpath
index a774301..4186c24 100644
--- a/.classpath
+++ b/.classpath
@@ -74,6 +74,7 @@
<classpathentry kind="src" path="modules/plugins/netservices/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/target/generated-sources/xjc"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apt/src/test/java"/>
commit 6cd27378f6f85912275418ef03cd2fac53e953fd
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Oct 20 10:29:57 2009 -0400
do not include virt plugin in ear until errors in it are fixed
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 7403400..0aaf838 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -341,13 +341,13 @@
<artifactId>rhq-sshd-plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
-
+<!-- TODO: Uncomment once errors in virt plugin have been fixed.
<artifactItem>
<groupId>org.rhq</groupId>
<artifactId>rhq-virt-plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
-
+-->
</artifactItems>
<outputDirectory>${earDirectory}/rhq-downloads/rhq-plugins</outputDirectory>
</configuration>
commit b7a1e9e9f30d7a2d7fc488ca10fb87f3a923541c
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Tue Oct 20 15:17:44 2009 +0200
RHQ-2470 Postgres message for non-existing table has changeg. Use the SQLState code to determine non-existing table.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
index 4ca20aa..cdf29a3 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
@@ -54,9 +54,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
* @see DatabaseType#isTableNotFoundException(SQLException)
*/
public boolean isTableNotFoundException(SQLException e) {
- String msg = e.getMessage();
- msg = (msg == null) ? "" : msg.trim();
- return msg.endsWith("does not exist");
+ return (e.getSQLState().toUpperCase().equals("42P01"));
}
/**
commit 7beb55bb72dcc52bfd7d4ac6915efcb7c10b45af
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Tue Oct 20 09:15:32 2009 -0400
back out my augeas/hosts plugin changes from last Friday (6dc0d3ff445cb0e5fdd4957577327ccf24a15db6)
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 3ef73bd..d51e43e 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
@@ -19,7 +19,6 @@
package org.rhq.plugins.augeas;
import java.io.File;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -61,8 +60,6 @@ import org.rhq.plugins.platform.PlatformComponent;
*/
public class AugeasConfigurationComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet {
public static final String CONFIGURATION_FILE_PROP = "configurationFile";
- public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
- public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/local/share/augeas/lenses";
@@ -73,8 +70,8 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private ResourceContext resourceContext;
private File configFile;
private Augeas augeas;
+ private AugeasNode augeasConfigFileNode;
private AugeasNode augeasConfigFileMetadataNode;
- private AugeasNode resourceConfigRootNode;
public void start(ResourceContext<PlatformComponent> resourceContext) throws InvalidPluginConfigurationException,
Exception {
@@ -84,21 +81,9 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
this.configFile = new File(configFilePath);
this.augeas = createAugeas();
if (this.augeas != null) {
- AugeasNode augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
- // This is the metadata portion of the tree for this config file (e.g. /augeas/files/etc/hosts, where error
- // messages are stored as node values.
+ this.augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
this.augeasConfigFileMetadataNode = new AugeasNode("/augeas/files" + AugeasNode.SEPARATOR_CHAR
- + this.configFile.getPath());
- String resourceConfigRootNodePath = pluginConfig.getSimpleValue(RESOURCE_CONFIGURATION_ROOT_NODE_PROP, null);
- if (resourceConfigRootNodePath != null) {
- if (resourceConfigRootNodePath.indexOf(AugeasNode.SEPARATOR_CHAR) == 0) {
- this.resourceConfigRootNode = new AugeasNode(resourceConfigRootNodePath);
- } else {
- this.resourceConfigRootNode = new AugeasNode(augeasConfigFileNode, resourceConfigRootNodePath);
- }
- } else {
- this.resourceConfigRootNode = augeasConfigFileNode;
- }
+ + this.configFile.getPath());
}
}
@@ -134,7 +119,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ loadProperty(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
}
return resourceConfig;
@@ -142,27 +127,16 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
if (!validateResourceConfiguration(report)) {
- log.debug("Validation of updated Resource configuration for "
- + this.getResourceContext().getResourceType() + " Resource with key '"
- + this.getResourceContext().getResourceKey() + "' failed with the following errors: "
- + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
if (!this.configFile.canWrite()) {
- report.setErrorMessage("Configuration file '" + this.configFile + "' is not writable.");
+ report.setErrorMessage("Configuration file '" + this.configFile + "' is not writeable.");
return;
}
- File configFileParentDir = this.configFile.getParentFile();
- if (!configFileParentDir.canWrite()) {
- report.setErrorMessage("Configuration file parent directory '" + configFileParentDir
- + "' is not writable.");
- return;
- }
-
- // Load the config file from disk and build a tree representation of it in memory.
+ // Load the config file from disk and build a tree representation of it.
this.augeas.load();
ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
@@ -171,7 +145,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ setNode(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
}
// Write the updated tree out to the config file.
@@ -219,7 +193,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private Augeas createAugeas() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String augeasModuleName = pluginConfig.getSimpleValue(AUGEAS_MODULE_NAME_PROP, null);
+ String augeasModuleName = pluginConfig.getSimpleValue("augeasModuleName", null);
if (augeasModuleName == null) {
return null;
}
@@ -311,10 +285,10 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertyList propList = new PropertyList(propDefList.getName());
String mapKey = getListMemberMapKey(propDefList);
- String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + listMemberPropDefMap.getName();
- List<String> listMemberPaths = augeas.match(listMemberPathsExpression);
+ List<String> listMemberPaths = augeas.match(node.getPath());
for (String listMemberPath : listMemberPaths) {
AugeasNode listMemberNode = new AugeasNode(listMemberPath);
+
PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName());
propList.add(listMemberPropMap);
@@ -323,7 +297,6 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName());
listMemberPropMap.put(keyProp);
}
-
// Populate the rest of the map child properties.
populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode);
}
@@ -406,15 +379,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
"Invalid Resource ConfigurationDefinition - only lists of maps are supported.");
}
PropertyDefinitionMap listMemberPropDefMap = (PropertyDefinitionMap) listMemberPropDef;
+ String mapKey = getListMemberMapKey(propDefList);
+ Set<String> keys = new HashSet<String>();
int listIndex = 0;
- List<String> existingListMemberPaths = augeas.match(listNode.getPath() + AugeasNode.SEPARATOR_CHAR
- + listMemberPropDefMap.getName());
- List<AugeasNode> existingListMemberNodes = new ArrayList<AugeasNode>();
- for (String existingListMemberPath : existingListMemberPaths) {
- existingListMemberNodes.add(new AugeasNode(existingListMemberPath));
- }
- Set<AugeasNode> updatedListMemberNodes = new HashSet<AugeasNode>();
+ Set<AugeasNode> updatedMemberNodes = new HashSet<AugeasNode>();
for (Property listMemberProp : propList.getList()) {
PropertyMap listMemberPropMap = (PropertyMap) listMemberProp;
AugeasNode memberNodeToUpdate = getExistingChildNodeForListMemberPropertyMap(listNode, propDefList,
@@ -422,11 +391,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
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);
+ updatedMemberNodes.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.
- memberNodeToUpdate = new AugeasNode(listNode, "0" + (listIndex++));
+ memberNodeToUpdate = new AugeasNode(listNode, "0" + listIndex);
}
// Update the node's children.
@@ -434,9 +403,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
}
// Now remove any existing nodes that we did not update in the previous loop.
- for (AugeasNode existingListMemberNode : existingListMemberNodes) {
- if (!updatedListMemberNodes.contains(existingListMemberNode)) {
- augeas.remove(existingListMemberNode.getPath());
+ List<String> existingListMemberPaths = augeas.match(listNode.getPath() + "/*");
+ for (String existingListMemberPath : existingListMemberPaths) {
+ AugeasNode existingListMemberNode = new AugeasNode(existingListMemberPath);
+ if (!updatedMemberNodes.contains(existingListMemberNode)) {
+ augeas.remove(existingListMemberPath);
}
}
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index 8e944db..875a4c1 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -54,6 +54,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
"(([a-zA-Z\\d]|[a-zA-Z\\d][a-zA-Z\\d\\-]*[a-zA-Z\\d])\\.)*([A-Za-z]|[A-Za-z][A-Za-z\\d\\-]*[A-Za-z\\d])";
private static final Pattern DOMAIN_NAME_PATTERN = Pattern.compile(DOMAIN_NAME_REGEX);
+
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
super.start(resourceContext);
}
@@ -187,7 +188,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
String existingIpaddr = augeas.get(ipaddrNode.getPath());
int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
if (existingIpAddressVersion == ipAddressVersion) {
- return childNode;
+ return ipaddrNode;
}
}
return null;
diff --git a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
index 326eec6..07e30fb 100644
--- a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
@@ -41,8 +41,8 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property name="." displayName="Entries">
- <c:map-property name="*[canonical]">
+ <c:list-property name="/*" displayName="Entries">
+ <c:map-property name="entry">
<c:simple-property name="ipaddr" displayName="IP Address" type="string" required="true" activationPolicy="immediate"
description="The IP address of the host entry. The address may be an IPv4 address (e.g., 192.168.1.10) or an IPv6 address (e.g., fec0:0:0:bebe::2)."/>
commit b145003cba4c81c44d5317b22d0b4cd03a7f35ad
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Tue Oct 20 12:28:58 2009 +0200
Fix a small typo.
diff --git a/modules/core/dbutils/src/test/java/org/rhq/core/db/DatabaseTest.java b/modules/core/dbutils/src/test/java/org/rhq/core/db/DatabaseTest.java
index 3aa0cca..c2bb4f5 100644
--- a/modules/core/dbutils/src/test/java/org/rhq/core/db/DatabaseTest.java
+++ b/modules/core/dbutils/src/test/java/org/rhq/core/db/DatabaseTest.java
@@ -32,7 +32,7 @@ import org.rhq.core.db.setup.DBSetup;
* Tests database utilities like types and the factory. If you do not want the tests to fail if a database is not
* available, set <code>DatabaseTest.nofail</code> system property to <code>true</code>.
*
- * <p>This test loads in the test-databases.properties file as its defaults for database connecitivity info. You can set
+ * <p>This test loads in the test-databases.properties file as its defaults for database connectivity info. You can set
* system properties to override those defaults, if your test environment is different than these defaults.</p>
*
* @author John Mazzitelli
commit 81929aecc0837c94ab115ea70561bc418249498b
Merge: e22d84e... 65b1d6c...
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Oct 19 17:23:29 2009 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit e22d84ed25a635fc2cbc416bdee87dc340166749
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Oct 19 17:22:46 2009 -0400
fix mtime-based inventory sync logic (http://jira.rhq-project.org/browse/RHQ-1996)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 138ea0e..220c42e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -1046,7 +1046,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setId(int id) {
this.id = id;
- setAgentSynchronizationNeeded();
}
/**
@@ -1061,7 +1060,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setUuid(String uuid) {
this.uuid = uuid;
- setAgentSynchronizationNeeded();
}
@NotNull
@@ -1071,7 +1069,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setName(@NotNull String name) {
this.name = name;
- setAgentSynchronizationNeeded();
}
public String getResourceKey() {
@@ -1080,7 +1077,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setResourceKey(String resourceKey) {
this.resourceKey = resourceKey;
- setAgentSynchronizationNeeded();
}
public ResourceType getResourceType() {
@@ -1089,7 +1085,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setResourceType(ResourceType resourceType) {
this.resourceType = resourceType;
- setAgentSynchronizationNeeded();
}
public InventoryStatus getInventoryStatus() {
@@ -1098,7 +1093,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setInventoryStatus(InventoryStatus inventoryStatus) {
this.inventoryStatus = inventoryStatus;
- setAgentSynchronizationNeeded();
}
/**
@@ -1130,7 +1124,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setDescription(String description) {
this.description = description;
- setAgentSynchronizationNeeded();
}
/**
@@ -1216,7 +1209,6 @@ public class Resource implements Comparable<Resource>, Externalizable {
public void setLocation(String location) {
this.location = location;
- setAgentSynchronizationNeeded();
}
public Set<Resource> getChildResources() {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/EditGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/EditGeneralPropertiesUIBean.java
index ec05a1f..c402155 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/EditGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/EditGeneralPropertiesUIBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -60,6 +60,10 @@ public class EditGeneralPropertiesUIBean {
resource.setName(this.name);
resource.setDescription(this.description);
resource.setLocation(this.location);
+
+ // Update the mtime so the corresponding Agent will know it needs to sync this Resource.
+ resource.setAgentSynchronizationNeeded();
+
this.resourceManager.updateResource(EnterpriseFacesContextUtility.getSubject(), resource);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "General properties updated.");
return OUTCOME_SUCCESS;
commit 65b1d6c0871e677b7c728724fd188755301a3e16
Author: Partha Aji <paji(a)redhat.com>
Date: Mon Oct 19 17:16:02 2009 -0400
Updated the rhq sudoer's plugin in to correctly map to the updated Augeas plugin
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 2e3abb3..6bff878 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
@@ -18,7 +18,6 @@
*/
package org.rhq.plugins.augeas.helper;
-import java.net.URI;
/**
* An abstract representation of a node in an Augeas configuration tree (e.g. /files/etc/hosts/3/canonical).
@@ -40,7 +39,7 @@ public class AugeasNode {
}
// Remove redundant "." and ".." components and redundant slashes.
- this.path = normalize(path);
+ this.path = path;
}
public AugeasNode(AugeasNode parent, String name) {
@@ -113,9 +112,4 @@ public class AugeasNode {
public String toString() {
return this.path;
}
-
- private static String normalize(String path) {
- URI uri = URI.create(path);
- return uri.normalize().getPath();
- }
}
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 60a406e..c72d01d 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
@@ -34,8 +34,8 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property name="spec[*]" displayName="Entries">
- <c:map-property name="entry">
+ <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"
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"
commit e32a27e5df5f9e0169878fd3c48bc78bccca537f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Oct 19 17:13:57 2009 -0400
update JBossAS version from 5.1.0-SNAPSHOT to 5.2.0-SNAPSHOT to ensure the snapshots can actually be found in the snapshot repo
diff --git a/modules/plugins/jboss-cache-v3/pom.xml b/modules/plugins/jboss-cache-v3/pom.xml
index 844f93e..dcfad62 100644
--- a/modules/plugins/jboss-cache-v3/pom.xml
+++ b/modules/plugins/jboss-cache-v3/pom.xml
@@ -23,7 +23,7 @@
<properties>
<scm.module.path>modules/plugins/jboss-cache-v3/</scm.module.path>
- <jbossas.version>5.1.0-SNAPSHOT</jbossas.version>
+ <jbossas.version>5.2.0-SNAPSHOT</jbossas.version>
</properties>
<dependencyManagement>
commit d4db0a83d2176bbf1af02bbb8fb5e09b038a5592
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 19 14:53:26 2009 +0200
added tests for <Skip> and <Transparent>
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Skip.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Skip.g
new file mode 100644
index 0000000..82813af
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Skip.g
@@ -0,0 +1,46 @@
+grammar Skip;
+
+options {
+ language = Java;
+ output = AST;
+}
+
+tokens {
+ FILE;
+ SEGMENT;
+ ASSIGNMENT;
+}
+
+@header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+
+ import org.rhq.plugins.antlrconfig.tokens.*;
+}
+
+@lexer::header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+}
+
+fragment
+LETTER : 'a'..'z' | 'A'..'Z' ;
+
+fragment
+DIGIT : '0'..'9' ;
+
+SEGMENT : 's' 'e' 'g' 'm' 'e' 'n' 't' ;
+
+WORD : LETTER (LETTER | DIGIT)* ;
+
+EQUALS : '=' ;
+
+VALUE : DIGIT+;
+
+WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
+
+NL : '\r'? '\n' ;
+
+file : (segment | NL)* -> ^(FILE<Unordered> segment*) ;
+
+segment : SEGMENT '[' NL assignment* ']' (NL | EOF) -> ^(SEGMENT<Skip> assignment*) ;
+
+assignment : WORD EQUALS VALUE NL -> ^(ASSIGNMENT ^(WORD<Id>) VALUE);
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Transparent.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Transparent.g
new file mode 100644
index 0000000..00c1b1f
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Transparent.g
@@ -0,0 +1,50 @@
+grammar Transparent;
+
+options {
+ language = Java;
+ output = AST;
+}
+
+tokens {
+ FILE;
+ SEGMENT;
+ ASSIGNMENT;
+}
+
+@header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+
+ import org.rhq.plugins.antlrconfig.tokens.*;
+}
+
+@lexer::header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+}
+
+fragment
+LETTER : 'a'..'z' | 'A'..'Z' ;
+
+fragment
+DIGIT : '0'..'9' ;
+
+SEGMENT : 's' 'e' 'g' 'm' 'e' 'n' 't' ;
+
+WORD : LETTER (LETTER | DIGIT | '_')* ;
+
+EQUALS : '=' ;
+
+VALUE : DIGIT+;
+
+WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
+
+NL : '\r'? '\n' ;
+
+file : (segmentOrAssignment | NL)* -> ^(FILE<Unordered> segmentOrAssignment*) ;
+
+segmentOrAssignment : segment
+ | assignment
+ ;
+
+segment : SEGMENT '[' NL assignment* ']' (NL | EOF) -> ^(SEGMENT<Transparent> assignment*) ;
+
+assignment : WORD EQUALS VALUE NL -> ^(ASSIGNMENT ^(WORD<Id>) VALUE);
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java
index 7f788bd..f2d93dd 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java
@@ -56,6 +56,8 @@ public abstract class AbstractTest {
protected abstract String[] getTokenNames();
+ protected abstract String getConfigurationFileResourceName();
+
protected abstract CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException;
protected ConfigMapper getConfigMapper() {
@@ -76,10 +78,14 @@ public abstract class AbstractTest {
return getStream(getResourceStream(resourceName));
}
- protected Configuration storeAndLoad(Configuration config, InputStream origSource) throws RecognitionException, IOException {
+ protected TokenRewriteStream getStream() throws IOException {
+ return getStreamFromResource(getConfigurationFileResourceName());
+ }
+
+ protected Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
ConfigMapper mapper = getConfigMapper();
- TokenRewriteStream stream = getStream(origSource);
+ TokenRewriteStream stream = getStream();
CommonTree file = loadFile(stream);
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java
index 92d4d57..c9b4ada 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java
@@ -194,6 +194,10 @@ public class OrderedTest extends AbstractTest {
return (CommonTree) ret.getTree();
}
+ protected String getConfigurationFileResourceName() {
+ return TEST_CONFIGURATION_FILE_NAME;
+ }
+
@Test
public void testRead() throws Exception {
Configuration config = getConfigMapper().read(loadFile(getStream()));
@@ -299,13 +303,5 @@ public class OrderedTest extends AbstractTest {
Configuration config2 = storeAndLoad(config);
assertEquals(config, config2);
- }
-
- private TokenRewriteStream getStream() throws IOException {
- return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
- }
-
- private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
- return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
- }
+ }
}
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SkipTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SkipTest.java
new file mode 100644
index 0000000..c266845
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SkipTest.java
@@ -0,0 +1,144 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.antlrconfig.test;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.plugins.antlrconfig.NewEntryCreator;
+import org.rhq.plugins.antlrconfig.test.parsers.SkipLexer;
+import org.rhq.plugins.antlrconfig.test.parsers.SkipParser;
+
+/**
+ * Test for the <Skip> token type. The config parsing should behave the same as in {@link UnorderedTest}
+ * test because the grammar only defines a new "skipped" level in the AST under which it looks the same
+ * as the one for the unordered test.
+ *
+ * @author Lukas Krejci
+ */
+public class SkipTest extends UnorderedTest {
+
+ //the grammar prescribes, that the assignments can only exist in a "segment".
+ //We therefore mustn't use the super class' entry creator that doesn't know about this
+ //restriction. Note that it is impossible from the ConfigMapper side to "guess" which
+ //segment would you like to insert the new entry into.
+ private static class EntryCreator implements NewEntryCreator {
+
+ public List<OpDef> getInstructions(CommonTree fullTree, CommonTree immediateParent, Property property) {
+ if (ASSIGNMENT.equals(property.getName())) {
+ int tokenIndex = -1;
+ if (immediateParent != null) {
+ tokenIndex = immediateParent.getTokenStopIndex();
+ } else {
+ tokenIndex = fullTree.getTokenStopIndex();
+ }
+
+ OpDef assignmentOp = new OpDef();
+ assignmentOp.type = OpType.INSERT_AFTER;
+ assignmentOp.tokenIndex = tokenIndex;
+
+ StringBuilder bld = new StringBuilder("\nsegment [\n");
+
+ PropertyMap assignment = (PropertyMap) property;
+
+ bld.append(assignment.getSimpleValue(NAME, ""));
+
+ bld.append(" = ");
+
+ bld.append(assignment.getSimpleValue(VALUE, ""));
+
+ bld.append("\n");
+
+ bld.append("]\n");
+
+ assignmentOp.text = bld.toString();
+
+ return Collections.singletonList(assignmentOp);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ protected NewEntryCreator getNewEntryCreator() {
+ return new EntryCreator();
+ }
+
+ @Override
+ protected String getConfigurationFileResourceName() {
+ return "skip";
+ }
+
+ @Override
+ protected Lexer getLexer() {
+ return new SkipLexer();
+ }
+
+ @Override
+ protected String[] getTokenNames() {
+ return SkipParser.tokenNames;
+ }
+
+ @Override
+ protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
+ SkipParser parser = new SkipParser(stream);
+ SkipParser.file_return ret = parser.file();
+ return (CommonTree) ret.getTree();
+ }
+
+ @Test
+ @Override
+ public void testCreate() throws Exception {
+ super.testCreate();
+ }
+
+ @Test
+ @Override
+ public void testDelete() throws Exception {
+ super.testDelete();
+ }
+
+ @Test
+ @Override
+ public void testRead() throws Exception {
+ super.testRead();
+ }
+
+ @Test
+ @Override
+ public void testUpdate() throws Exception {
+ super.testUpdate();
+ }
+
+
+}
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/TransparentTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/TransparentTest.java
new file mode 100644
index 0000000..451d690
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/TransparentTest.java
@@ -0,0 +1,93 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.antlrconfig.test;
+
+import java.io.IOException;
+
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.testng.annotations.Test;
+
+import org.rhq.plugins.antlrconfig.test.parsers.TransparentLexer;
+import org.rhq.plugins.antlrconfig.test.parsers.TransparentParser;
+import org.rhq.plugins.antlrconfig.test.parsers.UnorderedParser;
+
+/**
+ * The test for the transparent token. This can be the same as the {@link UnorderedTest} because
+ * the "segment"s in the grammar are trasparent and therefore invisible to the mapper.
+ * Besides from those, the grammar looks the same as for the unordered test.
+ *
+ * @author Lukas Krejci
+ */
+public class TransparentTest extends UnorderedTest {
+
+ @Override
+ protected String getConfigurationFileResourceName() {
+ return "transparent";
+ }
+
+ @Override
+ protected Lexer getLexer() {
+ return new TransparentLexer();
+ }
+
+ @Override
+ protected String[] getTokenNames() {
+ return TransparentParser.tokenNames;
+ }
+
+ @Override
+ protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
+ TransparentParser parser = new TransparentParser(stream);
+ TransparentParser.file_return ret = parser.file();
+ return (CommonTree) ret.getTree();
+ }
+
+ @Test
+ @Override
+ public void testCreate() throws Exception {
+ super.testCreate();
+ }
+
+ @Test
+ @Override
+ public void testDelete() throws Exception {
+ super.testDelete();
+ }
+
+ @Test
+ @Override
+ public void testRead() throws Exception {
+ super.testRead();
+ }
+
+ @Test
+ @Override
+ public void testUpdate() throws Exception {
+ super.testUpdate();
+ }
+
+}
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java
index d4449cc..26c5c99 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java
@@ -59,14 +59,11 @@ import org.rhq.plugins.antlrconfig.test.parsers.UnorderedParser;
* @author Lukas Krejci
*/
public class UnorderedTest extends AbstractTest {
- /**
- *
- */
private static final String TEST_CONFIGURATION_FILE_NAME = "unordered";
- private static final String FILE = "config:///file";
- private static final String ASSIGNMENT = "config://assignment";
- private static final String NAME = "config://$1";
- private static final String VALUE = "config://$2";
+ protected static final String FILE = "config:///file";
+ protected static final String ASSIGNMENT = "config://assignment";
+ protected static final String NAME = "config://$1";
+ protected static final String VALUE = "config://$2";
private static class EntryCreator implements NewEntryCreator {
@@ -141,6 +138,10 @@ public class UnorderedTest extends AbstractTest {
return (CommonTree) ret.getTree();
}
+ protected String getConfigurationFileResourceName() {
+ return TEST_CONFIGURATION_FILE_NAME;
+ }
+
@Test
public void testRead() throws Exception {
Configuration config = getConfigMapper().read(loadFile(getStream()));
@@ -243,14 +244,6 @@ public class UnorderedTest extends AbstractTest {
assertEquals(updated, config, "Simple create failed.");
}
- private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
- return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
- }
-
- private TokenRewriteStream getStream() throws IOException {
- return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
- }
-
private void basicTests(Configuration config) throws Exception {
assertNotNull(config, "Could not read the configuration from the file.");
diff --git a/modules/plugins/antlr-config/src/test/resources/skip b/modules/plugins/antlr-config/src/test/resources/skip
new file mode 100644
index 0000000..8da9b09
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/resources/skip
@@ -0,0 +1,14 @@
+segment [
+ a = 1
+ b = 2
+ c = 3
+]
+
+
+segment [
+ d = 4
+]
+
+segment [
+ e = 5
+]
\ No newline at end of file
diff --git a/modules/plugins/antlr-config/src/test/resources/transparent b/modules/plugins/antlr-config/src/test/resources/transparent
new file mode 100644
index 0000000..db3a899
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/resources/transparent
@@ -0,0 +1,11 @@
+segment [
+ this_is_invisible_to_the_mapper = 1
+]
+a = 1
+b = 2
+segment [
+ this_is_invisible_to_the_mapper = 1
+]
+c = 3
+d = 4
+e = 5
commit 7f08dcbf492a7b3bc4cbe9a6e87e9cc6f65b86b6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 19 12:15:59 2009 +0200
Renamed the "SimpleTest" to "OrderedTest" to reflect what it's actually testing.
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Ordered.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Ordered.g
new file mode 100644
index 0000000..b08b5c5
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Ordered.g
@@ -0,0 +1,45 @@
+grammar Ordered;
+
+options {
+ language = Java;
+ output = AST;
+ ASTLabelType = CommonTree;
+}
+
+tokens {
+ FILE;
+ ASSIGNMENT;
+}
+
+@header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+
+ import org.rhq.plugins.antlrconfig.tokens.*;
+}
+
+@lexer::header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+}
+
+fragment
+LETTER : 'a'..'z' | 'A'..'Z' ;
+
+fragment
+DIGIT : '0'..'9' ;
+
+EXPORT : 'e' 'x' 'p' 'o' 'r' 't' ;
+
+WORD : LETTER (LETTER | DIGIT)* ;
+
+EQUALS : '=' ;
+
+VALUE : DIGIT+;
+
+WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
+
+NL : '\r'? '\n' ;
+
+file : (assignment | NL)* -> ^(FILE<Ordered> assignment*)
+ ;
+
+assignment : EXPORT? WORD EQUALS VALUE (NL | EOF) -> ^(ASSIGNMENT ^(WORD<Id>) VALUE EXPORT?);
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g
deleted file mode 100644
index c4bc2f9..0000000
--- a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g
+++ /dev/null
@@ -1,45 +0,0 @@
-grammar Simple;
-
-options {
- language = Java;
- output = AST;
- ASTLabelType = CommonTree;
-}
-
-tokens {
- FILE;
- ASSIGNMENT;
-}
-
-@header {
- package org.rhq.plugins.antlrconfig.test.parsers;
-
- import org.rhq.plugins.antlrconfig.tokens.*;
-}
-
-@lexer::header {
- package org.rhq.plugins.antlrconfig.test.parsers;
-}
-
-fragment
-LETTER : 'a'..'z' | 'A'..'Z' ;
-
-fragment
-DIGIT : '0'..'9' ;
-
-EXPORT : 'e' 'x' 'p' 'o' 'r' 't' ;
-
-WORD : LETTER (LETTER | DIGIT)* ;
-
-EQUALS : '=' ;
-
-VALUE : DIGIT+;
-
-WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
-
-NL : '\r'? '\n' ;
-
-file : (assignment | NL)* -> ^(FILE<Ordered> assignment*)
- ;
-
-assignment : EXPORT? WORD EQUALS VALUE (NL | EOF) -> ^(ASSIGNMENT ^(WORD<Id>) VALUE EXPORT?);
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java
new file mode 100644
index 0000000..92d4d57
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/OrderedTest.java
@@ -0,0 +1,311 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.antlrconfig.test;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.plugins.antlrconfig.ConfigMapper;
+import org.rhq.plugins.antlrconfig.ConfigurationFacade;
+import org.rhq.plugins.antlrconfig.DefaultConfigurationFacade;
+import org.rhq.plugins.antlrconfig.NewEntryCreator;
+import org.rhq.plugins.antlrconfig.test.parsers.OrderedLexer;
+import org.rhq.plugins.antlrconfig.test.parsers.OrderedParser;
+import org.rhq.plugins.antlrconfig.test.parsers.SimpleLexer;
+import org.rhq.plugins.antlrconfig.test.parsers.SimpleParser;
+
+/**
+ * Tests with the Simple.g grammar
+ *
+ * @author Lukas Krejci
+ */
+public class OrderedTest extends AbstractTest {
+
+ private static final String TEST_CONFIGURATION_FILE_NAME = "ordered";
+ private static final String FILE = "config:///file";
+ private static final String ASSIGNMENT = "config://assignment";
+ private static final String NAME = "config://$1";
+ private static final String VALUE = "config://$2";
+ private static final String EXPORT = "config://$3";
+
+ protected ConfigurationDefinition getConfigurationDefinition() {
+ ConfigurationDefinition def = new ConfigurationDefinition("", null);
+
+ PropertyDefinitionList file = new PropertyDefinitionList(FILE, null, true, null);
+ def.put(file);
+
+ PropertyDefinitionMap assignment = new PropertyDefinitionMap(ASSIGNMENT, null, false, (PropertyDefinition[])null);
+ file.setMemberDefinition(assignment);
+
+ assignment.put(new PropertyDefinitionSimple(NAME, null, true, PropertySimpleType.STRING));
+ assignment.put(new PropertyDefinitionSimple(VALUE, null, true, PropertySimpleType.STRING));
+ assignment.put(new PropertyDefinitionSimple(EXPORT, null, true, PropertySimpleType.BOOLEAN));
+
+ return def;
+ }
+
+ private static class CustomFacade extends DefaultConfigurationFacade {
+
+ public CustomFacade(ConfigurationDefinition definition) {
+ super(definition);
+ }
+
+ @Override
+ public void applyValue(PropertySimple property, String value) {
+ if (EXPORT.equals(property.getName())) {
+ property.setBooleanValue("export".equalsIgnoreCase(value));
+ } else {
+ super.applyValue(property, value);
+ }
+ }
+
+ @Override
+ public String getPersistableValue(PropertySimple property) {
+ if (EXPORT.equals(property.getName())) {
+ return property.getBooleanValue() ? "export" : "";
+ } else {
+ return super.getPersistableValue(property);
+ }
+ }
+
+ @Override
+ public boolean isEqual(PropertySimple property, String value) {
+ if (EXPORT.equals(property.getName())) {
+ if (property.getBooleanValue()) {
+ return "export".equalsIgnoreCase(value);
+ } else {
+ return value == null || value.length() == 0;
+ }
+ } else {
+ return super.isEqual(property, value);
+ }
+ }
+ }
+
+ private static class EntryCreator implements NewEntryCreator {
+
+ public List<OpDef> getInstructions(CommonTree fullTree, CommonTree immediateParent, Property property) {
+ if (EXPORT.equals(property.getName()) && ((PropertySimple)property).getBooleanValue()) {
+ //immediate parent should never be null
+ if (immediateParent != null) {
+ OpDef op = new OpDef();
+ op.type = OpType.INSERT_BEFORE;
+ op.text = "export ";
+ op.tokenIndex = immediateParent.getTokenStartIndex();
+ return Collections.singletonList(op);
+ }
+ } else if (ASSIGNMENT.equals(property.getName())) {
+ int tokenIndex = -1;
+ if (immediateParent != null) {
+ tokenIndex = immediateParent.getTokenStopIndex();
+ } else {
+ tokenIndex = fullTree.getTokenStopIndex();
+ }
+
+ OpDef op = new OpDef();
+ op.type = OpType.INSERT_AFTER;
+ op.tokenIndex = tokenIndex;
+
+ StringBuilder bld = new StringBuilder();
+
+ PropertyMap assignment = (PropertyMap) property;
+
+ PropertySimple export = assignment.getSimple(EXPORT);
+ if (export != null && export.getBooleanValue()) {
+ bld.append("export ");
+ }
+
+ bld.append(assignment.getSimpleValue(NAME, ""));
+
+ bld.append(" = ");
+
+ bld.append(assignment.getSimpleValue(VALUE, ""));
+
+ bld.append("\n");
+
+ op.text = bld.toString();
+
+ return Collections.singletonList(op);
+ }
+ return null;
+ }
+ }
+
+ protected ConfigurationFacade getConfigurationFacade() {
+ return new CustomFacade(getConfigurationDefinition());
+ }
+
+ protected Lexer getLexer() {
+ return new OrderedLexer();
+ }
+
+ protected NewEntryCreator getNewEntryCreator() {
+ return new EntryCreator();
+ }
+
+ protected String[] getTokenNames() {
+ return OrderedParser.tokenNames;
+ }
+
+ protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
+ OrderedParser parser = new OrderedParser(stream);
+ OrderedParser.file_return ret = parser.file();
+ return (CommonTree) ret.getTree();
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
+
+ assertNotNull(config, "Could not read the configuration from the file.");
+
+ PropertyList file = config.getList(FILE);
+
+ assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ assertEquals(file.getList().size(), 5, "There should be 5 assignments in the test file.");
+
+ for(int i = 0; i < 5; ++i) {
+ PropertyMap assignment = (PropertyMap) file.getList().get(i);
+
+ String name = assignment.getSimpleValue(NAME, "");
+ String value = assignment.getSimpleValue(VALUE, "");
+ boolean export = assignment.getSimple(EXPORT).getBooleanValue();
+
+ switch (i) {
+ case 0:
+ assertEquals(name, "a", "The first variable should be called 'a'");
+ assertEquals(value, "1", "The value of the first variable should be 1.");
+ assertEquals(export, false, "The first variable shouldn't be exported.");
+ break;
+ case 1:
+ assertEquals(name, "b", "The second variable should be called 'b'");
+ assertEquals(value, "2", "The value of the second variable should be 2.");
+ assertEquals(export, false, "The second variable shouldn't be exported.");
+ break;
+ case 2:
+ assertEquals(name, "c", "The third variable should be called 'c'");
+ assertEquals(value, "3", "The value of the third variable should be 3.");
+ assertEquals(export, true, "The third variable should be exported.");
+ break;
+ case 3:
+ assertEquals(name, "d", "The first variable should be called 'd'");
+ assertEquals(value, "4", "The value of the first variable should be 4.");
+ assertEquals(export, false, "The first variable shouldn't be exported.");
+ break;
+ case 4:
+ assertEquals(name, "e", "The first variable should be called 'e'");
+ assertEquals(value, "5", "The value of the first variable should be 5.");
+ assertEquals(export, false, "The first variable shouldn't be exported.");
+ break;
+ }
+ }
+ }
+
+ @Test
+ public void testUpdate() throws Exception {
+ ConfigMapper mapper = getConfigMapper();
+
+ Configuration config = mapper.read(loadFile(getStream()));
+ assertNotNull(config, "Could not read the configuration from the file.");
+
+ PropertyList file = config.getList(FILE);
+ assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ PropertyMap firstAssignment = (PropertyMap) file.getList().get(0);
+
+ firstAssignment.getSimple(VALUE).setStringValue("12");
+ firstAssignment.getSimple(EXPORT).setBooleanValue(true);
+
+ Configuration config2 = storeAndLoad(config);
+
+ assertEquals(config, config2);
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
+ assertNotNull(config, "Could not read the configuration from the file.");
+
+ PropertyList file = config.getList(FILE);
+ assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ PropertyMap newAssignment = new PropertyMap(ASSIGNMENT);
+ newAssignment.put(new PropertySimple(NAME, "new"));
+ newAssignment.put(new PropertySimple(VALUE, "42"));
+ newAssignment.put(new PropertySimple(EXPORT, true));
+ file.add(newAssignment);
+
+ Configuration config2 = storeAndLoad(config);
+
+ assertEquals(config, config2);
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
+ assertNotNull(config, "Could not read the configuration from the file.");
+
+ PropertyList file = config.getList(FILE);
+ assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ //remove export c = 3
+ file.getList().remove(2);
+ Property firstAssignment = file.getList().remove(0);
+ //add it as last
+ file.add(firstAssignment);
+
+ Configuration config2 = storeAndLoad(config);
+
+ assertEquals(config, config2);
+ }
+
+ private TokenRewriteStream getStream() throws IOException {
+ return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
+ }
+
+ private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
+ return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
+ }
+}
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
deleted file mode 100644
index 9e81ec3..0000000
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.plugins.antlrconfig.test;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.antlr.runtime.Lexer;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.TokenRewriteStream;
-import org.antlr.runtime.tree.CommonTree;
-import org.testng.annotations.Test;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-import org.rhq.plugins.antlrconfig.ConfigMapper;
-import org.rhq.plugins.antlrconfig.ConfigurationFacade;
-import org.rhq.plugins.antlrconfig.DefaultConfigurationFacade;
-import org.rhq.plugins.antlrconfig.NewEntryCreator;
-import org.rhq.plugins.antlrconfig.test.parsers.SimpleLexer;
-import org.rhq.plugins.antlrconfig.test.parsers.SimpleParser;
-
-/**
- * Tests with the Simple.g grammar
- *
- * @author Lukas Krejci
- */
-public class SimpleTest extends AbstractTest {
-
- private static final String TEST_CONFIGURATION_FILE_NAME = "simple";
- private static final String FILE = "config:///file";
- private static final String ASSIGNMENT = "config://assignment";
- private static final String NAME = "config://$1";
- private static final String VALUE = "config://$2";
- private static final String EXPORT = "config://$3";
-
- protected ConfigurationDefinition getConfigurationDefinition() {
- ConfigurationDefinition def = new ConfigurationDefinition("", null);
-
- PropertyDefinitionList file = new PropertyDefinitionList(FILE, null, true, null);
- def.put(file);
-
- PropertyDefinitionMap assignment = new PropertyDefinitionMap(ASSIGNMENT, null, false, (PropertyDefinition[])null);
- file.setMemberDefinition(assignment);
-
- assignment.put(new PropertyDefinitionSimple(NAME, null, true, PropertySimpleType.STRING));
- assignment.put(new PropertyDefinitionSimple(VALUE, null, true, PropertySimpleType.STRING));
- assignment.put(new PropertyDefinitionSimple(EXPORT, null, true, PropertySimpleType.BOOLEAN));
-
- return def;
- }
-
- private static class CustomFacade extends DefaultConfigurationFacade {
-
- public CustomFacade(ConfigurationDefinition definition) {
- super(definition);
- }
-
- @Override
- public void applyValue(PropertySimple property, String value) {
- if (EXPORT.equals(property.getName())) {
- property.setBooleanValue("export".equalsIgnoreCase(value));
- } else {
- super.applyValue(property, value);
- }
- }
-
- @Override
- public String getPersistableValue(PropertySimple property) {
- if (EXPORT.equals(property.getName())) {
- return property.getBooleanValue() ? "export" : "";
- } else {
- return super.getPersistableValue(property);
- }
- }
-
- @Override
- public boolean isEqual(PropertySimple property, String value) {
- if (EXPORT.equals(property.getName())) {
- if (property.getBooleanValue()) {
- return "export".equalsIgnoreCase(value);
- } else {
- return value == null || value.length() == 0;
- }
- } else {
- return super.isEqual(property, value);
- }
- }
- }
-
- private static class EntryCreator implements NewEntryCreator {
-
- public List<OpDef> getInstructions(CommonTree fullTree, CommonTree immediateParent, Property property) {
- if (EXPORT.equals(property.getName()) && ((PropertySimple)property).getBooleanValue()) {
- //immediate parent should never be null
- if (immediateParent != null) {
- OpDef op = new OpDef();
- op.type = OpType.INSERT_BEFORE;
- op.text = "export ";
- op.tokenIndex = immediateParent.getTokenStartIndex();
- return Collections.singletonList(op);
- }
- } else if (ASSIGNMENT.equals(property.getName())) {
- int tokenIndex = -1;
- if (immediateParent != null) {
- tokenIndex = immediateParent.getTokenStopIndex();
- } else {
- tokenIndex = fullTree.getTokenStopIndex();
- }
-
- OpDef op = new OpDef();
- op.type = OpType.INSERT_AFTER;
- op.tokenIndex = tokenIndex;
-
- StringBuilder bld = new StringBuilder();
-
- PropertyMap assignment = (PropertyMap) property;
-
- PropertySimple export = assignment.getSimple(EXPORT);
- if (export != null && export.getBooleanValue()) {
- bld.append("export ");
- }
-
- bld.append(assignment.getSimpleValue(NAME, ""));
-
- bld.append(" = ");
-
- bld.append(assignment.getSimpleValue(VALUE, ""));
-
- bld.append("\n");
-
- op.text = bld.toString();
-
- return Collections.singletonList(op);
- }
- return null;
- }
- }
-
- protected ConfigurationFacade getConfigurationFacade() {
- return new CustomFacade(getConfigurationDefinition());
- }
-
- protected Lexer getLexer() {
- return new SimpleLexer();
- }
-
- protected NewEntryCreator getNewEntryCreator() {
- return new EntryCreator();
- }
-
- protected String[] getTokenNames() {
- return SimpleParser.tokenNames;
- }
-
- protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
- SimpleParser parser = new SimpleParser(stream);
- SimpleParser.file_return ret = parser.file();
- return (CommonTree) ret.getTree();
- }
-
- @Test
- public void testRead() throws Exception {
- Configuration config = getConfigMapper().read(loadFile(getStream()));
-
- assertNotNull(config, "Could not read the configuration from the file.");
-
- PropertyList file = config.getList(FILE);
-
- assertNotNull(file, "the configuration should contain a list of assignments.");
-
- assertEquals(file.getList().size(), 5, "There should be 5 assignments in the test file.");
-
- for(int i = 0; i < 5; ++i) {
- PropertyMap assignment = (PropertyMap) file.getList().get(i);
-
- String name = assignment.getSimpleValue(NAME, "");
- String value = assignment.getSimpleValue(VALUE, "");
- boolean export = assignment.getSimple(EXPORT).getBooleanValue();
-
- switch (i) {
- case 0:
- assertEquals(name, "a", "The first variable should be called 'a'");
- assertEquals(value, "1", "The value of the first variable should be 1.");
- assertEquals(export, false, "The first variable shouldn't be exported.");
- break;
- case 1:
- assertEquals(name, "b", "The second variable should be called 'b'");
- assertEquals(value, "2", "The value of the second variable should be 2.");
- assertEquals(export, false, "The second variable shouldn't be exported.");
- break;
- case 2:
- assertEquals(name, "c", "The third variable should be called 'c'");
- assertEquals(value, "3", "The value of the third variable should be 3.");
- assertEquals(export, true, "The third variable should be exported.");
- break;
- case 3:
- assertEquals(name, "d", "The first variable should be called 'd'");
- assertEquals(value, "4", "The value of the first variable should be 4.");
- assertEquals(export, false, "The first variable shouldn't be exported.");
- break;
- case 4:
- assertEquals(name, "e", "The first variable should be called 'e'");
- assertEquals(value, "5", "The value of the first variable should be 5.");
- assertEquals(export, false, "The first variable shouldn't be exported.");
- break;
- }
- }
- }
-
- @Test
- public void testUpdate() throws Exception {
- ConfigMapper mapper = getConfigMapper();
-
- Configuration config = mapper.read(loadFile(getStream()));
- assertNotNull(config, "Could not read the configuration from the file.");
-
- PropertyList file = config.getList(FILE);
- assertNotNull(file, "the configuration should contain a list of assignments.");
-
- PropertyMap firstAssignment = (PropertyMap) file.getList().get(0);
-
- firstAssignment.getSimple(VALUE).setStringValue("12");
- firstAssignment.getSimple(EXPORT).setBooleanValue(true);
-
- Configuration config2 = storeAndLoad(config);
-
- assertEquals(config, config2);
- }
-
- @Test
- public void testCreate() throws Exception {
- Configuration config = getConfigMapper().read(loadFile(getStream()));
- assertNotNull(config, "Could not read the configuration from the file.");
-
- PropertyList file = config.getList(FILE);
- assertNotNull(file, "the configuration should contain a list of assignments.");
-
- PropertyMap newAssignment = new PropertyMap(ASSIGNMENT);
- newAssignment.put(new PropertySimple(NAME, "new"));
- newAssignment.put(new PropertySimple(VALUE, "42"));
- newAssignment.put(new PropertySimple(EXPORT, true));
- file.add(newAssignment);
-
- Configuration config2 = storeAndLoad(config);
-
- assertEquals(config, config2);
- }
-
- @Test
- public void testDelete() throws Exception {
- Configuration config = getConfigMapper().read(loadFile(getStream()));
- assertNotNull(config, "Could not read the configuration from the file.");
-
- PropertyList file = config.getList(FILE);
- assertNotNull(file, "the configuration should contain a list of assignments.");
-
- //remove export c = 3
- file.getList().remove(2);
- Property firstAssignment = file.getList().remove(0);
- //add it as last
- file.add(firstAssignment);
-
- Configuration config2 = storeAndLoad(config);
-
- assertEquals(config, config2);
- }
-
- private TokenRewriteStream getStream() throws IOException {
- return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
- }
-
- private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
- return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
- }
-}
diff --git a/modules/plugins/antlr-config/src/test/resources/ordered b/modules/plugins/antlr-config/src/test/resources/ordered
new file mode 100644
index 0000000..649d4dd
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/resources/ordered
@@ -0,0 +1,5 @@
+a = 1
+b = 2
+export c = 3
+d = 4
+e = 5
diff --git a/modules/plugins/antlr-config/src/test/resources/simple b/modules/plugins/antlr-config/src/test/resources/simple
deleted file mode 100644
index 649d4dd..0000000
--- a/modules/plugins/antlr-config/src/test/resources/simple
+++ /dev/null
@@ -1,5 +0,0 @@
-a = 1
-b = 2
-export c = 3
-d = 4
-e = 5
commit 9332e05aa150cf9eaf374861f5bf6cf88fee755e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 19 12:12:27 2009 +0200
Fixing the delete behavior.
diff --git a/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
index b76181a..f9e6702 100644
--- a/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
+++ b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
@@ -49,7 +49,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.plugins.antlrconfig.NewEntryCreator.OpDef;
import org.rhq.plugins.antlrconfig.tokens.Id;
import org.rhq.plugins.antlrconfig.tokens.Ordered;
-import org.rhq.plugins.antlrconfig.tokens.Transparent;
import org.rhq.plugins.antlrconfig.tokens.Unordered;
/**
@@ -133,7 +132,12 @@ public class ConfigMapper {
applyInstructions(instructions, fileStream);
}
} else if (isDelete) {
- addReorder(rec, reorders);
+ if (rec.parent != null && rec.parent.getToken() instanceof Ordered) {
+ //this sub tree is inside an <Ordered> list. Will deal with it later.
+ addReorder(rec, reorders);
+ } else {
+ fileStream.delete(rec.tree.getTokenStartIndex(), rec.tree.getTokenStopIndex());
+ }
} else if (rec.property instanceof PropertySimple) {
String value = configFacade.getPersistableValue((PropertySimple)rec.property);
fileStream.replace(rec.tree.getTokenStartIndex(), rec.tree.getTokenStopIndex(), value);
@@ -147,6 +151,7 @@ public class ConfigMapper {
return o1.treeIndex - o2.treeIndex;
}
};
+
for(Map.Entry<CommonTree, List<MergeRecord>> entry : reorders.entrySet()) {
List<MergeRecord> thisReorders = entry.getValue();
Collections.sort(thisReorders, sorter);
@@ -416,14 +421,12 @@ public class ConfigMapper {
}
private void addReorder(MergeRecord rec, Map<CommonTree, List<MergeRecord>> reorders) {
- if (rec.parent.getToken() instanceof Ordered) {
- List<MergeRecord> concreteReorders = reorders.get(rec.parent);
- if (concreteReorders == null) {
- concreteReorders = new ArrayList<MergeRecord>();
- reorders.put(rec.parent, concreteReorders);
- }
- concreteReorders.add(rec);
+ List<MergeRecord> concreteReorders = reorders.get(rec.parent);
+ if (concreteReorders == null) {
+ concreteReorders = new ArrayList<MergeRecord>();
+ reorders.put(rec.parent, concreteReorders);
}
+ concreteReorders.add(rec);
}
private static class MergeRecord {
commit 26751e5ef40457cac8ca5fe49db53d5b6ba05b4c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 19 12:12:04 2009 +0200
Added a test for <Unordered> token type in grammars.
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Unordered.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Unordered.g
new file mode 100644
index 0000000..1fb4b45
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Unordered.g
@@ -0,0 +1,43 @@
+grammar Unordered;
+
+options {
+ language = Java;
+ output = AST;
+ ASTLabelType = CommonTree;
+}
+
+tokens {
+ FILE;
+ ASSIGNMENT;
+}
+
+@header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+
+ import org.rhq.plugins.antlrconfig.tokens.*;
+}
+
+@lexer::header {
+ package org.rhq.plugins.antlrconfig.test.parsers;
+}
+
+fragment
+LETTER : 'a'..'z' | 'A'..'Z' ;
+
+fragment
+DIGIT : '0'..'9' ;
+
+WORD : LETTER (LETTER | DIGIT)* ;
+
+EQUALS : '=' ;
+
+VALUE : DIGIT+;
+
+WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
+
+NL : '\r'? '\n' ;
+
+file : (assignment | NL)* -> ^(FILE<Unordered> assignment*)
+ ;
+
+assignment : WORD EQUALS VALUE (NL | EOF) -> ^(ASSIGNMENT ^(WORD<Id>) VALUE);
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java
new file mode 100644
index 0000000..d4449cc
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/UnorderedTest.java
@@ -0,0 +1,263 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.antlrconfig.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.plugins.antlrconfig.ConfigurationFacade;
+import org.rhq.plugins.antlrconfig.DefaultConfigurationFacade;
+import org.rhq.plugins.antlrconfig.NewEntryCreator;
+import org.rhq.plugins.antlrconfig.test.parsers.UnorderedLexer;
+import org.rhq.plugins.antlrconfig.test.parsers.UnorderedParser;
+
+/**
+ * Test for <Unordered> token in grammars and its effect on
+ * the mapping.
+ *
+ * @author Lukas Krejci
+ */
+public class UnorderedTest extends AbstractTest {
+ /**
+ *
+ */
+ private static final String TEST_CONFIGURATION_FILE_NAME = "unordered";
+ private static final String FILE = "config:///file";
+ private static final String ASSIGNMENT = "config://assignment";
+ private static final String NAME = "config://$1";
+ private static final String VALUE = "config://$2";
+
+
+ private static class EntryCreator implements NewEntryCreator {
+
+ public List<OpDef> getInstructions(CommonTree fullTree, CommonTree immediateParent, Property property) {
+ if (ASSIGNMENT.equals(property.getName())) {
+ int tokenIndex = -1;
+ if (immediateParent != null) {
+ tokenIndex = immediateParent.getTokenStopIndex();
+ } else {
+ tokenIndex = fullTree.getTokenStopIndex();
+ }
+
+ OpDef op = new OpDef();
+ op.type = OpType.INSERT_AFTER;
+ op.tokenIndex = tokenIndex;
+
+ StringBuilder bld = new StringBuilder();
+
+ PropertyMap assignment = (PropertyMap) property;
+
+ bld.append(assignment.getSimpleValue(NAME, ""));
+
+ bld.append(" = ");
+
+ bld.append(assignment.getSimpleValue(VALUE, ""));
+
+ bld.append("\n");
+
+ op.text = bld.toString();
+
+ return Collections.singletonList(op);
+ }
+ return null;
+ }
+ }
+
+ protected ConfigurationDefinition getConfigurationDefinition() {
+ ConfigurationDefinition def = new ConfigurationDefinition("", null);
+
+ PropertyDefinitionList file = new PropertyDefinitionList(FILE, null, true, null);
+ def.put(file);
+
+ PropertyDefinitionMap assignment = new PropertyDefinitionMap(ASSIGNMENT, null, false, (PropertyDefinition[])null);
+ file.setMemberDefinition(assignment);
+
+ assignment.put(new PropertyDefinitionSimple(NAME, null, true, PropertySimpleType.STRING));
+ assignment.put(new PropertyDefinitionSimple(VALUE, null, true, PropertySimpleType.STRING));
+
+ return def;
+ }
+
+ protected ConfigurationFacade getConfigurationFacade() {
+ return new DefaultConfigurationFacade(getConfigurationDefinition());
+ }
+
+ protected Lexer getLexer() {
+ return new UnorderedLexer();
+ }
+
+ protected NewEntryCreator getNewEntryCreator() {
+ return new EntryCreator();
+ }
+
+ protected String[] getTokenNames() {
+ return UnorderedParser.tokenNames;
+ }
+
+ protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
+ UnorderedParser parser = new UnorderedParser(stream);
+ UnorderedParser.file_return ret = parser.file();
+ return (CommonTree) ret.getTree();
+ }
+
+ @Test
+ public void testRead() throws Exception {
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
+ basicTests(config);
+
+ PropertyList file = config.getList(FILE);
+ for(int i = 0; i < 5; ++i) {
+ PropertyMap assignment = (PropertyMap) file.getList().get(i);
+
+ String name = assignment.getSimpleValue(NAME, "");
+ String value = assignment.getSimpleValue(VALUE, "");
+
+ switch (i) {
+ case 0:
+ assertEquals(name, "a", "The first variable should be called 'a'");
+ assertEquals(value, "1", "The value of the first variable should be 1.");
+ break;
+ case 1:
+ assertEquals(name, "b", "The second variable should be called 'b'");
+ assertEquals(value, "2", "The value of the second variable should be 2.");
+ break;
+ case 2:
+ assertEquals(name, "c", "The third variable should be called 'c'");
+ assertEquals(value, "3", "The value of the third variable should be 3.");
+ break;
+ case 3:
+ assertEquals(name, "d", "The first variable should be called 'd'");
+ assertEquals(value, "4", "The value of the first variable should be 4.");
+ break;
+ case 4:
+ assertEquals(name, "e", "The first variable should be called 'e'");
+ assertEquals(value, "5", "The value of the first variable should be 5.");
+ break;
+ }
+ }
+ }
+
+ @Test
+ public void testUpdate() throws Exception {
+ Configuration origConfig = getConfigMapper().read(loadFile(getStream()));
+ basicTests(origConfig);
+
+ //first a simple update
+ Configuration simpleUpdateConfig = origConfig.deepCopy();
+ PropertyMap firstAssignment = (PropertyMap)simpleUpdateConfig.getList(FILE).getList().get(0);
+ firstAssignment.put(new PropertySimple(NAME, "a"));
+ firstAssignment.put(new PropertySimple(VALUE, "42"));
+
+ Configuration updatedSimpleUpdate = storeAndLoad(simpleUpdateConfig);
+
+ assertEquals(updatedSimpleUpdate, simpleUpdateConfig, "Simple update failed.");
+
+ //now shuffle and compare with original
+ Configuration shuffleConfig = origConfig.deepCopy();
+ Collections.reverse(shuffleConfig.getList(FILE).getList());
+
+ Configuration updatedShuffle = storeAndLoad(shuffleConfig);
+
+ assertEquals(updatedShuffle, origConfig, "Changing the order of the persisted properties shouldn't affect the file.");
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ Configuration origConfig = getConfigMapper().read(loadFile(getStream()));
+ basicTests(origConfig);
+
+ //simple delete
+ Configuration simpleConfig = origConfig.deepCopy();
+ simpleConfig.getList(FILE).getList().remove(0);
+
+ Configuration updatedSimple = storeAndLoad(simpleConfig);
+ assertEquals(updatedSimple, simpleConfig, "Simple delete failed.");
+
+ //shuffle and delete
+ Configuration shuffleConfig = origConfig.deepCopy();
+ shuffleConfig.getList(FILE).getList().remove(0);
+ Collections.reverse(shuffleConfig.getList(FILE).getList());
+
+ Configuration expectedShuffled = origConfig.deepCopy();
+ expectedShuffled.getList(FILE).getList().remove(0);
+
+ Configuration updatedShuffle = storeAndLoad(shuffleConfig);
+
+ assertEquals(updatedShuffle, expectedShuffled, "Delete with shuffle failed.");
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
+ basicTests(config);
+
+ PropertyMap newPropertyMap = new PropertyMap(ASSIGNMENT);
+ newPropertyMap.put(new PropertySimple(NAME, "test"));
+ newPropertyMap.put(new PropertySimple(VALUE, "42"));
+
+ config.getList(FILE).add(newPropertyMap);
+
+ Configuration updated = storeAndLoad(config);
+
+ assertEquals(updated, config, "Simple create failed.");
+ }
+
+ private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
+ return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
+ }
+
+ private TokenRewriteStream getStream() throws IOException {
+ return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
+ }
+
+ private void basicTests(Configuration config) throws Exception {
+ assertNotNull(config, "Could not read the configuration from the file.");
+
+ PropertyList file = config.getList(FILE);
+
+ assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ assertEquals(file.getList().size(), 5, "There should be 5 assignments in the test file.");
+ }
+}
diff --git a/modules/plugins/antlr-config/src/test/resources/unordered b/modules/plugins/antlr-config/src/test/resources/unordered
new file mode 100644
index 0000000..0cb9668
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/resources/unordered
@@ -0,0 +1,5 @@
+a = 1
+b = 2
+c = 3
+d = 4
+e = 5
commit 1747f6673d63d453eff57cf17a4e690482a1241b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 19 12:11:05 2009 +0200
Extracted an abstract class for the tests.
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java
new file mode 100644
index 0000000..7f788bd
--- /dev/null
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/AbstractTest.java
@@ -0,0 +1,96 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.antlrconfig.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenRewriteStream;
+import org.antlr.runtime.tree.CommonTree;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.plugins.antlrconfig.ConfigMapper;
+import org.rhq.plugins.antlrconfig.ConfigurationFacade;
+import org.rhq.plugins.antlrconfig.NewEntryCreator;
+
+/**
+ * A base class for tests.
+ *
+ * @author Lukas Krejci
+ */
+public abstract class AbstractTest {
+
+ protected abstract ConfigurationDefinition getConfigurationDefinition();
+
+ protected abstract Lexer getLexer();
+
+ protected abstract ConfigurationFacade getConfigurationFacade();
+
+ protected abstract NewEntryCreator getNewEntryCreator();
+
+ protected abstract String[] getTokenNames();
+
+ protected abstract CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException;
+
+ protected ConfigMapper getConfigMapper() {
+ return new ConfigMapper(getConfigurationDefinition(), getConfigurationFacade(), getNewEntryCreator(), getTokenNames());
+ }
+
+ protected TokenRewriteStream getStream(InputStream stream) throws IOException {
+ Lexer lexer = getLexer();
+ lexer.setCharStream(new ANTLRInputStream(stream));
+ return new TokenRewriteStream(lexer);
+ }
+
+ protected InputStream getResourceStream(String resourceName) throws IOException {
+ return this.getClass().getClassLoader().getResourceAsStream(resourceName);
+ }
+
+ protected TokenRewriteStream getStreamFromResource(String resourceName) throws IOException {
+ return getStream(getResourceStream(resourceName));
+ }
+
+ protected Configuration storeAndLoad(Configuration config, InputStream origSource) throws RecognitionException, IOException {
+ ConfigMapper mapper = getConfigMapper();
+
+ TokenRewriteStream stream = getStream(origSource);
+
+ CommonTree file = loadFile(stream);
+
+ mapper.update(file, stream, config);
+
+ String updatedConfig = stream.toString();
+
+ ByteArrayInputStream updatedInputStream = new ByteArrayInputStream(updatedConfig.getBytes());
+
+ TokenRewriteStream updatedStream = getStream(updatedInputStream);
+
+ return mapper.read(loadFile(updatedStream));
+ }
+}
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
index 9fec44c..9e81ec3 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
@@ -25,17 +25,14 @@ package org.rhq.plugins.antlrconfig.test;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Collections;
import java.util.List;
-import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.Lexer;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenRewriteStream;
import org.antlr.runtime.tree.CommonTree;
-import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
@@ -50,6 +47,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.plugins.antlrconfig.ConfigMapper;
+import org.rhq.plugins.antlrconfig.ConfigurationFacade;
import org.rhq.plugins.antlrconfig.DefaultConfigurationFacade;
import org.rhq.plugins.antlrconfig.NewEntryCreator;
import org.rhq.plugins.antlrconfig.test.parsers.SimpleLexer;
@@ -60,20 +58,16 @@ import org.rhq.plugins.antlrconfig.test.parsers.SimpleParser;
*
* @author Lukas Krejci
*/
-public class SimpleTest {
+public class SimpleTest extends AbstractTest {
+ private static final String TEST_CONFIGURATION_FILE_NAME = "simple";
private static final String FILE = "config:///file";
private static final String ASSIGNMENT = "config://assignment";
private static final String NAME = "config://$1";
private static final String VALUE = "config://$2";
private static final String EXPORT = "config://$3";
- @BeforeSuite
- public void dummy() {
-
- }
-
- private static ConfigurationDefinition getConfigurationDefinition() {
+ protected ConfigurationDefinition getConfigurationDefinition() {
ConfigurationDefinition def = new ConfigurationDefinition("", null);
PropertyDefinitionList file = new PropertyDefinitionList(FILE, null, true, null);
@@ -91,8 +85,8 @@ public class SimpleTest {
private static class CustomFacade extends DefaultConfigurationFacade {
- public CustomFacade() {
- super(getConfigurationDefinition());
+ public CustomFacade(ConfigurationDefinition definition) {
+ super(definition);
}
@Override
@@ -176,28 +170,31 @@ public class SimpleTest {
}
}
- private static ConfigMapper getMapper() {
- return new ConfigMapper(getConfigurationDefinition(), new CustomFacade(), new EntryCreator(), SimpleParser.tokenNames);
+ protected ConfigurationFacade getConfigurationFacade() {
+ return new CustomFacade(getConfigurationDefinition());
}
-
- private static TokenRewriteStream getStream(InputStream stream) throws IOException {
- return new TokenRewriteStream(new SimpleLexer(new ANTLRInputStream(stream)));
+
+ protected Lexer getLexer() {
+ return new SimpleLexer();
}
-
- private static TokenRewriteStream getStream() throws IOException {
- InputStream inputStream = SimpleTest.class.getClassLoader().getResourceAsStream("simple");
- return getStream(inputStream);
+
+ protected NewEntryCreator getNewEntryCreator() {
+ return new EntryCreator();
}
-
- private static CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
+
+ protected String[] getTokenNames() {
+ return SimpleParser.tokenNames;
+ }
+
+ protected CommonTree loadFile(TokenRewriteStream stream) throws IOException, RecognitionException {
SimpleParser parser = new SimpleParser(stream);
SimpleParser.file_return ret = parser.file();
return (CommonTree) ret.getTree();
}
-
+
@Test
public void testRead() throws Exception {
- Configuration config = getMapper().read(loadFile(getStream()));
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
assertNotNull(config, "Could not read the configuration from the file.");
@@ -246,7 +243,7 @@ public class SimpleTest {
@Test
public void testUpdate() throws Exception {
- ConfigMapper mapper = getMapper();
+ ConfigMapper mapper = getConfigMapper();
Configuration config = mapper.read(loadFile(getStream()));
assertNotNull(config, "Could not read the configuration from the file.");
@@ -266,7 +263,7 @@ public class SimpleTest {
@Test
public void testCreate() throws Exception {
- Configuration config = getMapper().read(loadFile(getStream()));
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
assertNotNull(config, "Could not read the configuration from the file.");
PropertyList file = config.getList(FILE);
@@ -285,7 +282,7 @@ public class SimpleTest {
@Test
public void testDelete() throws Exception {
- Configuration config = getMapper().read(loadFile(getStream()));
+ Configuration config = getConfigMapper().read(loadFile(getStream()));
assertNotNull(config, "Could not read the configuration from the file.");
PropertyList file = config.getList(FILE);
@@ -302,21 +299,11 @@ public class SimpleTest {
assertEquals(config, config2);
}
+ private TokenRewriteStream getStream() throws IOException {
+ return getStreamFromResource(TEST_CONFIGURATION_FILE_NAME);
+ }
+
private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
- ConfigMapper mapper = getMapper();
-
- TokenRewriteStream stream = getStream();
-
- CommonTree file = loadFile(stream);
-
- mapper.update(file, stream, config);
-
- String updatedConfig = stream.toString();
-
- ByteArrayInputStream updatedInputStream = new ByteArrayInputStream(updatedConfig.getBytes());
-
- TokenRewriteStream updatedStream = getStream(updatedInputStream);
-
- return mapper.read(loadFile(updatedStream));
+ return storeAndLoad(config, getResourceStream(TEST_CONFIGURATION_FILE_NAME));
}
}
commit 7fff679c584839c6fc4ff1426ef3d7b35c79799c
Author: Ian P. Springer <ips(a)jetengine.springer.net>
Date: Fri Oct 16 19:14:05 2009 -0400
fix copyright headers and add xml prologs to plugin descriptors
diff --git a/modules/plugins/augeas/pom.xml b/modules/plugins/augeas/pom.xml
index 1dd23be..a6c5939 100644
--- a/modules/plugins/augeas/pom.xml
+++ b/modules/plugins/augeas/pom.xml
@@ -1,4 +1,8 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
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 8deaa0a..3ef73bd 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
@@ -1,29 +1,30 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.augeas;
import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import net.augeas.Augeas;
import net.augeas.AugeasException;
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 77c0922..e0e8afa 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasPluginLifecycleListener.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasPluginLifecycleListener.java
index cd251d4..71d4cae 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasPluginLifecycleListener.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasPluginLifecycleListener.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
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 7eb4b5b..2e3abb3 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
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.augeas.helper;
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasUtility.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasUtility.java
index 341da1b..560e50c 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasUtility.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasUtility.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2009 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.augeas.helper;
diff --git a/modules/plugins/augeas/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/augeas/src/main/resources/META-INF/rhq-plugin.xml
index 34a9320..299afe1 100644
--- a/modules/plugins/augeas/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/augeas/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8"?>
<plugin name="Augeas"
displayName="Abstract Augeas Plugin"
diff --git a/modules/plugins/hosts/pom.xml b/modules/plugins/hosts/pom.xml
index 82cc5bd..923a9b9 100644
--- a/modules/plugins/hosts/pom.xml
+++ b/modules/plugins/hosts/pom.xml
@@ -1,4 +1,8 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
commit 6dc0d3ff445cb0e5fdd4957577327ccf24a15db6
Author: Ian P. Springer <ips(a)jetengine.springer.net>
Date: Fri Oct 16 19:02:36 2009 -0400
various fixes to augeas and hosts plugins
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 e0b5f14..8deaa0a 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
@@ -23,11 +23,7 @@
package org.rhq.plugins.augeas;
import java.io.File;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import net.augeas.Augeas;
import net.augeas.AugeasException;
@@ -64,6 +60,8 @@ import org.rhq.plugins.platform.PlatformComponent;
*/
public class AugeasConfigurationComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet {
public static final String CONFIGURATION_FILE_PROP = "configurationFile";
+ public static final String RESOURCE_CONFIGURATION_ROOT_NODE_PROP = "resourceConfigurationRootNode";
+ public static final String AUGEAS_MODULE_NAME_PROP = "augeasModuleName";
private static final boolean IS_WINDOWS = (File.separatorChar == '\\');
private static final String AUGEAS_LOAD_PATH = "/usr/local/share/augeas/lenses";
@@ -74,8 +72,8 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private ResourceContext resourceContext;
private File configFile;
private Augeas augeas;
- private AugeasNode augeasConfigFileNode;
private AugeasNode augeasConfigFileMetadataNode;
+ private AugeasNode resourceConfigRootNode;
public void start(ResourceContext<PlatformComponent> resourceContext) throws InvalidPluginConfigurationException,
Exception {
@@ -85,9 +83,21 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
this.configFile = new File(configFilePath);
this.augeas = createAugeas();
if (this.augeas != null) {
- this.augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ AugeasNode augeasConfigFileNode = new AugeasNode("/files" + AugeasNode.SEPARATOR_CHAR + this.configFile.getPath());
+ // This is the metadata portion of the tree for this config file (e.g. /augeas/files/etc/hosts, where error
+ // messages are stored as node values.
this.augeasConfigFileMetadataNode = new AugeasNode("/augeas/files" + AugeasNode.SEPARATOR_CHAR
- + this.configFile.getPath());
+ + this.configFile.getPath());
+ String resourceConfigRootNodePath = pluginConfig.getSimpleValue(RESOURCE_CONFIGURATION_ROOT_NODE_PROP, null);
+ if (resourceConfigRootNodePath != null) {
+ if (resourceConfigRootNodePath.indexOf(AugeasNode.SEPARATOR_CHAR) == 0) {
+ this.resourceConfigRootNode = new AugeasNode(resourceConfigRootNodePath);
+ } else {
+ this.resourceConfigRootNode = new AugeasNode(augeasConfigFileNode, resourceConfigRootNodePath);
+ }
+ } else {
+ this.resourceConfigRootNode = augeasConfigFileNode;
+ }
}
}
@@ -123,7 +133,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
return resourceConfig;
@@ -131,16 +141,27 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
if (!validateResourceConfiguration(report)) {
+ log.debug("Validation of updated Resource configuration for "
+ + this.getResourceContext().getResourceType() + " Resource with key '"
+ + this.getResourceContext().getResourceKey() + "' failed with the following errors: "
+ + report.getErrorMessage());
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
if (!this.configFile.canWrite()) {
- report.setErrorMessage("Configuration file '" + this.configFile + "' is not writeable.");
+ report.setErrorMessage("Configuration file '" + this.configFile + "' is not writable.");
return;
}
- // Load the config file from disk and build a tree representation of it.
+ File configFileParentDir = this.configFile.getParentFile();
+ if (!configFileParentDir.canWrite()) {
+ report.setErrorMessage("Configuration file parent directory '" + configFileParentDir
+ + "' is not writable.");
+ return;
+ }
+
+ // Load the config file from disk and build a tree representation of it in memory.
this.augeas.load();
ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
@@ -149,7 +170,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.augeasConfigFileNode);
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
}
// Write the updated tree out to the config file.
@@ -197,7 +218,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
private Augeas createAugeas() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
- String augeasModuleName = pluginConfig.getSimpleValue("augeasModuleName", null);
+ String augeasModuleName = pluginConfig.getSimpleValue(AUGEAS_MODULE_NAME_PROP, null);
if (augeasModuleName == null) {
return null;
}
@@ -289,10 +310,10 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertyList propList = new PropertyList(propDefList.getName());
String mapKey = getListMemberMapKey(propDefList);
- List<String> listMemberPaths = augeas.match(node.getPath());
+ String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + listMemberPropDefMap.getName();
+ List<String> listMemberPaths = augeas.match(listMemberPathsExpression);
for (String listMemberPath : listMemberPaths) {
AugeasNode listMemberNode = new AugeasNode(listMemberPath);
-
PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName());
propList.add(listMemberPropMap);
@@ -301,6 +322,7 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName());
listMemberPropMap.put(keyProp);
}
+
// Populate the rest of the map child properties.
populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode);
}
@@ -383,11 +405,15 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
"Invalid Resource ConfigurationDefinition - only lists of maps are supported.");
}
PropertyDefinitionMap listMemberPropDefMap = (PropertyDefinitionMap) listMemberPropDef;
- String mapKey = getListMemberMapKey(propDefList);
- Set<String> keys = new HashSet<String>();
int listIndex = 0;
- Set<AugeasNode> updatedMemberNodes = new HashSet<AugeasNode>();
+ List<String> existingListMemberPaths = augeas.match(listNode.getPath() + AugeasNode.SEPARATOR_CHAR
+ + listMemberPropDefMap.getName());
+ 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,
@@ -395,11 +421,11 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
if (memberNodeToUpdate != null) {
// Keep track of the existing nodes that we'll be updating, so that we can remove all other existing
// nodes.
- updatedMemberNodes.add(memberNodeToUpdate);
+ 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.
- memberNodeToUpdate = new AugeasNode(listNode, "0" + listIndex);
+ memberNodeToUpdate = new AugeasNode(listNode, "0" + (listIndex++));
}
// Update the node's children.
@@ -407,11 +433,9 @@ public class AugeasConfigurationComponent implements ResourceComponent<PlatformC
}
// Now remove any existing nodes that we did not update in the previous loop.
- List<String> existingListMemberPaths = augeas.match(listNode.getPath() + "/*");
- for (String existingListMemberPath : existingListMemberPaths) {
- AugeasNode existingListMemberNode = new AugeasNode(existingListMemberPath);
- if (!updatedMemberNodes.contains(existingListMemberNode)) {
- augeas.remove(existingListMemberPath);
+ for (AugeasNode existingListMemberNode : existingListMemberNodes) {
+ if (!updatedListMemberNodes.contains(existingListMemberNode)) {
+ augeas.remove(existingListMemberNode.getPath());
}
}
}
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 2596a44..7eb4b5b 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
@@ -44,7 +44,7 @@ public class AugeasNode {
}
// Remove redundant "." and ".." components and redundant slashes.
- this.path = path;
+ this.path = normalize(path);
}
public AugeasNode(AugeasNode parent, String name) {
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index 875a4c1..8e944db 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -54,7 +54,6 @@ public class HostsComponent extends AugeasConfigurationComponent {
"(([a-zA-Z\\d]|[a-zA-Z\\d][a-zA-Z\\d\\-]*[a-zA-Z\\d])\\.)*([A-Za-z]|[A-Za-z][A-Za-z\\d\\-]*[A-Za-z\\d])";
private static final Pattern DOMAIN_NAME_PATTERN = Pattern.compile(DOMAIN_NAME_REGEX);
-
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
super.start(resourceContext);
}
@@ -188,7 +187,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
String existingIpaddr = augeas.get(ipaddrNode.getPath());
int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
if (existingIpAddressVersion == ipAddressVersion) {
- return ipaddrNode;
+ return childNode;
}
}
return null;
diff --git a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
index 07e30fb..326eec6 100644
--- a/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hosts/src/main/resources/META-INF/rhq-plugin.xml
@@ -41,8 +41,8 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property name="/*" displayName="Entries">
- <c:map-property name="entry">
+ <c:list-property name="." displayName="Entries">
+ <c:map-property name="*[canonical]">
<c:simple-property name="ipaddr" displayName="IP Address" type="string" required="true" activationPolicy="immediate"
description="The IP address of the host entry. The address may be an IPv4 address (e.g., 192.168.1.10) or an IPv6 address (e.g., fec0:0:0:bebe::2)."/>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 871bc14..da45f9b 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -118,7 +118,7 @@
<module>snmptrapd</module>
<module>sshd</module>
<module>twitter</module>
- <module>virt</module>
+ <!--<module>virt</module>-->
<!-- make this the last - it will validate all the plugins -->
<module>validate-all-plugins</module>
commit c602ae31f16c2f3d81bed2904e0cbba9f8def4c6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 16 18:48:01 2009 +0200
Added support for <Ordered> list so that we can support config files where order of statements is significant.
diff --git a/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
index fb3ccb2..b76181a 100644
--- a/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
+++ b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/ConfigMapper.java
@@ -26,7 +26,10 @@ package org.rhq.plugins.antlrconfig;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenRewriteStream;
@@ -45,6 +48,8 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.plugins.antlrconfig.NewEntryCreator.OpDef;
import org.rhq.plugins.antlrconfig.tokens.Id;
+import org.rhq.plugins.antlrconfig.tokens.Ordered;
+import org.rhq.plugins.antlrconfig.tokens.Transparent;
import org.rhq.plugins.antlrconfig.tokens.Unordered;
/**
@@ -115,6 +120,9 @@ public class ConfigMapper {
List<MergeRecord> mergeRecords = new ArrayList<MergeRecord>();
mapTreeForMerge(configurationDefinition.getPropertyDefinitions().values(), configuration.getProperties(), configurationFileAST, mergeRecords);
+ //reordering has to be done after all other processing has been done.
+ HashMap<CommonTree, List<MergeRecord>> reorders = new HashMap<CommonTree, List<MergeRecord>>();
+
for(MergeRecord rec : mergeRecords) {
boolean isAdd = rec.property != null && rec.tree == null;
boolean isDelete = rec.property == null && rec.tree != null;
@@ -125,10 +133,37 @@ public class ConfigMapper {
applyInstructions(instructions, fileStream);
}
} else if (isDelete) {
- fileStream.delete(rec.tree.getTokenStartIndex(), rec.tree.getTokenStopIndex());
+ addReorder(rec, reorders);
} else if (rec.property instanceof PropertySimple) {
String value = configFacade.getPersistableValue((PropertySimple)rec.property);
fileStream.replace(rec.tree.getTokenStartIndex(), rec.tree.getTokenStopIndex(), value);
+ } else if (rec.propertyIndex != -1 && rec.treeIndex != -1 && rec.propertyIndex != rec.treeIndex && rec.parent != null) {
+ addReorder(rec, reorders);
+ }
+ }
+
+ Comparator<MergeRecord> sorter = new Comparator<MergeRecord>() {
+ public int compare(MergeRecord o1, MergeRecord o2) {
+ return o1.treeIndex - o2.treeIndex;
+ }
+ };
+ for(Map.Entry<CommonTree, List<MergeRecord>> entry : reorders.entrySet()) {
+ List<MergeRecord> thisReorders = entry.getValue();
+ Collections.sort(thisReorders, sorter);
+ int toDelete = 0;
+ List<CommonTree> siblings = astStructure.getChildren(entry.getKey());
+ for(MergeRecord rec : thisReorders) {
+ if (rec.propertyIndex != -1) {
+ CommonTree treeAtPropertyIndex = siblings.get(rec.propertyIndex);
+ fileStream.replace(treeAtPropertyIndex.getTokenStartIndex(), treeAtPropertyIndex.getTokenStopIndex(), treeToString(rec.tree, fileStream));
+ } else {
+ toDelete++;
+ }
+ }
+
+ for (int i = siblings.size() - 1; toDelete > 0; --i, --toDelete) {
+ MergeRecord rec = thisReorders.get(i);
+ fileStream.delete(rec.tree.getTokenStartIndex(), rec.tree.getTokenStopIndex());
}
}
}
@@ -193,6 +228,10 @@ public class ConfigMapper {
List<CommonTree> treeMatches = path.matches();
boolean lookingForChildren = path.getPath().size() > 1;
+ boolean inOrdered = tree.getToken() instanceof Ordered;
+ int propIndex = 0;
+
+ List<CommonTree> matched = new ArrayList<CommonTree>();
//now figure out what to delete and what to add
for (Property prop : matchedProperties) {
@@ -203,19 +242,25 @@ public class ConfigMapper {
rec.tree = match;
rec.parent = lookingForChildren ? tree : astStructure.getParent(tree);
+ if(inOrdered) {
+ rec.propertyIndex = propIndex;
+ }
+
if (match == null) {
mergeRecords.add(rec);
- } else if (prop instanceof PropertySimple) {
- //only add in the updates
- if (!configFacade.isEqual((PropertySimple)prop, match.getText())) {
+ } else {
+ rec.treeIndex = treeMatches.indexOf(match);
+ if (prop instanceof PropertySimple) {
+ //only add in the updates
+ if (!configFacade.isEqual((PropertySimple)prop, match.getText())) {
+ mergeRecords.add(rec);
+ }
+ } else if (rec.propertyIndex != -1 && rec.treeIndex != rec.propertyIndex) {
mergeRecords.add(rec);
}
- }
-
- if (match != null) {
- int treeIdx = treeMatches.indexOf(match);
- if (treeIdx >= 0) {
- treeMatches.remove(treeIdx);
+
+ if (rec.treeIndex >= 0) {
+ matched.add(match);
}
//if we have a matching sub tree, let's go down a level if we can
@@ -230,15 +275,22 @@ public class ConfigMapper {
mapTreeForMerge(subDefs, subProps, match, mergeRecords);
}
}
+
+ propIndex++;
}
- //after the previous loop, we're left with the sub trees that
+ //we're left with the sub trees that
//correspond to a definition (i.e. are mapped) but aren't present
//in the supplied configuration - i.e. are to be deleted.
for(CommonTree toDelete : treeMatches) {
- MergeRecord rec = new MergeRecord();
- rec.tree = toDelete;
- mergeRecords.add(rec);
+ if(!matched.contains(toDelete)) {
+ MergeRecord rec = new MergeRecord();
+ rec.tree = toDelete;
+ rec.parent = lookingForChildren ? tree : astStructure.getParent(tree);
+ rec.treeIndex = treeMatches.indexOf(toDelete);
+
+ mergeRecords.add(rec);
+ }
}
}
}
@@ -287,7 +339,7 @@ public class ConfigMapper {
}
private CommonTree getMatch(Property prop, CommonTree tree, List<CommonTree> possibleMatches, boolean lookingForChildren) throws RecognitionException, MatchException {
- if (lookingForChildren && tree.getToken() instanceof Unordered) {
+ if (lookingForChildren && (tree.getToken() instanceof Unordered || tree.getToken() instanceof Ordered)) {
List<CommonTree> idTokensInTree = new ArrayList<CommonTree>();
for(CommonTree child : astStructure.getChildren(tree)) {
getIdTokensInTree(child, idTokensInTree);
@@ -336,8 +388,8 @@ public class ConfigMapper {
return;
}
- //do not traverse into another Unordered dictionary
- if (tree.getToken() instanceof Unordered) {
+ //do not traverse into another (Un)ordered dictionary
+ if (tree.getToken() instanceof Unordered || tree.getToken() instanceof Ordered) {
return;
}
@@ -359,9 +411,26 @@ public class ConfigMapper {
return parent;
}
+ private String treeToString(CommonTree tree, TokenRewriteStream stream) {
+ return stream.toOriginalString(tree.getTokenStartIndex(), tree.getTokenStopIndex());
+ }
+
+ private void addReorder(MergeRecord rec, Map<CommonTree, List<MergeRecord>> reorders) {
+ if (rec.parent.getToken() instanceof Ordered) {
+ List<MergeRecord> concreteReorders = reorders.get(rec.parent);
+ if (concreteReorders == null) {
+ concreteReorders = new ArrayList<MergeRecord>();
+ reorders.put(rec.parent, concreteReorders);
+ }
+ concreteReorders.add(rec);
+ }
+ }
+
private static class MergeRecord {
public Property property;
public CommonTree tree;
public CommonTree parent;
+ public int treeIndex = -1;
+ public int propertyIndex = -1;
}
}
diff --git a/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/tokens/Ordered.java b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/tokens/Ordered.java
new file mode 100644
index 0000000..c5424b3
--- /dev/null
+++ b/modules/plugins/antlr-config/src/main/java/org/rhq/plugins/antlrconfig/tokens/Ordered.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.plugins.antlrconfig.tokens;
+
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.Token;
+
+/**
+ * This is similar to {@link Unordered} but tells the {@link ConfigMapper} that
+ * subtrees of the current tree are identified by their {@link Id}s but require a strict order.
+ *
+ * In another words with this token type we are able to detect that the properties have been
+ * reordered in the configuration and are able to reorder them accordingly in the configuration file.
+ *
+ * @author Lukas Krejci
+ */
+public class Ordered extends RhqConfigToken {
+
+ private static final long serialVersionUID = 1L;
+
+ public Ordered(CharStream input, int type, int channel, int start, int stop) {
+ super(input, type, channel, start, stop);
+ }
+
+ public Ordered(int type, String text) {
+ super(type, text);
+ }
+
+ public Ordered(int type) {
+ super(type);
+ }
+
+ public Ordered(Token oldToken) {
+ super(oldToken);
+ }
+
+}
diff --git a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g
index 47ba125..c4bc2f9 100644
--- a/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g
+++ b/modules/plugins/antlr-config/src/test/antlr3/org/rhq/plugins/antlrconfig/test/parsers/Simple.g
@@ -39,7 +39,7 @@ WS : (' ' | '\t')+ {$channel = HIDDEN;} ;
NL : '\r'? '\n' ;
-file : (assignment | NL)* -> ^(FILE<Unordered> assignment*)
+file : (assignment | NL)* -> ^(FILE<Ordered> assignment*)
;
assignment : EXPORT? WORD EQUALS VALUE (NL | EOF) -> ^(ASSIGNMENT ^(WORD<Id>) VALUE EXPORT?);
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
index b8822d1..9fec44c 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
@@ -291,7 +291,11 @@ public class SimpleTest {
PropertyList file = config.getList(FILE);
assertNotNull(file, "the configuration should contain a list of assignments.");
- file.getList().remove(0);
+ //remove export c = 3
+ file.getList().remove(2);
+ Property firstAssignment = file.getList().remove(0);
+ //add it as last
+ file.add(firstAssignment);
Configuration config2 = storeAndLoad(config);
diff --git a/modules/plugins/antlr-config/src/test/resources/simple b/modules/plugins/antlr-config/src/test/resources/simple
index 9c70af6..649d4dd 100644
--- a/modules/plugins/antlr-config/src/test/resources/simple
+++ b/modules/plugins/antlr-config/src/test/resources/simple
@@ -2,6 +2,4 @@ a = 1
b = 2
export c = 3
d = 4
-
-
e = 5
commit 60cee343ea616757f98e74748f31b98e8f80157b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 16 11:11:00 2009 +0200
added the simple delete test.
diff --git a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
index 59d4c7f..b8822d1 100644
--- a/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
+++ b/modules/plugins/antlr-config/src/test/java/org/rhq/plugins/antlrconfig/test/SimpleTest.java
@@ -56,7 +56,7 @@ import org.rhq.plugins.antlrconfig.test.parsers.SimpleLexer;
import org.rhq.plugins.antlrconfig.test.parsers.SimpleParser;
/**
- * Tests with the SimpleTest.g grammar
+ * Tests with the Simple.g grammar
*
* @author Lukas Krejci
*/
@@ -290,6 +290,12 @@ public class SimpleTest {
PropertyList file = config.getList(FILE);
assertNotNull(file, "the configuration should contain a list of assignments.");
+
+ file.getList().remove(0);
+
+ Configuration config2 = storeAndLoad(config);
+
+ assertEquals(config, config2);
}
private Configuration storeAndLoad(Configuration config) throws RecognitionException, IOException {
@@ -297,7 +303,9 @@ public class SimpleTest {
TokenRewriteStream stream = getStream();
- mapper.update(loadFile(stream), stream, config);
+ CommonTree file = loadFile(stream);
+
+ mapper.update(file, stream, config);
String updatedConfig = stream.toString();
14 years, 6 months
[rhq] Branch 'content' - 6 commits - modules/enterprise modules/helpers
by Mike McCune
modules/enterprise/gui/installer-war/pom.xml | 5 +++--
modules/enterprise/gui/portal-war/pom.xml | 9 +++++----
modules/helpers/pluginAnnotations/pom.xml | 4 ++--
modules/helpers/pluginGen/pom.xml | 6 +++---
4 files changed, 13 insertions(+), 11 deletions(-)
New commits:
commit 01e739eafb4688851598adac72565d50626438ed
Merge: 7107975... 59cad4f...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Oct 26 09:47:23 2009 -0700
Merge branch 'master' into content2
Conflicts:
.classpath
commit 59cad4fcb211675be4167f684664deab5f1db696
Merge: cb30db0... bacd1ba...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:15:21 2009 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit cb30db0ea4dea73a4de3d9003c07d5033df000ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:11:39 2009 -0400
upping jsp precompiler since the previous version seems gone from the central repo. may want to up again when a non RC is available.
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 896dd3c..0d35569 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -27,6 +27,7 @@
<!-- dependency versions -->
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -307,8 +308,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 4f38976..dd751d3 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -26,6 +26,7 @@
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
<seam.version>2.1.0.SP1</seam.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -367,8 +368,8 @@
<!-- new jetty based jsp compiler -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.5</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<scope>provided</scope>
</dependency>
@@ -556,8 +557,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
commit bacd1ba678d44af463226cc1a7102212b35faa09
Merge: 9dba749... 4422052...
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:38:17 2009 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9dba7497582b27dd7b2a547a3d43f3183dc224bf
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:35:05 2009 +0100
Change the group of the helper artifacts to 'org.rhq.helpers' so that they end up in a subgroup
on their own. This gives less clutter to the repo.
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index 3e73c16..a3dc269 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<packaging>jar</packaging>
@@ -50,4 +50,4 @@
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index e58e36d..0fd3ff7 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginGen</artifactId>
<packaging>jar</packaging>
@@ -86,9 +86,9 @@
<version>2.3.11</version>
</dependency>
<dependency>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
commit 4422052c4b3f2a882d650303cc462e2ce9492b7d
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Oct 23 10:35:27 2009 -0700
adding helpers src dir
diff --git a/.classpath b/.classpath
index 4186c24..222ef84 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/>
+ <classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/>
<classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/>
@@ -74,7 +75,7 @@
<classpathentry kind="src" path="modules/plugins/netservices/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/iis/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/target/generated-sources/xjc"/>
- <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/perftest/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/apt/src/test/java"/>
@@ -83,9 +84,9 @@
<classpathentry kind="src" path="modules/plugins/hardware/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/oracle/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/grub/src/test/java"/>
- <classpathentry kind="src" path="modules/plugins/grub/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/grub/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/samba/src/test/java"/>
- <classpathentry kind="src" path="modules/plugins/samba/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/samba/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/sudoers/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/sudoers/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/hudson/src/main/java"/>
14 years, 6 months
[rhq] Branch 'linux-config' - modules/plugins
by lkrejci
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 7 +++++++
1 file changed, 7 insertions(+)
New commits:
commit 45d5a0346f8597b349418d249bd16fcbd9fce08e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 26 17:19:14 2009 +0100
fixing hosts plugin to work with the latest augeas base.
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index 8e944db..6c278c9 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -62,6 +62,13 @@ public class HostsComponent extends AugeasConfigurationComponent {
return;
}
+ @Override
+ protected String getResourceConfigurationRootPath() {
+ String include = getResourceContext().getPluginConfiguration().getSimpleValue(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP, null);
+
+ return "/files" + include;
+ }
+
public AvailabilityType getAvailability() {
return super.getAvailability();
}
14 years, 6 months
[rhq] 2 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/installer-war/pom.xml | 5 +++--
modules/enterprise/gui/portal-war/pom.xml | 9 +++++----
2 files changed, 8 insertions(+), 6 deletions(-)
New commits:
commit 59cad4fcb211675be4167f684664deab5f1db696
Merge: cb30db0... bacd1ba...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:15:21 2009 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit cb30db0ea4dea73a4de3d9003c07d5033df000ec
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Oct 26 12:11:39 2009 -0400
upping jsp precompiler since the previous version seems gone from the central repo. may want to up again when a non RC is available.
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml
index 896dd3c..0d35569 100644
--- a/modules/enterprise/gui/installer-war/pom.xml
+++ b/modules/enterprise/gui/installer-war/pom.xml
@@ -27,6 +27,7 @@
<!-- dependency versions -->
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -307,8 +308,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 4f38976..dd751d3 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -26,6 +26,7 @@
<el.version>1.0</el.version>
<jsf-facelets.version>1.1.14</jsf-facelets.version>
<seam.version>2.1.0.SP1</seam.version>
+ <jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
@@ -367,8 +368,8 @@
<!-- new jetty based jsp compiler -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.5</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<scope>provided</scope>
</dependency>
@@ -556,8 +557,8 @@
<plugin>
<!-- See http://jetty.mortbay.org/jspc-maven-plugin/ -->
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-jspc-plugin</artifactId>
- <version>6.1.7</version>
+ <artifactId>jetty-jspc-maven-plugin</artifactId>
+ <version>${jetty-jspc.version}</version>
<configuration>
<keepSources>false</keepSources>
<validateXml>false</validateXml> <!-- TODO: set to true -->
14 years, 6 months
[rhq] Branch 'linux-config' - 9 commits - modules/core modules/plugins
by lkrejci
modules/core/client-api/src/main/resources/rhq-configuration.xsd | 2
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 4
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 38 +
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java | 3
modules/plugins/cron/pom.xml | 217 ++++++++
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 243 ++++++++++
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java | 29 +
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java | 84 +++
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java | 71 ++
modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml | 187 +++++++
modules/plugins/cron/src/test/resources/log4j.xml | 32 +
13 files changed, 914 insertions(+), 10 deletions(-)
New commits:
commit 05e5c96234714f9af8ef316a754edc87cd265ca7
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 11:28:18 2009 +0200
Updating standalone container to support showing plugin and resource configuration.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 0508fc8..1244ecc 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -35,6 +35,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
+import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.discovery.AvailabilityReport;
@@ -344,7 +345,12 @@ public class StandaloneContainer {
case WAIT:
Thread.sleep(Integer.valueOf(tokens[1]));
break;
-
+ case P_CONFIG:
+ showPluginConfig();
+ break;
+ case R_CONFIG:
+ showResourceConfig();
+ break;
}
return false;
@@ -659,6 +665,30 @@ public class StandaloneContainer {
return config;
}
+ private void showPluginConfig() {
+ if (resourceId == 0) {
+ System.err.println("You must first set the resource to work with.");
+ return;
+ }
+
+ Configuration config = pc.getInventoryManager().getResourceContainer(resourceId).getResource().getPluginConfiguration();
+ showConfig(config);
+ }
+
+ private void showResourceConfig() throws PluginContainerException {
+ if (resourceId == 0) {
+ System.err.println("You must first set the resource to work with.");
+ return;
+ }
+
+ Configuration config = pc.getConfigurationManager().loadResourceConfiguration(resourceId);
+ showConfig(config);
+ }
+
+ private void showConfig(Configuration config) {
+ System.out.println(config.getProperties());
+ }
+
/**
* List of possible commands
*/
@@ -679,8 +709,10 @@ public class StandaloneContainer {
RESOURCES("res", "", 0, "Shows the discovere resources"), //
SET("set", "resourceId n", 2,
"Sets the resource id to work with. N can be a number or '$r' as result of last find resource call"), //
- WAIT("w", "milliseconds", 1, "Waits the given amount of time");
-
+ WAIT("w", "milliseconds", 1, "Waits the given amount of time"),
+ P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."),
+ R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource.");
+
private String abbrev;
private String args;
private String help;
commit 37eb9362a1d6694241e65ceaf74b6e76912f7dae
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Oct 23 18:06:12 2009 +0200
pushing cron plugin impl further...
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index e57af45..22f4280 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -37,7 +37,9 @@ import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
+import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
+import org.rhq.plugins.augeas.helper.GlobFilter;
import org.rhq.plugins.platform.PlatformComponent;
/**
@@ -115,6 +117,32 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
throw new RuntimeException("A file with given name already exists. Creating the crontab would overwrite it.");
}
+ //check that the crontab's name passes the glob filters
+ Configuration pluginConfiguration = getResourceContext().getPluginConfiguration();
+
+ List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ boolean isIncluded = false;
+
+ for(String include : includeGlobs) {
+ if (new GlobFilter(include).accept(crontabFile)) {
+ isIncluded = true;
+ break;
+ }
+ }
+
+ String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
+ if (!isIncluded) {
+ throw new IllegalArgumentException(errorText);
+ }
+
+ for(String exclude : excludeGlobs) {
+ if (new GlobFilter(exclude).accept(crontabFile)) {
+ throw new IllegalArgumentException(errorText);
+ }
+ }
+
updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
return resourceName;
@@ -174,14 +202,24 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
ret.setNotes("Loaded by Augeas at " + new Date());
PropertyDefinitionMap basicSettingsDef = crontabConfigurationDefinition.getPropertyDefinitionMap(CronTabComponent.BASIC_SETTINGS_PROP);
- PropertyMap basicSettings = new PropertyMap(basicSettingsDef.getName());
+ PropertyMap dummyParent = new PropertyMap(".");
+ basicSettingsDef.setName(".");
+ loadProperty(basicSettingsDef, dummyParent, augeas, baseNode);
+ basicSettingsDef.setName(CronTabComponent.BASIC_SETTINGS_PROP);
+ PropertyMap basicSettings = dummyParent.getMap(".");
+ basicSettings.setName(CronTabComponent.BASIC_SETTINGS_PROP);
+ basicSettings.setParentMap(null);
ret.put(basicSettings);
- loadProperty(basicSettingsDef, basicSettings, augeas, baseNode);
PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
- PropertyList entries = new PropertyList(entriesDef.getName());
+ entriesDef.setName(".");
+ loadProperty(entriesDef, dummyParent, augeas, baseNode);
+ entriesDef.setName(CronTabComponent.ENTRIES_PROP);
+ PropertyList entries = dummyParent.getList(".");
+ entries.setName(CronTabComponent.ENTRIES_PROP);
+ entries.setParentMap(null);
ret.put(entries);
- loadProperty(entriesDef, ret, augeas, baseNode);
+
List<String> envSettings = augeas.match(basePath + "/*[label() != \"entry\" and label() != \"#comment\"]");
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java
index 73bdea5..a5f5049 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java
@@ -23,32 +23,49 @@
package org.rhq.plugins.cron;
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.augeas.AugeasConfigurationComponent;
+import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
+import org.rhq.plugins.augeas.helper.Glob;
/**
- *
+ * Discovery for cron tabs.
*
* @author Lukas Krejci
*/
-public class CronTabDiscoveryComponent implements ResourceDiscoveryComponent<CronComponent>, ManualAddFacet<CronComponent>{
-
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
- ResourceDiscoveryContext<CronComponent> context) throws InvalidPluginConfigurationException {
- // TODO Auto-generated method stub
- return null;
- }
+public class CronTabDiscoveryComponent implements ResourceDiscoveryComponent<CronComponent> {
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<CronComponent> context)
throws InvalidPluginConfigurationException, Exception {
- // TODO Auto-generated method stub
- return null;
- }
+ Configuration cronConfiguration = context.getParentResourceContext().getPluginConfiguration();
+
+ List<String> includes = AugeasConfigurationDiscoveryComponent.getGlobList(cronConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludes = AugeasConfigurationDiscoveryComponent.getGlobList(cronConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ List<File> files = Glob.matchAll(new File(AugeasConfigurationComponent.AUGEAS_ROOT_PATH), includes);
+ Glob.excludeAll(files, excludes);
+
+ HashSet<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>();
+
+ ResourceType resourceType = context.getResourceType();
+
+ for(File f : files) {
+ String resourceKey = f.getAbsolutePath();
+ Configuration defaultConfiguration = context.getDefaultPluginConfiguration();
+ DiscoveredResourceDetails result = new DiscoveredResourceDetails(resourceType, resourceKey, resourceKey, null, null, defaultConfiguration, null);
+ results.add(result);
+ }
+ return results;
+ }
}
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
index 9c9bb01..e965015 100644
--- a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,22 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ <c:simple-property name="time/minute" displayName="Minute" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="[0-9\*][0-9\/,-\*]*"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/hour" displayName="Hour" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="[0-9\*][0-9\/,-\*]*"/></c:constraint>
+ <c:simple-property>
+ <c:simple-property name="time/dayofmonth" displayName="Day of Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="[0-9\*][0-9\/,-\*]*"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/month" displayName="Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="[0-9\*][0-9\/,-\*]*|[a-zA-Z]{3}"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/dayofweek" displayName="Day of Week" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="[0-9\*][0-9\/,-\*]*|[a-zA-Z]{3}"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="user" displayName="Executing user" required="true" description="TODO"/>
+ <c:simple-property name="." displayName="Command" required="true" description="TODO"/>
+ -->
+<!--
+ <c:simple-property name="time/minute" displayName="Minute" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="B;0-9\*D;B;0-9\/,-\*D;*"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/hour" displayName="Hour" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="B;0-9\*D;B;0-9\/,-\*D;*"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/dayofmonth" displayName="Day of Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="B;0-9\*D;B;0-9\/,-\*D;*"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/month" displayName="Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="B;0-9\*D;B;0-9\/,-\*D;*|B;a-zA-ZD;{3}"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="time/dayofweek" displayName="Day of Week" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO">
+ <c:constraint><c:regex-constraint expression="B;0-9\*D;B;0-9\/,-\*D;*|B;a-zA-ZD;{3}"/></c:constraint>
+ </c:simple-property>
+ <c:simple-property name="user" displayName="Executing user" required="false" description="TODO"/>
+ <c:simple-property name="." displayName="Command" required="true" description="TODO"/>
+
+ -->
<!DOCTYPE plugin [
<!ENTITY cronEntry '
<c:simple-property name="time/minute" displayName="Minute" type="string" required="true" activationPolicy="immediate"
- default="*" description="TODO"/>
+ default="*" description="TODO">
+ </c:simple-property>
<c:simple-property name="time/hour" displayName="Hour" type="string" required="true" activationPolicy="immediate"
- default="*" description="TODO"/>
+ default="*" description="TODO">
+ </c:simple-property>
<c:simple-property name="time/dayofmonth" displayName="Day of Month" type="string" required="true" activationPolicy="immediate"
- default="*" description="TODO"/>
+ default="*" description="TODO">
+ </c:simple-property>
<c:simple-property name="time/month" displayName="Month" type="string" required="true" activationPolicy="immediate"
- default="*" description="TODO"/>
+ default="*" description="TODO">
+ </c:simple-property>
<c:simple-property name="time/dayofweek" displayName="Day of Week" type="string" required="true" activationPolicy="immediate"
- default="*" description="TODO"/>
+ default="*" description="TODO">
+ </c:simple-property>
<c:simple-property name="user" displayName="Executing user" required="false" description="TODO"/>
<c:simple-property name="." displayName="Command" required="true" description="TODO"/>
'>
+<!ENTITY cronTabRef '
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" description="TODO"/>
+'>
+
]>
<plugin name="Cron"
displayName="Cron"
@@ -41,6 +99,7 @@
<parent-resource-type name="AIX" plugin="Platforms"/>
<parent-resource-type name="FreeBSD" plugin="Platforms"/>
<parent-resource-type name="Mac OS X" plugin="Platforms"/>
+ <parent-resource-type name="Java" plugin="Platforms"/>
</runs-inside>
<plugin-configuration>
@@ -57,34 +116,39 @@
</plugin-configuration>
<resource-configuration>
- <c:list-property displayName="Hourly Jobs" name='entry[time/minute != "*" and time/hour = "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:list-property displayName="Hourly Jobs" readOnly="true"
+ name='entry[time/minute != "*" and time/hour = "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
+ &cronTabRef;
</c:map-property>
</c:list-property>
- <c:list-property displayName="Daily Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:list-property displayName="Daily Jobs" readOnly="true"
+ name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
+ &cronTabRef;
</c:map-property>
</c:list-property>
- <c:list-property displayName="Weekly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek != "*"]'>
+ <c:list-property displayName="Weekly Jobs" readOnly="true"
+ name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek != "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
+ &cronTabRef;
</c:map-property>
</c:list-property>
- <c:list-property displayName="Monthly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:list-property displayName="Monthly Jobs" readOnly="true"
+ name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
+ &cronTabRef;
</c:map-property>
</c:list-property>
- <c:list-property displayName="Yearly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month != "*" and time/dayofweek = "*"]'>
+ <c:list-property displayName="Yearly Jobs" readOnly="true"
+ name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month != "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
+ &cronTabRef;
</c:map-property>
</c:list-property>
</resource-configuration>
commit 7be0246ddf03cfb6730aee01b28aeaed66c4257b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 16:37:10 2009 +0200
Further implementing cron plugin.
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index d398128..e57af45 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -18,11 +18,24 @@
*/
package org.rhq.plugins.cron;
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
import net.augeas.Augeas;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
import org.rhq.plugins.platform.PlatformComponent;
@@ -30,19 +43,35 @@ import org.rhq.plugins.platform.PlatformComponent;
/**
* @author Lukas Krejci
*/
-public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> {
+public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> implements CreateChildResourceFacet {
private static final String CRONTAB_PROP = "..";
- private static final int AUGEAS_FILES_PREFIX_LENGTH = "/files".length();
+ private static final String AUGEAS_FILES_PREFIX = "/files";
+ private static final int AUGEAS_FILES_PREFIX_LENGTH = AUGEAS_FILES_PREFIX.length();
+ private static final String CRONTAB_RESOURCE_TYPE_NAME = "Cron Tab";
+ public CreateResourceReport createResource(CreateResourceReport report) {
+ if (CRONTAB_RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
+ try {
+ String resourceKey = createCrontab(report.getResourceName(), report.getResourceType().getResourceConfigurationDefinition(), report.getResourceConfiguration());
+ report.setResourceKey(resourceKey);
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ } catch (Exception e) {
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ } else {
+ report.setErrorMessage("Don't know how to create resource of type " + report.getResourceType().getName());
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ return report;
+ }
+
@Override
protected Property createPropertySimple(PropertyDefinitionSimple propDefSimple, Augeas augeas, AugeasNode node) {
if (CRONTAB_PROP.equals(propDefSimple.getName())) {
//we want the full path to the crontab file the entry is in..
- //the node's path is /files/blah/blah/entry/..
- //we want the /blah/blah part
- String crontabPath = node.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
-
+ String crontabPath = getEntryCrontabPath(node);
return new PropertySimple(CRONTAB_PROP, crontabPath);
} else {
return super.createPropertySimple(propDefSimple, augeas, node);
@@ -54,9 +83,123 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
PropertySimple propSimple) {
if (CRONTAB_PROP.equals(propDefSimple.getName())) {
- //TODO we want to move this entry into the crontab specified
+ String origPath = getEntryCrontabPath(node);
+ if (!propSimple.getStringValue().equals(origPath)) {
+ String newCrontab = AUGEAS_FILES_PREFIX + propSimple.getStringValue();
+ //check that the newly specified crontab exists
+ if (!augeas.exists(newCrontab)) {
+ throw new RuntimeException("The crontab '" + newCrontab + "' doesn't exist. You need to create it before you can move entries into it.");
+ }
+ augeas.move(node.getPath(), newCrontab);
+ }
} else {
super.setNodeFromPropertySimple(augeas, node, propDefSimple, propSimple);
}
}
+
+ private String getEntryCrontabPath(AugeasNode crontabNode) {
+ //the node's path is /files/blah/blah/entry/..
+ //we want the /blah/blah part
+ return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+ }
+
+ /**
+ * Creates a new crontab resource based on the provided configuration.
+ *
+ * @param resourceConfiguration
+ * @return the resource key of the crontab
+ */
+ private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition, Configuration resourceConfiguration) {
+ File crontabFile = new File(resourceName);
+ if (crontabFile.exists()) {
+ throw new RuntimeException("A file with given name already exists. Creating the crontab would overwrite it.");
+ }
+
+ updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
+
+ return resourceName;
+ }
+
+ protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition, Configuration crontabConfiguration) {
+ Augeas augeas = getAugeas();
+ augeas.load();
+
+ File crontabFile = new File(crontabPath);
+ String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
+ AugeasNode baseNode = new AugeasNode(basePath);
+
+ PropertyMap basicSettings = crontabConfiguration.getMap(CronTabComponent.BASIC_SETTINGS_PROP);
+ PropertyDefinitionMap basicSettingsDef = crontabConfigurationDefinition.getPropertyDefinitionMap(CronTabComponent.BASIC_SETTINGS_PROP);
+
+ setNodeFromPropertyMap(basicSettingsDef, basicSettings, augeas, baseNode);
+
+ PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
+
+ PropertyList additionalSettings = crontabConfiguration.getList(CronTabComponent.ADDITIONAL_SETTINGS_PROP);
+ if (additionalSettings != null) {
+ for(Property p : additionalSettings.getList()) {
+ PropertyMap setting = (PropertyMap)p;
+ String name = setting.getSimpleValue(CronTabComponent.NAME_PROP, null);
+ String value = setting.getSimpleValue(CronTabComponent.VALUE_PROP, "");
+ if (name != null) {
+ String settingPath = basePath + AugeasNode.SEPARATOR + name;
+ augeas.set(settingPath, value);
+ }
+ }
+ }
+
+ augeas.save();
+ }
+
+ /**
+ * This method is only used by the {@link CronTabComponent}.
+ * I placed the method in the parent component class, because here, we have all the information the
+ * sub component need and we don't have to make them load stuff that is accessible right here and now.
+ *
+ * @param crontabPath
+ * @param crontabConfigurationDefinition
+ * @return
+ */
+ protected Configuration loadCronTab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition) {
+ Augeas augeas = getAugeas();
+ augeas.load();
+
+ File crontabFile = new File(crontabPath);
+ String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
+ AugeasNode baseNode = new AugeasNode(basePath);
+
+ Configuration ret = new Configuration();
+ ret.setNotes("Loaded by Augeas at " + new Date());
+
+ PropertyDefinitionMap basicSettingsDef = crontabConfigurationDefinition.getPropertyDefinitionMap(CronTabComponent.BASIC_SETTINGS_PROP);
+ PropertyMap basicSettings = new PropertyMap(basicSettingsDef.getName());
+ ret.put(basicSettings);
+ loadProperty(basicSettingsDef, basicSettings, augeas, baseNode);
+
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ PropertyList entries = new PropertyList(entriesDef.getName());
+ ret.put(entries);
+ loadProperty(entriesDef, ret, augeas, baseNode);
+
+ List<String> envSettings = augeas.match(basePath + "/*[label() != \"entry\" and label() != \"#comment\"]");
+
+ PropertyList additionalSettings = new PropertyList(CronTabComponent.ADDITIONAL_SETTINGS_PROP);
+ ret.put(additionalSettings);
+
+ for(String env : envSettings) {
+ String name = env.substring(env.lastIndexOf(AugeasNode.SEPARATOR_CHAR) + 1);
+ if (!basicSettings.getMap().containsKey(name)) {
+ String value = augeas.get(env);
+ PropertyMap entry = new PropertyMap(CronTabComponent.SETTING_PROP);
+ additionalSettings.add(entry);
+ entry.put(new PropertySimple(CronTabComponent.NAME_PROP, name));
+ entry.put(new PropertySimple(CronTabComponent.VALUE_PROP, value));
+ }
+
+ }
+
+ return ret;
+ }
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java
index eb055d9..d3eb7cf 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java
@@ -23,7 +23,11 @@
package org.rhq.plugins.cron;
+import java.io.File;
+
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
@@ -32,35 +36,49 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
/**
- *
+ * A component representing a single crontab file.
*
* @author Lukas Krejci
*/
public class CronTabComponent implements ResourceComponent<CronComponent>, ConfigurationFacet {
+ public static final String BASIC_SETTINGS_PROP = "basicSettings";
+ public static final String ENTRIES_PROP = "entries";
+ public static final String ADDITIONAL_SETTINGS_PROP = "additionalSettings";
+ public static final String SETTING_PROP = "setting";
+ public static final String NAME_PROP = "name";
+ public static final String VALUE_PROP = "value";
+
+ private ResourceContext<CronComponent> resourceContext;
+ private File crontabFile;
+
public Configuration loadResourceConfiguration() throws Exception {
- // TODO Auto-generated method stub
- return null;
+ CronComponent parent = resourceContext.getParentResourceComponent();
+ String resourceKey = resourceContext.getResourceKey();
+ ConfigurationDefinition configDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
+
+ return parent.loadCronTab(resourceKey, configDef);
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- // TODO Auto-generated method stub
+ CronComponent parent = resourceContext.getParentResourceComponent();
+ ConfigurationDefinition configDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
+ parent.updateCrontab(resourceContext.getResourceKey(), configDef, report.getConfiguration());
+
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
}
public void start(ResourceContext<CronComponent> context) throws InvalidPluginConfigurationException, Exception {
- // TODO Auto-generated method stub
-
+ this.resourceContext = context;
+ crontabFile = new File(context.getResourceKey());
}
public void stop() {
- // TODO Auto-generated method stub
-
}
public AvailabilityType getAvailability() {
- // TODO Auto-generated method stub
- return null;
+ return crontabFile.exists() ? AvailabilityType.UP : AvailabilityType.DOWN;
}
}
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
index 201d760..9c9bb01 100644
--- a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -31,7 +31,8 @@
<service name="Cron"
description="The cron configuration"
discovery="CronDiscoveryComponent"
- class="CronComponent">
+ class="CronComponent"
+ singleton="true">
<runs-inside>
<parent-resource-type name="Linux" plugin="Platforms"/>
@@ -91,7 +92,8 @@
<service name="Cron Tab"
description="A single cron tab file"
discovery="CronTabDiscoveryComponent"
- class="CronTabComponent">
+ class="CronTabComponent"
+ createDeletePolicy="both">
<resource-configuration>
<c:map-property name="basicSettings" displayName="Basic Environment Settings">
<c:simple-property name="SHELL" displayName="Shell" default="/bin/sh" required="false"/>
@@ -100,8 +102,8 @@
<c:simple-property name="CRON_TZ" displayName="Cron Timezone" required="false"/>
<c:simple-property name="MLS_LEVEL" displayName="SELinux security context" required="false"/>
</c:map-property>
- <c:list-property name="commands" displayName="Cron Commands">
- <c:map-property name="command">
+ <c:list-property name="entries" displayName="Cron Entries">
+ <c:map-property name="entry">
&cronEntry;
</c:map-property>
</c:list-property>
commit d1ab4a84ecc0cfa4da435829f3b932fff86b3653
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 13:18:59 2009 +0200
Can read the crontab name now.
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index 854cf2f..d398128 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -18,11 +18,45 @@
*/
package org.rhq.plugins.cron;
+import net.augeas.Augeas;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
+import org.rhq.plugins.augeas.helper.AugeasNode;
import org.rhq.plugins.platform.PlatformComponent;
/**
* @author Lukas Krejci
*/
public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> {
+
+ private static final String CRONTAB_PROP = "..";
+ private static final int AUGEAS_FILES_PREFIX_LENGTH = "/files".length();
+
+ @Override
+ protected Property createPropertySimple(PropertyDefinitionSimple propDefSimple, Augeas augeas, AugeasNode node) {
+ if (CRONTAB_PROP.equals(propDefSimple.getName())) {
+ //we want the full path to the crontab file the entry is in..
+ //the node's path is /files/blah/blah/entry/..
+ //we want the /blah/blah part
+ String crontabPath = node.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+
+ return new PropertySimple(CRONTAB_PROP, crontabPath);
+ } else {
+ return super.createPropertySimple(propDefSimple, augeas, node);
+ }
+ }
+
+ @Override
+ protected void setNodeFromPropertySimple(Augeas augeas, AugeasNode node, PropertyDefinitionSimple propDefSimple,
+ PropertySimple propSimple) {
+
+ if (CRONTAB_PROP.equals(propDefSimple.getName())) {
+ //TODO we want to move this entry into the crontab specified
+ } else {
+ super.setNodeFromPropertySimple(augeas, node, propDefSimple, propSimple);
+ }
+ }
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
index d2a0b42..676921c 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
@@ -25,4 +25,5 @@ import org.rhq.plugins.platform.PlatformComponent;
* @author Lukas Krejci
*/
public class CronDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<PlatformComponent> {
+ //the super class provides everything we need...
}
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
index d45b2dc..201d760 100644
--- a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -59,31 +59,31 @@
<c:list-property displayName="Hourly Jobs" name='entry[time/minute != "*" and time/hour = "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
<c:list-property displayName="Daily Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
<c:list-property displayName="Weekly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek != "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
<c:list-property displayName="Monthly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month = "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
<c:list-property displayName="Yearly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month != "*" and time/dayofweek = "*"]'>
<c:map-property name=".">
&cronEntry;
- <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="true" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
</resource-configuration>
commit ef68b0fb6931094270a700c8721ed05bee4a59e6
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 26 11:14:44 2009 +0100
Because of the possible length of mappings, we need to increase the length of the property name in rhq-plugin.xml and in database. Setting it to 255 chars hoping it's going to be enough.
diff --git a/modules/core/client-api/src/main/resources/rhq-configuration.xsd b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
index 20c74e3..d173134 100644
--- a/modules/core/client-api/src/main/resources/rhq-configuration.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
@@ -142,7 +142,7 @@
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
<xs:minLength value="1"/>
- <xs:maxLength value="100"/>
+ <xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 0befb0c..ba56771 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.58</db.schema.version>
+ <db.schema.version>2.61</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index c129874..7d31bc4 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -23,7 +23,7 @@
<table name="RHQ_CONFIG_PROP_DEF">
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
- <column name="NAME" type="VARCHAR2" required="false" size="100"/>
+ <column name="NAME" type="VARCHAR2" required="false" size="255"/>
<column name="DISPLAY_NAME" type="VARCHAR2" required="false" size="100"/>
<column name="DESCRIPTION" type="VARCHAR2" required="false" size="1000"/>
<column name="DEFAULT_VALUE" type="VARCHAR2" required="false" size="2000"/>
@@ -78,7 +78,7 @@
<column name="CONFIGURATION_ID" type="INTEGER" required="false" references="RHQ_CONFIG" ondelete="cascade"/>
<column name="STRING_VALUE" type="VARCHAR2" required="false" size="2000"/>
<column name="OVERRIDE" type="BOOLEAN" required="false"/>
- <column name="NAME" type="VARCHAR2" required="true" size="100"/>
+ <column name="NAME" type="VARCHAR2" required="true" size="255"/>
<column name="DTYPE" type="VARCHAR2" required="true" size="10"/>
<!-- Recursive cascade path to RHQ_CONFIG_PROPERTY causes constraint creation errors on SQL Server, see
http://support.microsoft.com/kb/321843 -->
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index d5a4e24..716ebd6 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -1518,6 +1518,18 @@ DB Upgrade:
<schema-addColumn table="RHQ_ALERT_DEFINITION" column="GROUP_ALERT_DEF_ID" columnType="INTEGER" />
</schemaSpec>
+ <schemaSpec version="2.61">
+ <schema-alterColumn
+ table="RHQ_CONFIG_PROP_DEF"
+ column="NAME"
+ columnType="VARCHAR2"
+ precision="255" />
+ <schema-alterColumn
+ table="RHQ_CONFIG_PROPERTY"
+ column="NAME"
+ columnType="VARCHAR2"
+ precision="255" />
+ </schemaSpec>
</dbupgrade>
</target>
commit d4a4b4c99dadb7f329d2d24a5fafd78803590804
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Oct 22 11:54:21 2009 +0200
basic mappings of cron components.
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index 0a2c2cc..854cf2f 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -19,9 +19,10 @@
package org.rhq.plugins.cron;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
+import org.rhq.plugins.platform.PlatformComponent;
/**
* @author Lukas Krejci
*/
-public class CronComponent extends AugeasConfigurationComponent {
+public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> {
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
index 2e2a7f3..d2a0b42 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
@@ -19,9 +19,10 @@
package org.rhq.plugins.cron;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
+import org.rhq.plugins.platform.PlatformComponent;
/**
* @author Lukas Krejci
*/
-public class CronDiscoveryComponent extends AugeasConfigurationDiscoveryComponent {
+public class CronDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<PlatformComponent> {
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java
new file mode 100644
index 0000000..eb055d9
--- /dev/null
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabComponent.java
@@ -0,0 +1,66 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.cron;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class CronTabComponent implements ResourceComponent<CronComponent>, ConfigurationFacet {
+
+ public Configuration loadResourceConfiguration() throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void start(ResourceContext<CronComponent> context) throws InvalidPluginConfigurationException, Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public AvailabilityType getAvailability() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java
new file mode 100644
index 0000000..73bdea5
--- /dev/null
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronTabDiscoveryComponent.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.plugins.cron;
+
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+public class CronTabDiscoveryComponent implements ResourceDiscoveryComponent<CronComponent>, ManualAddFacet<CronComponent>{
+
+ public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
+ ResourceDiscoveryContext<CronComponent> context) throws InvalidPluginConfigurationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<CronComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
index b06af0e..d45b2dc 100644
--- a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,5 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plugin [
+
+<!ENTITY cronEntry '
+ <c:simple-property name="time/minute" displayName="Minute" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO"/>
+ <c:simple-property name="time/hour" displayName="Hour" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO"/>
+ <c:simple-property name="time/dayofmonth" displayName="Day of Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO"/>
+ <c:simple-property name="time/month" displayName="Month" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO"/>
+ <c:simple-property name="time/dayofweek" displayName="Day of Week" type="string" required="true" activationPolicy="immediate"
+ default="*" description="TODO"/>
+ <c:simple-property name="user" displayName="Executing user" required="false" description="TODO"/>
+ <c:simple-property name="." displayName="Command" required="true" description="TODO"/>
+'>
+
+]>
<plugin name="Cron"
displayName="Cron"
description="Configuration of cron"
@@ -22,14 +40,13 @@
<parent-resource-type name="AIX" plugin="Platforms"/>
<parent-resource-type name="FreeBSD" plugin="Platforms"/>
<parent-resource-type name="Mac OS X" plugin="Platforms"/>
- <parent-resource-type name="Java" plugin="Platforms"/>
</runs-inside>
<plugin-configuration>
<c:simple-property name="augeasModuleName" displayName="Augeas Module Name" default="Cron" required="true" readOnly="true"
description="the name of the Augeas module/lens to use for loading and updating this resource's configuration"/>
<c:simple-property name="configurationFilesInclusionPatterns" required="true" readOnly="true"
- default="/etc/crontab|etc/cron.d/*">
+ default="/etc/crontab|/etc/cron.d/*">
<c:description>A | delimited list of patterns of files to configure.</c:description>
</c:simple-property>
<c:simple-property name="configurationFilesExclusionPatterns" required="true" readOnly="true"
@@ -39,22 +56,66 @@
</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"
- 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"/>
- <c:simple-property name="host_group/command" displayName="Command" type="string" required="false" activationPolicy="immediate"
- description="The Command/Command Alias that the specified user is allowed to execute from the specified hosts. Set it to ALL if the user is allowed to execute any command. Alternatively if you have a Cmnd_Alias defined you can use that here. Eg:if you defined Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables - in /etc/sudoers you can specify NETWORKING here."/>
- <c:simple-property name="host_group/command/runas_user" displayName="Run as User" type="string" required="false" activationPolicy="immediate"
- description="The User name/Run Alias of the user the specified command will be run as. For example if you wanted the command to be run as user 'foo' you would specify foo here. Set it to ALL if the user is allowed to execute the command as any user. Alternatively if you have a Run_Alias defined you can use that here. Eg:if you defined Runas_Alias OP = root, operator - in /etc/sudoers you can specify OP here."/>
- <c:simple-property name="host_group/command/tag" displayName="Require Password" type="string" required="false" activationPolicy="immediate"
- description="True if password is required to execute the command. False otherwise."/>
+ <c:list-property displayName="Hourly Jobs" name='entry[time/minute != "*" and time/hour = "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:map-property name=".">
+ &cronEntry;
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property displayName="Daily Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:map-property name=".">
+ &cronEntry;
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property displayName="Weekly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth = "*" and time/month = "*" and time/dayofweek != "*"]'>
+ <c:map-property name=".">
+ &cronEntry;
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property displayName="Monthly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month = "*" and time/dayofweek = "*"]'>
+ <c:map-property name=".">
+ &cronEntry;
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property displayName="Yearly Jobs" name='entry[time/minute != "*" and time/hour != "*" and time/dayofmonth != "*" and time/month != "*" and time/dayofweek = "*"]'>
+ <c:map-property name=".">
+ &cronEntry;
+ <c:simple-property name=".." displayName="Cron Tab" type="string" required="false" readOnly="true" description="TODO"/>
</c:map-property>
</c:list-property>
</resource-configuration>
+ <service name="Cron Tab"
+ description="A single cron tab file"
+ discovery="CronTabDiscoveryComponent"
+ class="CronTabComponent">
+ <resource-configuration>
+ <c:map-property name="basicSettings" displayName="Basic Environment Settings">
+ <c:simple-property name="SHELL" displayName="Shell" default="/bin/sh" required="false"/>
+ <c:simple-property name="MAILTO" displayName="Mail To" required="false"/>
+ <c:simple-property name="HOME" displayName="Home directory" required="false"/>
+ <c:simple-property name="CRON_TZ" displayName="Cron Timezone" required="false"/>
+ <c:simple-property name="MLS_LEVEL" displayName="SELinux security context" required="false"/>
+ </c:map-property>
+ <c:list-property name="commands" displayName="Cron Commands">
+ <c:map-property name="command">
+ &cronEntry;
+ </c:map-property>
+ </c:list-property>
+
+ <c:group name="advanced" displayName="Advanced">
+ <c:list-property name="additionalSettings">
+ <c:map-property name="setting">
+ <c:simple-property name="name" required="true" />
+ <c:simple-property name="value" required="true"/>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+ </service>
</service>
</plugin>
commit 1393822ad4c1727d8be269270a9041e4594b02ce
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 14:25:31 2009 +0200
some basic stuff in the rhq-plugin.xml
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
index 47dc32e..b06af0e 100644
--- a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -17,7 +17,6 @@
<runs-inside>
<parent-resource-type name="Linux" plugin="Platforms"/>
- <parent-resource-type name="Windows" plugin="Platforms"/>
<parent-resource-type name="Solaris" plugin="Platforms"/>
<parent-resource-type name="HP-UX" plugin="Platforms"/>
<parent-resource-type name="AIX" plugin="Platforms"/>
@@ -29,8 +28,14 @@
<plugin-configuration>
<c:simple-property name="augeasModuleName" displayName="Augeas Module Name" default="Cron" required="true" readOnly="true"
description="the name of the Augeas module/lens to use for loading and updating this resource's configuration"/>
- <c:simple-property name="configurationFile" displayName="Crontab File Path" required="true" readOnly="true"
- default="/etc/crontab" description="Location of the crontab file."/>
+ <c:simple-property name="configurationFilesInclusionPatterns" required="true" readOnly="true"
+ default="/etc/crontab|etc/cron.d/*">
+ <c:description>A | delimited list of patterns of files to configure.</c:description>
+ </c:simple-property>
+ <c:simple-property name="configurationFilesExclusionPatterns" required="true" readOnly="true"
+ default="*.augnew|*.augsave|*.rpmsave|*.rpmnew|*~">
+ <c:description>A | delimited list of patterns of files to exclude from configuration.</c:description>
+ </c:simple-property>
</plugin-configuration>
<resource-configuration>
commit 321ba2fd971ab81a162b442ab5c17efe604b6cc4
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 21 13:13:07 2009 +0200
initial commit for cron plugin. nothing to see here.
diff --git a/modules/plugins/cron/pom.xml b/modules/plugins/cron/pom.xml
new file mode 100644
index 0000000..5992726
--- /dev/null
+++ b/modules/plugins/cron/pom.xml
@@ -0,0 +1,217 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-cron-plugin</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ Augeas-based Cron Plugin</name>
+ <description>A plugin for managing the *nix cron file</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/cron</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/plugins/cron</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/plugins/cron/</scm.module.path>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-platform-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-augeas-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <echo>Setting up plugin dependencies for ${project.artifactId}-${project.version}.jar...
+ </echo>
+ <property name="settings.localRepository" location="${user.home}/.m2/repository" />
+ <mkdir dir="target/itest" />
+ <mkdir dir="target/itest/plugins" />
+ <mkdir dir="target/itest/lib" />
+ <copy toDir="target/itest/plugins" flatten="true">
+ <fileset dir="${settings.localRepository}/">
+ <include name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar" />
+ </fileset>
+ <fileset dir="${project.build.directory}">
+ <include name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+ <unzip dest="target/itest/lib">
+ <fileset dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}" includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/itest/lib" flatten="true">
+ <fileset dir="target/itest/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete dir="target/itest/lib/hyperic-sigar-${sigar.version}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Integration testing voodoo to load and test this plugin with its plugin dependencies -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <useSystemClassLoader>false</useSystemClassLoader>
+ <argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib</argLine>
+ <!--<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/itest/lib -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine>-->
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>
+ ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins
+ </rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
+ <patternset><include name="META-INF/**" /></patternset>
+ </unjar>
+ <jar destfile="${deployment.file}" manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF" update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
new file mode 100644
index 0000000..0a2c2cc
--- /dev/null
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -0,0 +1,27 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.cron;
+
+import org.rhq.plugins.augeas.AugeasConfigurationComponent;
+
+/**
+ * @author Lukas Krejci
+ */
+public class CronComponent extends AugeasConfigurationComponent {
+}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
new file mode 100644
index 0000000..2e2a7f3
--- /dev/null
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronDiscoveryComponent.java
@@ -0,0 +1,27 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.cron;
+
+import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
+
+/**
+ * @author Lukas Krejci
+ */
+public class CronDiscoveryComponent extends AugeasConfigurationDiscoveryComponent {
+}
diff --git a/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..47dc32e
--- /dev/null
+++ b/modules/plugins/cron/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="Cron"
+ displayName="Cron"
+ description="Configuration of cron"
+ package="org.rhq.plugins.cron"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <depends plugin="Augeas"/>
+
+ <service name="Cron"
+ description="The cron configuration"
+ discovery="CronDiscoveryComponent"
+ class="CronComponent">
+
+ <runs-inside>
+ <parent-resource-type name="Linux" plugin="Platforms"/>
+ <parent-resource-type name="Windows" plugin="Platforms"/>
+ <parent-resource-type name="Solaris" plugin="Platforms"/>
+ <parent-resource-type name="HP-UX" plugin="Platforms"/>
+ <parent-resource-type name="AIX" plugin="Platforms"/>
+ <parent-resource-type name="FreeBSD" plugin="Platforms"/>
+ <parent-resource-type name="Mac OS X" plugin="Platforms"/>
+ <parent-resource-type name="Java" plugin="Platforms"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="augeasModuleName" displayName="Augeas Module Name" default="Cron" required="true" readOnly="true"
+ description="the name of the Augeas module/lens to use for loading and updating this resource's configuration"/>
+ <c:simple-property name="configurationFile" displayName="Crontab File Path" required="true" readOnly="true"
+ default="/etc/crontab" description="Location of the crontab file."/>
+ </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"
+ 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"/>
+ <c:simple-property name="host_group/command" displayName="Command" type="string" required="false" activationPolicy="immediate"
+ description="The Command/Command Alias that the specified user is allowed to execute from the specified hosts. Set it to ALL if the user is allowed to execute any command. Alternatively if you have a Cmnd_Alias defined you can use that here. Eg:if you defined Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables - in /etc/sudoers you can specify NETWORKING here."/>
+ <c:simple-property name="host_group/command/runas_user" displayName="Run as User" type="string" required="false" activationPolicy="immediate"
+ description="The User name/Run Alias of the user the specified command will be run as. For example if you wanted the command to be run as user 'foo' you would specify foo here. Set it to ALL if the user is allowed to execute the command as any user. Alternatively if you have a Run_Alias defined you can use that here. Eg:if you defined Runas_Alias OP = root, operator - in /etc/sudoers you can specify OP here."/>
+ <c:simple-property name="host_group/command/tag" displayName="Require Password" type="string" required="false" activationPolicy="immediate"
+ description="True if password is required to execute the command. False otherwise."/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
+
+ </service>
+
+</plugin>
diff --git a/modules/plugins/cron/src/test/resources/log4j.xml b/modules/plugins/cron/src/test/resources/log4j.xml
new file mode 100644
index 0000000..ef41b92
--- /dev/null
+++ b/modules/plugins/cron/src/test/resources/log4j.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Messagen -->
+
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="Append" value="false"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
commit 336b05a63b5ed21e2a3ba1b2059cf53d180b2d0d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Oct 26 11:07:00 2009 +0100
Removing unused imports.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
index 1330800..49e8331 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java
@@ -19,7 +19,6 @@
package org.rhq.plugins.augeas;
import java.io.File;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -30,8 +29,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
14 years, 6 months
[rhq] Branch 'linux-config' - modules/plugins
by Shannon Hughes
modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml | 16 +++++-----
1 file changed, 8 insertions(+), 8 deletions(-)
New commits:
commit e42a5b8e8b8cd8739686e25bdcb3af82107aab88
Author: Shannon Hughes <shughes(a)fred.hughes.lan>
Date: Mon Oct 26 08:43:59 2009 -0400
fixing schema validation on samba rhq-plugin
diff --git a/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
index af52aea..0d4cb7c 100644
--- a/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-
+
<plugin name="Samba"
displayName="Samba"
description="Support for RHEL Samba service"
@@ -29,7 +29,7 @@
<resource-configuration>
<c:group name="Basic Configurations">
-
+
<c:simple-property name="workgroup" description="The workgroup your server will appear to be in when queried by clients" required="false"/>
<c:simple-property name="server string" description="Value that will display in the printer comment box in print manager" required="false"/>
@@ -44,15 +44,15 @@
<c:option value="user"/>
</c:property-options>
</c:simple-property>
-
+
<c:simple-property name="encrypt passwords" type="boolean" required="false" description="This option must be enabled if the clients are connecting from a Windows 98, Windows NT 4.0 with Service Pack 3, or other more recent versions of Microsoft Windows. The passwords are transfered between the server and the client in an encrypted format instead of in as a plain-text word that can be intercepted."/>
-
+
</c:group>
-
+
<c:group name="Printing">
<c:simple-property name="load printers" displayName="Printing Enabled" type="boolean" description="Controls whether all printers in the printcap will be loaded for browsing by default"/>
- <c:simple-property name="cups options" required="false" description=""/>
-
+ <c:simple-property name="cups options" required="false" description="Free form string of options passed to cups library"/>
+
</c:group>
</resource-configuration>
@@ -62,7 +62,7 @@
<plugin-configuration>
<c:simple-property name="augeasModuleName" displayName="Augeas Module Name" default="Samba" required="true" readOnly="true"
- description="the name of the Augeas module/lens to use for loading and updating this resource's configuration"/>
+ description="the name of the Augeas lens to use for loading and updating this resource's configuration"/>
<c:simple-property name="configurationFilesInclusionPatterns" displayName="File Path" type="file" required="true" readOnly="true"
default="/etc/samba/smb.conf"
14 years, 6 months
[rhq] Branch 'linux-config' - modules/plugins
by Shannon Hughes
modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 6694863633a01f9672f810a990b07d8c3bebcbb5
Author: Shannon Hughes <shughes(a)fred.hughes.lan>
Date: Mon Oct 26 08:35:08 2009 -0400
typo in plugin descriptor
diff --git a/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
index bb32383..af52aea 100644
--- a/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/samba/src/main/resources/META-INF/rhq-plugin.xml
@@ -50,7 +50,7 @@
</c:group>
<c:group name="Printing">
- <c:simple-property name="load printers" displayName="Printing Enabled" type="boolean" description="Controls whether all printers in the printcap will be loaded for browsing by default""/>
+ <c:simple-property name="load printers" displayName="Printing Enabled" type="boolean" description="Controls whether all printers in the printcap will be loaded for browsing by default"/>
<c:simple-property name="cups options" required="false" description=""/>
</c:group>
14 years, 6 months
[rhq] 2 commits - modules/helpers
by Heiko W. Rupp
modules/helpers/pluginAnnotations/pom.xml | 4 ++--
modules/helpers/pluginGen/pom.xml | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit bacd1ba678d44af463226cc1a7102212b35faa09
Merge: 9dba749... 4422052...
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:38:17 2009 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9dba7497582b27dd7b2a547a3d43f3183dc224bf
Author: Heiko W. Rupp <hrupp(a)snert.(none)>
Date: Mon Oct 26 11:35:05 2009 +0100
Change the group of the helper artifacts to 'org.rhq.helpers' so that they end up in a subgroup
on their own. This gives less clutter to the repo.
diff --git a/modules/helpers/pluginAnnotations/pom.xml b/modules/helpers/pluginAnnotations/pom.xml
index 3e73c16..a3dc269 100644
--- a/modules/helpers/pluginAnnotations/pom.xml
+++ b/modules/helpers/pluginAnnotations/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<packaging>jar</packaging>
@@ -50,4 +50,4 @@
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml
index e58e36d..0fd3ff7 100644
--- a/modules/helpers/pluginGen/pom.xml
+++ b/modules/helpers/pluginGen/pom.xml
@@ -10,7 +10,7 @@
</parent>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginGen</artifactId>
<packaging>jar</packaging>
@@ -86,9 +86,9 @@
<version>2.3.11</version>
</dependency>
<dependency>
- <groupId>org.rhq</groupId>
+ <groupId>org.rhq.helpers</groupId>
<artifactId>rhq-pluginAnnotations</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
14 years, 6 months
[rhq] Branch 'content' - modules/core
by sayli karmarkar
modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoGroupTest.java | 186 ++++++++++
1 file changed, 186 insertions(+)
New commits:
commit 7107975fd42133036f5c5494f808f742c8e6d1b4
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Oct 26 05:49:08 2009 -0400
Unit tests for RepoGroup
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoGroupTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoGroupTest.java
new file mode 100644
index 0000000..073395d
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoGroupTest.java
@@ -0,0 +1,186 @@
+ /*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.content.test;
+
+import javax.persistence.EntityManager;
+import org.testng.annotations.Test;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.content.Architecture;
+import org.rhq.core.domain.content.ContentSource;
+import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.core.domain.content.Package;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.content.RepoGroup;
+
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+@Test
+public class RepoGroupTest extends AbstractEJB3Test {
+ public void testInsert() throws Exception {
+ getTransactionManager().begin();
+ try {
+ EntityManager em = getEntityManager();
+
+ ResourceType rt = new ResourceType("testCSResourceType", "testPlugin", ResourceCategory.PLATFORM, null);
+ Resource resource = new Resource("testCSResource", "testCSResource", rt);
+ Architecture arch = new Architecture("testCSInsertArch");
+ PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
+ Package pkg = new Package("testCSInsertPackage", pt);
+ PackageVersion pv = new PackageVersion(pkg, "version", arch);
+ ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
+ ContentSource cs = new ContentSource("testCSContentSource", cst);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("one", "oneValue"));
+ cs.setConfiguration(config);
+
+ em.persist(rt);
+ em.persist(resource);
+ em.persist(arch);
+ em.persist(pt);
+ em.persist(pkg);
+ em.persist(pv);
+ em.persist(cst);
+ em.persist(cs);
+ em.flush();
+ em.close();
+ em = getEntityManager();
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs != null;
+ assert cs.getConfiguration() != null;
+ assert cs.getConfiguration().getSimple("one").getStringValue().equals("oneValue");
+ assert cs.getSyncSchedule() != null;
+ assert cs.getContentSourceType().getDefaultSyncSchedule() != null;
+
+ em.remove(cs);
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs == null;
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ public void testNullSyncSchedule() throws Exception {
+ getTransactionManager().begin();
+ try {
+ EntityManager em = getEntityManager();
+
+ ResourceType rt = new ResourceType("testCSResourceType", "testPlugin", ResourceCategory.PLATFORM, null);
+ Resource resource = new Resource("testCSResource", "testCSResource", rt);
+ Architecture arch = new Architecture("testCSInsertArch");
+ PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
+ Package pkg = new Package("testCSInsertPackage", pt);
+ PackageVersion pv = new PackageVersion(pkg, "version", arch);
+ ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
+ cst.setDefaultSyncSchedule(null);
+ ContentSource cs = new ContentSource("testCSContentSource", cst);
+ cs.setSyncSchedule(null);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("one", "oneValue"));
+ cs.setConfiguration(config);
+
+ em.persist(rt);
+ em.persist(resource);
+ em.persist(arch);
+ em.persist(pt);
+ em.persist(pkg);
+ em.persist(pv);
+ em.persist(cst);
+ em.persist(cs);
+ em.flush();
+ em.close();
+ em = getEntityManager();
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs != null;
+ assert cs.getConfiguration() != null;
+ assert cs.getConfiguration().getSimple("one").getStringValue().equals("oneValue");
+ assert cs.getSyncSchedule() == null;
+ assert cs.getContentSourceType().getDefaultSyncSchedule() == null;
+
+ em.remove(cs);
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs == null;
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ public void testEmptySyncSchedule() throws Exception {
+ // using empty strings to see that Oracle still behaves itself
+ getTransactionManager().begin();
+ try {
+ EntityManager em = getEntityManager();
+
+ ResourceType rt = new ResourceType("testCSResourceType", "testPlugin", ResourceCategory.PLATFORM, null);
+ Resource resource = new Resource("testCSResource", "testCSResource", rt);
+ Architecture arch = new Architecture("testCSInsertArch");
+ PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
+ Package pkg = new Package("testCSInsertPackage", pt);
+ PackageVersion pv = new PackageVersion(pkg, "version", arch);
+ ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
+ cst.setDefaultSyncSchedule("");
+ ContentSource cs = new ContentSource("testCSContentSource", cst);
+ cs.setSyncSchedule("");
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("one", "oneValue"));
+ cs.setConfiguration(config);
+
+ em.persist(rt);
+ em.persist(resource);
+ em.persist(arch);
+ em.persist(pt);
+ em.persist(pkg);
+ em.persist(pv);
+ em.persist(cst);
+ em.persist(cs);
+ em.flush();
+ em.close();
+ em = getEntityManager();
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs != null;
+ assert cs.getConfiguration() != null;
+ assert cs.getConfiguration().getSimple("one").getStringValue().equals("oneValue");
+ assert cs.getSyncSchedule() == null;
+ assert cs.getContentSourceType().getDefaultSyncSchedule() == null;
+
+ em.remove(cs);
+
+ cs = em.find(ContentSource.class, cs.getId());
+ assert cs == null;
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+}
14 years, 6 months
[rhq] Branch 'content' - modules/core
by sayli karmarkar
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 6e5f62a295facae09fd7aa10cab3bb2ba0e96f1f
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Oct 26 05:46:59 2009 -0400
db-upgrade typo corrections
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index ed75475..858d05d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -1524,7 +1524,7 @@
ALTER TABLE RHQ_REPO
ADD CONSTRAINT RHQ_REPO_PKEY PRIMARY KEY ( ID )
</statement>
- <!-- RHQ_CHANNEL_CONTENT_SRC_MAP => RHQ_CHANNEL_CONTENT_SRC_MAP -->
+ <!-- RHQ_CHANNEL_CONTENT_SRC_MAP => RHQ_REPO_CONTENT_SRC_MAP -->
<statement>
ALTER TABLE RHQ_CHANNEL_CONTENT_SRC_MAP
RENAME TO RHQ_REPO_CONTENT_SRC_MAP
@@ -1558,7 +1558,7 @@
FOREIGN KEY ( CONTENT_SRC_ID )
REFERENCES RHQ_CONTENT_SOURCE( ID )
</statement>
- <!-- RHQ_CHANNEL_PKG_VERSION_MAP => RHQ_CHANNEL_PKG_VERSION_MAP -->
+ <!-- RHQ_CHANNEL_PKG_VERSION_MAP => RHQ_REPO_PKG_VERSION_MAP -->
<statement>
ALTER TABLE RHQ_CHANNEL_PKG_VERSION_MAP
RENAME TO RHQ_REPO_PKG_VERSION_MAP
14 years, 6 months