4 Replies Latest reply: Oct 7, 2012 3:45 AM by Shameer Kunjumohamed RSS

CLI non-interactive mode improvements

r.reimann Newbie

First of all i would like to thank the contributing developers for the great command line support in AS7.

 

I'm currently evaluating the options to provide a configuration mechanism for our projects with the follwing goals in mind:

  • encapsulation of environment settings: since most of the developer and operations folks don't know the CLI they should be able to provide the settings (IPs, ports, DB-Connection settings) for the target system in a separate properties file without searching/editing the CLI scripts.
  • repeatable: In case of a missconfiguration (e.g. wrong IP or DB-Password provided) the script execution should be repeatable.
  • portability: the scripts should work for developer machines (windows, macosx) as well as the test, qa and production environments (linux)
  • zero dependencies: since the environments are heterogenous (see above) and especially test, qa and production environments are very restricted (e.g. no curl) there should no need for additional tools or scripting languages.
  • maintainability: The ability to use line breaks to improve the readability for long commands would be a great help. This is already adressed by https://issues.jboss.org/browse/AS7-2640

 

Since i assume that these are advanced but common requirements it would be great if the the CLI would provide two new features to achieve these goals. Below are my suggestions for the corresponding improvements. I would appreciate to get feedback on my suggestions and also concerning the chances of beeing implemented in a (not so far) future release.

 

1. Encapsulation of environment settings


The CLI should support interpolation of properties provided by properties files and system properties (analogue to the properties support in the domain.sh/standalone.sh scripts)

 

For example:

./jboss-admin.sh --connect --file=some/location/my-script.cli --properties=/some/location/environment.properties

 

environment.properties

db_url=jdbc:h2:mem:test
db_user=sa
db_password=sa

 

my-script.cli

/profile=default/subsystem=datasources/data-source=h2:add(connection-url="${db_url}",driver-name=h2,enabled=true,jndi-name="java:jboss/datasources/ExampleDS",pool-name="H2DS",user-name="${db_user}",password="${db_password}")

 

2. Repeatable script executions


To allow for repeatable script executions conditional logic is required to prevent "Duplicate resource" failures:

exists = test if the resource to be (re-)added already exists
if (exists) remove resource
add resource

 

The conditional logic currently requires a wrapper script which violates either the portability goal (a shell script is sufficient but not portable) or the zero dependencies goal (e.g. requires cygwin to exec the shell script under windows or another portable scripting language).

 

Adding a force or override attribute to the add operation (which recreates the resources transparently if necessary) would remove the need for conditional logic and additional wrapper scripts/dependencies.

 

For example:

/profile=default/subsystem=logging/logger="com.arjuna":add(level=TRACE, force=true)

 

Since the CLI is already portable and has no further dependencies these two new features (plus AS7-2640) would be sufficent to provide a solution for all the initially described goals. It would be great if these enhancements could make their way into AS7.1.0.Final

 

Regards

Robert

  • 2. Re: CLI non-interactive mode improvements
    Alexey Loubyansky Master

    About the environment properties, makes sense. Although, I think it's a different issue from interactive value prompting.

     

    While conditions and force are interesting features, you can achieve repeatable script executions by using batches which make a script an atomic action, i.e. everything in the script will be applied or rolled back.

     

    The force in the suggested form (for operations especially) won't be implemented. For some commands, perhaps. In general, though, I, personally, don't like the idea... but I see your point. Conditions are interesting.

  • 3. Re: CLI non-interactive mode improvements
    r.reimann Newbie

    Hi Alexey,

     

    thanks for your response.

    About the environment properties, makes sense. Although, I think it's a different issue from interactive value prompting.

    I put the environment properties in there since i thought they could share  the same foundation, e.g. same substitution/defaults syntax.

     

    While conditions and force are interesting features, you can achieve repeatable script executions by using batches which make a script an atomic action, i.e. everything in the script will be applied or rolled back.

    Sorry, my explenation concerning repeatable script executions wasn't precise enough. What i'm looking for is a way to repeat the execution (with corrected parameters) in case of a missconfiguration (wrong IP, DB port, etc.).  Since the CLI can't recognize a misconfigured DB port i doubt that batches can help in this case.

     

     

    The force in the suggested form (for operations especially) won't be implemented. For some commands, perhaps. In general, though, I, personally, don't like the idea... but I see your point. Conditions are interesting.

    Conditions as an alternative to force would be absolutely okay. I just suggested the force (probably "override" would be a better name) option since i thought it would be easier to implement than conditions.

     

    Can you make any predictions about if an when parameter substitution and conditions could be available? As i mentioned in my initial post i'm currently evaluating which way to go concerning the scipt automation and it would be great if we could accieve that with the CLI and discard additional scripting languages in the near future.

  • 4. Re: CLI non-interactive mode improvements
    Shameer Kunjumohamed Newbie

    Hi,

     

    Is this CLI improvement with environment properties finally implemented ? Can I externalize certain properties such as database_properties into a properties file and execut a script as follows ?

     

    ./jboss-cli.sh --connect --file=some/location/my-script.cli --properties=/some/location/environment.properties