Running defined commands

From ControlTier

Jump to: navigation, search
ctl

Defined commands are procedures formally defined in a ControlTier type and provide a standard calling interface to the command dispatcher. These defined commands encapsulate your routine procedures and form the basis of your own automation toolkit. Commands can be combined into workflows that represent multi-step processes.

ControlTier includes a variety of types containing standalone commands and workflows that you can use to automate your processes.

Defined commands can be executed either via a command line utility via ctl or as a Job via a graphical console called Jobcenter.

Contents

Command line usage

CTL has a variety of options that can be displayed via -help. Typing ctl -help shows a complete listing of all the ctl options.

usage: ctl [-h] [-v] [-V] [-z] [-p project -t type -r resource -c command] [-p
           project -m module -c command] [--threadcount <1>] [-I filter] [-X filter]
           [--filter-exclude-precedence true/false][-l level] [-- command-options]
 -R,--report-category              The reporting category name
 -P,--process-instance             The process instance identifier
 -Z,--filter-exclude-precedence    true/false. if true, exclusion filters have
                                   precedence over inclusion filters
 -C,--threadcount                  number of threads
 -F,--failednodes                  Filepath to store failed nodes (Since 3.4.7)
 -I,--nodes                        include node parameter list
 -K,--keepgoing                    continue node dispatch when execution on one
                                   node fails
 -V                                run verbose and with loglevel "debug"
 -X,--xnodes                       exclude node parameter list
 -c                                command
 -h                                display this help
 -l,--level                        log level. debug|verbose|info|warning|error
 -m                                module name
 -r                                resource resource name
 -p                                project name name
 -t                                resource type name
 -v                                run verbose
 -z,--terse                        leave log messages unadorned

The general option pattern follows this form:

ctl [ctl-options] [-- [command-options]]

Node Dispatch

The ctl command includes a feature called node dispatch that allows you to call commands across a set of hosts without having to specify specific host names. Internally, CTL looks up the nodes that have the command, and then dispatches that command to those matching nodes. Options provide a way to filter the lookup results.

These options control nodedispatch:

Note:

Use these options with nodedispatch:

See the document Use node filtering options for further discussion of node filtering.

Listing

The ctl command provides a listing capability that will let you see which modules, commands and objects are available in a specified CTL project project. The listing is controlled by specifying the "-p", "-m", "-t", "-o" options.

When no arguments are specified, all modules, commands and objects are listed.

Note:

Examples

To list all the modules in project "demo" run: ctl -p demo. You will see each module and the commands defined for that type listed:

.
.
.
zip: A zip package
commands: [Get-Process-View, Get-Properties, Get-Supers, Install, Install-Module, Properties, Set-Properties, 
assertPackageIsInstalled, assertPackageIsUnInstalled, assertPackageIsVerified, create, extract, finish, get, 
installDependencies, installPackage, object-deployment-uninstall, prepare, purge, register, remove, upload]
objects: [j2eetutorial14.zip, demo-pkgs-1.2.zip]

If objects exist for that type, you will see an additional line saying: objects:[ obj1,obj2...]

You can list the options for a command like so: ctl -p project -m type -- -?:

$ ctl -p demo -m zip -- -?
zip: A zip package
[commands]
.
.
.
  upload: Upload the file to the repository.
    [options]
    [-url <>]: repository url
    [-filename <>]: file to upload
    [-xml <>]: package metadata xml file
    [-register]: register the package based on filename and module info

You can also list commands of an object similarly; ctl -p project -t type -r object:

$ctl -p demo -t zip -r demo-pkgs-1.2.zip
.
.
.
  upload: Upload the file to the repository.
    [options]
    [-url <>]: repository url
    [-filename <>]: file to upload
    [-xml <>]: package metadata xml file
    [-register]: register the package based on filename and module info

Command line execution

Commands can be executed in one of two contexts:

The commands defined in the coreutils library are all defined as static.

Here are some examples of static command execution:

ctl -m netutil -c listening -- -port 80
ctl -I '.*' -m netutil -c listening -- -port 80

This example shows the defined command called "listening" from the netutil module.

ctl -m fileutil -c copy -- \
      -file http://repo/myapp/file1.txt -target /myapp/file1.txt -backup

The fileutil "copy" command can copy a local file or one from a web repository, as this example shows off. The "-backup" flag says to create a backup if that file will be overwritten.

ctl -m fileutil -c available -- -file /myapp/file1.txt

This checks to see if the file "/myapp/file1.txt" is present.

ctl -I '.*' -m fileutil -c available -- -file /myapp/file1.txt

This checks to see if the file "/myapp/file1.txt" is present

Here are some examples showing object-context commands:

ctl -p ProjectBuilder -r default -c Install

You can also see the ctl command also supports the node filtering, threadcount and keepgoing flags. See: options.

ctl -I 'web.*' -t Service -r tomcat1 -c Status
ctl -C 10 -I tags=tomcats -t Service -r tomcat1 -c Status

Job execution

Defined commands can also be executed via the GUI as a job. The job definition sample below shows the use of the type and command tags to specify the netutil type name and the listening command, and one of its options:

<job>
  <name>Run netutil</name>
  <description/>
  <additional/>
  <context>
    <depot>demo</depot>
    <type>netutil</type>
    <command>listening</command>
    <options>
      <option name="port" value="8080"/>
    </options>
  </context>
</job>

[Job.xml]] files can be loaded using ProjectBuilder's load-jobs command which will read the job definitions and store them on the server:

ctl -m ProjectBuilder -c load-jobs -- -file job.xml
Succeeded creating/updating 2 Jobs:
	1: Run netutil [1] </jobcenter/scheduledExecution/show/1>

With a browser you can view the defined jobs and execute them by accessing the GUI's home page where they are listed or go directly to a job URL. To access the "Run netutil" job, reference it by its ID, "1": http://strongbad:8080/jobcenter/scheduledExecution/show/1

Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export