[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit b3681f22dd3d7d893f57af56a9be6602111e3d7b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Feb 27 16:38:00 2014 -0500
BZ 1044986 - fix rhqctl script so it doesn't hang when starting the agent in DEBUG mode
diff --git a/modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh b/modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh
index baaea2b..c898272 100755
--- a/modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh
+++ b/modules/enterprise/agent/src/etc/rhq-agent-wrapper.sh
@@ -262,7 +262,7 @@ case "$1" in
# start the agent now!
if [ -n "$RHQ_AGENT_DEBUG" ] && [ "$RHQ_AGENT_DEBUG" != "false" ]; then
debug_wrapper_msg "Executing agent with command: ${RHQ_AGENT_START_COMMAND}"
- eval $RHQ_AGENT_START_COMMAND
+ eval "$RHQ_AGENT_START_COMMAND > \"${RHQ_AGENT_HOME}/logs/${wrapper}\" 2>&1"
else
# since the start command may run as non-root user, ensure the old
# wrapper (which may be owned by root) is removed
9 years, 9 months
[rhq] 2 commits - etc/rhq-ircBot modules/core modules/enterprise modules/plugins
by Jiri Kremser
etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java | 1
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java | 7
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java | 10
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/admin/topology/AgentDetailView.java | 141 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/TopologyGWTService.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/TopologyGWTServiceImpl.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerBean.java | 16 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerLocal.java | 12
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 1
10 files changed, 207 insertions(+), 3 deletions(-)
New commits:
commit 3b2ad9a91b31451fb2ec9b223f7daa2e9716c941
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Feb 27 19:47:06 2014 +0100
[BZ 1065680] - Agent admin page should list the installed plugins - Implementing new method on TopologyManagerBean for obtaining the corresponding resource id for an agent instance. If there is such an id, web UI runs the "retrieveAllPluginInfo" operation and displays its result in the agent admin UI (on the agent detail page). So the assumption here is that the agent has already imported the RHQ Agent resource.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
index 186c968..4cbbb09 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Agent.java
@@ -62,6 +62,12 @@ import org.rhq.core.domain.cloud.Server;
@NamedQuery(name = Agent.QUERY_REMOVE_SERVER_REFERENCE, query = "UPDATE Agent a SET a.server.id = NULL WHERE a.server.id = :serverId "),
@NamedQuery(name = Agent.QUERY_COUNT_ALL, query = "SELECT count(a.id) FROM Agent a"),
@NamedQuery(name = Agent.QUERY_FIND_RESOURCE_IDS_FOR_AGENT, query = "SELECT r.id FROM Resource r WHERE r.agent.id = :agentId"),
+ @NamedQuery(name = Agent.QUERY_FIND_AGENT_RESOURCE_ID_AGENT_ID, query = "" //
+ + "SELECT r.id " //
+ + "FROM Resource r " //
+ + "WHERE r.resourceType.name = 'RHQ Agent' " //
+ + "AND r.inventoryStatus = 'COMMITTED'" //
+ + "AND r.agent.id = :agentId"),
@NamedQuery(name = Agent.QUERY_FIND_RESOURCE_IDS_WITH_AGENTS_BY_RESOURCE_IDS, query = "" //
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceIdWithAgentComposite(r.id, r.agent) " //
+ " FROM Resource r " //
@@ -163,6 +169,7 @@ public class Agent implements Serializable {
public static final String QUERY_FIND_BY_SERVER = "Agent.findByServer";
public static final String QUERY_COUNT_ALL = "Agent.countAll";
public static final String QUERY_FIND_RESOURCE_IDS_FOR_AGENT = "Agent.findResourceIdsForAgent";
+ public static final String QUERY_FIND_AGENT_RESOURCE_ID_AGENT_ID = "Agent.findAgentResourceIdByAgentId";
public static final String QUERY_FIND_RESOURCE_IDS_WITH_AGENTS_BY_RESOURCE_IDS = "Agent.findResourceIdsWithAgentsByResourceIds";
public static final String QUERY_FIND_ALL_SUSPECT_AGENTS = "Agent.findAllSuspectAgents";
public static final String QUERY_FIND_BY_AFFINITY_GROUP = "Agent.findByAffinityGroup";
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
index 11eb3e3..72f3422 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
@@ -168,7 +168,10 @@ public class AgentManagement implements AgentManagementMBean, MBeanRegistration
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
PluginUpdate updater = getPluginUpdateObject();
plugins = updater.getCurrentPluginFiles();
-
+ PluginContainerConfiguration pcConfig = m_agent.getConfiguration().getPluginContainerConfiguration();
+ List<String> enabledPlugins = pcConfig.getEnabledPlugins();
+ List<String> disabledPlugins = pcConfig.getDisabledPlugins();
+
PropertyList list = new PropertyList("plugins".intern());
info.getComplexResults().put(list);
@@ -192,6 +195,11 @@ public class AgentManagement implements AgentManagementMBean, MBeanRegistration
map.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
map.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
map.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
+ // plugin is either whitelisted or the white list is empty
+ boolean isEnabled = enabledPlugins.isEmpty() || enabledPlugins.contains(pluginName);
+ // ..and is not on the black list
+ isEnabled &= !disabledPlugins.contains(pluginName);
+ map.put(new PropertySimple(PLUGIN_INFO_ENABLED, isEnabled));
try {
map.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
index 9ba53b4..c6093f3 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
@@ -81,6 +81,11 @@ public interface AgentManagementMBean {
* Identifies the filesize of a plugin.
*/
String PLUGIN_INFO_SIZE = "size";
+
+ /**
+ * Identifies whether the plugin is currently being used by the agent
+ */
+ String PLUGIN_INFO_ENABLED = "enabled";
/**
* Identifies the MD5 of a plugin.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/admin/topology/AgentDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/admin/topology/AgentDetailView.java
index 5db839c..c614f1c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/admin/topology/AgentDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/admin/topology/AgentDetailView.java
@@ -31,19 +31,32 @@ import static org.rhq.coregui.client.admin.topology.AgentDatasourceField.FIELD_S
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.types.VisibilityMode;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import org.rhq.core.domain.cloud.AffinityGroup;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.AgentCriteria;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.coregui.client.CoreGUI;
import org.rhq.coregui.client.LinkManager;
+import org.rhq.coregui.client.admin.AgentPluginTableView;
+import org.rhq.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.coregui.client.gwt.GWTServiceLookup;
import org.rhq.coregui.client.util.StringUtility;
@@ -58,10 +71,15 @@ public class AgentDetailView extends EnhancedVLayout {
private final int agentId;
- private static final int SECTION_COUNT = 2;
+ private static final int SECTION_COUNT = 3;
+ private static final String LOADING_ICON = "ajax-loader.gif";
private final SectionStack sectionStack;
private SectionStackSection detailsSection = null;
private SectionStackSection failoverListSection = null;
+ private SectionStackSection agentPluginsSection = null;
+ private volatile boolean waitingForPlugins = false;
+ private EnhancedVLayout pluginsSection;
+ private Img loading;
private volatile int initSectionCount = 0;
@@ -95,6 +113,24 @@ public class AgentDetailView extends EnhancedVLayout {
}
prepareDetailsSection(sectionStack, agents.get(0));
prepareFailoverListSection(sectionStack, agents.get(0));
+
+ GWTServiceLookup.getTopologyService().getResourceIdOfAgent(agentId, new AsyncCallback<Integer>() {
+ public void onSuccess(final Integer resourceId) {
+ if (resourceId != null) {
+ prepareAgentPluginsSection(sectionStack, resourceId);
+ loadPlugins(resourceId);
+ } else {
+ initSectionCount = SECTION_COUNT;
+ }
+ }
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_adminTopology_message_fetchAgentFail(String.valueOf(agentId)) + " "
+ + caught.getMessage(), caught);
+ initSectionCount = SECTION_COUNT;
+ }
+ });
+
}
public void onFailure(Throwable caught) {
@@ -127,7 +163,10 @@ public class AgentDetailView extends EnhancedVLayout {
if (null != failoverListSection) {
sectionStack.addSection(failoverListSection);
}
-
+ if (null != agentPluginsSection) {
+ sectionStack.addSection(agentPluginsSection);
+ }
+
addMember(sectionStack);
markForRedraw();
@@ -153,6 +192,48 @@ public class AgentDetailView extends EnhancedVLayout {
++initSectionCount;
return;
}
+
+ private void prepareAgentPluginsSection(SectionStack stack, int resourceId) {
+ SectionStackSection section = new SectionStackSection(MSG.view_adminConfig_agentPlugins());
+ section.setExpanded(false);
+ loading = new Img(LOADING_ICON, 16, 16);
+ loading.setValign(VerticalAlignment.CENTER);
+ loading.setAlign(Alignment.CENTER);
+ pluginsSection = new EnhancedVLayout();
+ pluginsSection.addMember(loading);
+ section.setItems(pluginsSection);
+ agentPluginsSection = section;
+ ++initSectionCount;
+ return;
+ }
+
+
+ protected Canvas buildResultsSection(ResourceOperationHistory operationHistory) {
+ OperationRequestStatus status = operationHistory.getStatus();
+ if (status == OperationRequestStatus.SUCCESS || status == OperationRequestStatus.FAILURE) {
+ EnhancedVLayout resultsSection = new EnhancedVLayout();
+
+ OperationDefinition operationDefinition = operationHistory.getOperationDefinition();
+ ConfigurationDefinition resultsConfigurationDefinition = operationDefinition
+ .getResultsConfigurationDefinition();
+ if (resultsConfigurationDefinition != null
+ && !resultsConfigurationDefinition.getPropertyDefinitions().isEmpty()) {
+ ConfigurationEditor editor = new ConfigurationEditor(
+ operationDefinition.getResultsConfigurationDefinition(), operationHistory.getResults());
+ editor.setPreserveTextFormatting(true);
+ editor.setReadOnly(true);
+ resultsSection.addMember(editor);
+ } else {
+ Label noResultsLabel = new Label(MSG.view_operationHistoryDetails_noResults());
+ noResultsLabel.setHeight(17);
+ resultsSection.addMember(noResultsLabel);
+ }
+
+ return resultsSection;
+ } else {
+ return null;
+ }
+ }
private void prepareDetailsSection(SectionStack stack, Agent agent) {
final DynamicForm form = new DynamicForm();
@@ -222,4 +303,60 @@ public class AgentDetailView extends EnhancedVLayout {
detailsSection = section;
++initSectionCount;
}
+
+
+ private void loadPlugins(final int resourceId) {
+ if (waitingForPlugins) {
+ return;
+ }
+ waitingForPlugins = true;
+ GWTServiceLookup.getOperationService().scheduleResourceOperation(resourceId, "retrieveAllPluginInfo", null,
+ "Run by RHQ Server", 0, new AsyncCallback<Void>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ waitingForPlugins = false;
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ waitingForPlugins = false;
+ final ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addFilterOperationName("retrieveAllPluginInfo");
+ criteria.addSortEndTime(PageOrdering.DESC);
+ criteria.fetchResults(true);
+ new Timer() {
+ @Override
+ public void run() {
+ GWTServiceLookup.getOperationService().findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ waitingForPlugins = false;
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ if (!result.isEmpty()) {
+ ResourceOperationHistory opHistory = result.get(0);
+ if (opHistory.getStatus() == OperationRequestStatus.SUCCESS
+ || opHistory.getStatus() == OperationRequestStatus.FAILURE) {
+ pluginsSection.removeMembers(pluginsSection.getMembers());
+ pluginsSection.addMember(buildResultsSection(opHistory));
+ pluginsSection.markForRedraw();
+ waitingForPlugins = false;
+ } else if (opHistory.getStatus() == OperationRequestStatus.INPROGRESS) {
+ schedule(1000);
+ }
+ }
+ }
+ });
+ }
+
+ }.schedule(700);
+ }
+ });
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/TopologyGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/TopologyGWTService.java
index 2547a19..8565070 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/TopologyGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/TopologyGWTService.java
@@ -235,4 +235,12 @@ public interface TopologyGWTService extends RemoteService {
*/
void removeAgentsFromGroup(Integer[] agentIds) throws RuntimeException;
+ /**
+ * Returns the id of managed reource representing this agent instance
+ *
+ * @param agentId an id of <code>Agent</code> instance
+ * @return id of the associated resource <code>null</code> if there is no associated resource
+ * @throws RuntimeException
+ */
+ Integer getResourceIdOfAgent(int agentId) throws RuntimeException;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/TopologyGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/TopologyGWTServiceImpl.java
index baeb312..90b4b0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/TopologyGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/TopologyGWTServiceImpl.java
@@ -268,4 +268,13 @@ public class TopologyGWTServiceImpl extends AbstractGWTServiceImpl implements To
throw getExceptionToThrowToClient(t);
}
}
+
+ @Override
+ public Integer getResourceIdOfAgent(int agentId) throws RuntimeException {
+ try {
+ return topologyManager.getResourceIdOfAgent(getSessionSubject(), agentId);
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerBean.java
index c4225de..8c945ea 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerBean.java
@@ -26,6 +26,7 @@ import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
+import javax.persistence.TypedQuery;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -336,4 +337,19 @@ public class TopologyManagerBean implements TopologyManagerLocal {
CriteriaQueryRunner<Server> runner = new CriteriaQueryRunner<Server>(criteria, generator, entityManager);
return runner.execute();
}
+
+ @RequiredPermissions({ @RequiredPermission(Permission.MANAGE_SETTINGS),
+ @RequiredPermission(Permission.MANAGE_INVENTORY) })
+ public Integer getResourceIdOfAgent(Subject subject, int agentId) {
+ TypedQuery<Integer> query = entityManager.<Integer> createNamedQuery(
+ Agent.QUERY_FIND_AGENT_RESOURCE_ID_AGENT_ID, Integer.class);
+ query.setParameter("agentId", agentId);
+
+ try {
+ Integer resourceId = query.getSingleResult();
+ return resourceId;
+ } catch (NoResultException nre) {
+ return null;
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerLocal.java
index 11b9f95..c5e3c6e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/TopologyManagerLocal.java
@@ -163,4 +163,16 @@ public interface TopologyManagerLocal {
* @return list of servers
*/
PageList<Server> findServersByCriteria(Subject subject, ServerCriteria criteria);
+
+
+ /**
+ * Returns the id of managed reource representing this agent instance
+ *
+ * the subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ *
+ * @param subject caller
+ * @param agentId an id of <code>Agent</code> instance
+ * @return id of the associated resource <code>null</code> if there is no associated resource
+ */
+ Integer getResourceIdOfAgent(Subject subject, int agentId);
}
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index b8ca439..f0b4cc7 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -99,6 +99,7 @@
<c:simple-property name="timestamp" description="Last time the plugin was updated" />
<c:simple-property name="size" description="Size of the plugin file" />
<c:simple-property name="md5" description="MD5 of the plugin file" />
+ <c:simple-property name="enabled" type="boolean" description="Identifies whether the plugin is enabled on the agent" />
</c:map-property>
</c:list-property>
</results>
commit a0dcf786728aaca8720f631674dd5e5cad7a4d3f
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Feb 26 15:43:47 2014 +0100
Adding Libor to !jon-team irc bot command.
diff --git a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
index ed74576..e40e83f 100644
--- a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
+++ b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
@@ -77,6 +77,7 @@ public class RhqIrcBotListener extends ListenerAdapter<RhqIrcBot> {
JON_DEVS.add("jsanda");
JON_DEVS.add("jshaughn");
JON_DEVS.add("lkrejci");
+ JON_DEVS.add("lzoubek");
JON_DEVS.add("mazz");
JON_DEVS.add("mtho11");
JON_DEVS.add("pilhuhn");
9 years, 9 months
[rhq] Branch 'release/jon3.2.x' - 2 commits - modules/plugins
by Jay Shaughnessy
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java | 6 +++---
modules/plugins/script/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
New commits:
commit 27d664d1c294822a0162711f73decbf03b1ea73a
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Feb 27 09:24:25 2014 -0500
[BZ 1005951] ScriptServer resource availability regular expression matching
fails due to complete string matching being applied to multiline output
Improved description for availabilityOutputRegex config property.
Cherry-Pick master 62cc988c8980a15e00b61fc45370f76c10a3608f
Signed-off-by: Jay Shaughnessy <jshaughn(a)redhat.com>
diff --git a/modules/plugins/script/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/script/src/main/resources/META-INF/rhq-plugin.xml
index e1a96f2..92aded8 100644
--- a/modules/plugins/script/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/script/src/main/resources/META-INF/rhq-plugin.xml
@@ -29,7 +29,7 @@
<c:group name="avail" displayName="Availability Definition">
<c:simple-property name="availabilityExecuteCheck" required="false" type="boolean" description="If specified and true, the ability to successfully execute the executable can determine whether or not the managed resource is considered up and available. If you set this to true, you normally do not set the availability regex settings in order to allow availability to be determined based solely on the successful execution, regardless of the exit code or output. If this is false, setting one of the avail regex settings will override it as if it were true."/>
<c:simple-property name="availabilityExitCodeRegex" required="false" description="If specified, the executable must return an exit code that matches this regular expression if the managed resource is to be considered up and available"/>
- <c:simple-property name="availabilityOutputRegex" required="false" description="If specified, the executable must output text that matches this regular expression if the managed resource is to be considered up and available"/>
+ <c:simple-property name="availabilityOutputRegex" required="false" description="If specified, the executable must output text that matches this regular expression if the managed resource is to be considered up and available. Expression is evaluated by Pattern.find() so match actually means first match found in text. Pattern `OK` matches multiline text `Service status\n is OK`. By default ^$ represent start/end of output text. To match start/end of line add (?m). eg. `(?m)^ is OK$`. To match whole multi-line output use (?s), eg. `(?s)Service.*OK`."/>
<c:simple-property name="availabilityArguments" required="false" description="If the executable needs to be executed in order to determine availability, these are the arguments that will be passed to the executable. If you do not specify the regex settings and you set the execute check setting to false, the executable will not be executed and these arguments will not be used - in this case, availability will be determined by the mere existence of the executable file."/>
</c:group>
<c:group name="version" displayName="Version Definition">
commit 26b3ff9c1d544267405804bc4cd72d762a8c0586
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Feb 27 09:21:04 2014 -0500
[BZ 1005951] ScriptServer resource availability regular expression matching
fails due to complete string matching being applied to multiline output
Fixed by changing to Pattern.matcher().find() instead of String.matches.
Users do not need to write long or crazy regexes to find match in multi-line
output. Previously you'd write `(?s).*OK.*` to match 'a\nb\nOK\n' now just
use `OK`
Signed-off-by: Jay Shaughnessy <jshaughn(a)redhat.com>
diff --git a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
index d62f2a1..a440d8e 100644
--- a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
+++ b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
@@ -442,7 +442,7 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
boolean availExecuteCheck = false;
String availArgs = null;
String availExitCodeRegex = null;
- String availOutputRegex = null;
+ Pattern availOutputRegex = null;
// determine how we are to consider the CLI available by looking at the plugin configuration
try {
@@ -471,7 +471,7 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
}
if (availOutputRegexProp != null && availOutputRegexProp.getStringValue() != null) {
- availOutputRegex = availOutputRegexProp.getStringValue();
+ availOutputRegex = Pattern.compile(availOutputRegexProp.getStringValue());
}
} catch (Exception e) {
throw new InvalidPluginConfigurationException("Cannot get avail plugin config. Cause: " + e);
@@ -526,7 +526,7 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
output = output.trim();
}
- boolean outputMatches = output.matches(availOutputRegex);
+ boolean outputMatches = availOutputRegex.matcher(output).find();
if (!outputMatches) {
if (log.isDebugEnabled()) {
logDebug("CLI output [" + truncateString(output) + "] did not match regex [" + availOutputRegex
9 years, 9 months
[rhq] Changes to 'spinder/cumulative'
by Simeon Pinder
New branch 'spinder/cumulative' available with the following commits:
commit f83b2a2ae6696eecf6e7ab0d78c75b0be324dfd3
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Feb 26 16:04:01 2014 -0500
A few more updates for independent versioning of rhq-core-domain as used in many places.
- user project.parent.version instead as this will not change.
commit a647415466b36145142a92b1c4661a9c11b2eb62
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Wed Feb 26 14:36:50 2014 -0500
Update rhq-core-domain for independent versioning as well.
commit a3128d74d05328046785d4670fee518f74887966
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Tue Feb 25 15:58:10 2014 -0500
Add support for incremental pom versioning for dependencies.
commit 1737a19f0974f614a043af829177fc602f0ec886
Author: Simeon Pinder <spinder(a)fulliautomatix.conchfritter.com>
Date: Mon Feb 24 06:24:38 2014 -0500
Modify jboss-as-dmr-client to be patchable.
9 years, 9 months
[rhq] Branch 'release/jon3.2.x' - modules/plugins
by Jay Shaughnessy
modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java | 14 ++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
New commits:
commit e66e440677ca2059a8c44ee0aef8b5826d6228d6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 26 17:12:23 2014 -0500
[915532] [apache] Unable to discover Apache httpd on Windows if Include...
Revision of fix in commit 3d9cdf6d9d7eae5643ff270816b236ba0dc74f9b after review.
(revised fix)
Apply fix based on Larry O'Leary's suggestion in the BZ. Localize the
change to a windows-only block in Glob.rootPortion such that all callers
benefit and non-windows is unaffected.
Conflicts:
modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
Cherry-Pick of Master 213f42ae56da1215cf57bc56bf05dfcbe28e11c7
Reviewed-by: Larry O'Leary <loleary(a)redhat.com>
Signed-off-by: Jay Shaughnessy <jshaughn(a)redhat.com>
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
index c61f932..588ab7f 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
@@ -30,6 +30,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -214,6 +215,15 @@ public class Glob {
}
public static String rootPortion(String path) {
+ // On Windows, make sure we have the correct drive letter format and slash direction for comparison.
+ if (File.separator.equals("\\")) {
+ try {
+ File f = new File(path);
+ path = f.isAbsolute() ? f.getCanonicalPath() : f.getPath();
+ } catch (Exception e) {
+ // should not happen but just leave path as-is
+ }
+ }
File[] roots = File.listRoots();
if (roots != null) {
for (File root : roots) {
@@ -223,8 +233,8 @@ public class Glob {
}
} else {
log.warn("Could not determine file system roots. This is strange.");
- }
-
+ }
+
return "";
}
}
9 years, 9 months
[rhq] modules/plugins
by Jay Shaughnessy
modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java | 12 +++++-----
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 213f42ae56da1215cf57bc56bf05dfcbe28e11c7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 26 16:51:27 2014 -0500
[915532] [apache] Unable to discover Apache httpd on Windows if Include...
Revision of fix in commit 3d9cdf6d9d7eae5643ff270816b236ba0dc74f9b after review.
(revised fix)
Apply fix based on Larry O'Leary's suggestion in the BZ. Localize the
change to a windows-only block in Glob.rootPortion such that all callers
benefit and non-windows is unaffected.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
index 96faf5c..993acd8 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
@@ -24,7 +24,6 @@
package org.rhq.augeas.util;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -216,12 +215,13 @@ public class Glob {
}
public static String rootPortion(String path) {
- // On Windows, make sure we have the correct case and slash direction for comparison.
+ // On Windows, make sure we have the correct drive letter format and slash direction for comparison.
if (File.separator.equals("\\")) {
try {
- path = new File(path).getCanonicalPath();
- } catch (IOException e) {
- // should never happen but just leave path as-is
+ File f = new File(path);
+ path = f.isAbsolute() ? f.getCanonicalPath() : f.getPath();
+ } catch (Exception e) {
+ // should not happen but just leave path as-is
}
}
File[] roots = File.listRoots();
@@ -233,7 +233,7 @@ public class Glob {
}
} else {
log.warn("Could not determine file system roots. This is strange.");
- }
+ }
return "";
}
9 years, 9 months
[rhq] modules/plugins
by Jay Shaughnessy
modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java | 88 +++++-----
1 file changed, 49 insertions(+), 39 deletions(-)
New commits:
commit 3d9cdf6d9d7eae5643ff270816b236ba0dc74f9b
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Feb 26 13:11:03 2014 -0500
[915532] [apache] Unable to discover Apache httpd on Windows if Include directive contains a path that starts with a lowercase drive letter or contains a forward-slash (/) as the file separator
Apply fix based on Larry O'Leary's suggestion in the BZ. Localize the
change to a windows-only block in Glob.rootPortion such that all callers
benefit and non-windows is unaffected.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
index c61f932..96faf5c 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/util/Glob.java
@@ -24,18 +24,20 @@
package org.rhq.augeas.util;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A helper class for easy work with glob patterns.
- *
+ *
* @author Lukas Krejci
*/
public class Glob {
@@ -43,22 +45,22 @@ public class Glob {
private static final Log log = LogFactory.getLog(Glob.class);
public static final Comparator<File> ALPHABETICAL_COMPARATOR = new Comparator<File>() {
-
+
public int compare(File o1, File o2) {
String path1 = o1.getAbsolutePath();
String path2 = o2.getAbsolutePath();
-
+
return path1.compareTo(path2);
}
};
-
+
private Glob() {
-
+
}
-
+
/**
* Checks whether the provided string is a wildcard glob pattern.
- *
+ *
* @param globPattern
* @return
*/
@@ -68,13 +70,13 @@ public class Glob {
}
return false;
}
-
+
/**
* Checks if the file matches the glob pattern with given path as a root of the filesystem.
- *
+ *
* If the glob pattern denotes an absolute path, it is understood to be under the supplied
* fs root.
- *
+ *
* @param rootPath
* @param globPattern
* @param file
@@ -83,32 +85,32 @@ public class Glob {
public static boolean matches(File rootPath, String globPattern, File file) {
String rootPortion = rootPortion(globPattern);
globPattern = globPattern.substring(rootPortion.length());
-
+
globPattern = new File(rootPath, globPattern).getAbsolutePath();
-
+
return new GlobFilter(globPattern).accept(file);
}
-
+
/**
* This is an overloaded version of the {@link #match(File, String, Comparator)} method
* that passes <code>null</code> as the comparator to use.
- *
- * @see #match(File, String, Comparator)
+ *
+ * @see #match(File, String, Comparator)
*/
public static List<File> match(File parentPath, String globPattern) {
return match(parentPath, globPattern, null);
}
-
+
/**
* Returns a fixed size list of matches.
- *
+ *
* The parent path specifies the "root" from which the glob pattern applies.
* The glob pattern can span several directories with wildcards present only
* on the lowest level.
* The glob pattern is always relative to the specified parent path, even if it denotes
* an absolute path. In that case, the leading root path is chopped off and the rest is
* appended to the parent path.
- *
+ *
* @param parentPath the parent path to start the pattern search
* @param globPattern the glob pattern to match against
* @param resultComparator the comparator using which to sort the results or null if no sorting is necessary
@@ -124,7 +126,7 @@ public class Glob {
String rootPortion = rootPortion(globPattern);
globPattern = globPattern.substring(rootPortion.length());
-
+
//now search for the first special character in the patterns
int specialCharIdx = globPattern.length();
for(char specialChar : GlobFilter.WILDCARD_CHARS) {
@@ -133,12 +135,12 @@ public class Glob {
specialCharIdx = idx;
}
}
-
+
if (specialCharIdx > 0) {
//now search for the first path separator preceding the special char
int globParentIdx = globPattern.lastIndexOf(File.separatorChar, specialCharIdx);
if (globParentIdx > 0) {
- //move the parent path down to the nearest parent of the wildcard part of the
+ //move the parent path down to the nearest parent of the wildcard part of the
//glob pattern
parentPath = new File(parentPath, globPattern.substring(0, globParentIdx));
globPattern = createGlobPattern(parentPath.getAbsolutePath(), globPattern.substring(globParentIdx));
@@ -146,7 +148,7 @@ public class Glob {
globPattern = createGlobPattern(parentPath.getAbsolutePath(),globPattern);
}
} else {
- globPattern = createGlobPattern(parentPath.getAbsolutePath(),globPattern);
+ globPattern = createGlobPattern(parentPath.getAbsolutePath(),globPattern);
}
globPattern = new File(globPattern).getAbsolutePath();
@@ -155,46 +157,46 @@ public class Glob {
log.debug("Could list files in " + parentPath);
return Collections.emptyList();
}
-
+
if (resultComparator != null) {
Arrays.sort(files, resultComparator);
}
-
+
return Arrays.asList(files);
}
-
+
private static String createGlobPattern(String parent,String pattern){
if (!parent.endsWith(File.separator))
parent = parent + File.separatorChar;
return parent+pattern;
}
-
+
/**
* This is an overloaded version of the {@link #matchAll(File, List, Comparator)} method
* that passes <code>null</code> as the comparator to use.
- *
- * @see #matchAll(File, List, Comparator)
+ *
+ * @see #matchAll(File, List, Comparator)
*/
public static List<File> matchAll(File parentPath, List<String> globPatterns) {
return matchAll(parentPath, globPatterns, null);
}
-
+
public static List<File> matchAll(File parentPath, List<String> globPatterns, Comparator<? super File> resultComparator) {
ArrayList<File> matches = new ArrayList<File>();
for(String p : globPatterns) {
matches.addAll(match(parentPath, p, null));
}
-
+
if (resultComparator != null) {
Collections.sort(matches, resultComparator);
}
-
+
return matches;
}
-
+
public static void exclude(List<File> matches, String globPattern) {
GlobFilter filter = new GlobFilter(globPattern);
-
+
Iterator<File> it = matches.iterator();
while (it.hasNext()) {
if (filter.accept(it.next())) {
@@ -202,18 +204,26 @@ public class Glob {
}
}
}
-
+
public static void excludeAll(List<File> matches, String... globPattern) {
excludeAll(matches, Arrays.asList(globPattern));
- }
-
- public static void excludeAll(List<File> matches, List<String> globPatterns) {
+ }
+
+ public static void excludeAll(List<File> matches, List<String> globPatterns) {
for(String p : globPatterns) {
exclude(matches, p);
}
}
public static String rootPortion(String path) {
+ // On Windows, make sure we have the correct case and slash direction for comparison.
+ if (File.separator.equals("\\")) {
+ try {
+ path = new File(path).getCanonicalPath();
+ } catch (IOException e) {
+ // should never happen but just leave path as-is
+ }
+ }
File[] roots = File.listRoots();
if (roots != null) {
for (File root : roots) {
@@ -223,8 +233,8 @@ public class Glob {
}
} else {
log.warn("Could not determine file system roots. This is strange.");
- }
-
+ }
+
return "";
}
}
9 years, 9 months