Usage of Petals CLIusage: Petals JMX Command Line Interface [-d] [-y] [-h <host>] [-n <port>] [-u <user>] [-p <password>] [-H | -V | -f <file> | -c <command> <command-args> | -C] -c,--command <command> Execute a command given on the command line. -C,--console Enable the mode 'console'. -d,--debug Print stack trace and debugging informations -f,--file <filename> Enable the script file execution. If filename is '-', commands are read from the stdin. -H,--help Print this help message and exit. -h,--host <host> remote petals ESB host name. -n,--port <port> port number. -p,--password <password> password. -u,--user <user> username. -V,--version Print the version number and exit. To get help on a command, use the command 'help' on command-line: petals-cli.sh -c help <command> Available commands: - deploy: Deploy and start a JBI artifact in petals container. - exit: Exit this shell. - help: Display this help message or help for a specific command. - list: List JBI artifacts name and current status. - list-registry: List the entries of the registry. - load: Load properties from files. - print: Print a message. - pwd: Print the working directory. - set: Assign a value to the system property named key. - show: Print informations about a JBI artifact. - shutdown: Shutdown the container. - stop: Stop the container. - undeploy: Stop and uninstall or undeploy JBI artifacts. - version: Print version informations about petals container. Which evolution would you like on Petals? Share it! http://www.petalslink.com/feedback |
Table of contents
Contributors
No contributors found for: authors on selected page(s)
|
Use cases
Petals CLI realizes the following use-cases.
Petals CLI capabilities about script and shell usages
Interactive console
Launching the Petals CLI with the following command line starts an interactive console with a prompt where the user can enter commands:
> ./petals-cli.sh -C
Type 'help' for help.
------------------------------------------------------------------------------
petals-cli>
This command is wrapped by another shell: petals-cli-console.sh
Execution of a Petals CLI command directly on the command line
Launching the Petals CLI with the following command line executes the command specified on the command line:
> ./petals-cli.sh -c <command> <command-args>
Execution of a Petals script file
Launching the Petals CLI with the following command line executes commands of a Petals script:
> ./petals-cli.sh -f <filename>
| A Petals script is text file containing command supported by Petals CLI. |
Execution of an inlined Petals script
Launching the Petals CLI with the following command line executes commands provided through the 'stdin':
> cat <filename> | ./petals-cli.sh -f - > ./petals-cli.sh -f - << EOF <command1> <command1-args> <command2> <command2-args> EOF
Getting help
Getting help on command-line options and arguments
The help on command-line options and arguments is available through the option '-H'. A text containing options, arguments and available command is displayed according to the usage defined above:
> ./petals-cli.sh -H
Getting help on command from the command line
The help on a command can be get using the command 'help'. A usage and a description of the command is displayed:
> ./petals-cli.sh -c help <command> usage: <command> <command-arguments> <command description> >
where:
- <command> is the command for which we want to get help
- <command-arguments> is the list of arguments of the command
- <command-description is a text explaining the command
Getting help on available commands and on a command in interactive mode
The list of available command can be get using the command 'help' without argument:
The help on a command can be get using the command 'help'. A usage and a description of the command is displayed:
> ./petals-cli.sh -C Type 'help' for help. ------------------------------------------------------------------------------ petals-cli> help Available commands: deploy Deploy and start a JBI artifact in petals container. exit Exit this shell. help Display this help message or help for a specific command. ... For help on a specific command type: help <command> petals-cli> help <command> usage: <command> <command-arguments> <command description> >
where:
- <command> is the command for which we want to get help
- <command-arguments> is the list of arguments of the command
- <command-description is a text explaining the command
Return code of Petals CLI
Return code when all is ok
When there is no error about options and arguments on the command line, the return code of Petals CLI is 0
Return code on error about option or arguments on the command line
When there is an error about options and arguments on the command line, the return code of Petals CLI is 1
Return code on error about option and arguments of a command
When there is an error about options and arguments of a command, the return code of Petals CLI is 1
Error management
Options et argument parsing error management
If an error of parsing of options and/or arguments of the command line or commands, Petals CLI is interrupted with the right return code.
Error management of a command set on the command line
If an error occurs during the execution of a command set on the command line:
- the command is interrupted,
- Petals CLI is interrupted with the return code 2
Error management of a command entered in interactive mode (mode 'console')
If an error occurs during the execution of a command entered in interactive mode:
- the error message is displayed
- Petals CLI is not interrupted, the user can enter other commands
Error management of a command read from stdin or a file (mode 'script')
If an error occurs during the execution of a flow of commands:
- the command that has thrown the error is interrupted,
- the return code of the command can be check using the commands isParsingErrorReturned, isExecutionErrorReturned, isNoErrorReturned, the ternary conditional operator, and the attribute lastErrorCode:
> ./petals-cli.sh -f - << EOF deploy <artifact-url> isNoErrorReturned ? listartefacts : exit lastErrorCode EOF
Note:
- the return values of command isParsingErrorReturned, isExecutionErrorReturned and isNoErrorReturned are re-intialized when invoking command. Only the error of the last command execution can be checked.
- the attribute lastErrorCode is an argument of the command exit to return the return code of the last executed command.
Connection to a Petals node
Connection options from the command line
All parameters needed to a JMX connection to a remote Petals node must be configurable on the command line as options:
> ./petals-cli.sh -h <host> -n <port> -u <user> -p <password> -c <command> > ./petals-cli.sh -h <host> -n <port> -u <user> -p <password> -C Conected on <host1>:<port1> with <user1> petals-cli>
Interacting with several Petals node without exiting Petals CLI
In interactive mode or script mode, we should be able to close a connection and open another one without leaving Petals CLI. This is done by commands 'close' and 'open'. If no arguments are set on command 'open', default values (localhost:7700, login=petals, pwd=petals) are used:
> ./petals-cli.sh -C
Type 'help' for help.
------------------------------------------------------------------------------
petals-cli> open <user1>:<password1>@<host1>:<port1>
Conected on <host1>:<port1> with '<user1>'
petals-cli> close
petals-cli> open
Conected on localhost:7700 with 'petals'
Default connection
By default (if no argument or option is set):
- In mode 'console', the connexion is establish on command 'open' to localhost:7700 with credentials 'petals/petals',
> ./petals-cli.sh -C Type 'help' for help. ------------------------------------------------------------------------------ petals-cli> open Conected on localhost:7700 with 'petals' - In mode 'command line', connexion parameter are mandatory
> ./petals-cli.sh -h <host> -n <port> -u <user> -p <password> -c <command>
- In mode 'script', the connexion is establish on command 'open' to localhost:7700 with credentials 'petals/petals'
> ./petals-cli.sh -f - << EOF open EOF
Petals CLI commands
Command 'deploy'
Installation/Deployment and start of an artifact in one command
Petals CLI is able to install/deploy and start a JBI artifact without distinction between shared-library, component and service assembly using the following command:
deploy <artifact-file> [<configuration-file> | <configuration-properties>]
where:
- <artifact-file> is the local file name or the URL of the artifact to install or deploy and start
- <configuration-file> is the local file name or the URL of the properties file used to configure the artifact. This argument is used only if the component is a component. It has no sens for other artifacts. This argument is exclusive with <configuration-properties>.
- <configuration-properties> is a list of '<property-name>=<property-value>', separated by space, where <property-name> is the name of the property to configure with <property-value>. This argument is used only if the component is a component. It has no sens for other artifacts. This argument is exclusive with <configuration-file>.
Installation/Deployment of an artifact located into a Maven repository
Petals CLI is able to install/deploy and start an JBI artifact located into a Maven repository using the following command:
deploy <maven-artifact> [<configuration-file> | <configuration-properties>]
where:
- <maven-artifact> is the Maven identifiers of the artifact to install: group-id:artifact-id:version[:classifier]. If needed, the Maven repository is to define in the Maven configuration file ($HOME/.m2/settings.xml)
- <configuration-file> is the local file name or the URL of the properties file used to configure the artifact. This argument is used only if the component is a component. It has no sens for other artifacts. This argument is exclusive with <configuration-properties>.
- <configuration-properties> is a list of '<property-name>=<property-value>', separated by space, where <property-name> is the name of the property to configure with <property-value>. This argument is used only if the component is a component. It has no sens for other artifacts. This argument is exclusive with <configuration-file>.
Installation/Deployment and start in mass
To deploy several artifact in one command, just put them in a local directory and execute the command 'deploy':
> ./petals-cli.sh -y -f - << EOF
deploy /tmp
EOF
> ./petals-cli.sh -C
Type 'help' for help.
------------------------------------------------------------------------------
petals-cli> deploy /tmp
Are you sure you want to deploy all artifacts of directory '/tmp' (Y/n) ?
If the argument <artifact-file> of the command deploy is a local directory, all artifacts of the directory are deployed. In this case a confirmation is expected, except if the flag 'yes' is set on the command line. A confirmation message is displayed in the mode 'console', except is the flag 'yes' is set on the command line.
Command 'undeploy'
Uninstallation/Undeployment and stop of an artifact in one command
Petals CLI is able to stop and uninstall/undeploy a JBI artifact without distinction between shared-library, component and service assembly using the following command:
undeploy [ <artifact-file> | [<artifact-type> <artifact-id>] ]
where:
- <artifact-file> is the local file name or the URL of the artifact to undeploy
- <artifact-type> is the nature (SL, component, SA) of the artifact to undeploy
- <artifact-id> is the JBI identifier of the artifact to undeploy
Uninstallation/Undeployment and stop in mass
To undeploy several artifact in one command, just put them in a local directory and execute the command 'undeploy':
> ./petals-cli.sh -y -f - << EOF
undeploy
EOF
> ./petals-cli.sh -C
Type 'help' for help.
------------------------------------------------------------------------------
petals-cli> undeploy
Are you sure you want to undeploy all artifacts of the Petals node (Y/n) ?
If no arguments is set on command undeploy, all artifacts are undeployed. In this case a confirmation is expected, except if the flag 'yes' is set on the command line. A confirmation message is displayed in the mode 'console', except is the flag 'yes' is set on the command line.
Command 'exit'
Exit the mode 'console'
To exit the mode 'console', use the command 'exit'. If a number is set as argument, it is used as return code otherwise, the return code 0 is used:
> ./petals-cli.sh -C Type 'help' for help. ------------------------------------------------------------------------------ petals-cli> exit > echo $? 0 > ./petals-cli.sh -C Type 'help' for help. ------------------------------------------------------------------------------ petals-cli> exit 1 > echo $? 1
Interrupt a flow of commands
A flow of commands can be interrupted using the command 'exit'. If a number is set as argument, it is used as return code. The argument 'lastErrorCode' is used as return code value of the last executed command. Otherwise the return code 0 is returned to the shell:
> ./petals-cli.sh -y -f - << EOF deploy /tmp/my-artifact.zip exit lastErrorCode EOF
Ending a flow of commands
When the end of a flow of commands is reached, if the last command is not 'exit', the command 'exit lastErrorCode' is implicitly executed:
> ./petals-cli.sh -y -f - << EOF deploy /tmp/my-artifact.zip EOF echo $? 0
Showing what is installed
Showing installed JBI artefacts
All installed JBI artefacts can be listed using the command 'list [<artifact-pattern>]':
> ./petals-cli.sh -c list "petals-bc-*"
petals-bc-soap Started Component
petals-bc-soap-provide Started Service-Assembly
where <artifact-pattern> is an optional RegExp pattern to filter the content of the returned list. All JBI artifact returned must have a JBI identifier matching the pattern. If not pattern is defined, all installed artifacts are returned.
The command isplayed for each artifact:
- its JBI identifier
- its current status,
- its type (SL, Component, SA)