etc/cli-scripts/reset_conn_props.js | 59 +++++++++++++++++++++++++++++++-----
1 file changed, 52 insertions(+), 7 deletions(-)
New commits:
commit 4e7a5da9176eb3198f2b3497e966352818642a80
Merge: a2addce... 148c25c...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 28 16:54:04 2010 -0400
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit a2addcee76d260a82fff7faf848773a5932bd803
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 28 16:50:02 2010 -0400
[BZ 573034] Updating script to not retrieve defaults from default template
The script originally fetched the default values for connection properties from the
default
template and used the values from the default template to apply default values to
connection
properties of resources. This is a nice solution because it is generic and applicable
across resource types; however, since 2.3.1 does not have the code changes in the
plugin
upgrade code, the new properties do not exist in the default template in 2.3.1.
Consequently, the values are essentially hard-coded on a per resource type basis.
diff --git a/etc/cli-scripts/reset_conn_props.js b/etc/cli-scripts/reset_conn_props.js
index bb2ac46..274bc5c 100644
--- a/etc/cli-scripts/reset_conn_props.js
+++ b/etc/cli-scripts/reset_conn_props.js
@@ -31,8 +31,13 @@ function log(msg) {
println("DEBUG " + msg);
}
+function loadPluginConfiguration(resource) {
+ log("Loading plugin configuration for " + resource);
+ return ConfigurationManager.getPluginConfiguration(resource.id);
+}
+
function loadPluginConfigDef(resourceTypeName, pluginName) {
- log("Loading plugin configuration for [resourceType=" + resourceTypeName +
", plugin=" +
+ log("Loading plugin configuration definition for [resourceType=" +
resourceTypeName + ", plugin=" +
pluginName + "]");
var resourceType =
ResourceTypeManager.getResourceTypeByNameAndPlugin(resourceTypeName,
pluginName);
@@ -64,6 +69,10 @@ function findResourcesByTypeAndPlugin(resourceType, plugin) {
log("Found " + resources.size() + " " + resourceType + "
resources ");
+ iterate(resources, function(resource) {
+ resource.pluginConfiguration = loadPluginConfiguration(resource);
+ });
+
return resources;
}
@@ -171,7 +180,6 @@ function getJBossSnapshotPropertyNames() {
set.add('snapshotDataRecursive');
set.add('snapshotAdditionalFilesEnabled');
set.add('snapshotAdditionalFilesDirectory');
- set.add('snapshotAdditionalFilesRegex');
set.add('snapshotAdditionalFilesRecursive');
return set;
@@ -197,7 +205,7 @@ function getAgentSnapshotPropertyNames() {
* param: snapshotDefaults: The names of the plugin configuration properties to reset.
This
* is expected to be a java.util.Collection.
*/
-function resetPluginConfigProps(resources, snapshotDefaults) {
+function resetPluginConfigPropsFromTemplate(pluginConfigDef, resources, snapshotDefaults)
{
iterate(resources, function(resource) {
log("Preparing to reset plugin configuration properties for " + resource);
var simpleProperties = flattenProperties(resource.pluginConfiguration);
@@ -208,6 +216,7 @@ function resetPluginConfigProps(resources, snapshotDefaults) {
iterate(snapshotProperties, function(property) {
var defaultProperty = snapshotDefaults.get(property.name);
property.stringValue = defaultProperty.stringValue;
+ log("Set property " + property.name + " to " +
property.stringValue);
});
ConfigurationManager.updatePluginConfiguration(resource.id,
resource.pluginConfiguration);
@@ -215,14 +224,44 @@ function resetPluginConfigProps(resources, snapshotDefaults) {
});
}
+function resetPluginConfigProps(resources, applyDefaults) {
+ iterate(resources, function(resource) {
+ applyDefaults(resource.pluginConfiguration);
+ ConfigurationManager.updatePluginConfiguration(resource.id,
resource.pluginConfiguration);
+ log("Updated plugin configuration for " + resource);
+ });
+}
+
function resetJBossPluginConfigProps() {
var jbossResourceTypeName = 'JBossAS Server';
var jbossPluginName = 'JBossAS';
var jbossServers = findResourcesByTypeAndPlugin(jbossResourceTypeName,
jbossPluginName);
var jbossPluginConfigDef = loadPluginConfigDef(jbossResourceTypeName,
jbossPluginName);
- resetPluginConfigProps(jbossServers, loadSnapshotDefaults(jbossPluginConfigDef,
- getJBossSnapshotPropertyNames()));
+ //resetPluginConfigProps(jbossServers, loadSnapshotDefaults(jbossPluginConfigDef,
+ // getJBossSnapshotPropertyNames()));
+
+ resetPluginConfigProps(jbossServers, function(pluginConfig) {
+ pluginConfig.put(PropertySimple('snapshotConfigEnabled', true));
+ pluginConfig.put(PropertySimple('snapshotConfigDirectory',
'config'));
+ pluginConfig.put(PropertySimple('snapshotConfigRecursive', true));
+ pluginConfig.put(PropertySimple('snapshotLogEnabled', true));
+ pluginConfig.put(PropertySimple('snapshotLogDirectory', 'log'));
+ pluginConfig.put(PropertySimple('snapshotLogRecursive', false));
+ pluginConfig.put(PropertySimple('snapshotDataEnabled', false));
+ pluginConfig.put(PropertySimple('snapshotDataDirectory', 'data'));
+ pluginConfig.put(PropertySimple('snapshotDataRecursive', true));
+
+ var propertyMap = PropertyMap('snapshotAdditionalFilesMap');
+ propertyMap.put(PropertySimple('snapshotAdditionalFilesEnabled', true));
+ propertyMap.put(PropertySimple('snapshotAdditionalFilesDirectory',
''));
+ propertyMap.put(PropertySimple('snapshotAdditionalFilesRecursive', true));
+
+ var propertyList = PropertyList('snapshotAdditionalFilesList');
+ propertyList.list.add(propertyMap);
+
+ pluginConfig.put(propertyList);
+ });
}
function resetAgentPluginConfigProps() {
@@ -231,8 +270,14 @@ function resetAgentPluginConfigProps() {
var agents = findResourcesByTypeAndPlugin(agentResourceTypeName, agentPluginName);
var agentPluginConfigDef = loadPluginConfigDef(agentResourceTypeName,
agentPluginName);
- resetPluginConfigProps(agents, loadSnapshotDefaults(agentPluginConfigDef,
- getAgentSnapshotPropertyNames()));
+ //resetPluginConfigProps(agents, loadSnapshotDefaults(agentPluginConfigDef,
+ // getAgentSnapshotPropertyNames()));
+
+ resetPluginConfigProps(agents, function(pluginConfig) {
+ pluginConfig.put(PropertySimple('snapshotConfigEnabled', true));
+ pluginConfig.put(PropertySimple('snapshotLogEnabled', true));
+ pluginConfig.put(PropertySimple('snapshotDataEnabled', true));
+ });
}
//////////////