Command Line Interface

The AS7 Command Line Interface (CLI) is a command line management tool for the AS 7 domain or a standalone server. It allows a user to connect to the AS7 domain controller or a standalone server and execute management operations available through the AS7 detyped management model. Depending on the operation system, the CLI is launched using jboss-admin.sh or jboss-admin.bat located in the AS7 bin directory.

 

Features

 

The CLI features include:

 

Commands

 

There are commands and operations. They are different. Operations are considered a low level but comprehensive way to manage the AS controller, i.e. if it can't be done with operations it can't be done in any other way.

Commands, on the other hand, are more user-friendly in syntax, although most of them still translate into operation requests and some of them even into a few composite operation requests, i.e. commands also simplify some management operations from the user's point of view.

 

To see all the list of all the supported commands enter command help --commands. Another way to list all the supported commands is to press the tab key at the command line prompt which will trigger the tab-completion for the commands. The list of the available commands depends on the current context, i.e. it may change since some of the commands may require an established connection to the AS controller, or the presence of a certain node address in the domain management model, etc. For example, if the server configuration doesn't include messaging subsystem then the CLI will not expose messaging related commands.

To see a detailed description of a specific command, execute the command with --help as the argument.

 

Connection

 

The first thing to do after the CLI has started is to connect to a managed AS7 instance. This is done using the command connect, e.g.

 

connect

 

which is equivalent to

 

connect localhost:9999

 

localhost:9999 is the default host and port combination for the AS7 model controller client. Both, the host and the port, are optional parameters and can be specified together or separately.

 

Quit

 

To terminate the session type quit.

 

Operation requests

 

Operation requests is considered a raw low level way to manage things. Normally, for convenience and friendliness users would use commands instead of operations. Although, there might be cases when operations can be more convenient or even the only way to do something.

 

The format of the CLI operation requests is described in detail in The Format of the Command-line Operation Requests. And another useful article is The Command-line Compound Parameter Value Format.

Operation requests can be long and verbose. But the tab-completion can help at almost any point.

 

 

To syntactically disambiguate between the commands and operations, operations require one of the following prefixes:

 

  • : - to execute an operation against the current node, e.g.

 

 

[standalone@localhost:9999 subsystem=web] :read-resource(recursive=true)

 


  • ./ - to execute an operation against a child node of the current node, e.g.

 

 

[standalone@localhost:9999 subsystem=web] ./connector=http:read-resource

 

 

i.e. the full address of the operation will be subsystem=web,connector=http.

 

  • / - to execute an operation against the root node, e.g.

 

 

[standalone@localhost:9999 subsystem=web] /:read-resource

 

 

or its child, e.g.

 

 

[standalone@localhost:9999 subsystem=web] /subsystem=logging:read-resource

 

 

 

How the tab-completion works

 

Suppose, the cursor is positioned at the beginning of an empty line. If you type in './' and press the tab key, you will get a list of all the available node types. After selecting the node type you want and adding '=', pressing the tab key again will result in a list of all the node names available for the chosen node type. If, after selecting the node name from the list, you want to continue with the node path then add ',' after the selected node name and press the tab key again. This will print all the available node types for the previously select node.

 

After you are done with the node path, adding ':' at the end of the node path and pressing the tab key will print all the available operation names for the selected node.

 

To see all the parameters of the operation, add '(' after the operation name and press the tab key. Choose the parameter you want and specify its value after '='. Tab-completion for parameter values is not supported (yet?). If you want to add more parameters, add ',' and press the tab key to see the rest of the available parameter names.

 

Finally, when all the parameters have been specified, add ')' and press enter.

 

In the node path you can use the following strings for navigations:

  • .. - parent node, e.g.

 

 

[standalone@localhost:9999 /] ./subsystem=web/../subsystem=transactions

 

 

is equivalent to

 

 

[standalone@localhost:9999 /] ./subsystem=transactions

 

 

  • .type - the type of the current node, e.g.

 

 

[standalone@localhost:9999 /] ./subsystem=web/.type/transactions

 

 

is equivalent to the same

 

 

[standalone@localhost:9999 /] ./subsystem=transactions

 

 

Current node path and navigation

 

The current node path is indicated in the command line prompt. The default value is '/', i.e. the root node. All the operation requests that don't contain the address part will be executed against the current node path.

 

Change node command (cn or cd)

 

cn, or cd, command allows you to change the current node path, e.g.

 

 

[host:port /] cd subsystem=web

 

 

After that the command line prompt will change to

 

 

[host:port /subsystem=web]

 

 

and every operation entered w/o the node path will be executed against the node subsystem=web. If you do specify a node path for the operation, it will be considered relative to subsystem=web.

 

The node path might not necessarily end on a node name. It might be just

 

 

[host:port /] cd subsystem
[host:port /subsystem]

 

 

Then to execute an operation against the logging subsystem you would type in

 

 

[host:port /subsystem] logging:read-resource

 

 

To go back to the root node, type in

 

 

[host:port /subsystem] cd /
[host:port /]

 

 

You can also navigate to the parent node

 

 

[host:port /subsystem=web,connector=http] cd ..
[host:port /subsystem=web]

 

 

or the node type

 

 

[host:port /subsystem=web] cd .type
[host:port /subsystem]

 

 

List contents command (ls)

 

ls command will list the contents of a node path. The command has an optional node path argument. If the argument is specified, the command will print the contents of the node path specified in the argument. If the argument is not specified, the command will print the contents of the current node path (indicated in the prompt).

 

If the node path ends on a node type then the contents will be the child node names. If the node path ends on a node name then the contents will be the child node types.

 

If the contents of the node path is empty, nothing will be printed.

 

Example:

 

 

[localhost:9999 /subsystem=web] ls
virtual-server   connector
[localhost:9999 /subsystem=web] ls connectorhttp
[localhost:9999 /subsystem=web]

 

 

Special characters in node names

 

While ':' and '/' have special significance for in the format of the operation request, these characters aren't disallowed in node names.

If they are typed in though, the operation request parser will be confused and will probably result it an error. To workaround this issue you should quote the names with special characters, e.g.

 

 

[localhost:9999 /subsystem=datasources] cd data-source="java:/H2DS"
[localhost:9999 /subsystem=datasources/data-source=java:/H2DS]

 

 

The node name, actually, is also allowed to contain '"'. In case the node name has to be quoted and it also contains quotes in its content then the quotes that are a part of the node name content have to be escaped using, i.e. '\"'.

 

 

[localhost:9999 /] cd nodetype="node:name/with\"quotes\""
[localhost:9999 /node:name/with"quotes"]

 

 

Note, that the tab-completion takes care of this automatically.

 

Command history

 

Command (and operation request) history is enabled by default. The history is kept both: in-memory and in a file on the disk, i.e. it is preserved between the command line sessions. The history file name is .jboss-cli-history and is automatically created in the user's home directory. When the command line interface is launched this file is read and the in-memory history is initialized with its content.

 

While in the command line session, you can use the arrow keys to go back and forth in the history of commands and operations. To manipulate the history you can use history command.

 

If executed w/o the argument, it will print all the recorded commands and operations (up to the configured maximum, which is by default 500) from the in-memory history.

 

history supports three optional arguments:

  • disable - will disable history expansion (but will not clear the previously recorded history);
  • enabled - will re-enable history expansion (starting from the last recorded command before the history expansion was disabled);
  • clear - will clear the in-memory history (but not the file one).