modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java | 8 ++ modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java | 30 ++++++++++ modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java | 24 +++++--- modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml | 12 ++-- 4 files changed, 60 insertions(+), 14 deletions(-)
New commits: commit 151cff225dfbe064eda95ab5488ec36df4dedf18 Author: Jay Shaughnessy jshaughn@jshaughn.csb Date: Fri Sep 28 17:59:59 2012 -0400
Start migrating RHQ Server support to AS7 plugin/platform - Identify the AS7 process as an RHQ Server and tweak the resource name in discovery - Have the installer create a default rhqadmin mgmt user so that the RHQ Server resource will allow for an immediate connection with the plugin - Update the runs-inside elements in the rhq-server plugin desc to use the AS7 plugin *** The service are not yet integrated properly
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java index 5c73766..c252569 100644 --- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java +++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java @@ -328,8 +328,14 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins // ensure the server info is up to date and stored in the DB ServerInstallUtil.storeServerDetails(serverProperties, clearTextDbPassword, serverDetails);
+ String appServerConfigDir = getAppServerConfigDir(); + // create a keystore whose cert has a CN of this server's public endpoint address - ServerInstallUtil.createKeystore(serverDetails, getAppServerConfigDir()); + ServerInstallUtil.createKeystore(serverDetails, appServerConfigDir); + + // create an rhqadmin/rhqadmin management user so when discovered, the AS7 plugin can immediately + // connect to the RHQ Server. + ServerInstallUtil.createDefaultManagementUser(serverDetails, appServerConfigDir);
// perform stuff that has to get done via the JBossAS management client ModelControllerClient mcc = null; diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java index aa3faff..6d002de 100644 --- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java +++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java @@ -1230,6 +1230,36 @@ public class ServerInstallUtil { } }
+ /** + * Create an rhqadmin/rhqadmin management user so when discovered, the AS7 plugin can immediately + * connect to the RHQ Server. + * + * @param serverDetails details of the server being installed + * @param configDirStr location of a configuration directory where the mgmt-users.properties file lives + */ + public static void createDefaultManagementUser(ServerDetails serverDetails, String configDirStr) { + File confDir = new File(configDirStr); + File mgmtUsers = new File(confDir, "mgmt-users.properties"); + + // Add the default admin user, or if for some reason this file does not exist, just log the issue + if (mgmtUsers.exists()) { + FileOutputStream fos = null; + + try { + fos = new FileOutputStream(mgmtUsers, true); + fos.write("\nrhqadmin=35c160c1f841a889d4cda53f0bfc94b6\n".getBytes()); + + } catch (Exception e) { + LOG.warn("Could not create default management user in file: [" + mgmtUsers.getPath() + "] : ", e); + + } finally { + StreamUtil.safeClose(fos); + } + } else { + LOG.warn("Could not create default management user. Could not find file: [" + mgmtUsers.getPath() + "]"); + } + } + public static File getMarkerFile(String dir, String artifact, Marker marker) { File markerFile = new File(dir, artifact + marker.getExtenstion()); return markerFile; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java index efa814d..1220aaf 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASDiscovery.java @@ -18,10 +18,6 @@ */ package org.rhq.modules.plugins.jbossas7;
-import java.io.File; - -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.system.ProcessInfo; @@ -69,7 +65,8 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery { }
@Override - protected String buildDefaultResourceName(HostPort hostPort, HostPort managementHostPort, JBossProductType productType) { + protected String buildDefaultResourceName(HostPort hostPort, HostPort managementHostPort, + JBossProductType productType) { return String.format("%s (%s:%d)", productType.SHORT_NAME, managementHostPort.host, managementHostPort.port); }
@@ -80,9 +77,15 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery {
@Override protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContext discoveryContext, - ProcessInfo process, AS7CommandLine commandLine) throws Exception { + ProcessInfo process, AS7CommandLine commandLine) throws Exception { + DiscoveredResourceDetails resourceDetails = super.buildResourceDetails(discoveryContext, process, commandLine); - Configuration pluginConfig = resourceDetails.getPluginConfiguration(); + + // Do RHQ Server specific work + if (isRhqServer(process)) { + String name = resourceDetails.getResourceName(); + resourceDetails.setResourceName(name + " RHQ Server"); + }
return resourceDetails; } @@ -93,4 +96,11 @@ public class StandaloneASDiscovery extends BaseProcessDiscovery { return process.getParentProcess(); }
+ private boolean isRhqServer(ProcessInfo process) { + + String javaOpts = process.getEnvironmentVariable("JAVA_OPTS"); + + return (null != javaOpts && javaOpts.contains("-Dapp.name=rhq-server")); + } + } diff --git a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml index 651d290..1052390 100644 --- a/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/rhq-server/src/main/resources/META-INF/rhq-plugin.xml @@ -14,7 +14,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration> @@ -98,7 +98,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration> @@ -160,7 +160,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration> @@ -206,7 +206,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration> @@ -283,7 +283,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration> @@ -328,7 +328,7 @@ singleton="true">
<runs-inside> - <parent-resource-type name="JBossAS Server" plugin="JBossAS"/> + <parent-resource-type name="JBossAS7 Standalone Server" plugin="JBossAS7"/> </runs-inside>
<plugin-configuration>
rhq-commits@lists.fedorahosted.org