JBoss Community

Command Line Interface

modified by Alexey Loubyansky in JBoss AS7 Development - View the full document

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:

  • connect to the specific controller or server instance by specifying the host and the port;
  • send operation requests (providing the managed component's address, attribute or operation name and parameters) following the AS7 detyped management model;
  • view the available managed components, their attributes and operations;
  • tab-completion for commands and operation requests;
  • history of the executed commands and operation requests.

 

 

Commands

 

There are commands and operations. Commands don't trigger server management actions, they are performed locally and may affect only the command line session settings. Operations, on the other hand, are actually translated into the operation requests and sent for the execution to the server.

 

To see all the commands and their description, enter command help. 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.

 

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

 

The format for the operation requests is

 

[node-type=node-name (,node-type=node-name)*] : operation-name [( [parameter-name=parameter-value (,parameter-name=parameter-value)*] )]

 

e.g.

 

profile=production,subsystem=threads,bounded-queue-thread-pool=pool1:write-core-threads (count=0, per-cpu=20)

 

It's a lot of typing but tab-completion is supported for all the composing parts, i.e. node-types and node-names, operation names and parameter names. We are also looking into adding custom commands/aliases that would be less verbose for the user but would translate into the corresponding operation requests on the background.

 

Whitespaces between the separators in the operation request strings are not significant.

 

Operation requests might not always have the address part or the parameters. E.g.

 

:read-resource

 

which will list all the node types for the current node.

 

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.

 

[subsystem=web] :read-resource(recursive="true")


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

 

[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.

 

[subsystem=web] /:read-resource

 

or its child, e.g.

 

[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.

 

[/] ./subsystem=web/../subsystem=transactions

 

is equivalent to

 

[/] ./subsystem=transactions

 

 

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

 

[/] ./subsystem=web/.type/transactions

 

is equivalent to the same

 

[/] ./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 connector    

http

[localhost:9999 /subsystem=web]

 

Special characters in node names

 

White ':' 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).

 

 

Ideas for features and improvements

  • custom aliases/commands for existing commands and operations (too avoid verbosity)
  • command/operation output redirection, e.g. operation > file, operation < file
  • report operation results nicer (success shorter, failure with more details)
  • an easy way to get an operation description, e.g. 'help operation-name

Comment by going to Community

Create a new document in JBoss AS7 Development at Community