modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
| 48 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
| 5 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
| 15 +++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 21 ----
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
| 27 +++++
5 files changed, 98 insertions(+), 18 deletions(-)
New commits:
commit 8588f93e2b0752b38c95b50f8ad94922667ee206
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 29 15:21:29 2011 +0200
Create / delete server groups via the usual means.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
index 7b20363..d28d078 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -22,8 +22,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.Result;
@@ -61,4 +65,48 @@ public class HostControllerComponent extends BaseServerComponent
implements Oper
// Defer other stuff to the base component for now
return super.invokeOperation(name, parameters);
}
+
+
+ @Override
+ public CreateResourceReport createResource(CreateResourceReport report) {
+
+ // TODO check for types of children -- this is server group only at the moment.
+
+ String name = report.getUserSpecifiedResourceName();
+ Address address = new Address(path);
+ address.add("server-group",name);
+ Operation op = new Operation("add",address);
+
+ Configuration rc = report.getResourceConfiguration();
+ String profile = rc.getSimpleValue("profile","");
+ if (profile.isEmpty()) {
+ report.setErrorMessage("No profile given");
+ report.setStatus(CreateResourceStatus.FAILURE);
+ return report;
+ }
+ op.addAdditionalProperty("profile",profile);
+ String socketBindingGroup =
rc.getSimpleValue("socket-binding-group","");
+ if (socketBindingGroup.isEmpty()) {
+ report.setErrorMessage("No socket-binding-group given");
+ report.setStatus(CreateResourceStatus.FAILURE);
+ return report;
+ }
+ op.addAdditionalProperty("socket-binding-group",socketBindingGroup);
+ PropertySimple offset = rc.getSimple("socket-binding-port-offset");
+ if (offset!=null && offset.getStringValue()!=null)
+ op.addAdditionalProperty("socket-binding-port-offset",offset);
+ // TODO add jvm info
+
+ Result res = getASConnection().execute(op);
+ if (res.isSuccess()) {
+ report.setResourceKey(address.getPath());
+ report.setResourceName(name);
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ }
+ else {
+ report.setErrorMessage(res.getFailureDescription());
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ return report;
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index ad1109b..750743b 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -29,6 +29,8 @@ import java.util.Set;
import org.codehaus.jackson.JsonNode;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.ContentResponseResult;
@@ -37,10 +39,13 @@ import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index d762485..cb63263 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -53,6 +53,8 @@ public class Address {
public Address(String path) {
this();
+ if (path==null || path.isEmpty())
+ return;
String[] components = path.split(",");
for (String component : components) {
String tmp = component.trim();
@@ -94,4 +96,17 @@ public class Address {
builder.append('}');
return builder.toString();
}
+
+ public String getPath() {
+ StringBuilder builder = new StringBuilder();
+ Iterator<PROPERTY_VALUE> iter = path.iterator();
+ while (iter.hasNext()) {
+ PROPERTY_VALUE val = iter.next();
+ builder.append(val.getKey()).append('=').append(val.getValue());
+ if (iter.hasNext())
+ builder.append(',');
+ }
+ return builder.toString();
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 222300e..3432cb6 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -50,7 +50,7 @@
xmlns:c="urn:xmlns:rhq-configuration"
- <depends plugin="JMX" useClasses="true"/>
+ <depends plugin="JMX" useClasses="true"/>
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some
base functionality and then
@@ -137,21 +137,6 @@
</operation>
-->
- <operation name="server-group:add" displayName="Add
ServerGroup" description="Add a server group to the Domain.">
- <parameters>
- <c:simple-property name="name" description="Name of
Group to add"/>
- <c:simple-property name="profile" description="Profile
to add this group to">
- <c:option-source target="resource"
expression="type=Profile plugin=jboss-as-7"/>
- </c:simple-property>
- </parameters>
- </operation>
- <operation name="server-group:remove" displayName="Remove
ServerGroup" description="Remove a server group from the Domain.">
- <parameters>
- <c:simple-property name="name" description="Name of
Group to remove">
- <c:option-source target="resource"
expression="type=ServerGroup"/>
- </c:simple-property>
- </parameters>
- </operation>
<operation name="managed-server:add" displayName="Add managed
server" description="Add a new managed server">
<parameters>
<c:simple-property name="servername" displayName="Name
of the new server" required="true"/>
@@ -245,8 +230,8 @@
description="Server groups on this domain"
discovery="SubsystemDiscovery"
class="ServerGroupComponent"
+ createDeletePolicy="both"
- <!-- TODO move
operation to createDeletePolicy="create-only" -->
<plugin-configuration>
<c:simple-property name="path"
default="server-group" readOnly="true"/>
@@ -260,7 +245,7 @@
</c:simple-property>
<c:simple-property name="socket-binding-port-offset"
required="false" defaultValue="0" type="integer"
description="The default offset to be added to
the port values given by the socket binding group."/>
- <c:simple-property name="jvm"
required="false"/>
+ <c:simple-property name="jvm"
required="false"/> <!-- TODO -->
</resource-configuration>
</server>
diff --git
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
index cb10279..100abbd 100644
---
a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
+++
b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.testng.annotations.Test;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
/**
@@ -103,4 +104,30 @@ public class PathHandlingTest {
String path2 = bc.addressToPath(list);
assert path.equals(path2);
}
+
+ public void emptyAddress() throws Exception {
+
+ Address a = new Address();
+ assert a.getPath() != null;
+ assert a.getPath().isEmpty();
+ }
+
+ public void emptyAddress2() throws Exception {
+
+ Address a = new Address((String)null);
+ assert a.getPath() != null;
+ assert a.getPath().isEmpty();
+ }
+
+ public void addressPath1() throws Exception {
+ String path = "subsystem=jms,profile=default,queue=foo";
+ Address a = new Address("/"+path);
+ assert a.getPath().equals(path);
+ }
+
+ public void addressPath2() throws Exception {
+ String path = "subsystem=jms,profile=default,queue=foo";
+ Address a = new Address(path);
+ assert a.getPath().equals(path);
+ }
}