modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties | 4 modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java | 26 ++- modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java | 3 modules/core/dbutils/pom.xml | 2 modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml | 6 modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 31 ++++ modules/core/util/src/main/java/org/rhq/core/util/obfuscation/Obfuscator.java | 13 + modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 17 +- modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java | 11 - modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 39 ++++- modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java | 76 +++++++++- modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerProperties.java | 8 + 12 files changed, 201 insertions(+), 35 deletions(-)
New commits: commit 553db312306ca9f49d27b5c9041d4a52d3bc59a2 Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Sep 19 11:53:14 2013 -0400
Bug 1006419 - Improve handling of obfuscated passwords for installation Use generated username/password for storage nodes.
This removes the need for the user to generate a password and manually paste it into rhq-server.properties prior to an install. It also generates a username so that the username will not conflict with any rhq username, in anticipation of a chained authentication mechanism that can use rhq auth as a secondary login mechanism. This will be useful for support, for example, since the generated username/password will be internally used only.
The generated username and encoded version of the password are now also stored as system config values in the database. This allows the installer to use the previously generated values for additional HA nodes.
The username/password logic used in install is: IF set, use the values in the db system config ELSE IF pre-set, use the values in rhq-server.properties (primarily for dev builds) ELSE generate username/password and set in rhq-server.properties
store values in db system config
also: - removed username/password defaults from cassandra.properties (which should likely go away, or minimally not be used in rhq-container.build.xml. - added the new system config props to dbsetup and dbupgrade (2.141) - limit generated usernames to alpha chars to avoid invalid c* identifiers - remove logging of plain text storage password when creating superuser - remove use of plain text storage password in temporary task file when creating superuser (now decodes just prior to cql statement execution) - added ServerInstallUtil.fetchStorageClusterSettings() to fetch current storage settings in the db and updated persistStorageClusterSettingsIfNecessary() to include the new props. - added storage property constants to ServerProperties and started using the constants in place of string literals in various places.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties index f9bdc30..e44b3ac 100644 --- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties +++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties @@ -7,10 +7,10 @@ rhq.cassandra.basedir=${rhq.rootDir}
# The username with which to authenticate requests to Cassandra. -rhq.storage.username=rhqadmin +# rhq.storage.username=
# The password with which to authenticate requests to Cassandra. -rhq.storage.password=1eeb2f255e832171df8592078de921bc +# rhq.storage.password=
# Defines the number of tokens randomly assigned to a node on the ring. The more tokens, # relative to other nodes, the larger the proportion of data that this node will store. You diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java index fb9f127..778b8d5 100644 --- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java +++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/AbstractManager.java @@ -40,6 +40,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.rhq.cassandra.util.ClusterBuilder; +import org.rhq.core.util.obfuscation.PicketBoxObfuscator;
/** * @author Stefan Negrea @@ -53,12 +54,7 @@ abstract class AbstractManager { private final Log log = LogFactory.getLog(AbstractManager.class);
enum Query { - USER_EXISTS, - SCHEMA_EXISTS, - VERSION_COLUMNFAMILY_EXISTS, - VERSION, - REPLICATION_FACTOR, - INSERT_SCHEMA_VERSION; + USER_EXISTS, SCHEMA_EXISTS, VERSION_COLUMNFAMILY_EXISTS, VERSION, REPLICATION_FACTOR, INSERT_SCHEMA_VERSION;
@Override public String toString() { @@ -295,7 +291,6 @@ abstract class AbstractManager { return execute(queryString); }
- /** * Execute all the queries in an update file as returned by @link {@link UpdateFile#getOrderedSteps()}. * @@ -334,7 +329,13 @@ abstract class AbstractManager {
log.info("Applying update file: " + updateFile); for (String step : updateFile.getOrderedSteps(properties)) { - log.info("Statement: \n" + step); + if (step.toUpperCase().contains("CREATE USER")) { + // the task file must not contain plain text passwords, so assume it needs to be decoded + step = replaceEncodedPassword(step); + log.debug("Statement: \n" + step); + } else { + log.info("Statement: \n" + step); + } results.add(execute(step)); } log.info("Applied update file: " + updateFile); @@ -342,6 +343,15 @@ abstract class AbstractManager { return results; }
+ private String replaceEncodedPassword(String step) { + int firstQuoteIndex = step.indexOf("'"); + int lastQuoteIndex = step.lastIndexOf("'"); + String encodedPassword = step.substring(++firstQuoteIndex, lastQuoteIndex); + String decodedPassword = PicketBoxObfuscator.decode(encodedPassword); + String decodedStep = step.replace(encodedPassword, decodedPassword); + return decodedStep; + } + /** * Execute a CQL query. * diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java index 9184af3..e71d12f 100644 --- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java +++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java @@ -36,7 +36,6 @@ import org.apache.commons.logging.LogFactory; import org.rhq.cassandra.schema.exception.InstalledSchemaTooAdvancedException; import org.rhq.cassandra.schema.exception.InstalledSchemaTooOldException; import org.rhq.cassandra.schema.exception.SchemaNotInstalledException; -import org.rhq.core.util.obfuscation.PicketBoxObfuscator;
/** * @author Stefan Negrea @@ -107,7 +106,7 @@ class VersionManager extends AbstractManager { properties.put("replication_factor", calculateNewReplicationFactor() + ""); properties.put("cassandra_user_password", UUID.randomUUID() + ""); properties.put("rhq_admin_username", getUsername()); - properties.put("rhq_admin_password", PicketBoxObfuscator.decode(getPassword())); + properties.put("rhq_admin_password", getPassword());
/** * NOTE: Before applying any schema, we need to create the rhqadmin user. If we have more diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml index 086f15e..5c8da9b 100644 --- a/modules/core/dbutils/pom.xml +++ b/modules/core/dbutils/pom.xml @@ -17,7 +17,7 @@ <description>Database schema setup, upgrade and other utilities</description>
<properties> - <db.schema.version>2.140</db.schema.version> + <db.schema.version>2.141</db.schema.version> <rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping> <rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name> <rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name> diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml index c6da7d2..671853f 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml @@ -143,11 +143,15 @@ PROPERTY_VALUE="true" DEFAULT_PROPERTY_VALUE="true" FREAD_ONLY="TRUE"/>
- <!-- STORAGE_CQL_PORT and STORAGE_GOSSIP_PORT will get updated by the installer --> + <!-- STORAGE_USERNAME, STORAGE_PASSWORD, STORAGE_CQL_PORT and STORAGE_GOSSIP_PORT will get updated by the installer --> <data ID="61" PROPERTY_KEY="STORAGE_CQL_PORT" FREAD_ONLY="TRUE"/>
<data ID="62" PROPERTY_KEY="STORAGE_GOSSIP_PORT" FREAD_ONLY="TRUE"/>
+ <data ID="63" PROPERTY_KEY="STORAGE_USERNAME" FREAD_ONLY="TRUE"/> + + <data ID="64" PROPERTY_KEY="STORAGE_PASSWORD" FREAD_ONLY="TRUE"/> + </table>
</dbsetup> 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 e98c95e..94688f6 100644 --- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml +++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml @@ -2036,6 +2036,8 @@ </schema-directSQL> </schemaSpec>
+<!-- RHQ 4.7.0 uses DB Schema 2.132 --> + <schemaSpec version="2.133"> <!-- RHQ_STORAGE_NODE --> <schema-createSequence name="RHQ_STORAGE_NODE_ID_SEQ" initial="10001" /> @@ -2073,6 +2075,8 @@ </schema-directSQL> </schemaSpec>
+<!-- RHQ 4.7.0 uses DB Schema 2.133 --> + <schemaSpec version="2.134"> <!-- Make sure existing storage nodes are storing IP addresses and not hostnames --> <schema-javaTask className="StorageNodeAddressUpgradeTask" /> @@ -2252,6 +2256,33 @@ </statement> </schema-directSQL> </schemaSpec> + +<!-- RHQ 4.9.0 uses DB Schema 2.140 --> + + <schemaSpec version="2.141"> + <schema-directSQL> + <statement targetDBVendor="postgresql" desc="Adding storage username"> + INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value, fread_only) + VALUES (63, 'STORAGE_USERNAME', null, null, true) + </statement> + <statement targetDBVendor="oracle" desc="Adding storage username"> + INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value, fread_only) + VALUES (63, 'STORAGE_USERNAME', null, null, 1) + </statement> + </schema-directSQL> + + <schema-directSQL> + <statement targetDBVendor="postgresql" desc="Adding storage password"> + INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value, fread_only) + VALUES (64, 'STORAGE_PASSWORD', null, null, true) + </statement> + <statement targetDBVendor="oracle" desc="Adding default storage password"> + INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value, fread_only) + VALUES (64, 'STORAGE_PASSWORD', null, null, 1) + </statement> + </schema-directSQL> + </schemaSpec> + </dbupgrade> </target> </project> diff --git a/modules/core/util/src/main/java/org/rhq/core/util/obfuscation/Obfuscator.java b/modules/core/util/src/main/java/org/rhq/core/util/obfuscation/Obfuscator.java index 4743548..2198f9e 100644 --- a/modules/core/util/src/main/java/org/rhq/core/util/obfuscation/Obfuscator.java +++ b/modules/core/util/src/main/java/org/rhq/core/util/obfuscation/Obfuscator.java @@ -119,9 +119,18 @@ public final class Obfuscator { return new String(decode); }
- // adapted from http://stackoverflow.com/questions/2863852/how-to-generate-a-random-string-i... + /** + * Adapted from http://stackoverflow.com/questions/2863852/how-to-generate-a-random-string-i.... + * <p/> + * The default set of validCharacters: 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @param random + * @param validCharacters + * @param length + * @return + */ public static String generateString(Random random, String validCharacters, int length) { - validCharacters = (null == validCharacters || validCharacters.isEmpty()) ? "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#$" + validCharacters = (null == validCharacters || validCharacters.isEmpty()) ? "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" : validCharacters; length = (length < 1) ? 10 : length;
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml index c76ba7b..6c2f6f9 100644 --- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml +++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml @@ -21,9 +21,12 @@
<property name="default.rhq.server.drift.binary.content" value="false"/>
+ <property name="default.rhq.storage.username" value=""/> + <property name="default.rhq.storage.password" value=""/> + <property name="default.jboss.bind.address" value=""/>
- <target name="set-predeploy-prop"> + <target name="set-predeploy-prop"> <condition property="predeploy" value="true"> <or> <equals arg1="${dev.profile.active}" arg2="true" /> @@ -46,6 +49,9 @@ <property name="rhq.server.quartz.selectWithLockSQL" value="${rhq.dev.quartz.selectWithLockSQL}" /> <property name="rhq.server.quartz.lockHandlerClass" value="${rhq.dev.quartz.lockHandlerClass}" /> <property name="rhq.server.drift.store-binary-content" value="${default.rhq.server.drift.binary.content}"/> + <!-- these are only set explicitly in dev envs, prod envs generate these at install time --> + <property name="rhq.storage.username" value="rhqadmin"/> + <property name="rhq.storage.password" value="1eeb2f255e832171df8592078de921bc"/> <!-- this is only set explicitly in dev envs, prod envs must set these manually for security --> <property name="jboss.bind.address" value="0.0.0.0"/> </target> @@ -64,6 +70,9 @@ <property name="rhq.server.quartz.selectWithLockSQL" value="${default.rhq.server.quartz.selectWithLockSQL}" /> <property name="rhq.server.quartz.lockHandlerClass" value="${default.rhq.server.quartz.lockHandlerClass}" /> <property name="rhq.server.drift.store-binary-content" value="${default.rhq.server.drift.binary.content}"/> + <!-- these are only set explicitly in dev envs, prod envs generate these at install time --> + <property name="rhq.storage.username" value="${default.rhq.storage.username}"/> + <property name="rhq.storage.password" value="${default.rhq.storage.password}"/> <!-- this is only set by default in dev envs, prod envs must set these manually for security --> <property name="jboss.bind.address" value="${default.jboss.bind.address}"/> </target> @@ -419,10 +428,10 @@ <target name="prepare-bin-dir"> <echo>*** Preparing bin dir ***</echo>
- <loadproperties> - <zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-ccm-core/${project.version}/rhq-cassandra-ccm-core-${project.version}.jar" + <loadproperties> + <zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-ccm-core/${project.version}/rhq-cassandra-ccm-core-${project.version}.jar" name="cassandra.properties"/> - </loadproperties> + </loadproperties>
<echo>Connection URL is ${rhq.server.database.connection-url}</echo>
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java index 7d3d4e0..04f5cff 100644 --- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java +++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/Installer.java @@ -228,7 +228,7 @@ public class Installer { }
case 'e': { - // prompt for the password. we don't use a command line option because then the plain test password + // prompt for the password. we don't use a command line option because then the plain text password // could get captured in command history. Console console = System.console(); if (null != console) { @@ -262,13 +262,12 @@ public class Installer { } }
- // if a password was asked to be obfuscated, that's all we do on the execution + // if a password was asked to be encoded, that's all we do on the execution if (passwordToEncode != null) { - String obfuscatedPassword = new InstallerServiceImpl(installerConfig).obfuscatePassword(String + String encodedPassword = new InstallerServiceImpl(installerConfig).obfuscatePassword(String .valueOf(passwordToEncode)); - LOG.info("*** Encoded password properties for rhq-server.properties:"); - LOG.info("*** rhq.server.database.password=" + obfuscatedPassword); - LOG.info("*** rhq.storage.password=" + obfuscatedPassword); + LOG.info("*** Encoded password for rhq-server.properties:"); + LOG.info("*** rhq.server.database.password=" + encodedPassword);
return new WhatToDo[] { WhatToDo.DO_NOTHING }; } diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java index 906e4ea..4b42c53 100644 --- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java +++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java @@ -265,7 +265,8 @@ public class InstallerServiceImpl implements InstallerService { // create an rhqadmin management user so when discovered, the AS7 plugin can immediately // connect to the RHQ Server. The password is generated as we try to make the RHQ server manageable by // the plugin without the user having to get involved. - String managementPassword = Obfuscator.generateString(new Random(), null, 8); + Random random = new Random(); + String managementPassword = Obfuscator.generateString(random, null, 8); ServerInstallUtil.createDefaultManagementUser(managementPassword, serverDetails, appServerConfigDir);
// Doing this prior to prepareDatabase sets the property before they are validated and saved. @@ -275,6 +276,21 @@ public class InstallerServiceImpl implements InstallerService { String encodedManagementPassword = Obfuscator.encode(managementPassword); serverProperties.put(ServerProperties.PROP_MGMT_USER_PASSWORD, encodedManagementPassword);
+ // Similarly generate a storage username and password, and encode the password. If already set, don't + // override. This allows for canned values in a dev env, or user override in a prod env. + String storageUsername = serverProperties.get(ServerProperties.PROP_STORAGE_USERNAME); + String storagePassword = serverProperties.get(ServerProperties.PROP_STORAGE_PASSWORD); + if (ServerInstallUtil.isEmpty(storageUsername)) { + // note, limit to alpha usernames to ensure we don't violate cassandra identifier rules + storageUsername = Obfuscator.generateString(random, "abcdefghijklmnopqrstuvwxyz", 8); + serverProperties.put(ServerProperties.PROP_STORAGE_USERNAME, storageUsername); + } + if (ServerInstallUtil.isEmpty(storagePassword)) { + storagePassword = Obfuscator.generateString(random, null, 8); + String encodedStoragePassword = PicketBoxObfuscator.encode(storagePassword); + serverProperties.put(ServerProperties.PROP_STORAGE_PASSWORD, encodedStoragePassword); + } + prepareDatabase(serverProperties, serverDetails, existingSchemaOption);
// perform stuff that has to get done via the JBossAS management client @@ -490,6 +506,19 @@ public class InstallerServiceImpl implements InstallerService { throw new Exception("Could not complete the database schema installation", e); }
+ // if the storage cluster credentials are already set (typically an HA install), override + // what's currently in the server properties file, and then continue with storage schema setup + Map<String, String> storageProperties = ServerInstallUtil.fetchStorageClusterSettings(serverProperties, + clearTextDbPassword); + String storageUsernameSetting = storageProperties.get(ServerProperties.PROP_STORAGE_USERNAME); + String storagePasswordSetting = storageProperties.get(ServerProperties.PROP_STORAGE_PASSWORD); + if (null != storageUsernameSetting) { + serverProperties.put(ServerProperties.PROP_STORAGE_USERNAME, storageUsernameSetting); + } + if (null != storagePasswordSetting) { + serverProperties.put(ServerProperties.PROP_STORAGE_PASSWORD, storagePasswordSetting); + } + SchemaManager storageNodeSchemaManager = null; try { storageNodeSchemaManager = createStorageNodeSchemaManager(serverProperties); @@ -1174,8 +1203,8 @@ public class InstallerServiceImpl implements InstallerService { }
private List<StorageNode> parseNodeInformation(HashMap<String, String> serverProps) { - String[] nodes = serverProps.get("rhq.storage.nodes").split(","); - String cqlPort = serverProps.get("rhq.storage.cql-port"); + String[] nodes = serverProps.get(ServerProperties.PROP_STORAGE_NODES).split(","); + String cqlPort = serverProps.get(ServerProperties.PROP_STORAGE_CQL_PORT);
List<StorageNode> parsedNodes = new ArrayList<StorageNode>(); for (String node : nodes) { @@ -1189,8 +1218,8 @@ public class InstallerServiceImpl implements InstallerService { }
private SchemaManager createStorageNodeSchemaManager(HashMap<String, String> serverProps) { - String username = serverProps.get("rhq.storage.username"); - String password = serverProps.get("rhq.storage.password"); + String username = serverProps.get(ServerProperties.PROP_STORAGE_USERNAME); + String password = serverProps.get(ServerProperties.PROP_STORAGE_PASSWORD);
List<StorageNode> storageNodes = this.parseNodeInformation(serverProps); String[] nodes = new String[storageNodes.size()]; diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java index 8b9ce6f..c01ef5c 100644 --- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java +++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java @@ -977,6 +977,64 @@ public class ServerInstallUtil { } }
+ public static Map<String, String> fetchStorageClusterSettings(HashMap<String, String> serverProperties, + String password) throws Exception { + + Map<String, String> result = new HashMap<String, String>(4); + DatabaseType db = null; + Connection connection = null; + PreparedStatement statement = null; + + try { + String dbUrl = serverProperties.get(ServerProperties.PROP_DATABASE_CONNECTION_URL); + String userName = serverProperties.get(ServerProperties.PROP_DATABASE_USERNAME); + connection = getDatabaseConnection(dbUrl, userName, password); + db = DatabaseTypeFactory.getDatabaseType(connection); + + if (!(db instanceof PostgresqlDatabaseType || db instanceof OracleDatabaseType)) { + throw new IllegalArgumentException("Unknown database type, can't continue: " + db); + } + + connection = getDatabaseConnection(dbUrl, userName, password); + connection.setAutoCommit(false); + + statement = connection.prepareStatement("" // + + "SELECT property_key, property_value FROM rhq_system_config " // + + " WHERE property_key LIKE 'STORAGE%' " // + + " AND NOT property_value IS NULL "); + ResultSet rs = statement.executeQuery(); + + while (rs.next()) { + String key = rs.getString(1); + String value = rs.getString(2); + + if (key.equals("STORAGE_USERNAME")) { + result.put(ServerProperties.PROP_STORAGE_USERNAME, value); + } else if (key.equals("STORAGE_PASSWORD")) { + result.put(ServerProperties.PROP_STORAGE_PASSWORD, value); + } else if (key.equals("STORAGE_GOSSIP_PORT")) { + result.put(ServerProperties.PROP_STORAGE_GOSSIP_PORT, value); + } else if (key.equals("STORAGE_CQL_PORT")) { + result.put(ServerProperties.PROP_STORAGE_CQL_PORT, value); + } + } + + connection.commit(); + + } catch (SQLException e) { + LOG.error("Failed to fetch storage cluster settings. Transaction will be rolled back.", e); + connection.rollback(); + throw e; + } finally { + if (db != null) { + db.closeStatement(statement); + db.closeConnection(connection); + } + } + + return result; + } + public static void persistStorageClusterSettingsIfNecessary(HashMap<String, String> serverProperties, String password) throws Exception { DatabaseType db = null; @@ -1000,13 +1058,23 @@ public class ServerInstallUtil { + "SET property_value = ?, default_property_value = ? " + "WHERE property_key = ? AND property_value IS NULL AND default_property_value IS NULL");
- updateClusterSetting.setString(1, serverProperties.get("rhq.storage.cql-port")); - updateClusterSetting.setString(2, serverProperties.get("rhq.storage.cql-port")); + updateClusterSetting.setString(1, serverProperties.get(ServerProperties.PROP_STORAGE_USERNAME)); + updateClusterSetting.setString(2, serverProperties.get(ServerProperties.PROP_STORAGE_USERNAME)); + updateClusterSetting.setString(3, "STORAGE_USERNAME"); + updateClusterSetting.executeUpdate(); + + updateClusterSetting.setString(1, serverProperties.get(ServerProperties.PROP_STORAGE_PASSWORD)); + updateClusterSetting.setString(2, serverProperties.get(ServerProperties.PROP_STORAGE_PASSWORD)); + updateClusterSetting.setString(3, "STORAGE_PASSWORD"); + updateClusterSetting.executeUpdate(); + + updateClusterSetting.setString(1, serverProperties.get(ServerProperties.PROP_STORAGE_CQL_PORT)); + updateClusterSetting.setString(2, serverProperties.get(ServerProperties.PROP_STORAGE_CQL_PORT)); updateClusterSetting.setString(3, "STORAGE_CQL_PORT"); updateClusterSetting.executeUpdate();
- updateClusterSetting.setString(1, serverProperties.get("rhq.storage.gossip-port")); - updateClusterSetting.setString(2, serverProperties.get("rhq.storage.gossip-port")); + updateClusterSetting.setString(1, serverProperties.get(ServerProperties.PROP_STORAGE_GOSSIP_PORT)); + updateClusterSetting.setString(2, serverProperties.get(ServerProperties.PROP_STORAGE_GOSSIP_PORT)); updateClusterSetting.setString(3, "STORAGE_GOSSIP_PORT"); updateClusterSetting.executeUpdate();
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerProperties.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerProperties.java index 6177830..6ac264d 100644 --- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerProperties.java +++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerProperties.java @@ -118,6 +118,12 @@ public class ServerProperties {
public static final String PROP_MGMT_USER_PASSWORD = "rhq.server.management.password";
+ public static final String PROP_STORAGE_USERNAME = "rhq.storage.username"; + public static final String PROP_STORAGE_PASSWORD = "rhq.storage.password"; + public static final String PROP_STORAGE_NODES = "rhq.storage.nodes"; + public static final String PROP_STORAGE_CQL_PORT = "rhq.storage.cql-port"; + public static final String PROP_STORAGE_GOSSIP_PORT = "rhq.storage.gossip-port"; + // this list contains all the properties that are to have boolean values (true | false) public static final Set<String> BOOLEAN_PROPERTIES; static { @@ -147,6 +153,8 @@ public class ServerProperties { INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_MEASSCHED_REQ); INTEGER_PROPERTIES.add(PROP_CONCURRENCY_LIMIT_WEBCONNS); INTEGER_PROPERTIES.add(PROP_AGENT_MULTICAST_DETECTOR_PORT); + INTEGER_PROPERTIES.add(PROP_STORAGE_CQL_PORT); + INTEGER_PROPERTIES.add(PROP_STORAGE_GOSSIP_PORT); }
// this list contains all the properties that are to have non-empty string values
rhq-commits@lists.fedorahosted.org