[wildfly-dev] HTTP API support for plain JBoss-CLI commands

John Mazzitelli mazz at redhat.com
Thu May 28 22:14:07 EDT 2015


FYI: This might be useful... Hawkular has a DMR client library built on top of the ModelNode/ModelControllerClient stuff - it is meant to be a more strongly typed library that helps you not have to know how to do all the low level ModelNode stuff to do basic things (though it still allows you to send custom ModelNode requests).

It's here:

https://github.com/hawkular/hawkular-agent/tree/master/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient

released here:

https://repository.jboss.org/nexus/content/groups/public/org/hawkular/agent/hawkular-dmr-client/

which includes javadoc/source jars.

Doesn't give you "everything", but it has the basics and then some for what we need it for. This lib will get built out as we need more functionality.

Example usage:

ModelControllerClient mcc; // get this somehow - usually by ModelControllerClient.Factory.create
CoreJBossASClient client = new CoreJBossASClient(mcc); // use one of the provided JBossASClient subclasses
String dataDir = client.getAppServerDataDir(); // gets the app server's data directory
ModelNode node = client.readResource(Address.parse("/deployment=foo.war")); // gets info on foo.war
...
DeploymentJBossASClient dClient = new DeploymentJBossASClient(mcc); // to do deployment specific things
dClient.enableDeployment("foo.war");
...

etc, etc... a bunch of subclasses to JBossASClient that lets you do specific things to things like datasources, logging, web connectors, etc.

----- Original Message -----
> Heiko,
> 
> Thank you, but how do I build a ModelNode from a CLI command?
> 
> Before using JSON I was investigating how Administration Console perform
> operations and I realized (using firebug) that it uses application/dmr, but
> I presumed it uses ModelNode to build commands, not plain CLI syntax.
> 
> On Thu, May 28, 2015 at 5:58 AM Heiko Braun < hbraun at redhat.com > wrote:
> 
> 
> 
> The DMR library can be found here:
> 
> https://github.com/jbossas/jboss-dmr
> 
> 
> 
> 
> 
> On 28 May 2015, at 10:56, Heiko Braun < hbraun at redhat.com > wrote:
> 
> 
> You can already use DMR over HTTP. It requires a different content-type
> ('application/dmr-encoded') and uses a base64 encoded representation of the
> payload ('ModelNode.toBase64String()').
> 
> You can describe an operation through the DMR API and then simply do HTTP
> POST to ‘/management’ endpoint. make sure to use 'application/dmr-encoded’
> for both 'Content-Type' and ‘Accept’ headers.
> 
> The response can be parse using 'ModelNode.fromBase64()'.
> 
> Hope this helps,
> Heiko
> 
> 
> 
> 
> 
> On 27 May 2015, at 19:54, Jairo Junior < junior.jairo1 at gmail.com > wrote:
> 
> I've been working on a Puppet Module for Wildfly [1] that uses his HTTP
> Management API to perform operations (manage resources/deploys and execute
> commands), but my command execution code is a little bit limited cause I
> have to transform from CLI syntax to JSON. e.g.:
> 
> :shutdown(restart=true)
> 
> becomes
> 
> {"operation" : "shutdown", "restart" : "true" }
> 
> Is there any specific reason to not support plain CLI commands through HTTP
> API? I looked at the code and it didn't see hard to implement this...
> 
> [1] https://github.com/biemond/biemond-wildfly
> 
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
> 
> 
> 
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev



More information about the wildfly-dev mailing list