Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Workflow

...

Operation Script

The script is provided for download and can be used as a command line interface to operations on workflows, jobs and orders.

...

jq ships with the MIT license, see https://opensource.org/licenses/MIT.

Download

Download: manageoperate-workflow.sh

Usage

Invoking the script without arguments displays the usage clause:

...

Code Block
titleUsage
Usage: manageoperate-workflow.sh [Command] [Options] [Switches]

  Commands:
    add-order         --workflow  [--date-to] [--order-name] [--block-position] [--start-position] [--end-position] [--variable] [--force]
    cancel-order     [--workflow] [--folder] [--recursive] [--order-id] [--state] [--date-from] [--date-to] [--time-zone] [--force]
    suspend-order    [--workflow] [--folder] [--recursive] [--order-id] [--state] [--date-from] [--date-to] [--time-zone] [--force]
    resume-order     [--workflow] [--folder] [--recursive] [--order-id] [--state] [--label] [--variable]
    letrun-order     [--workflow] [--folder] [--recursive] [--order-id] [--state]
    transfer-order    --workflow] [--folder] [--recursive]
    suspend-workflow  --workflow  [--folder] [--recursive]
    resume-workflow   --workflow  [--folder] [--recursive]
    stop-job          --workflow --label
    unstop-job        --workflow --label
    skip-job          --workflow --label
    unskip-job        --workflow --label
    post-notice       --notice-board  [--notice-id] [--notice-lifetime]
    get-notice       [--notice-board] [--notice-id] [--folder] [--recursive] [--date-to]
    delete-notice    [--notice-board] [--notice-id] [--folder] [--recursive] [--date-to]

  Options:
    --url=<url>                        | required: JOC Cockpit URL
    --controller-id=<id>               | required: Controller ID
    --user=<account>                   | required: JOC Cockpit user account
    --password=<password>              | optional: JOC Cockpit password
    --ca-cert=<path>                   | optional: path to CA Certificate used for JOC Cockpit login
    --client-cert=<path>               | optional: path to Client Certificate used for login
    --client-key=<path>                | optional: path to Client Key used for login
    --timeout=<seconds>                | optional: timeout for request, default: 15
    --order-name=<string>              | optional: name for order, default: <current user>
    --block-position=<label>           | optional: label for block instruction that holds start position
    --start-position=<label>           | optional: label from which the order will be started
    --end-position=<label[,label]>     | optional: list of labels before which the order will terminate
    --variable=<key=value[,key=value]> | optional: list of variables holding key/value pairs
    --date-from=<date>                 | optional: order past scheduled date
    --date-to=<date>                   | optional: order scheduled date or notice date, default: now
    --time-zone=<tz>                   | optional: time zone for dates, default: <current-time-zone>
                                                   see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
    --state=<state[,state]>            | optional: list of states limiting orders to be processed such as
                                                   SCHEDULED, INPROGRESS, RUNNING, SUSPENDED, WAITING, FAILED
    --folder=<path[,path]>             | optional: list of folders holding workflows, orders, notice boards
    --workflow=<name[,name]>           | optional: list of workflow names
    --order-id=<id[,id]>               | optional: list of order identifiers
    --label=<label[,label]>            | optional: list of labels for jobs
    --notice-board=<name[,name]>       | optional: list of notice boards
    --notice-id=<id>                   | optional: notice identifier, default: <current date>
    --notice-lifetime=<period>         | optional: lifetime for notice
    --log-dir=<directory>              | optional: path to directory holding the script's log files

  Switches:
    -h | --help                        | displays usage
    -v | --verbose                     | displays verbose output
    -p | --password                    | asks for password
    -r | --recursive                   | specifies folders to be looked up recursively
    -f | --force                       | specifies forced start or termination of jobs
    --show-logs                        | shows log output if --log-dir is used
    --make-dirs                        | creates directories if they do not exist 

...

  • --url
  • --user
    • Specifies the user account for login to JOC Cockpit. If JS7 - Identity Services are available for Client authentication certificates that are specified with the --client-cert and --client-key options then their common name (CN) attribute has to match the user account.
    • If a user account is specified then a password can be specified using the --password option or interactive keyboard input can be prompted using the -p switch.
  • --password
    • Specifies the password used for the account specified with the --user option for login to JOC Cockpit.
    • Consider use of the -p switch offering a secure option for interactive keyboard input.
  • --controller-id
    • Specifies the identification of the Controller that holds related orders.
  • --ca-cert
    • Specifies the path to a file in PEM format that holds the Root CA Certificate and optionally Intermediate CA Certificates to verify HTTPS connections to JOC Cockpit.
  • --client-cert
    • Specifies the path to a file in PEM format that holds the Client Certificate if HTTPS mutual authentication is used..
  • --client-key
    • Specifies the path to a file in PEM format that holds the Client Private Key if HTTPS mutual authentication is used..
  • --timeout
    • Specifies the maximum duration for requests to the JS7 REST Web Service. Default: 15 seconds.
  • --order-name
    • Specifies a qualifier that is added to newly created orders. Used with add-order command.
  • --block-position
    • Specifies the label of a block instruction such as JS7 - Resource Locks, should the --start-position option be used for a position inside the block instruction. Used with add-order command.
  • --start-position
    • Specifies the label of an instruction in the workflow from which the order is started, for example from a job. Used with add-order and resume-order commands.
    • The label of a top-level instruction can be specified. For start positions from nested instructions the --block-position option has to be specified too.
  • --end-position
    • Specifies the label of an instruction before which the order will terminate. More than one label can be specified separated by comma. Used with add-order command.
    • If the --block-position option is used then the end position is inside the block. Otherwise the order will terminate when reaching the block's end.
  • --variable
    • One or more variables can be specified that hold key/value pairs separated by comma. Used with add-order and resume-order commands.
    • Example: --variable="myVar1=myValue1,myVar2=myValue2"
  • --date-from
    • Specifies the date and time in ISO format of the daily plan date, for example 2023-10-23. Used with cancel-order and suspend-order commands.
    • Dates can be calculated from the date command, for example:
      • --date-to="$(TZ=Europe/London date +'%Y-%m-%d')" specifies the daily plan date before the current day in the Europe/London time zone.
      • --date-to="$(TZ=Europe/London date --date="1 day ago" +'%Y-%m-%d')" specifies the daily plan date before yesterday.
  • --date-to
    • Specifies the date and time in ISO format of the daily plan date, for example 2023-10-23. Used with add-order, cancel-order,suspend-order, get-notice and delete-notice commands.
    • Dates can be calculated from the date command, for example:
      • --date-to="$(TZ=Europe/London date +'%Y-%m-%d')" specifies the daily plan date before the current day in the Europe/London time zone.
      • --date-to="$(TZ=Europe/London date --date="1 day ago" +'%Y-%m-%d')" specifies the daily plan date before yesterday.
  • --time-zone
  • --state
    • Specifies one or more states - separated by comma - for which orders should be processed. Used with cancel-order, suspend-order, resume-order and letrun-order commands.
    • Valid states includePENDING, SCHEDULED, INPROGRESS, RUNNING, SUSPENDED, WAITING, PROMPTING, FAILED, BLOCKED.
    • For example --state=SCHEDULED,SUSPENDED,FAILED will process orders holding any of the given states.
  • --folder
    • Specifies one or more inventory folders from absolute paths - separated by comma - holding workflows that should be processed.
    • For example --folder=/ProductDemo/CyclicExecution,/ProductDemo/ScheduledExecution will process workflows in the given folders.
    • If the --recursive switch is used then sub-folders will be looked up recursively.
  • --workflow
    • Specifies one or more workflows - separated by comma - that should be processed. Used with most of the commands.
    • For example --workflow=Cyclic-Check,Daily-EOD will consider the Cyclic-Check and Daily-EOD workflows.
  • --order-id
    • Specifies one or more order identifiers - separated by comma - for which orders should be processed. Used with cancel-order, suspend-order, resume-order and letrun-order commands.
    • For example --order-id=#2024-08-25#T54565139012-sos,#2024-08-25#T56189833113-sos will process the indicated orders.
  • --label
    • Specifies one or more labels - separated by comma - for jobs that should be processed. Used with stop-job, unstop-job, skip-job and unskip-job commands.
    • For example --label=job1,job2 will consider jobs assigned the indicated labels.
  • --notice-board
    • Specifies one or more JS7 - Notice Boards - separated by comma - that should be processed. Used with the post-notice, get-notice and delete-notice commands.
  • --notice-id
    • Specifies the identifier of a notice, frequently the daily plan date is used, for example 2024-08-21. Used with the post-notice, get-notice and delete-notice commands.
  • --notice-lifetime
    • Specifies the max. period for which the notice will be available. Periods such as 1h, 30m can be specified. Used with the post-notice command.
  • --log-dir
    • If a log directory is specified then the script will log information about processing steps to a log file in this directory.
    • File names are created according to the pattern: manageoperate-workflow.<yyyy>-<MM>-<dd>T<hh>-<mm>-<ss>.log
    • For example: manageoperate-workflow.2022-03-19T20-50-45.log

...

  • -h | --help
    • Displays usage.
  • -v | --verbose
    • Displays verbose log output that includes requests and responses with the JS7 REST Web Service.
  • -p | --password
    • Asks the user for interactive keyboard input of the password used for the account specified with the --user option..
    • The switch is used for secure interactive input as an alternative to use of the option --password=<password>.
  • -r | --recursive
    • Specifies that folders will be looked up recursively if the --workflow-folders or  --schedule-folders option is used.
  • -f | --force
  • --show-logs
    • Displays the log output created by the script if the --log-dir option is used.
  • --make-dirs
    • If directories are missing that are indicated with the --log-dir option then they will be created.

...

Code Block
titleExamples for Adding Orders
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# add ad hoc order
./manageoperate-workflow.sh add-order ${request_options[@]} \
	--workflow=ap3jobs

# add ad hoc order for specific job
./manageoperate-workflow.sh add-order ${request_options[@]} \
	--workflow=ap3jobs --start-position=job2 --end-position=job3

# add pending order
./manageoperate-workflow.sh add-order ${request_options[@]} \
	--workflow=ap3jobs --date-to=never

# add scheduled order and force admission
./manageoperate-workflow.sh add-order ${request_options[@]} \
	--workflow=ap3jobs --order-name=sample-1 --date-to=now+15 --force

...

Code Block
titleExamples for Cancelling Orders
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# cancel orders by state
./manageoperate-workflow.sh cancel-order ${request_options[@]} \
    --workflow=ap3jobs --date-to=-2h --state=SCHEDULED,PROMPTING,SUSPENDED,INPROGRESS,RUNNING

# cancel orders by state, yesterday's start date, folder recursively
./manageoperate-workflow.sh cancel-order ${request_options[@]} \
	--folder=/ap --recursive --date-to="$(TZ=Europe/London date + '%Y-%m-%d')" --state=SCHEDULED,PROMPTING,SUSPENDED,INPROGRESS,RUNNING

...

Code Block
titleExamples for Suspending and Resuming Orders
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# suspend orders in workflow
./manageoperate-workflow.sh suspend-order ${request_options[@]} \
	--workflow=ap3jobs

# suspend orders in workflow and terminate running job
./manageoperate-workflow.sh suspend-order ${request_options[@]} \
	--workflow=ap3jobs --force

# resume suspended orders in workflow
./manageoperate-workflow.sh resume-order ${request_options[@]} \
	--workflow=ap3jobs --state=SUSPENDED

...

Code Block
titleExample for Letting Run Orders
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# let run waiting orders in workflow
./manageoperate-workflow.sh letrun-order ${request_options[@]} \
	--workflow=ap3jobs --state=WAITING

...

Code Block
titleExample for Transferring Orders
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# transfer orders to latest workflow version
./manageoperate-workflow.sh transfer-order ${request_options[@]} \
	--workflow=ap3jobs

...

Code Block
titleExample for Suspending and Resuming Workflows
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# suspend workflow
./manageoperate-workflow.sh suspend-workflow ${request_options[@]} \
	--workflow=ap3jobs

# resume workflow
./manageoperate-workflow.sh resume-workflow ${request_options[@]} \
	--workflow=ap3jobs

...

Code Block
titleExample for Stopping and Unstopping Jobs
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# stop jobs from labels
./manageoperate-workflow.sh stop-job ${request_options[@]} \
	--workflow=ap3jobs --label=job1,job2

# unstop jobs from labels
./manageoperate-workflow.sh unstop-job ${request_options[@]} \
	--workflow=ap3jobs --label=job1,job2

...

Code Block
titleExample for Skipping and Unskipping Jobs
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# skip jobs from labels
./manageoperate-workflow.sh skip-job ${request_options[@]} \
	--workflow=ap3jobs --label=job1,job2

# unskip jobs from labels
./manageoperate-workflow.sh unskip-job ${request_options[@]} \
	--workflow=ap3jobs --label=job1,job2

...

Code Block
titleExample for Posting, Reading and Deleting Notices
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root --controller-id=controller)

# post notice for current daily plan date
./manageoperate-workflow.sh post-notice ${request_options[@]} \
	--notice-board=ap3jobs

# post notice for specific daily plan date and lifetime
./manageoperate-workflow.sh post-notice ${request_options[@]} \
	--notice-board=ap3jobs --notice-id=2024-08-26 --notice-lifetime=6h


# reading notices from notice board
./manageoperate-workflow.sh get-notice ${request_options[@]} \
    --notice-board=ap3jobs

# reading specific notice from notice board
./manageoperate-workflow.sh get-notice ${request_options[@]} \
    --notice-board=ap3jobs --notice-id=2024-08-26

# reading notices by folder
./manageoperate-workflow.sh get-notice ${request_options[@]} \
    --folder=/ap --recursive


# delete notices from notice board for current daily plan date
./manageoperate-workflow.sh delete-notice ${request_options[@]} \
	--notice-board=ap3jobs

# delete specific notices from notice board using notice identifiers
./manageoperate-workflow.sh delete-notice ${request_options[@]} \
	--notice-board=ap3jobs --notice-id=2024-08-25,2024-08-26

# delete notices by folder
 ./manageoperate-workflow.sh delete-notice ${request_options[@]} \
	--folder=/ap --recursive

...