modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java |
67 +++++++++-
modules/enterprise/server/jar/pom.xml |
17 --
2 files changed, 67 insertions(+), 17 deletions(-)
New commits:
commit 9b6831b83b685647ea558295a5164ccba85c5e17
Merge: 9f86763... 0109deb...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jan 18 09:20:56 2011 +0100
Merge branch 'master' of
ssh://git.fedorahosted.org/git/rhq/rhq
commit 9f8676316a606be9fe2c5798c8edb934fa8958d3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jan 17 18:58:48 2011 +0100
Allow to list metrics on the resource.
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index c5c7de7..25b5394 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -46,6 +46,7 @@ import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataRequest;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -369,14 +370,14 @@ public class StandaloneContainer {
* @throws Exception if anything goes wrong
*/
private void invokeOps(String[] tokens) throws Exception {
- if (resourceId == 0)
+ if (resourceId == 0) {
+ System.err.println("No resource selected");
return;
+ }
String operation = tokens[1];
if (operation.equals("-list")) {
- ResourceContainer rc = inventoryManager.getResourceContainer(resourceId);
- Resource res = rc.getResource();
- ResourceType rt = res.getResourceType();
+ ResourceType rt = getTypeForResourceId();
Set<OperationDefinition> opDefs = rt.getOperationDefinitions();
for (OperationDefinition def :opDefs) {
System.out.println(def.getName() + " : " +
def.getDescription());
@@ -419,6 +420,12 @@ public class StandaloneContainer {
}
+ private ResourceType getTypeForResourceId() {
+ ResourceContainer rc = inventoryManager.getResourceContainer(resourceId);
+ Resource res = rc.getResource();
+ return res.getResourceType();
+ }
+
/**
* Enables or disables the native layer.
* @param tokens tokenized command line tokens[0] is the command itself
@@ -587,6 +594,11 @@ public class StandaloneContainer {
} catch (NumberFormatException nfe) {
System.err.println("Sorry, but [" + arg + "] is no valid
number");
}
+ ResourceContainer rc = inventoryManager.getResourceContainer(resourceId);
+ if (rc==null) {
+ System.err.println("No resource with that id exists");
+ resourceId=0;
+ }
} else
System.err.println("Bad command " + tokens[1]);
@@ -638,6 +650,26 @@ public class StandaloneContainer {
return;
}
+ MeasurementManager mm = pc.getMeasurementManager();
+
+ if (tokens[1].equals("-list")) {
+ ResourceType rt = getTypeForResourceId();
+ Set<MeasurementDefinition> defs = rt.getMetricDefinitions();
+ if (defs==null || defs.isEmpty()) {
+ System.out.println("Resource has no metrics");
+ return;
+ }
+ for (MeasurementDefinition def : defs) {
+ System.out.println(def.getName() + " : " + def.getDataType() +
", " + def.getDescription());
+ }
+ return;
+ }
+
+ if (tokens.length<3) {
+ System.err.println("measure needs at least two parameters");
+ return;
+ }
+
DataType dataType = getDataType(tokens[1]);
if (dataType == null) {
System.err.println("Unknown DataType " + tokens[1]);
@@ -652,7 +684,6 @@ public class StandaloneContainer {
requests.add(new MeasurementDataRequest(metric, dataType));
}
- MeasurementManager mm = pc.getMeasurementManager();
Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(resourceId,
requests);
if (dataset == null) {
System.err.println("No data returned");
@@ -743,7 +774,7 @@ public class StandaloneContainer {
"Searches a (r)esource, resource (t)ype or resources of (rt)ype. Use *
as wildcard.\n"
+ " Will set $r for the last resource shown."),
HELP("h", "", 0, "Shows this help"), //
INVOKE("i", "operation [params]", 1, "Triggers running
an operation. If operation is '-list' it shows available operations"), //
- MEASURE("m", "datatype property+", 2, "Triggers getting
metric values. All need to be of the same data type"), //
+ MEASURE("m", "datatype property+", 1, "Triggers getting
metric values. All need to be of the same data type. If datatype is '-list' it
shows the defined metrics"), //
NATIVE("n", "e | d | s", 1, "Enables/disables native
system or shows native status"), //
QUIT("quit", "", 0, "Terminates the application"),
//
RESOURCES("res", "", 0, "Shows the discovered
resources"), //
commit ccd96c0230d78ec15798ca398268747953eb67d5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jan 17 17:24:13 2011 +0100
Allow to list operations on the resource.
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 6aa3378..c5c7de7 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -38,12 +38,15 @@ import java.util.Stack;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataRequest;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.inventory.InventoryManager;
@@ -369,6 +372,29 @@ public class StandaloneContainer {
if (resourceId == 0)
return;
+ String operation = tokens[1];
+ if (operation.equals("-list")) {
+ ResourceContainer rc = inventoryManager.getResourceContainer(resourceId);
+ Resource res = rc.getResource();
+ ResourceType rt = res.getResourceType();
+ Set<OperationDefinition> opDefs = rt.getOperationDefinitions();
+ for (OperationDefinition def :opDefs) {
+ System.out.println(def.getName() + " : " +
def.getDescription());
+ ConfigurationDefinition params =
def.getParametersConfigurationDefinition();
+ if (params!=null && params.getPropertyDefinitions()!=null
&& !params.getPropertyDefinitions().isEmpty()) {
+ System.out.println(" Parameters:");
+ for (Map.Entry<String,PropertyDefinition> param :
params.getPropertyDefinitions().entrySet()) {
+ System.out.println(" " + param.getKey()); // TODO
add more info
+ }
+ }
+ }
+ if (opDefs.isEmpty()) {
+ System.out.println("Resource has no operations");
+ }
+ return;
+ }
+
+
OperationManager opMan = pc.getOperationManager();
OperationServices operationServices = new OperationServicesAdapter(opMan);
OperationContext operationContext = new OperationContextImpl(resourceId,
operationServices);
@@ -716,7 +742,7 @@ public class StandaloneContainer {
FIND("find", "r | t | rt <name>", 2,
"Searches a (r)esource, resource (t)ype or resources of (rt)ype. Use *
as wildcard.\n"
+ " Will set $r for the last resource shown."),
HELP("h", "", 0, "Shows this help"), //
- INVOKE("i", "operation [params]", 1, "Triggers running
an operation"), //
+ INVOKE("i", "operation [params]", 1, "Triggers running
an operation. If operation is '-list' it shows available operations"), //
MEASURE("m", "datatype property+", 2, "Triggers getting
metric values. All need to be of the same data type"), //
NATIVE("n", "e | d | s", 1, "Enables/disables native
system or shows native status"), //
QUIT("quit", "", 0, "Terminates the application"),
//
commit 1e4d3b0fd98264b476cb36f196a25b49bda959a3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Sun Jan 16 19:29:28 2011 +0100
Remove duplicate def of test-utils.
diff --git a/modules/enterprise/server/jar/pom.xml
b/modules/enterprise/server/jar/pom.xml
index 7363fcc..36298c2 100644
--- a/modules/enterprise/server/jar/pom.xml
+++ b/modules/enterprise/server/jar/pom.xml
@@ -1,5 +1,5 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -410,18 +410,11 @@
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>test-utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>1.8</version>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.rhq.helpers</groupId>
@@ -745,12 +738,12 @@ Build-OS-Version=${os.version}
<build>
<plugins>
<plugin>
- <artifactId>maven-antrun-plugin</artifactId>
+ <artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
- <version>1.9.4.1</version>
+ <version>1.9.4.1</version>
</dependency>
</dependencies>
<executions>
commit 9fda617cec96a818efba1135207598491b5ac7bf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jan 12 21:37:30 2011 +0100
Wrong variable was checked for null.
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 45cad5d..6aa3378 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -385,7 +385,7 @@ public class StandaloneContainer {
System.err.println("Operation timed out ");
} else {
Configuration result = res.getComplexResults();
- if (res == null)
+ if (result == null)
System.out.println("Operation did not return a result");
else
System.out.println(result.getProperties());