[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e486ae34722cff4146a22d446a99f4a2d95d4659
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 14 23:55:21 2010 -0400
A temporary fix for getting around the ResourceSearchView not rendering
issue. This is a precursor to a more comprehensive change that aims to
solve issues regarding grid field vs ds field use.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index 7c6aaf9..15bf220 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,7 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
- idField.setHidden(true);
+ //idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
13 years, 8 months
[rhq] Branch 'nagios' - 2 commits - modules/core modules/plugins
by Alexander Kiefer
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 21 +
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 77 ++++++-
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeComponent.java | 109 +++++-----
modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeDiscovery.java | 103 ++++-----
4 files changed, 201 insertions(+), 109 deletions(-)
New commits:
commit 29ff68ac16801f0da8cadbdc7b37f8cd6dcbdc33
Author: Alexander Kiefer <alexander.kiefer(a)dillinger.biz>
Date: Fri Oct 15 01:20:13 2010 +0200
Made some changes to enable the usage of child type discovery and
component classes
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
index 0c5e0b6..f2dc59b 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
@@ -55,7 +55,7 @@ public class PluginMetadataManager {
private Object typesLock = new Object();
private Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>();
-
+
public PluginMetadataManager() {
}
@@ -89,13 +89,28 @@ public class PluginMetadataManager {
}
public String getDiscoveryClass(ResourceType resourceType) {
+
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
- return (parser != null) ? parser.getDiscoveryComponentClass(resourceType) : null;
+
+ //TODO: make it more generic without hardcoded comparison
+ if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
+ return (parser != null) ? parser.getChildTypeDiscoveryComponentClass(resourceType) : null;
+ } else {
+ return (parser != null) ? parser.getDiscoveryComponentClass(resourceType) : null;
+ }
+
}
public String getComponentClass(ResourceType resourceType) {
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
- return (parser != null) ? parser.getComponentClass(resourceType) : null;
+
+ //TODO: make it more generic without hardcoded comparison
+ if (parser.getDescriptor().getName().equals("NagiosMonitor")) {
+ return (parser != null) ? parser.getChildTypeComponentClass(resourceType) : null;
+ } else {
+ return (parser != null) ? parser.getComponentClass(resourceType) : null;
+ }
+
}
/**
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 686b16b..95a8943 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -80,6 +80,13 @@ public class PluginMetadataParser {
private Map<ResourceType, String> discoveryClasses = new HashMap<ResourceType, String>();
private Map<ResourceType, String> componentClasses = new HashMap<ResourceType, String>();
+ private String childTypeDiscoveryClass;
+ private String childTypeComponentClass;
+
+ //Hashmaps for ChildType discovery and component classes
+ private Map<ResourceType, String> childTypeDiscoveryClasses = new HashMap<ResourceType, String>();
+ private Map<ResourceType, String> childTypeComponentClasses = new HashMap<ResourceType, String>();
+
// a map keyed on plugin name that contains the parsers for all other known plugin descriptors
// this map is managed by this parser's PluginMetadataManager and is how the manager shares information
// from other plugins to this parser instance
@@ -87,6 +94,10 @@ public class PluginMetadataParser {
public PluginMetadataParser(PluginDescriptor descriptor, Map<String, PluginMetadataParser> parsersByPlugin)
throws InvalidPluginDescriptorException {
+
+ this.childTypeDiscoveryClass = null;
+ this.childTypeComponentClass = null;
+
this.pluginDescriptor = descriptor;
this.parsersByPlugin = parsersByPlugin;
parseDescriptor();
@@ -189,7 +200,23 @@ public class PluginMetadataParser {
.setCreateDeletePolicy(convertCreateDeletePolicy(serverDescriptor.getCreateDeletePolicy()));
serverResourceType.setSingleton(serverDescriptor.isSingleton());
- parseResourceDescriptor(serverDescriptor, serverResourceType, null, null, null);
+ String childTypeDiscovery = null;
+ String childTypeClass = null;
+
+ //get childType discovery and component class names
+ this.childTypeDiscoveryClass = serverDescriptor.getChildTypeDiscovery();
+ this.childTypeComponentClass = serverDescriptor.getChildTypeClass();
+
+ //Check if it is the Nagios plugin and if the serverResourceType is a child
+ //Only nagios plugin decriptor has child type discovery and component class tags
+ if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null
+ && parentServerType != null) {
+ parseResourceDescriptor(serverDescriptor, serverResourceType, this.childTypeDiscoveryClass,
+ this.childTypeComponentClass, null);
+ } else {
+ parseResourceDescriptor(serverDescriptor, serverResourceType, null, null, null);
+ }
+
LOG.debug("Parsed server Resource type: " + serverResourceType);
} else if ((sourcePlugin.length() > 0) && (sourceServer.length() > 0)) {
// using Embedded extension model - the defined type is actually a copy of another plugin's server type
@@ -307,7 +334,16 @@ public class PluginMetadataParser {
.getCreateDeletePolicy()));
serviceResourceType.setSingleton(serviceDescriptor.isSingleton());
- parseResourceDescriptor(serviceDescriptor, serviceResourceType, null, null, null);
+ //Check if it is the Nagios plugin and if the serviceResourceType is a child
+ //Only nagios plugin decriptor has child type discovery and component class tags
+ if (this.childTypeDiscoveryClass != null && this.childTypeComponentClass != null && parentType != null) {
+ parseResourceDescriptor(serviceDescriptor, serviceResourceType, this.childTypeDiscoveryClass,
+ this.childTypeComponentClass, null);
+ } else {
+ parseResourceDescriptor(serviceDescriptor, serviceResourceType, null, null, null);
+
+ }
+
LOG.debug("Parsed service Resource type: " + serviceResourceType);
if ((serviceResourceType.getProcessScans() != null) && (serviceResourceType.getProcessScans().size() > 0)) {
@@ -597,13 +633,44 @@ public class PluginMetadataParser {
return this.componentClasses.get(resourceType);
}
+ /**
+ * Returns the fully qualified name of the resource discovery component class for the given Child ResourceType.
+ *
+ * @param resourceType the ResourceType
+ * @return the resource discovery component class name
+ */
+ public String getChildTypeDiscoveryComponentClass(ResourceType resourceType) {
+ return this.childTypeDiscoveryClasses.get(resourceType);
+ }
+
+ /**
+ * Returns the fully qualified name of the resource component class for the given Child ResourceType.
+ *
+ * @param resourceType the ResourceType
+ * @return the resource component class name
+ */
+ public String getChildTypeComponentClass(ResourceType resourceType) {
+ return this.childTypeComponentClasses.get(resourceType);
+ }
+
private void registerResourceTypeAndComponentClasses(ResourceType resourceType, String discoveryClass,
String componentClass) {
this.resourceTypes.add(resourceType);
- this.componentClasses.put(resourceType, componentClass);
- if (discoveryClass != null) {
- this.discoveryClasses.put(resourceType, discoveryClass);
+
+ //if it is the child resource type of Nagios plugin
+ if (discoveryClass.equals(this.childTypeDiscoveryClass) && componentClass.equals(this.childTypeComponentClass)) {
+ //Put the childresource type and its discovery and component classes to the childtype map
+ this.childTypeComponentClasses.put(resourceType, componentClass);
+ if (discoveryClass != null) {
+ this.childTypeDiscoveryClasses.put(resourceType, discoveryClass);
+ }
+ } else {
+ this.componentClasses.put(resourceType, componentClass);
+ if (discoveryClass != null) {
+ this.discoveryClasses.put(resourceType, discoveryClass);
+ }
}
+
}
private Map<String, ServerDescriptor> getPluginServerDescriptors(String pluginName) {
commit e24a63de7dc5d32cd1a6dee328353b441986d17a
Author: Alexander Kiefer <alexander.kiefer(a)dillinger.biz>
Date: Fri Oct 15 01:18:59 2010 +0200
Made the child type discovery and component classes ready to work
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeComponent.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeComponent.java
index ddb5a50..facde60 100755
--- a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeComponent.java
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeComponent.java
@@ -21,12 +21,17 @@ package org.rhq.plugins.nagios;
import java.util.HashSet;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
@@ -38,6 +43,8 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.plugins.nagios.controller.NagiosManagementInterface;
+import org.rhq.plugins.nagios.data.NagiosSystemData;
+import org.rhq.plugins.nagios.error.NagiosException;
/**
*
@@ -59,57 +66,57 @@ public class NagiosMonitorChildTypeComponent implements ResourceComponent, Measu
@Override
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- // NagiosSystemData nagiosSystemData = null;
- // String serviceName = this.context.getResourceType().getName();
- // log.info("getValues() of ResourceType: " + serviceName);
- //
- // try {
- // //Getting all Nagios system information
- // nagiosSystemData = nagiosManagementInterface.createNagiosSystemData();
- // } catch (Exception e) {
- // log.warn(" Can not get information from Nagios: ", e);
- // return;
- // }
- //
- // //iterating over the metrics
- // for (MeasurementScheduleRequest req : metrics) {
- // try { // Don't let one bad egg spoil the cake
- //
- // String[] splitter = req.getName().split("\\|");
- // String property = splitter[1];
- // String pattern = splitter[2];
- //
- // if (log.isDebugEnabled()) {
- // log.debug("Name of Metric: " + property);
- // log.debug("RegEx: " + pattern);
- // }
- //
- // // Get "raw" data from nagios data structures - we need to pick our value below
- // String value = nagiosSystemData.getSingleHostServiceMetric(property, serviceName, "localhost")
- // .getValue(); // TODO use 'real' host
- //
- // Pattern p = Pattern.compile(pattern);
- // Matcher m = p.matcher(value);
- // if (m.matches()) {
- // String val = m.group(1); // Our metric is always in the first match group.
- //
- // // We have a match, now dispatch by dataType of the request
- // if (req.getDataType() == DataType.MEASUREMENT) {
- // MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
- // report.addData(res);
- // } else if (req.getDataType() == DataType.TRAIT) {
- // MeasurementDataTrait res = new MeasurementDataTrait(req, val);
- // report.addData(res);
- // } else
- // log.error("Unknown DataType for request " + req);
- // } else {
- // log.warn("Pattern >>" + pattern + "<< did not match for input >>" + value + "<< and request: >>"
- // + req.getName());
- // }
- // } catch (NagiosException e) {
- // log.error(e);
- // }
- // }
+ NagiosSystemData nagiosSystemData = null;
+ String serviceName = this.context.getResourceType().getName();
+ log.info("getValues() of ResourceType: " + serviceName);
+
+ try {
+ //Getting all Nagios system information
+ nagiosSystemData = nagiosManagementInterface.createNagiosSystemData();
+ } catch (Exception e) {
+ log.warn(" Can not get information from Nagios: ", e);
+ return;
+ }
+
+ //iterating over the metrics
+ for (MeasurementScheduleRequest req : metrics) {
+ try { // Don't let one bad egg spoil the cake
+
+ String[] splitter = req.getName().split("\\|");
+ String property = splitter[1];
+ String pattern = splitter[2];
+
+ if (log.isDebugEnabled()) {
+ log.debug("Name of Metric: " + property);
+ log.debug("RegEx: " + pattern);
+ }
+
+ // Get "raw" data from nagios data structures - we need to pick our value below
+ String value = nagiosSystemData.getSingleHostServiceMetric(property, serviceName, "localhost")
+ .getValue(); // TODO use 'real' host
+
+ Pattern p = Pattern.compile(pattern);
+ Matcher m = p.matcher(value);
+ if (m.matches()) {
+ String val = m.group(1); // Our metric is always in the first match group.
+
+ // We have a match, now dispatch by dataType of the request
+ if (req.getDataType() == DataType.MEASUREMENT) {
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
+ report.addData(res);
+ } else if (req.getDataType() == DataType.TRAIT) {
+ MeasurementDataTrait res = new MeasurementDataTrait(req, val);
+ report.addData(res);
+ } else
+ log.error("Unknown DataType for request " + req);
+ } else {
+ log.warn("Pattern >>" + pattern + "<< did not match for input >>" + value + "<< and request: >>"
+ + req.getName());
+ }
+ } catch (NagiosException e) {
+ log.error(e);
+ }
+ }
}
diff --git a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeDiscovery.java b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeDiscovery.java
index 32c8f65..b4f961f 100755
--- a/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeDiscovery.java
+++ b/modules/plugins/nagios/src/main/java/org/rhq/plugins/nagios/NagiosMonitorChildTypeDiscovery.java
@@ -19,18 +19,23 @@ package org.rhq.plugins.nagios;
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.nagios.network.NetworkConnection;
import org.rhq.plugins.nagios.reply.LqlReply;
+import org.rhq.plugins.nagios.request.LqlResourceTypeRequest;
/**
*
@@ -45,40 +50,40 @@ public class NagiosMonitorChildTypeDiscovery implements ResourceDiscoveryCompone
* Don run the auto-discovery for the services below the NagiosMonitor server type.
*/
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
- // Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
- //
- // // If we have no parent, it means the NagioMonitoring server type is not yet up.
- // ResourceComponent tmpComponent = discoveryContext.getParentResourceComponent();
- // if (tmpComponent == null || !(tmpComponent instanceof NagiosMonitorComponent))
- // return discoveredResources;
- //
- // NagiosMonitorComponent parentComponent = (NagiosMonitorComponent) tmpComponent;
- // String nagiosHost = parentComponent.getNagiosHost();
- // int nagiosPort = parentComponent.getNagiosPort();
- //
- // //Method requests available nagios services an returns the names of them
- // LqlReply resourceTypeReply = getResourceTypeInformation(nagiosHost, nagiosPort);
- //
- // // the resource type we are interested in this invocation
- // ResourceType wanted = discoveryContext.getResourceType();
- // //for each available service
- // for (int i = 0; i < resourceTypeReply.getLqlReply().size(); i++) {
- //
- // String nagiosType = resourceTypeReply.getLqlReply().get(i);
- // if (!nagiosType.equals(wanted.getName()))
- // continue;
- //
- // //create new DiscoveredResourceDetails instance
- // DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- // //new ResourceType instance per service
- // wanted, "nagiosKey@" + "Nr:" + i + ":" + resourceTypeReply.getLqlReply().get(i), "Nagios@" + "Nr:" + i
- // + ":" + resourceTypeReply.getLqlReply().get(i), null, "NagiosService: "
- // + resourceTypeReply.getLqlReply().get(i), null, null);
- //
- // //add DiscoveredResourceDetails instance to Set
- // discoveredResources.add(detail);
- // log.info("Discovered a nagios service: " + detail);
- // }
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+ // If we have no parent, it means the NagioMonitoring server type is not yet up.
+ ResourceComponent tmpComponent = discoveryContext.getParentResourceComponent();
+ if (tmpComponent == null || !(tmpComponent instanceof NagiosMonitorComponent))
+ return discoveredResources;
+
+ NagiosMonitorComponent parentComponent = (NagiosMonitorComponent) tmpComponent;
+ String nagiosHost = parentComponent.getNagiosHost();
+ int nagiosPort = parentComponent.getNagiosPort();
+
+ //Method requests available nagios services an returns the names of them
+ LqlReply resourceTypeReply = getResourceTypeInformation(nagiosHost, nagiosPort);
+
+ // the resource type we are interested in this invocation
+ ResourceType wanted = discoveryContext.getResourceType();
+ //for each available service
+ for (int i = 0; i < resourceTypeReply.getLqlReply().size(); i++) {
+
+ String nagiosType = resourceTypeReply.getLqlReply().get(i);
+ if (!nagiosType.equals(wanted.getName()))
+ continue;
+
+ //create new DiscoveredResourceDetails instance
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ //new ResourceType instance per service
+ wanted, "nagiosKey@" + "Nr:" + i + ":" + resourceTypeReply.getLqlReply().get(i), "Nagios@" + "Nr:" + i
+ + ":" + resourceTypeReply.getLqlReply().get(i), null, "NagiosService: "
+ + resourceTypeReply.getLqlReply().get(i), null, null);
+
+ //add DiscoveredResourceDetails instance to Set
+ discoveredResources.add(detail);
+ log.info("Discovered a nagios service: " + detail);
+ }
return null;
@@ -90,11 +95,11 @@ public class NagiosMonitorChildTypeDiscovery implements ResourceDiscoveryCompone
* explicitly add it to one platform.
*/
private LqlReply getResourceTypeInformation(String nagiosIp, int nagiosPort) {
- // LqlResourceTypeRequest resourceTypeRequest = new LqlResourceTypeRequest();
- // LqlReply resourceTypeReply;
- //
- // NetworkConnection connection = new NetworkConnection(nagiosIp, nagiosPort);
- // resourceTypeReply = connection.sendAndReceive(resourceTypeRequest);
+ LqlResourceTypeRequest resourceTypeRequest = new LqlResourceTypeRequest();
+ LqlReply resourceTypeReply;
+
+ NetworkConnection connection = new NetworkConnection(nagiosIp, nagiosPort);
+ resourceTypeReply = connection.sendAndReceive(resourceTypeRequest);
return null;
}
@@ -102,18 +107,16 @@ public class NagiosMonitorChildTypeDiscovery implements ResourceDiscoveryCompone
@Override
public DiscoveredResourceDetails discoverResource(Configuration configuration,
ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException {
- //
- // String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
- // String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
- //
- // DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
- // "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
- // "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
- // log.info("Adding NagiosMonitor " + detail);
- //
- // return detail;
- return null;
+ String nagiosHost = configuration.getSimpleValue("nagiosHost", NagiosMonitorComponent.DEFAULT_NAGIOSIP);
+ String nagiosPort = configuration.getSimpleValue("nagiosPort", NagiosMonitorComponent.DEFAULT_NAGIOSPORT);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(),
+ "nagios@" + nagiosHost + ":" + nagiosPort, "Nagios@" + nagiosHost + ":" + nagiosPort, null,
+ "Nagios server @ " + nagiosHost + ":" + nagiosPort, configuration, null);
+ log.info("Adding NagiosMonitor " + detail);
+
+ return detail;
}
}
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java | 147 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java | 45 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java | 90 ++++++
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 17 -
8 files changed, 279 insertions(+), 36 deletions(-)
New commits:
commit 2dfe611b1651f7312816b114b684fb90ec5f6854
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Oct 14 17:09:28 2010 -0400
group alert definition editor. there are still things broken in here. more stuff needs to be fixed/tested
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index 8096fcf..f0916e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -86,6 +86,7 @@
<servlet path="/ContentGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.ContentGWTServiceImpl"/>
<servlet path="/DashboardGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.DashboardGWTServiceImpl"/>
<servlet path="/EventGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.EventGWTServiceImpl"/>
+ <servlet path="/GroupAlertDefinitionGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl"/>
<servlet path="/MeasurementDataGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.MeasurementDataGWTServiceImpl"/>
<servlet path="/OperationGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl"/>
<servlet path="/RemoteInstallGWTService" class="org.rhq.enterprise.gui.coregui.server.gwt.RemoteInstallGWTServiceImpl"/>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
index 183faec..e632915 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -26,15 +26,21 @@ package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
import java.util.EnumSet;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* @author John Mazzitelli
@@ -44,10 +50,12 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
public static final String CRITERIA_GROUP_ID = "groupId";
private ResourceGroup group;
+ private ResourcePermission permissions;
- public GroupAlertDefinitionsView(String locatorId, ResourceGroup group) {
+ public GroupAlertDefinitionsView(String locatorId, ResourceGroupComposite groupComposite) {
super(locatorId, "Group Alert Definitions");
- this.group = group;
+ this.group = groupComposite.getResourceGroup();
+ this.permissions = groupComposite.getResourcePermission();
// make sure we loaded all the type info we'll need. if one of these is null, either the type
// doesn't have it or we haven't loaded it yet. since we can't know for sure if it was loaded, we have to ask.
@@ -86,55 +94,140 @@ public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
}
@Override
+ public SingleAlertDefinitionView getDetailsView(int id) {
+ SingleAlertDefinitionView view = super.getDetailsView(id);
+ if (id == 0) {
+ // when creating a new alert def, make sure to set this in the new alert def
+ view.getAlertDefinition().setResourceGroup(group);
+ }
+ return view;
+ }
+
+ @Override
protected boolean isAllowedToModifyAlertDefinitions() {
- // TODO: see if user can modify group alerts on this group
- return true;
+ return this.permissions.isAlert();
}
@Override
protected void newButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
- for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
- }
- SC.say(str);
+ newDetails();
}
@Override
protected void enableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+
+ GWTServiceLookup.getGroupAlertDefinitionService().enableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions enabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to enable group alert definitions", caught);
+ }
+ });
}
@Override
protected void disableButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().disableGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions disabled.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to disable group alert definitions.", caught);
+ }
+ });
}
@Override
protected void deleteButtonPressed(ListGridRecord[] selection) {
- // TODO Auto-generated method stub
- String str = "this is not implemented yet but you selected";
+ if (selection.length == 0) {
+ return;
+ }
+
+ Integer[] alertDefIds = new Integer[selection.length];
+ int i = 0;
for (ListGridRecord record : selection) {
- str += ": " + record.getAttribute("name");
+ Integer id = record.getAttributeAsInt(AbstractAlertDefinitionsDataSource.FIELD_ID);
+ alertDefIds[i++] = id;
}
- SC.say(str);
+ GWTServiceLookup.getGroupAlertDefinitionService().removeGroupAlertDefinitions(alertDefIds,
+ new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("[" + result + "] group alert definitions deleted.", Severity.Info));
+ GroupAlertDefinitionsView.this.refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to delete group alert definitions.", caught);
+ }
+ });
}
@Override
- protected void commitAlertDefinition(AlertDefinition alertDefinition) {
- // TODO call into server SLSB to store alert def
- // GroupAlertDefinitionManagerLocal groupAlertDefinitionManager = LookupUtil.getGroupAlertDefinitionManager();
- // groupAlertDefinitionManager.updateGroupAlertDefinitions(subject, alertDef, true);
+ protected void commitAlertDefinition(final AlertDefinition alertDefinition) {
+ if (alertDefinition.getId() == 0) {
+ GWTServiceLookup.getGroupAlertDefinitionService().createGroupAlertDefinitions(alertDefinition,
+ Integer.valueOf(this.group.getId()), new AsyncCallback<Integer>() {
+ @Override
+ public void onSuccess(Integer result) {
+ CoreGUI.getMessageCenter().notify(new Message("Alert definition is created", Severity.Info));
+ alertDefinition.setId(result.intValue());
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create alert definition.", caught);
+ }
+ });
+ } else {
+ GWTServiceLookup.getGroupAlertDefinitionService().updateGroupAlertDefinitions(alertDefinition, true,
+ new AsyncCallback<AlertDefinition>() {
+ @Override
+ public void onSuccess(AlertDefinition result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Group alert definition is updated.", Severity.Info));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to update group alert definition.", caught);
+ }
+ });
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
index 3bc7a3f..f53710f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -70,9 +70,8 @@ public class ResourceAlertDefinitionsDataSource extends AbstractAlertDefinitions
+ this.resource.getResourceType().getId() + "&from=" + from.getId() + "&ad=" + parentId);
record.setLinkText("View Template");
} else {
- record.setAttribute(FIELD_PARENT, "/alerts/Config.do?mode=viewRoles&groupId="
- + groupAlertDefinition.getResourceGroup().getId() + "&from=" + from.getId() + "&ad="
- + groupAlertDefinition.getId());
+ record.setAttribute(FIELD_PARENT, "#ResourceGroup/" + groupAlertDefinition.getResourceGroup().getId()
+ + "/Alerts/Definitions/" + groupAlertDefinition.getId());
record.setLinkText("View Group Definition");
}
record.setAttribute(FIELD_READONLY, readOnly);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index ebd0ab5..adc839d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -39,6 +39,10 @@ public class GWTServiceLookup {
return secure(AlertDefinitionGWTServiceAsync.Util.getInstance());
}
+ public static GroupAlertDefinitionGWTServiceAsync getGroupAlertDefinitionService() {
+ return secure(GroupAlertDefinitionGWTServiceAsync.Util.getInstance());
+ }
+
public static ConfigurationGWTServiceAsync getConfigurationService() {
return secure(ConfigurationGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
new file mode 100644
index 0000000..ff4299e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GroupAlertDefinitionGWTService.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.client.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+public interface GroupAlertDefinitionGWTService extends RemoteService {
+
+ int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId) throws Exception;
+
+ /**
+ * Updates a group alert definition.
+ *
+ * @param groupAlertDefinition
+ * @param purgeInternals must be true if you are updating conditions or dampening settings, can be false otherwise
+ * @return the updated definition
+ * @throws Exception
+ */
+ AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception;
+
+ int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+
+ int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception;
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 4f71441..225de69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -40,6 +40,7 @@ import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.alert.definitions.GroupAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.SubTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
@@ -265,6 +266,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
.extendLocatorId("CompositeHistView"), groupComposite), true, true);
}
+ // alerts tab is always visible
+ // TODO what about history subtab?
+ updateSubTab(this.alertsTab, this.alertDef, new GroupAlertDefinitionsView(alertsTab
+ .extendLocatorId("AlertDefView"), this.groupComposite), true, true);
+
this.show();
markForRedraw();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
new file mode 100644
index 0000000..7b65ee2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/GroupAlertDefinitionGWTServiceImpl.java
@@ -0,0 +1,90 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.enterprise.gui.coregui.server.gwt;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.enterprise.gui.coregui.client.gwt.GroupAlertDefinitionGWTService;
+import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
+import org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class GroupAlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implements
+ GroupAlertDefinitionGWTService {
+ private static final long serialVersionUID = 1L;
+
+ private GroupAlertDefinitionManagerLocal groupAlertDefManager = LookupUtil.getGroupAlertDefinitionManager();
+
+ @Override
+ public int createGroupAlertDefinitions(AlertDefinition groupAlertDefinition, Integer resourceGroupId)
+ throws Exception {
+ try {
+ int results = groupAlertDefManager.createGroupAlertDefinitions(getSessionSubject(), groupAlertDefinition,
+ resourceGroupId);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public AlertDefinition updateGroupAlertDefinitions(AlertDefinition groupAlertDefinition, boolean purgeInternals)
+ throws Exception {
+ try {
+ AlertDefinition results = groupAlertDefManager.updateGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinition, purgeInternals);
+ return SerialUtility.prepare(results, "updateGroupAlertDefinitions");
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int enableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .enableGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int disableGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager.disableGroupAlertDefinitions(getSessionSubject(),
+ groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
+ @Override
+ public int removeGroupAlertDefinitions(Integer[] groupAlertDefinitionIds) throws Exception {
+ try {
+ int results = groupAlertDefManager
+ .removeGroupAlertDefinitions(getSessionSubject(), groupAlertDefinitionIds);
+ return results;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index 377ae0d..40e7f16 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -42,18 +42,19 @@
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI AlertDefinitionGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.AlertDefinitionGWTServiceImpl</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.GroupAlertDefinitionGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
- <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl
- </servlet-class>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.OperationGWTServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI BundleGWTService</servlet-name>
@@ -158,6 +159,10 @@
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/AlertDefinitionGWTService</url-pattern>
</servlet-mapping>
<servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI GroupAlertDefinitionGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/GroupAlertDefinitionGWTService</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI OperationGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/OperationGWTService</url-pattern>
</servlet-mapping>
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 2 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
New commits:
commit b671cbfcba20b9ff445b17410a816231e6bcb420
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Oct 14 13:14:15 2010 -0400
i)fixed on more new registration session issue ii)extracted UserSessionManager.invalidateSession() method.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index ff9f246..da1ee4c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -290,7 +290,7 @@ public class LoginView extends Canvas {
IButton logout = new IButton("Logout");
logout.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- UserSessionManager.logout();
+ UserSessionManager.invalidateSession();
window.destroy();
loginShowing = false;
new LoginView().showLoginDialog();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 0dc4482..2d283a3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -176,6 +176,7 @@ public class UserSessionManager {
}
});
} else {//invalid session. Back to login
+ loggedIn = false;
new LoginView().showLoginDialog();
}
}
@@ -301,6 +302,15 @@ public class UserSessionManager {
return; // nothing to do, already called
}
+ invalidateSession();
+ }
+
+ /** There are times when you're logged in but you don't want the application to proceed as if you are.
+ * In these cases, like LDAP new user registration, the session only needs
+ * to be invalidated to reset the user back to the beginning.
+ */
+ public static void invalidateSession() {
+
loggedIn = false;
Log.info("Destroying session timer...");
sessionTimer.cancel();
13 years, 8 months
[rhq] Branch 'release-3.0.0' - 4 commits - modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 109 +++++++---
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 87 +++++--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 90 +++++---
6 files changed, 208 insertions(+), 103 deletions(-)
New commits:
commit 1afdc5b0c20f66a33f3f5965d5e4d7f8b014e9ac
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 16:41:07 2010 +0200
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index a725e57..9356ac9 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -248,7 +248,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
*/
private static String getUrl(ApacheDirectiveTree serverConfig, String version) throws Exception {
Address addr = HttpdAddressUtility.get(version).getMainServerSampleAddress(serverConfig, null, 0);
- return addr == null ? null : "http://" + addr.host + ":" + addr.port + "/";
+ return addr == null ? null : addr.toString();
}
@@ -423,4 +423,4 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index b2f76bc..8251658 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -124,7 +124,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String url;
if (hostToPing != null && portToPing != Address.PORT_WILDCARD_VALUE && portToPing != Address.NO_PORT_SPECIFIED_VALUE) {
- url = "http://" + hostToPing + ":" + portToPing + "/";
+ url = scheme + "://" + hostToPing + ":" + portToPing + "/";
} else {
url = COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS;
}
@@ -133,16 +133,18 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
pluginConfiguration.put(urlProp);
}
-
- File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
-
- PropertySimple rtLogProp = new PropertySimple(
- ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
- pluginConfiguration.put(rtLogProp);
-
+
+ if (address != null) {
+ File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
+
+ PropertySimple rtLogProp = new PropertySimple(
+ ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
+ pluginConfiguration.put(rtLogProp);
+ }
+
String resourceName;
if (serverName != null) {
- resourceName = address.toString();
+ resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index c5589fd..b5cdedf 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -82,7 +82,7 @@ public enum HttpdAddressUtility {
address = getLocalhost(address.port);
}
- updateWithServerName(address, ag);
+ updateWithServerName(address, ag, false);
return address;
}
@@ -90,7 +90,7 @@ public enum HttpdAddressUtility {
return null;
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -106,7 +106,7 @@ public enum HttpdAddressUtility {
addr = getLocalhost(addr.port);
}
- updateWithServerName(addr, ag);
+ updateWithServerName(addr, ag, false);
return addr;
}
@@ -115,7 +115,7 @@ public enum HttpdAddressUtility {
//there has to be at least one Listen directive
throw new IllegalStateException("Could find a listen address on port " + limitToPort);
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -131,6 +131,7 @@ public enum HttpdAddressUtility {
public static class Address {
public String host;
public int port = -1;
+ public String scheme = "http";
public static final String WILDCARD = "*";
public static final String DEFAULT_HOST = "_default_";
@@ -142,6 +143,10 @@ public enum HttpdAddressUtility {
this.port = port;
}
+ public Address(String scheme, String host, int port) {
+ this(host, port);
+ this.scheme = scheme;
+ }
/**
* A simple parser of the provided address into host and port
* sections.
@@ -150,6 +155,13 @@ public enum HttpdAddressUtility {
* @return an instance of Address with host and port set accordingly
*/
public static Address parse(String address) {
+ String scheme = "http";
+ int schemeSpecIdx = address.indexOf("://");
+ if (schemeSpecIdx >= 0) {
+ scheme = address.substring(0, schemeSpecIdx);
+ address = address.substring(schemeSpecIdx + "://".length());
+ }
+
int lastColonIdx = address.lastIndexOf(':');
if (lastColonIdx == NO_PORT_SPECIFIED_VALUE) {
return new Address(address, -1);
@@ -166,10 +178,10 @@ public enum HttpdAddressUtility {
port = Integer.parseInt(portSpec);
}
- return new Address(host, port);
+ return new Address(scheme, host, port);
} else {
//this is an IP6 address without a port spec
- return new Address(address, NO_PORT_SPECIFIED_VALUE);
+ return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE);
}
}
}
@@ -214,11 +226,11 @@ public enum HttpdAddressUtility {
@Override
public String toString() {
- if (port == NO_PORT_SPECIFIED_VALUE) return host;
+ if (port == NO_PORT_SPECIFIED_VALUE) return scheme + "://" + host;
else {
String portSpec = port == PORT_WILDCARD_VALUE ? WILDCARD : String.valueOf(port);
- return host + ":" + portSpec;
+ return scheme + "://" + host + ":" + portSpec;
}
}
}
@@ -245,30 +257,29 @@ public enum HttpdAddressUtility {
* @return the address on which the virtual host can be accessed or null on error
*/
public Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean snmpModuleCompatibleMode) {
- Address addr = Address.parse(virtualHost);
- if (addr.isHostDefault() || addr.isHostWildcard()) {
- Address serverAddr = null;
- if (snmpModuleCompatibleMode) {
- serverAddr = getLocalhost(addr.port);
- } else {
- serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ try {
+ Address addr = Address.parse(virtualHost);
+ if (addr.isHostDefault() || addr.isHostWildcard()) {
+ Address serverAddr = null;
+ if (snmpModuleCompatibleMode) {
+ serverAddr = getLocalhost(addr.port);
+ } else {
+ serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ }
+ if (serverAddr == null)
+ return null;
+ addr.host = serverAddr.host;
}
- if (serverAddr == null)
- return null;
- addr.host = serverAddr.host;
- }
- if (serverName != null) {
- int colonIdx = serverName.indexOf(':');
- if (colonIdx >= 0) {
- addr.host = serverName.substring(0, colonIdx);
- addr.port = Integer.parseInt(serverName.substring(colonIdx + 1));
- } else {
- addr.host = serverName;
+ if (serverName != null) {
+ updateWithServerName(addr, serverName, true);
}
- }
- return addr;
+ return addr;
+ } catch (Exception e) {
+ log.warn("Failed to obtain virtual host address.", e);
+ return null;
+ }
}
private static Address parseListen(String listenValue) {
@@ -335,12 +346,12 @@ public enum HttpdAddressUtility {
try {
return new Address(InetAddress.getLocalHost().getHostAddress(), port);
} catch (UnknownHostException e) {
- //well, this is bad, we can get address of the localhost. let's use the force...
+ //well, this is bad, we can't get address of the localhost. let's use the force...
return new Address("127.0.0.1", port);
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config, boolean updatePort) throws UnknownHostException {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -349,11 +360,20 @@ public enum HttpdAddressUtility {
//be the case if the server listens on more than one interfaces.
if (serverNameNodes.size() > 0) {
String serverName = serverNameNodes.get(0).getValuesAsString();
- InetAddress addrFromServerName = InetAddress.getByName(serverName);
- InetAddress addrFromAddress = InetAddress.getByName(address.host);
-
- if (addrFromAddress.equals(addrFromServerName)) {
- address.host = serverName;
+ updateWithServerName(address, serverName, updatePort);
+ }
+ }
+
+ private static void updateWithServerName(Address address, String serverName, boolean updatePort) throws UnknownHostException {
+ Address serverAddr = Address.parse(serverName);
+ InetAddress addrFromServerName = InetAddress.getByName(serverAddr.host);
+ InetAddress addrFromAddress = InetAddress.getByName(address.host);
+
+ if (addrFromAddress.equals(addrFromServerName)) {
+ address.scheme = serverAddr.scheme;
+ address.host = serverAddr.host;
+ if (updatePort) {
+ address.port = serverAddr.port;
}
}
}
commit fb4d2bdf36d713aa9bc9880db478efc81194c569
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:43:42 2010 +0200
BZ 642610 - directives found in included files aren't duplicated anymore
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
index 2e0f2a2..6cb168e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
@@ -121,18 +121,6 @@ public class ApacheAugeasNode extends AugeasNodeLazy implements AugeasNode {
childNodes.add(node);
}
- public List<AugeasNode> getChildByLabel(String labelName) {
- List<AugeasNode> nodes = super.getChildByLabel(labelName);
-
- if (includedNodes != null) {
- for (AugeasNode node : includedNodes) {
- if (node.getLabel().equals(labelName))
- nodes.add(node);
- }
- }
- return nodes;
- }
-
public void setPath(String path) throws AugeasTreeException {
this.path = path;
commit 58db325cb1ae56114309c43b492d10ac6ab44139
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:42:17 2010 +0200
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index c1f6323..4c61682 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -590,6 +590,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
/**
+ * @return The url the server is pinged for availability or null if the url is not set.
+ */
+ public @Nullable String getServerUrl() {
+ return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
+ }
+
+ /**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
*/
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index d97d9fc..a0f2120 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -345,40 +347,77 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
- for (AugeasNode node : nodes) {
- updated = false;
+//BZ 612189 - uncomment this algo once the resource upgrade is in place
+// for (AugeasNode node : nodes) {
+// updated = false;
+// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+// String tempServerName = null;
+//
+// if (!(serverNameNodes.isEmpty())) {
+// tempServerName = serverNameNodes.get(0).getValue();
+// }
+// if (tempServerName == null & serverName == null)
+// updated = true;
+// if (tempServerName != null & serverName != null)
+// if (tempServerName.equals(serverName)){
+// updated = true;
+// }
+//
+//
+// if (updated){
+// updated = false;
+// List<AugeasNode> params = node.getChildByLabel("param");
+// for (AugeasNode nd : params) {
+// updated = false;
+// for (String adr : addrs) {
+// if (adr.equals(nd.getValue()))
+// updated = true;
+// }
+// if (!updated)
+// break;
+// }
+//
+// if (updated)
+// virtualHosts.add(node);
+// }
+// }
+
+ //BZ 612189 - remove this once resource upgrade is in place
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+ for(AugeasNode node : nodes) {
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- String tempServerName = null;
-
- if (!(serverNameNodes.isEmpty())) {
- tempServerName = serverNameNodes.get(0).getValue();
- }
- if (tempServerName == null & serverName == null)
- updated = true;
- if (tempServerName != null & serverName != null)
- if (tempServerName.equals(serverName)){
- updated = true;
- }
+ List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+
+ String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
+ String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+
+ if (vhostAddressDef != null) {
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
+ if (vhostServerName != null) {
+ HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
+ vhostAddress.host = vhostServerAddress.host;
+ }
-
- if (updated){
- updated = false;
- List<AugeasNode> params = node.getChildByLabel("param");
- for (AugeasNode nd : params) {
- updated = false;
- for (String adr : addrs) {
- if (adr.equals(nd.getValue()))
- updated = true;
- }
- if (!updated)
- break;
- }
-
- if (updated)
- virtualHosts.add(node);
+ if (resourceKeyAddress.equals(vhostAddress)) {
+ virtualHosts.add(node);
}
- }
-
+ }
+ }
+
+ //BZ 612189 - remove this once we have resource upgrade
+ //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
+ try {
+ String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
+ URI serverUri = new URI(serverUrl);
+ String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
+
+ if (expectedResourceKey.equals(resourceKey)) {
+ return tree.getRootNode();
+ }
+ } catch (URISyntaxException e) {
+ log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
+ }
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -505,6 +544,14 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
+ } else {
+ //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
+ //to match the main server with its snmp index below.
+ HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
+ vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
+ if (vhostAddr != null) {
+ vhostAddresses.add(vhostAddr);
+ }
}
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 4a32e27..b2f76bc 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -19,7 +19,10 @@
package org.rhq.plugins.apache;
import java.io.File;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -37,6 +40,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -91,23 +95,13 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
serverName = serverNames.get(0).getValuesAsString();
}
- StringBuilder keyBuilder = new StringBuilder();
- if (serverName != null) {
- keyBuilder.append(serverName).append("|");
- }
- keyBuilder.append(firstAddress);
-
-
- for (int i=1;i<hosts.size();i++){
- keyBuilder.append(" ").append(hosts.get(i));
- }
-
- String resourceKey = keyBuilder.toString();
+ String resourceKey = createResourceKey(serverName, hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
if (address != null) {
+ String scheme = address.scheme;
String hostToPing = address.host;
int portToPing = address.port;
if (address.isPortWildcard()) {
@@ -178,6 +172,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
+
+ String key = null;
+
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -196,9 +193,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
+
+ //BZ 612189 - remove this once we have resource upgrade
+ key = host + ":" + port;
}
- String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
+ if (key == null) {
+ key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
//BZ 612189 - remove this once we have resource upgrade
if (snmpDiscoveries != null) {
@@ -237,6 +240,42 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
}
+ public static String createResourceKey(String serverName, List<String> hosts) {
+//BZ 612189 - swap the impls once resource upgrade is in place
+// StringBuilder keyBuilder = new StringBuilder();
+// if (serverName != null) {
+// keyBuilder.append(serverName).append("|");
+// }
+// keyBuilder.append(hosts.get(0));
+//
+//
+// for (int i = 1; i < hosts.size(); ++i){
+// keyBuilder.append(" ").append(hosts.get(i));
+// }
+//
+// return keyBuilder.toString();
+
+ //try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
+ //vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
+ //kind of guessing being necessary.
+ String host = hosts.get(0);
+ HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
+ if (serverName != null) {
+ HttpdAddressUtility.Address serverAddr = HttpdAddressUtility.Address.parse(serverName);
+ hostAddr.host = serverAddr.host;
+ }
+
+ //the SNMP module seems to resolve the IPs to hostnames.
+ try {
+ InetAddress hostName = InetAddress.getByName(hostAddr.host);
+ hostAddr.host = hostName.getHostName();
+ } catch (UnknownHostException e) {
+ log.debug("Host " + hostAddr.host + " is not resolvable.", e);
+ }
+
+ return hostAddr.host + ":" + hostAddr.port;
+ }
+
/**
* @deprecated remove this once we have resource upgrade
* @param discoveryContext
@@ -279,7 +318,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey());
+ log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
return null;
}
}
commit e8bfc17fde0d6f5bc837d2a96f230a8109114279
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:33:57 2010 +0200
BZ 642588 - config is reloaded if ServerRoot is redefined in config
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index 9c2e448..a725e57 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -137,6 +137,8 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (!serverRoots.isEmpty()) {
serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
serverRootProp.setValue(serverRoot);
+ //reparse the configuration with the new ServerRoot
+ serverConfig = loadParser(serverConfigFile.getAbsolutePath(), serverRoot);
}
serverUrl = getUrl(serverConfig, binaryInfo.getVersion());
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 88 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 54 +++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java | 21 ++
7 files changed, 114 insertions(+), 65 deletions(-)
New commits:
commit 7e38fa92bec032c5556e88a316db7cadf31c7cb6
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Oct 14 11:26:36 2010 -0400
i)fixed new registration session issues ii)lowered some logging to trace.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 97a97d9..ff9f246 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -99,6 +99,7 @@ public class LoginView extends Canvas {
private static final String PHONE = "phone";
private static final String DEPARTMENT = "department";
private static final String SESSIONID = "sessionid";
+ private static final String PASSWORD = "password";
public void showLoginDialog() {
if (!loginShowing) {
@@ -181,7 +182,8 @@ public class LoginView extends Canvas {
* @param sessionId pass in valid session id for LDAP registration steps.
* @param callback pass in callback reference to indicate success and launch of coreGUI
*/
- public void showRegistrationDialog(String user, final String sessionId, final AsyncCallback<Void> callback) {
+ public void showRegistrationDialog(String user, final String sessionId, final String password,
+ final AsyncCallback<Subject> callback) {
if (!loginShowing) {
loginShowing = true;
@@ -242,7 +244,7 @@ public class LoginView extends Canvas {
public void onClick(ClickEvent event) {
//validation
if (validateForms(forms)) {
- Log.trace("Successfully validated all forms");
+ Log.trace("Successfully validated all data for user registration.");
//populate form
form.setValue(FIRST, String.valueOf(first.getValue()));
form.setValue(LAST, String.valueOf(last.getValue()));
@@ -251,10 +253,16 @@ public class LoginView extends Canvas {
form.setValue(PHONE, String.valueOf(phone.getValue()));
form.setValue(DEPARTMENT, String.valueOf(department.getValue()));
form.setValue(SESSIONID, sessionId);
+ form.setValue(PASSWORD, password);
registerLdapUser(form, callback);
}
}
+ /** Iterates through the dynamic forms populated then calls validate().
+ *
+ * @param forms
+ * @return
+ */
private boolean validateForms(ArrayList<DynamicForm> forms) {
boolean allValid = true;
for (DynamicForm form : forms) {
@@ -314,8 +322,13 @@ public class LoginView extends Canvas {
}
}
- protected void registerLdapUser(DynamicForm populatedForm, final AsyncCallback<Void> callback) {
- Subject newSubject = new Subject();
+ /**Uses the information from the populated form to create the Subject for the new LDAP user.
+ *
+ * @param populatedForm - validated data
+ * @param callback
+ */
+ protected void registerLdapUser(DynamicForm populatedForm, final AsyncCallback<Subject> callback) {
+ final Subject newSubject = new Subject();
//insert some required data checking
boolean proceed = true;
@@ -327,8 +340,14 @@ public class LoginView extends Canvas {
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
+ retrieved = populatedForm.getValueAsString(PASSWORD);
+ if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
+ proceed = false;
+ }
+
newSubject.setName(populatedForm.getValueAsString(USERNAME));
newSubject.setSessionId(Integer.valueOf(populatedForm.getValueAsString(SESSIONID)));
+ String password = populatedForm.getValueAsString(PASSWORD);
//don't load null values not set or returned from ldap server
retrieved = populatedForm.getValueAsString(FIRST);
@@ -355,34 +374,39 @@ public class LoginView extends Canvas {
newSubject.setFsystem(false);
if (proceed) {
- GWTServiceLookup.getSubjectService().createSubjectUsingOverlord(newSubject, new AsyncCallback<Subject>() {
- public void onSuccess(Subject result) {
- CoreGUI.getMessageCenter().notify(
- new Message("Succesfully created new ldap Subject.", Message.Severity.Info));
- //now do group role assignment for initial login
- GWTServiceLookup.getLdapService().updateLdapGroupAssignmentsForSubject(result,
- new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to assign roles for ldap Subject.",
- caught);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message("Succesfully assigned roles for ldap Subject.", Message.Severity.Info));
- window.destroy();
- loginShowing = false;
- callback.onSuccess(result);
- }
- });
- }
+ GWTServiceLookup.getSubjectService().createSubjectUsingOverlord(newSubject, password,
+ new AsyncCallback<Subject>() {
+ public void onSuccess(final Subject newLoggedInSubject) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Succesfully created new ldap Subject.", Message.Severity.Info));
+ Log.trace("New subject created for ldap user.");
+ //now do group role assignment for initial login
+ GWTServiceLookup.getLdapService().updateLdapGroupAssignmentsForSubject(newLoggedInSubject,
+ new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to assign roles for ldap Subject.",
+ caught);
+ Log.debug("Failed to assign roles to ldap subject.");
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message("Succesfully assigned roles for ldap Subject.",
+ Message.Severity.Info));
+ Log.trace("Role assignment update for ldap subject complete.");
+ window.destroy();
+ loginShowing = false;
+ callback.onSuccess(newLoggedInSubject);
+ }
+ });
+ }
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to create ldap Subject.", caught);
- }
- });
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to create ldap Subject.", caught);
+ }
+ });
} else {//log them out then reload LoginView
- com.allen_sauer.gwt.log.client.Log.warn("Failed to locate username required to create LDAP subject.");
+ Log.warn("Failed to locate username required to create LDAP subject.");
UserSessionManager.logout();
new LoginView().showLoginDialog();
}
@@ -411,7 +435,7 @@ public class LoginView extends Canvas {
return form;
}
- /**Build and loads the custom validators for each of the formItems
+ /**Build and loads the validators for each of the formItems
*
* @param form
*/
@@ -478,7 +502,7 @@ public class LoginView extends Canvas {
ResourceTypeRepository.Cache.getInstance().getResourceTypes((Integer[]) null,
EnumSet.allOf(ResourceTypeRepository.MetadataType.class), new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- com.allen_sauer.gwt.log.client.Log.info("Preloaded [" + types.size() + "] resource types");
+ Log.info("Preloaded [" + types.size() + "] resource types");
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
index e3dc5df..0932e6f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/SearchGUI.java
@@ -22,6 +22,7 @@ import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.SC;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.coregui.client.search.SearchBar;
/**
@@ -45,14 +46,14 @@ public class SearchGUI implements EntryPoint {
return;
}
- UserSessionManager.checkLoginStatus(null, null, new AsyncCallback<Void>() {
+ UserSessionManager.checkLoginStatus(null, null, new AsyncCallback<Subject>() {
@Override
public void onFailure(Throwable caught) {
SC.say("Unable to determine login status, check server status");
}
@Override
- public void onSuccess(Void result) {
+ public void onSuccess(Subject result) {
singleton.buildSearchGUI();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 2722ea4..0dc4482 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -82,8 +82,7 @@ public class UserSessionManager {
private static Boolean needsRegistration = false;
- public static void checkLoginStatus(final String user, final String password, final AsyncCallback<Void> callback) {
- // public static void checkLoginStatus(final String password, final AsyncCallback<Boolean> callback) {
+ public static void checkLoginStatus(final String user, final String password, final AsyncCallback<Subject> callback) {
BrowserUtility.forceIe6Hacks();
RequestBuilder b = new RequestBuilder(RequestBuilder.GET, "/sessionAccess");
@@ -151,7 +150,7 @@ public class UserSessionManager {
GWTServiceLookup.getLdapService().checkSubjectForLdapAuth(subject, user, password,
new AsyncCallback<Subject>() {
public void onFailure(Throwable caught) {
- Log.info("Unable to check subject for LDAP authorization - check Server status."
+ Log.warn("Unable to check subject for LDAP authorization - check Server status."
+ caught.getMessage());
//TODO: how/what to display in LoginView when unexpected communication with server occurs?
// LoginView
@@ -163,20 +162,20 @@ public class UserSessionManager {
public void onSuccess(Subject checked) {
//now pull the flags/information back out of this subject
if (checked == null) {//no new subject was returned.
- Log.debug("No alternative case insensitive LDAP accounts located.");
- locateSubjectOrLogin(subjectId, sessionId, user, callback);
+ Log.trace("No alternative case insensitive LDAP accounts located.");
+ locateSubjectOrLogin(subjectId, sessionId, user, password, callback);
} else {//alternative Subject returned meaning we located
- Log.debug("Case insensitive matching LDAP account located.");
+ Log.trace("Case insensitive matching LDAP account located.");
needsRegistration = false;
//change the subject.sessionId
sessionSubject = checked;
locateSubjectOrLogin(checked.getId(), String.valueOf(checked.getSessionId()),
- checked.getName(), callback);
+ checked.getName(), password, callback);
}
- Log.debug("Subject registration required:" + needsRegistration);
+ Log.trace("Subject registration required:" + needsRegistration);
}
});
- } else {
+ } else {//invalid session. Back to login
new LoginView().showLoginDialog();
}
}
@@ -200,10 +199,10 @@ public class UserSessionManager {
* @param user
* @param callback
*/
- private static void locateSubjectOrLogin(int subjectId, final String sessionId, final String user,
- final AsyncCallback<Void> callback) {
+ private static void locateSubjectOrLogin(int subjectId, final String sessionId, final String user, String password,
+ final AsyncCallback<Subject> callback) {
if (subjectId > 0) {//registration not needed
- Log.debug("SubjectCriteria search with subjectId:" + subjectId);
+ Log.trace("SubjectCriteria search with subjectId:" + subjectId);
SubjectCriteria criteria = new SubjectCriteria();
criteria.fetchConfiguration(true);
criteria.addFilterId(subjectId);
@@ -216,14 +215,14 @@ public class UserSessionManager {
// LoginView
// .displayFormError("UserSessionManager: Unable to check subject for LDAP authorization "
// + "- check Server status.");
- com.allen_sauer.gwt.log.client.Log.info("Failed to load user's subject");
+ Log.debug("Failed to load user's subject");
//show login dialog
new LoginView().showLoginDialog();
}
public void onSuccess(PageList<Subject> result) {
Subject subject = result.get(0);
- Log.debug("Found subject [" + subject + "].");
+ Log.trace("Found subject [" + subject + "].");
subject.setSessionId(Integer.valueOf(sessionId));
// reset the session subject to the latest, for wrapping in user preferences
@@ -232,13 +231,12 @@ public class UserSessionManager {
userPreferences = new UserPreferences(sessionSubject);
refresh();
- callback.onSuccess((Void) null);
+ callback.onSuccess(subject);
}
});
} else {
- Log.info("Proceeding with registration for ldap user '" + user + "'.");
- loggedIn = true;
- new LoginView().showRegistrationDialog(user, sessionId, callback);
+ Log.trace("Proceeding with registration for ldap user '" + user + "'.");
+ new LoginView().showRegistrationDialog(user, sessionId, password, callback);
}
}
@@ -246,18 +244,30 @@ public class UserSessionManager {
login(null, null);
}
+ /**Same as login, but passes in credentials optionally needed during new LDAP user registration.
+ *
+ * @param user
+ * @param password
+ */
public static void login(String user, String password) {
- checkLoginStatus(user, password, new AsyncCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
+ checkLoginStatus(user, password, new AsyncCallback<Subject>() {
+ public void onSuccess(Subject result) {
// will build UI if necessary, then fires history event
+ loggedIn = true;
+ if (result != null) {// subject and session has been updated during this login request
+ Log.trace("A new subject and session has been returned. Updating sessionSubject.");
+ sessionSubject = result;
+ }
CoreGUI.get().buildCoreUI();
}
- @Override
public void onFailure(Throwable caught) {
Log.error("Unable to determine login status - check Server status.");
}
+
+ public String toString() {//attempt to identify call back
+ return super.toString() + " UserSessionManager.checkLoginStatus()";
+ }
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java
index b50900a..a277f90 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/SubjectGWTService.java
@@ -64,7 +64,7 @@ public interface SubjectGWTService extends RemoteService {
* @param subjectToCreate The subject to be created.
* @return the newly persisted {@link Subject}
*/
- Subject createSubjectUsingOverlord(Subject subjectToCreate);
+ Subject createSubjectUsingOverlord(Subject subjectToCreate, String password);
/**
* Deletes the given set of users, including both the {@link Subject} and {@link org.rhq.core.domain.auth.Principal} objects associated with
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 46f37b9..f0c2135 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -313,12 +313,10 @@ public abstract class RPCDataSource<T> extends DataSource {
}
/** Quick method to determine if current user is still logged in.
- * Builds a
- *
+ *
* @return boolean indication of logged in status.
*/
protected boolean userStillLoggedIn() {
return UserSessionManager.isLoggedIn();
}
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
index 6d06e3c..a1de14c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/rpc/MonitoringRequestCallback.java
@@ -25,6 +25,7 @@ import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.SC;
+import org.rhq.core.domain.auth.Subject;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
/**
@@ -63,9 +64,9 @@ public class MonitoringRequestCallback implements RequestCallback {
+ response.getStatusText());
// if we have a rich and coordinated client-side loggedIn state, do we need to check upon failure here?
- UserSessionManager.checkLoginStatus(null, null, new AsyncCallback<Void>() {
+ UserSessionManager.checkLoginStatus(null, null, new AsyncCallback<Subject>() {
@Override
- public void onSuccess(Void result) {
+ public void onSuccess(Subject result) {
History.fireCurrentHistoryState();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
index fa515bd..8c5e9ea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/SubjectGWTServiceImpl.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.server.gwt;
+import com.allen_sauer.gwt.log.client.Log;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.util.PageList;
@@ -62,10 +64,23 @@ public class SubjectGWTServiceImpl extends AbstractGWTServiceImpl implements Sub
}
}
- public Subject createSubjectUsingOverlord(Subject subjectToCreate) {
+ /**Same as create subject, but uses Overlord and returns new/non-temporary session.
+ *
+ * @param subjectToCreate
+ * @param password
+ * @return
+ */
+ public Subject createSubjectUsingOverlord(Subject subjectToCreate, String password) {
try {
- return SerialUtility.prepare(subjectManager.createSubject(subjectManager.getOverlord(), subjectToCreate),
- "SubjectManager.createSubjectUsingOverlord");
+ //Officially create the new subject
+ subjectToCreate = subjectManager.createSubject(subjectManager.getOverlord(), subjectToCreate);
+ // nuke the temporary session and establish a new
+ // one for this subject.. must be done before pulling the
+ // new subject in order to do it with his own credentials
+ subjectManager.logout(getSessionSubject().getSessionId());
+ subjectToCreate = subjectManager.login(subjectToCreate.getName(), password);
+ Log.trace("Created new user with overlord and logged back in with that user.");
+ return SerialUtility.prepare(subjectToCreate, "SubjectManager.createSubjectUsingOverlord");
} catch (Exception e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
13 years, 8 months
[rhq] Branch 'release-3.0.0-patch3' - 4 commits - modules/plugins
by lkrejci
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 7
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 109 +++++++---
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 87 +++++--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java | 12 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java | 90 +++++---
6 files changed, 208 insertions(+), 103 deletions(-)
New commits:
commit 1afdc5b0c20f66a33f3f5965d5e4d7f8b014e9ac
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 16:41:07 2010 +0200
BZ 642622 - Adding the ability to extract the scheme and port from the ServerName so that proper ping URLs can be discovered.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index a725e57..9356ac9 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -248,7 +248,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
*/
private static String getUrl(ApacheDirectiveTree serverConfig, String version) throws Exception {
Address addr = HttpdAddressUtility.get(version).getMainServerSampleAddress(serverConfig, null, 0);
- return addr == null ? null : "http://" + addr.host + ":" + addr.port + "/";
+ return addr == null ? null : addr.toString();
}
@@ -423,4 +423,4 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index b2f76bc..8251658 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -124,7 +124,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String url;
if (hostToPing != null && portToPing != Address.PORT_WILDCARD_VALUE && portToPing != Address.NO_PORT_SPECIFIED_VALUE) {
- url = "http://" + hostToPing + ":" + portToPing + "/";
+ url = scheme + "://" + hostToPing + ":" + portToPing + "/";
} else {
url = COULD_NOT_DETERMINE_THE_VIRTUAL_HOST_ADDRESS;
}
@@ -133,16 +133,18 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
pluginConfiguration.put(urlProp);
}
-
- File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
-
- PropertySimple rtLogProp = new PropertySimple(
- ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
- pluginConfiguration.put(rtLogProp);
-
+
+ if (address != null) {
+ File rtLogFile = new File(logsDir, address.host + address.port + RT_LOG_FILE_NAME_SUFFIX);
+
+ PropertySimple rtLogProp = new PropertySimple(
+ ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
+ pluginConfiguration.put(rtLogProp);
+ }
+
String resourceName;
if (serverName != null) {
- resourceName = address.toString();
+ resourceName = address.host + ":" + address.port;
} else {
resourceName = resourceKey;
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index c5589fd..b5cdedf 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -82,7 +82,7 @@ public enum HttpdAddressUtility {
address = getLocalhost(address.port);
}
- updateWithServerName(address, ag);
+ updateWithServerName(address, ag, false);
return address;
}
@@ -90,7 +90,7 @@ public enum HttpdAddressUtility {
return null;
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -106,7 +106,7 @@ public enum HttpdAddressUtility {
addr = getLocalhost(addr.port);
}
- updateWithServerName(addr, ag);
+ updateWithServerName(addr, ag, false);
return addr;
}
@@ -115,7 +115,7 @@ public enum HttpdAddressUtility {
//there has to be at least one Listen directive
throw new IllegalStateException("Could find a listen address on port " + limitToPort);
} catch (Exception e) {
- log.info("Failed to obtain main server address. Is augeas installed and correct lens in use?");
+ log.warn("Failed to obtain main server address.", e);
return null;
}
@@ -131,6 +131,7 @@ public enum HttpdAddressUtility {
public static class Address {
public String host;
public int port = -1;
+ public String scheme = "http";
public static final String WILDCARD = "*";
public static final String DEFAULT_HOST = "_default_";
@@ -142,6 +143,10 @@ public enum HttpdAddressUtility {
this.port = port;
}
+ public Address(String scheme, String host, int port) {
+ this(host, port);
+ this.scheme = scheme;
+ }
/**
* A simple parser of the provided address into host and port
* sections.
@@ -150,6 +155,13 @@ public enum HttpdAddressUtility {
* @return an instance of Address with host and port set accordingly
*/
public static Address parse(String address) {
+ String scheme = "http";
+ int schemeSpecIdx = address.indexOf("://");
+ if (schemeSpecIdx >= 0) {
+ scheme = address.substring(0, schemeSpecIdx);
+ address = address.substring(schemeSpecIdx + "://".length());
+ }
+
int lastColonIdx = address.lastIndexOf(':');
if (lastColonIdx == NO_PORT_SPECIFIED_VALUE) {
return new Address(address, -1);
@@ -166,10 +178,10 @@ public enum HttpdAddressUtility {
port = Integer.parseInt(portSpec);
}
- return new Address(host, port);
+ return new Address(scheme, host, port);
} else {
//this is an IP6 address without a port spec
- return new Address(address, NO_PORT_SPECIFIED_VALUE);
+ return new Address(scheme, address, NO_PORT_SPECIFIED_VALUE);
}
}
}
@@ -214,11 +226,11 @@ public enum HttpdAddressUtility {
@Override
public String toString() {
- if (port == NO_PORT_SPECIFIED_VALUE) return host;
+ if (port == NO_PORT_SPECIFIED_VALUE) return scheme + "://" + host;
else {
String portSpec = port == PORT_WILDCARD_VALUE ? WILDCARD : String.valueOf(port);
- return host + ":" + portSpec;
+ return scheme + "://" + host + ":" + portSpec;
}
}
}
@@ -245,30 +257,29 @@ public enum HttpdAddressUtility {
* @return the address on which the virtual host can be accessed or null on error
*/
public Address getVirtualHostSampleAddress(ApacheDirectiveTree ag, String virtualHost, String serverName, boolean snmpModuleCompatibleMode) {
- Address addr = Address.parse(virtualHost);
- if (addr.isHostDefault() || addr.isHostWildcard()) {
- Address serverAddr = null;
- if (snmpModuleCompatibleMode) {
- serverAddr = getLocalhost(addr.port);
- } else {
- serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ try {
+ Address addr = Address.parse(virtualHost);
+ if (addr.isHostDefault() || addr.isHostWildcard()) {
+ Address serverAddr = null;
+ if (snmpModuleCompatibleMode) {
+ serverAddr = getLocalhost(addr.port);
+ } else {
+ serverAddr = getMainServerSampleAddress(ag, null, addr.port);
+ }
+ if (serverAddr == null)
+ return null;
+ addr.host = serverAddr.host;
}
- if (serverAddr == null)
- return null;
- addr.host = serverAddr.host;
- }
- if (serverName != null) {
- int colonIdx = serverName.indexOf(':');
- if (colonIdx >= 0) {
- addr.host = serverName.substring(0, colonIdx);
- addr.port = Integer.parseInt(serverName.substring(colonIdx + 1));
- } else {
- addr.host = serverName;
+ if (serverName != null) {
+ updateWithServerName(addr, serverName, true);
}
- }
- return addr;
+ return addr;
+ } catch (Exception e) {
+ log.warn("Failed to obtain virtual host address.", e);
+ return null;
+ }
}
private static Address parseListen(String listenValue) {
@@ -335,12 +346,12 @@ public enum HttpdAddressUtility {
try {
return new Address(InetAddress.getLocalHost().getHostAddress(), port);
} catch (UnknownHostException e) {
- //well, this is bad, we can get address of the localhost. let's use the force...
+ //well, this is bad, we can't get address of the localhost. let's use the force...
return new Address("127.0.0.1", port);
}
}
- private static void updateWithServerName(Address address, ApacheDirectiveTree config) throws UnknownHostException {
+ private static void updateWithServerName(Address address, ApacheDirectiveTree config, boolean updatePort) throws UnknownHostException {
//check if there is a ServerName directive
List<ApacheDirective> serverNameNodes = config.search("/ServerName");
@@ -349,11 +360,20 @@ public enum HttpdAddressUtility {
//be the case if the server listens on more than one interfaces.
if (serverNameNodes.size() > 0) {
String serverName = serverNameNodes.get(0).getValuesAsString();
- InetAddress addrFromServerName = InetAddress.getByName(serverName);
- InetAddress addrFromAddress = InetAddress.getByName(address.host);
-
- if (addrFromAddress.equals(addrFromServerName)) {
- address.host = serverName;
+ updateWithServerName(address, serverName, updatePort);
+ }
+ }
+
+ private static void updateWithServerName(Address address, String serverName, boolean updatePort) throws UnknownHostException {
+ Address serverAddr = Address.parse(serverName);
+ InetAddress addrFromServerName = InetAddress.getByName(serverAddr.host);
+ InetAddress addrFromAddress = InetAddress.getByName(address.host);
+
+ if (addrFromAddress.equals(addrFromServerName)) {
+ address.scheme = serverAddr.scheme;
+ address.host = serverAddr.host;
+ if (updatePort) {
+ address.port = serverAddr.port;
}
}
}
commit fb4d2bdf36d713aa9bc9880db478efc81194c569
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:43:42 2010 +0200
BZ 642610 - directives found in included files aren't duplicated anymore
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
index 2e0f2a2..6cb168e 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/augeas/ApacheAugeasNode.java
@@ -121,18 +121,6 @@ public class ApacheAugeasNode extends AugeasNodeLazy implements AugeasNode {
childNodes.add(node);
}
- public List<AugeasNode> getChildByLabel(String labelName) {
- List<AugeasNode> nodes = super.getChildByLabel(labelName);
-
- if (includedNodes != null) {
- for (AugeasNode node : includedNodes) {
- if (node.getLabel().equals(labelName))
- nodes.add(node);
- }
- }
- return nodes;
- }
-
public void setPath(String path) throws AugeasTreeException {
this.path = path;
commit 58db325cb1ae56114309c43b492d10ac6ab44139
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:42:17 2010 +0200
BZ 642591 - make sure we always have the same resource keys as in old plugin version.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index c1f6323..4c61682 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -590,6 +590,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
/**
+ * @return The url the server is pinged for availability or null if the url is not set.
+ */
+ public @Nullable String getServerUrl() {
+ return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
+ }
+
+ /**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
*/
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index d97d9fc..a0f2120 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -21,6 +21,8 @@ package org.rhq.plugins.apache;
import java.io.File;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -345,40 +347,77 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
- for (AugeasNode node : nodes) {
- updated = false;
+//BZ 612189 - uncomment this algo once the resource upgrade is in place
+// for (AugeasNode node : nodes) {
+// updated = false;
+// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+// String tempServerName = null;
+//
+// if (!(serverNameNodes.isEmpty())) {
+// tempServerName = serverNameNodes.get(0).getValue();
+// }
+// if (tempServerName == null & serverName == null)
+// updated = true;
+// if (tempServerName != null & serverName != null)
+// if (tempServerName.equals(serverName)){
+// updated = true;
+// }
+//
+//
+// if (updated){
+// updated = false;
+// List<AugeasNode> params = node.getChildByLabel("param");
+// for (AugeasNode nd : params) {
+// updated = false;
+// for (String adr : addrs) {
+// if (adr.equals(nd.getValue()))
+// updated = true;
+// }
+// if (!updated)
+// break;
+// }
+//
+// if (updated)
+// virtualHosts.add(node);
+// }
+// }
+
+ //BZ 612189 - remove this once resource upgrade is in place
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+ for(AugeasNode node : nodes) {
List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
- String tempServerName = null;
-
- if (!(serverNameNodes.isEmpty())) {
- tempServerName = serverNameNodes.get(0).getValue();
- }
- if (tempServerName == null & serverName == null)
- updated = true;
- if (tempServerName != null & serverName != null)
- if (tempServerName.equals(serverName)){
- updated = true;
- }
+ List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
+
+ String vhostServerName = serverNameNodes.isEmpty() ? null : serverNameNodes.get(0).getValue();
+ String vhostAddressDef = vhostAddressNodes.isEmpty() ? null : vhostAddressNodes.get(0).getValue();
+
+ if (vhostAddressDef != null) {
+ HttpdAddressUtility.Address vhostAddress = HttpdAddressUtility.Address.parse(vhostAddressDef);
+ if (vhostServerName != null) {
+ HttpdAddressUtility.Address vhostServerAddress = HttpdAddressUtility.Address.parse(vhostServerName);
+ vhostAddress.host = vhostServerAddress.host;
+ }
-
- if (updated){
- updated = false;
- List<AugeasNode> params = node.getChildByLabel("param");
- for (AugeasNode nd : params) {
- updated = false;
- for (String adr : addrs) {
- if (adr.equals(nd.getValue()))
- updated = true;
- }
- if (!updated)
- break;
- }
-
- if (updated)
- virtualHosts.add(node);
+ if (resourceKeyAddress.equals(vhostAddress)) {
+ virtualHosts.add(node);
}
- }
-
+ }
+ }
+
+ //BZ 612189 - remove this once we have resource upgrade
+ //ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
+ try {
+ String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
+ URI serverUri = new URI(serverUrl);
+ String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
+
+ if (expectedResourceKey.equals(resourceKey)) {
+ return tree.getRootNode();
+ }
+ } catch (URISyntaxException e) {
+ log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
+ }
+
if (virtualHosts.size() == 0) {
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
@@ -505,6 +544,14 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
+ } else {
+ //this is not to choke on the old style resource keys for the main server. without this, we'd never be able
+ //to match the main server with its snmp index below.
+ HttpdAddressUtility.Address addr = HttpdAddressUtility.Address.parse(vhostAddressStrings[i]);
+ vhostAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, addr.host, addr.port);
+ if (vhostAddr != null) {
+ vhostAddresses.add(vhostAddr);
+ }
}
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index 4a32e27..b2f76bc 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -19,7 +19,10 @@
package org.rhq.plugins.apache;
import java.io.File;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -37,6 +40,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.HttpdAddressUtility.Address;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -91,23 +95,13 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
serverName = serverNames.get(0).getValuesAsString();
}
- StringBuilder keyBuilder = new StringBuilder();
- if (serverName != null) {
- keyBuilder.append(serverName).append("|");
- }
- keyBuilder.append(firstAddress);
-
-
- for (int i=1;i<hosts.size();i++){
- keyBuilder.append(" ").append(hosts.get(i));
- }
-
- String resourceKey = keyBuilder.toString();
+ String resourceKey = createResourceKey(serverName, hosts);
Configuration pluginConfiguration = context.getDefaultPluginConfiguration();
Address address = serverComponent.getAddressUtility().getVirtualHostSampleAddress(tree, firstAddress, serverName, false);
if (address != null) {
+ String scheme = address.scheme;
String hostToPing = address.host;
int portToPing = address.port;
if (address.isPortWildcard()) {
@@ -178,6 +172,9 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
String mainServerUrl = context.getParentResourceContext().getPluginConfiguration().getSimple(
ApacheServerComponent.PLUGIN_CONFIG_PROP_URL).getStringValue();
+
+ String key = null;
+
if (mainServerUrl != null && !"null".equals(mainServerUrl)) {
PropertySimple mainServerUrlProp = new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP,
mainServerUrl);
@@ -196,9 +193,15 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
PropertySimple rtLogProp = new PropertySimple(
ApacheVirtualHostServiceComponent.RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtLogFile.toString());
mainServerPluginConfig.put(rtLogProp);
+
+ //BZ 612189 - remove this once we have resource upgrade
+ key = host + ":" + port;
}
- String key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ //BZ 612189 - this can simply the MAIN_SERVER_RESOURCE_KEY only once we have resource upgrade
+ if (key == null) {
+ key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
+ }
//BZ 612189 - remove this once we have resource upgrade
if (snmpDiscoveries != null) {
@@ -237,6 +240,42 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
}
}
+ public static String createResourceKey(String serverName, List<String> hosts) {
+//BZ 612189 - swap the impls once resource upgrade is in place
+// StringBuilder keyBuilder = new StringBuilder();
+// if (serverName != null) {
+// keyBuilder.append(serverName).append("|");
+// }
+// keyBuilder.append(hosts.get(0));
+//
+//
+// for (int i = 1; i < hosts.size(); ++i){
+// keyBuilder.append(" ").append(hosts.get(i));
+// }
+//
+// return keyBuilder.toString();
+
+ //try to derive the same resource key as the SNMP would have... this is to prevent the duplication of
+ //vhost resources after the SNMP was configured - how I wish resource upgrade made it to 3.0 to prevent this
+ //kind of guessing being necessary.
+ String host = hosts.get(0);
+ HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
+ if (serverName != null) {
+ HttpdAddressUtility.Address serverAddr = HttpdAddressUtility.Address.parse(serverName);
+ hostAddr.host = serverAddr.host;
+ }
+
+ //the SNMP module seems to resolve the IPs to hostnames.
+ try {
+ InetAddress hostName = InetAddress.getByName(hostAddr.host);
+ hostAddr.host = hostName.getHostName();
+ } catch (UnknownHostException e) {
+ log.debug("Host " + hostAddr.host + " is not resolvable.", e);
+ }
+
+ return hostAddr.host + ":" + hostAddr.port;
+ }
+
/**
* @deprecated remove this once we have resource upgrade
* @param discoveryContext
@@ -279,7 +318,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
return ret;
} catch (Exception e) {
- log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey());
+ log.warn("Error while trying to contact SNMP of the apache server " + discoveryContext.getParentResourceContext().getResourceKey(), e);
return null;
}
}
commit e8bfc17fde0d6f5bc837d2a96f230a8109114279
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Oct 13 15:33:57 2010 +0200
BZ 642588 - config is reloaded if ServerRoot is redefined in config
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
index 9c2e448..a725e57 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java
@@ -137,6 +137,8 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
if (!serverRoots.isEmpty()) {
serverRoot = AugeasNodeValueUtil.unescape(serverRoots.get(0).getValuesAsString());
serverRootProp.setValue(serverRoot);
+ //reparse the configuration with the new ServerRoot
+ serverConfig = loadParser(serverConfigFile.getAbsolutePath(), serverRoot);
}
serverUrl = getUrl(serverConfig, binaryInfo.getVersion());
13 years, 8 months