Things I dont know how to do with plugins
by Bryan Kearney
Working through a plugin, there were a couple of things I did not know
how to do. Any pointers on best practices would be appreciated.
1) I would like to exposed operations based on the state (availability)
of the resource.
2) I would like to kick off discovery based on an operation being executed.
3) I would like to update availability based on an operation.
I assume some/all of this is supported.
-- bk
13 years, 9 months
CLI questions
by Marek Goldmann
Hi all,
How can I import a resource? I can see in ResourceManager a uninventory command, but where is addToInventory command? I cannot see InventoryManager exposed in remote API as InventoryManagerRemote? It is a bug or "feature"?
There is a need to add for more complicated examples to http://www.rhq-project.org/display/JOPR2/Running+the+RHQ+CLI page. Currently there are only searching examples which is good but not sufficient. More examples like: updating configuration, setting alerts, importing, unimporting, deploying apps, etc etc would be much appreciated.
--Marek
14 years, 2 months
[PATCH] Modify the AgentMain to use jline Consoles instead of reading from standard in. The big benefit is to be able to use command history in the agent
by Bryan Kearney
---
modules/enterprise/agent/ant-run.xml | 1 +
modules/enterprise/agent/pom.xml | 7 +++++++
.../java/org/rhq/enterprise/agent/AgentMain.java | 20 +++++++++++---------
.../rhq/enterprise/agent/AgentUpdateThread.java | 14 +-------------
modules/enterprise/remoting/cli/pom.xml | 2 --
pom.xml | 1 +
6 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/modules/enterprise/agent/ant-run.xml b/modules/enterprise/agent/ant-run.xml
index 0b5db52..ec28381 100644
--- a/modules/enterprise/agent/ant-run.xml
+++ b/modules/enterprise/agent/ant-run.xml
@@ -34,6 +34,7 @@ ANT Script that provides ways to package the agent.
<include name="javax/persistence/persistence-api/1.0/persistence-api-1.0.jar" />
<include name="i18nlog/i18nlog/1.0.9/i18nlog-1.0.9.jar" />
<include name="log4j/log4j/1.2.14/log4j-1.2.14.jar" />
+ <include name="jline/jline/${jline.version}/jline-${jline.version}.jar" />
<include name="commons-logging/commons-logging/1.1.0.jboss/commons-logging-1.1.0.jboss.jar" />
<include name="gnu-getopt/getopt/${getopt.version}/getopt-${getopt.version}.jar" />
<include name="commons-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar" />
diff --git a/modules/enterprise/agent/pom.xml b/modules/enterprise/agent/pom.xml
index 33060fb..b4607c8 100644
--- a/modules/enterprise/agent/pom.xml
+++ b/modules/enterprise/agent/pom.xml
@@ -58,6 +58,12 @@
<artifactId>rhq-core-client-api</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>${jline.version}</version>
+ </dependency>
<dependency>
<!-- The only reason why this is here is so we can pull this down from the repo.
@@ -174,6 +180,7 @@ Build-Number=${buildNumber}
<property name="sigar.version" value="${sigar.version}" />
<property name="jaxb-api.version" value="${jaxb-api.version}" />
<property name="jaxb-impl.version" value="${jaxb-impl.version}" />
+ <property name="jline.version" value="${jline.version}" />
</ant>
</tasks>
</configuration>
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index 32a7398..0d900d4 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -58,6 +58,8 @@ import java.util.prefs.Preferences;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import jline.ConsoleReader;
+
import mazz.i18n.Logger;
import mazz.i18n.Msg;
@@ -206,7 +208,7 @@ public class AgentMain {
/**
* The stream where the commands are input.
*/
- private BufferedReader m_input;
+ private ConsoleReader m_input;
/**
* Will be <code>true</code> if the input is coming directly from stdin; <code>false</code> if an input script file
@@ -461,7 +463,7 @@ public class AgentMain {
m_agentHomeDirectory = null;
m_daemonMode = false;
- m_input = new BufferedReader(new InputStreamReader(System.in));
+ m_input = new ConsoleReader() ;
m_output = new AgentPrintWriter(System.out, true);
m_stdinInput = true;
m_configuration = null;
@@ -802,7 +804,7 @@ public class AgentMain {
*
* @return the input stream or <code>null</code> if the agent is not currently accepting input
*/
- public BufferedReader getIn() {
+ public ConsoleReader getIn() {
return m_input;
}
@@ -1091,14 +1093,14 @@ public class AgentMain {
}
} else if (!m_stdinInput) {
// if we are processing a script, we hit the EOF, so close the input stream
- try {
- m_input.close();
- } catch (IOException e1) {
- }
+
// if we are not in daemon mode, let's now start processing prompt commands coming in via stdin
if (!m_daemonMode) {
- m_input = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ m_input = new ConsoleReader() ;
+ } catch (IOException e1) {
+ }
m_stdinInput = true;
input_string = "";
} else {
@@ -2770,7 +2772,7 @@ public class AgentMain {
File script = new File(getopt.getOptarg());
try {
- m_input = new BufferedReader(new FileReader(script));
+ m_input = new ConsoleReader(new FileInputStream(script), null);
m_stdinInput = false;
} catch (Exception e) {
throw new IllegalArgumentException(MSG.getMsg(AgentI18NResourceKeys.BAD_INPUT_FILE, script, e));
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java
index 5bc2a8a..4d691c2 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentUpdateThread.java
@@ -174,19 +174,7 @@ public class AgentUpdateThread extends Thread {
if (results.getError() != null) {
throw results.getError();
}
-
- // update has started! if this agent is running in non-daemon mode, kill
- // the input stream so the input thread knows to shutdown now
- try {
- BufferedReader in = this.agent.getIn();
- if (in != null) {
- System.in.close(); // we must ensure we close this directly!
- in.close();
- }
- } catch (Throwable t) {
- } finally {
- tryAgain = false;
- }
+ tryAgain = false;
} catch (Throwable t) {
showErrorMessage(AgentI18NResourceKeys.UPDATE_THREAD_EXCEPTION, ThrowableUtil.getAllMessages(t));
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 6f1d556..b4adfee 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -20,8 +20,6 @@
<properties>
<scm.module.path>modules/enterprise/remoting/</scm.module.path>
-
- <jline.version>0.9.94</jline.version>
<i18nlog.version>1.0.9</i18nlog.version>
<log4j.version>1.2.14</log4j.version>
<persistence-api.version>1.0</persistence-api.version>
diff --git a/pom.xml b/pom.xml
index c5cfd44..3fab5d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,6 +74,7 @@
<postgresql.version>8.4-701.jdbc3</postgresql.version>
<h2.version>1.1.117</h2.version>
<jtds.version>1.2.2</jtds.version>
+ <jline.version>0.9.94</jline.version>
<richfaces.version>3.3.2.SR1</richfaces.version>
<sigar.version>1.6.3.82</sigar.version>
<quartz.version>1.6.5</quartz.version>
--
1.6.5.2
14 years, 2 months
Master Frozen
by Jason Dobies
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Please refrain from checking anything into master while I get the
community release done. I'll e-mail again when it's clear to commit again.
- --
Jason Dobies
http://rhq-project.org
RHCE# 805008743336126
Freenode: jdob @ #rhq
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJLYuSZAAoJEOMmcTqOSQHCWb4H/0GJ35pepaolxFqnErTCh0l/
2PTmvfwNsrNNCPpcr7UxNfb31VQctDEOuatYrkYvkf0fk0vwkNk5T6YDzSYYyZNr
8/5XD2VAPJ/DbRV43C8C9qZ51LI6m78cB+5NbnXhEwCuMcLGhc6FnwX6peLqlGhj
hixTDqsD6nvK8HIhEsEps9+GZEAQ8/lBHlCYffdDLhwrG4WIIYjM7wpp8Dc2BskL
sCLS8eCniCZ34QALBbDSE0lwSIjRBZ8Vtk2pw2z67gabQvvHxzJd0/7vbs6d575Q
FQb+fQ8Rz+2h6GHKp9Ayp9VMfM2Eu2uwuvW4S4DfDcVti6Rc95HOXzFVzmljOp0=
=pCjH
-----END PGP SIGNATURE-----
14 years, 2 months
Fwd: How to get SystemInfo from a Plugin
by John Mazzitelli
> For templating, it looks like all the information we want is hanging
> off the SystmInfo interface.
> We can get the system info object off the resource context. I am not
> sure the correct way to get the resource context. I see that it is
> available fairly early in the creation of the resource object on the
> agent side, but I'm unclear about where to get it later, specifically
> when trying to write configuration files.
I actually think you don't need the resource context for what you want
to do. The resource context is really just for the plugin component's
use - you'll see we create a context in
InventoryManager.activateResource and just pass it to the plugin itself.
But we do store it in the ResourceContainer - so if you have a
ResourceContainer instance, just call
org.rhq.core.pc.inventory.ResourceContainer.getResourceContext()
But you don't need that if all you want is a SystemInfo.
The SystemInfo object is the API into the native system stuff - it
essentially is the API we give to plugin developers so they can access
things via SIGAR.
There is a SystemInfoFactory object that is used to initialize SIGAR and
get a SystemInfo instance - for use by the plugin container.
If you need a SystemInfo object within the plugin container code (e.g.
not within a plugin, but inside the actual plugin container managers),
you can directly create a SystemInfo from the factory:
org.rhq.core.system.SystemInfoFactory.createSystemInfo()
(note: that actually doesn't "create" one - in that code, it actually
just returns a cached instance, so it only creates it once the first
time its called)
Hope that helps,
John Mazz
14 years, 3 months
RfC: put jruby-complete jar into server/default/lib ?
by Heiko W.Rupp
Hi,
This question is triggered by classloading issues with my alert-scriptlang plugin
http://git.fedorahosted.org/git/rhq/rht.git?p=rhq/rhq.git;a=commit;h=1b98...
The plugin would use the jruby-complete-1.4.jar. When I put the jar into jbossas/server/default/lib/ , the plugin
works, when it is loaded with the plugin, it doesn't.
Before I spend much time debugging this:
How do people feel if we'd include the jruby jar into the server by default and thus allow more code
on the server (e.g. in server plugins) be written in Ruby?
Heiko
--
Reg. Adresse: Red Hat GmbH, Otto-Hahn-Strasse 20, 85609 Dornach bei München
Handelsregister: Amtsgericht München HRB 153243
Geschaeftsführer: Brendan Lane, Charlie Peters, Michael Cunningham, Charles Cachera
14 years, 3 months
Switching default log4j threshold
by Mike McCune
I spent 30 minutes being frustrated that I couldn't see any changes
affected by adding DEBUG packages to our log4j config file. No mater
what I did, my console wouldn't show the additional output.
I realized it was the Threshold setting in our config file.
Anyone object if I bump this to DEBUG? Why would we permanently want to
hide DEBUG from the console output. Seems pointless
diff --git
a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/jboss-log4j.xml
b/modules/enterprise/se
index 8ec0af5..4702cdd 100644
---
a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/jboss-log4j.xml
+++
b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/jboss-log4j.xml
@@ -23,7 +23,7 @@
<param name="Target" value="System.out"/>
<!-- Appender will not log any messages with priority lower than
INFO even if the category's priority is set lower.
So essentially, this means DEBUG and TRACE messages will
never be output to the console -->
- <param name="Threshold" value="INFO"/>
+ <param name="Threshold" value="DEBUG"/>
--
Mike McCune
mmccune AT redhat.com
Red Hat Engineering | Portland, OR
Systems Management | 650.254.4248
14 years, 3 months
RFC: Generate the .classpath file eclipse
by Bryan Kearney
Here is a patch which will generate the classpath off of the maven repo.
The main issue this avoids is that if there are plugins which are
commented out, the .classpath will never be out of sync. The process to
use this would be:
1) Check out the code.
2) Build it.
3) From the root, run mvn eclipse:eclipse
4) Go into eclipse, import the directory which you created in (1).
4.1) I would create a working set if you have other projects in eclipse.
The main differneces/issues:
A) There is now one project per maven pom.
-- You can see what eclipse looks like before at [1]
-- You can see what eclipse looks like after at [2].
B) Empty directories (i.e. the root) are not shown in eclipse
C) Each directory would need to be added to eGit if you use it.
Comments are welcome.
-- bk
[1] http://bkearney.fedorapeople.org/before.png
[2] http://bkearney.fedorapeople.org/after.png
14 years, 3 months
server side plugin versions
by John Mazzitelli
The agent plugins seem to get their version strings injected into
MANIFEST.MF ImplementationVersion by maven. This lets our build process
stamp the plugins with the proper versions.
Server side plugins don't have that. Versioning is ad-hoc for server
plugins.
We need a common way for all our server plugins to be versioned so its
more maintainable.
I actually don't know the trick the agent plugins do to get themselves
versioned. Ian? do you know? I want the server plugins to do the same
thing so everthing is consistent.
14 years, 3 months