Previous Topic: Global Users and Groups

Next Topic: Application and Appliance Locking

Advanced Usage

For those who use GNU bash: Client-side Macros - an alternative way to access the CA 3Tera AppLogic shell commands directly from your local command prompt.

Client-side Macros

Client-side macros for GNU Bash and OpenSSH client, for easy access to all the functionality of 3tshell - the CA 3Tera AppLogic command line interface, directly from your local shell prompt.

Download here:

To use this on your system, all you need is to have GNU Bash 2.0 or later and the OpenSSH client program (ssh), version 3.9 or later. Download the attached shell file, save it on your disk and include it in your shell using the source command (or .) - this can be done in the '.bashrc' file, so that it is available to every interactive shell instance that you start.

Once the rmacros.sh file is loaded, the following commands become available from the shell prompt. The same commands can also be used in a non-interactive script by simply including the rmacros.sh file from your script with the "source" command:

controller hostname-or-ip

Set the hostname of the controller to which to direct subsequent commands. This must be done before using any of the other commands.

controller -

Disconnect from controller. This closes the master ssh session with the controller.

3t any 3tshell command

This is the same as typing the command at the CA 3Tera AppLogic shell prompt. This form is useful for simple commands, and for unattended batch operation. use 3t -t for commands that require user interaction (for example, vol manage).

3t -t any 3tshell command

Same as 3t any 3tshell command, but enables interactive mode, by running the CA 3Tera AppLogic shell with the ssh pseudo-terminal enabled.

3t

Invoke the interactive CA 3Tera AppLogic shell.

ca appname

Set the current application. This works the same way as the 'ca' command in the interactive shell. Executing 3t ca myapp won't work because a new instance of the CA 3Tera AppLogic shell is started by each invocation of the '3t' command.

pwa

Print the name of the current application (as set by ca)

assh [appname:]component

Open an interactive shell to a running appliance instance in the current application, or in the specified application. component is the instance's full name in the application hierarchy. The name of the top-level assembly (main.) can be omitted, for example, the following are equivalent:

assh the-app:main.web.srv1 
ca the-app ; assh web.srv1 
assh [app:]component cmd [args]

Run a non-interactive command on an appliance instance. NOTE: on older (1.x) versions of CA 3Tera AppLogic, the command name and the arguments cannot contain spaces, that is, this will not work as expected:

assh web.srv1 cat "the file with spaces in its name". 

If you must do this on an older grid, make a short script and copy it to the running appliance using the ascp command below, then start that script.

ascp src dest

Copy a file to/from a running appliance. One of the src or dest parameters must be the name of a local file or directory. The other specifies the remote appliance and file name in a form similar to that of the 'scp' command:

comp.name:filename 

The component name is the full path of the component in the application assembly (as with assh, the main. prefix can be omitted). This command requires that the current application be set with the ca command.

als

Shortcut. same as 3t app list.

astart

Shortcut. Same as 3t app start `pwa`.

astop

Shortcut. Same as 3t app stop `pwa`.

vmnt

Not supported in CA 3Tera AppLogic 2.3 and later. Use the new vol manage operation instead.

vumnt

Not supported in CA 3Tera AppLogic 2.3 and later.

Configuring Custom SSH Options

Other than the normal way of setting SSH options (which is to put them in your ~/.ssh/config file), the commands provided by rmacros.sh also accept an environment variable setting with options that affect only ssh invocations generated by the macros, but not any other ssh commands. This is useful if you need a different set up for working with the CA 3Tera AppLogic grid(s) and for other ssh sessions, and the per-host method supported by the .ssh/config file is not suitable to separate the different options. This includes the case when you also have "maintainer" access to the CA 3Tera AppLogic grid (for example, if you installed that grid) - in such a case you have an SSH key that provides root access to the controller - not what is needed to work as a normal "client".

To provide additional options to the remote access macros in rmacros.sh, set the AL_SSH_OPT variable. It should contain options in the form accepted by ssh and all of its companion programs (scp, sftp, and so on): -o OptionName=option-value. Do not use shorthand options like -i, -t, and so on - they work with ssh, but not with scp.

Example:
export AL_SSH_OPT='-o IdentityFile=/home/lk/t-key -o IdentitiesOnly=yes -o StrictHostKeyChecking=no' 

This tells SSH: Use the key /home/lk/t-key for public-key authentication; do not use any keys served by ssh-agent; disable strict host identity checking (use the last one only if you frequently re-install grids from scratch, causing the SSH Id of the controller to change every time).

Fast and Easy Access with Master SSH Session

The functions defined in rmacros.sh use the Master Session feature of the OpenSSH client. The first command that is run will start a background ssh client in 'master' mode, and all subsequent commands use the session maintained by the 'master' to run additional ssh sessions over the same secure channel.

This provides two benefits: first, typing a passphrase to access the SSH private key is only necessary once - after that, the session is maintained open and no additional logins are made.

Second, this makes new invocations of 'ssh' as fast as typing commands to an already open SSH session - faster, in fact - because the command is sent once, when you press Enter, while an interactive session uses character-by-character echo as you type the command.

Also, running the commands locally from your shell and not from the 3tshell console allows one to use the full power of the shell, to make up commands that are not possible with an interactive 3tshell session, for example:

Get a list of running applications:
3t app list | grep running

Save volume list to a file:
3t vol list --all >file

Transfer configuration from one application to another:

3t app config app1 --batch | 3t app config app2 --stdin