[wildfly-dev] HTTP Management API

Brian Stansberry brian.stansberry at redhat.com
Wed Jan 8 12:33:54 EST 2014


On 1/7/14, 11:46 PM, Arun Gupta wrote:
> I realized I was doing something basic incorrectly ;)
>
> For a standalone instance, should it not show the default data source:
>

It's in the ee subsystem. I believe there was a thread on this list a 
few months back if you're interested in why it's there. I don't trust 
myself to do justice to the reasoning. ;)

[standalone at localhost:9990 /] cd subsystem=ee/service=default-bindings
[standalone at localhost:9990 service=default-bindings] ls -l
ATTRIBUTE                          VALUE 
        TYPE
context-service 
java:jboss/ee/concurrency/context/default   STRING
datasource                         java:jboss/datasources/ExampleDS 
        STRING
jms-connection-factory 
java:jboss/DefaultJMSConnectionFactory      STRING
managed-executor-service 
java:jboss/ee/concurrency/executor/default  STRING
managed-scheduled-executor-service 
java:jboss/ee/concurrency/scheduler/default STRING
managed-thread-factory 
java:jboss/ee/concurrency/factory/default   STRING

> -- cut here --
> [standalone at localhost:9990 subsystem=datasources] ls
>
> data-source
>
> jdbc-driver
>
> xa-data-source
>
> installed-drivers=[{"driver-name" => "h2","deployment-name" =>
> undefined,"driver-module-name" => "com.h2database.h2","module-slot" =>
> "main","driver-datasource-class-name" =>
> "","driver-xa-datasource-class-name" =>
> "org.h2.jdbcx.JdbcDataSource","driver-class-name" =>
> "org.h2.Driver","driver-major-version" => 1,"driver-minor-version" =>
> 3,"jdbc-compliant" => true}]
> -- cut here --
>
> How do I know which commands are targeted to domain host controller ?
>

For low level operations, use the 
:read-resource-description(operations=true) op to determine the relevant 
API for a resource.

For high level commands, the set of commands the CLI offers is tailored 
to the type of process to which you are connected. Start the CLI 
(without the -c param) and hit tab from the root resource prompt; you 
get a limited set of options. Then run the "connect" command and hit tab 
again; the options are greater and there will be small differences 
depending on whether the process is a standalone server or a host 
controller.


> product-name, product-version,

Because WildFly is not a Red Hat product. ;) These only have values with 
EAP, SOAP, etc.

> profile-name are returning "undefined".
>

I'm tempted to remove this from the standalone server API. It's only 
relevant to a managed domain server, where it identifies the name of the 
profile mapped to the server's server group. There is no name for the 
profile being run by a standalone server.

> Is there a typical set of operations that can be incorporated in a
> WildFly hands-on lab for standalone and domain host controller ?
>

I've attached a text file with a kind of script (as in movie, not as in 
software) for the demo that makes up the bulk of my "JBoss EAP CLI: 
Ninja Management" presentation. It takes quite a while to go through all 
that with me typing and talking, but it's at least an outline of the 
stuff I thought was important to cover.

Ping me privately if you'd like more details.


> Arun
>
> On Tue, Jan 7, 2014 at 6:13 PM, Brian Stansberry
> <brian.stansberry at redhat.com> wrote:
>> Are you connecting to a domain host controller? The examples are for a
>> standalone server.
>>
>> On 1/7/14, 7:24 PM, Arun Gupta wrote:
>>> Hi there ...
>>>
>>> I'm trying some samples from:
>>>
>>> https://docs.jboss.org/author/display/WFLY8/The+HTTP+management+API
>>>
>>> and have questions/comments.
>>>
>>> 1). First one is giving:
>>>
>>> curl --digest -L -D - http://localhost:9990/management --header
>>> "Content-Type: application/json" -d
>>> '{"operation":"read-attribute","name":"server-state","json.pretty":1}'
>>> -u u3:p3
>>> HTTP/1.1 401 Unauthorized
>>> Connection: keep-alive
>>> WWW-Authenticate: Digest
>>> realm="ManagementRealm",domain="/management",nonce="n6l3IRhNwTwNMTM4OTE0MjA3MTE4N55G54PM/ll8QrzSK+RrvTM=",opaque="00000000000000000000000000000000",algorithm=MD5
>>> Content-Length: 77
>>> Content-Type: text/html
>>>
>>> HTTP/1.1 500 Internal Server Error
>>> Connection: keep-alive
>>> Authentication-Info:
>>> nextnonce="I7Yrew1s+j4NMTM4OTE0MjA3MTE4NxXgrLGjS/rWgbUveRrchio="
>>> Content-Type: text/plain;utf-8
>>> Content-Length: 128
>>>
>>> {
>>>       "outcome" : "failed",
>>>       "failure-description" : "JBAS014792: Unknown attribute server-state",
>>>       "rolled-back" : true
>>> }
>>>
>>> http://wildscribe.github.io/Wildfly/8.0.0.CR1/index.html shows
>>> server-state as a valid attribute.
>>>
>>> Similar error for:
>>>
>>> "JBAS014792: Unknown attribute profile-name"
>>>
>>> Reading product-name and product-version returns:
>>>
>>> {"outcome" : "success", "result" : null}
>>>
>>> "name" attribute returns:
>>>
>>> {"outcome" : "success", "result" : "Unnamed Domain"}
>>>
>>> 2). curl --digest -L -D - http://localhost:9990/management --header
>>> "Content-Type: application/json" -d
>>> '{"operation":"whoami","json.pretty":1}' -u u3:p3
>>>
>>> does not return pretty JSON and instead returns:
>>>
>>> {"outcome" : "success", "result" : {"identity" : {"username" : "u3",
>>> "realm" : "ManagementRealm"}}}
>>>
>>> release-name and release-version returned correct values.
>>>
>>> 3). I think a restart-server operation would be useful.
>>>
>>> 4). Why is the following command failing:
>>>
>>>    curl --digest -D - http://localhost:9990/management --header
>>> "Content-Type: application/json" -d '{"operation":"read-resource",
>>> "address":["subsystem","data-sources"], "json.pretty":1}' -u u3:p3
>>> HTTP/1.1 401 Unauthorized
>>> Connection: keep-alive
>>> WWW-Authenticate: Digest
>>> realm="ManagementRealm",domain="/management",nonce="2oB+bvt990QNMTM4OTE0MzQ4Nzc0NkxPJHWOl6yAkN/F7PGdbYo=",opaque="00000000000000000000000000000000",algorithm=MD5
>>> Content-Length: 77
>>> Content-Type: text/html
>>>
>>> HTTP/1.1 500 Internal Server Error
>>> Connection: keep-alive
>>> Authentication-Info:
>>> nextnonce="JXNHCPPtBVwNMTM4OTE0MzQ4Nzc0N5YLxVykiaapgV5zTDnV++I="
>>> Content-Type: text/plain;utf-8
>>> Content-Length: 184
>>>
>>> {
>>>       "outcome" : "failed",
>>>       "failure-description" : "JBAS014883: No resource definition is
>>> registered for address [(\"subsystem\" => \"data-sources\")]",
>>>       "rolled-back" : true
>>> }
>>>
>>> Even though there is a default data source already registered. The
>>> management model
>>>
>>> Either I'm not doing something basic correctly, the management model
>>> is out of sync, or the API is not fully implemented.
>>>
>>> Comments ?
>>>
>>> Thanks,
>>> Arun
>>>
>>
>>
>> --
>> Brian Stansberry
>> Senior Principal Software Engineer
>> JBoss by Red Hat
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
>
>


-- 
Brian Stansberry
Senior Principal Software Engineer
JBoss by Red Hat
-------------- next part --------------
CLI demo plan:

1) Start standalone server
2) Start CLI, connect
3) tab
4) ls
5) ls -l
6) cd and tab completion to /subsystem=web/connector=http
7) read-attribute bytesSent
8) read-attribute bytesSent --verbose
9) access the root webapp
10) read-attribute bytesSent
10) :read-resource
10) :read-resource(include-runtime=true)
11) :read-resource-description
12) /deployment=kitchensink.ear:read-resource(include-runtime=true,recursive=true)
12) change some setting (JCA pool size)
13) batch
14) add jms queue
15) deploy the war
19) deploy the mdb
16) show app, add 3
18) run CLI with a file to remove everything
13) change HTTP port
14) reload
15) change it back, but with shutdown ?restart=true


20) disable local-auth
21) connect, authenticate

31) Start 3 hosts, master, 2 slaves
32) add a new server group
33) add a server in the group on each host
34) deploy w/ rollout plan
35) save rollout plan
36) undeploy with rollout plan


40) show and execute a bash script to stop 2 hosts


More information about the wildfly-dev mailing list