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/plug...
+
<
developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/mod...
+ </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;