Page History
Info | ||
---|---|---|
| ||
The functionality of the script presented in the article is migrated to JS7 - Unix Shell CLI for Workflow Status Operations Users can continue to use the below script, no maintenance is provided. |
Table of Contents |
---|
Introduction
...
The Script requires the jq utility to be available from the operating system.
jq is ships with the MIT license, see https://opensource.org/licenses/MIT.
...
--url
- Specifies the URL by which JOC Cockpit is accessible using
<http|https>://<host>:<port>
. - Example: http://centostest-primary.sos:4446
- Example: https://centostest-primary.sos:4443
- Specifies the URL by which JOC Cockpit is accessible using
--controller-id
- Specifies the identification of the Controller that holds related orders.
--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.
- Specifies the user account for login to JOC Cockpit. If JS7 - Identity Services are available for Client authentication certificates that are specified with the
--password
- Specifies the password used for the account specified with the
--user
option to login to JOC Cockpit. - Consider use of the
-p
switch offering a secure option for interactive keyboard input.
- Specifies the password used for the account specified with the
--cacert
- Specifies the path to a .pem file 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 .pem file that holds the Client Certificate if HTTPS mutual authentication is used..
--client-key
- Specifies the path to a .pem file that holds the Client Privae Key if HTTPS mutual authentication is used..
--date-to
- Specifies the date and time in ISO format to which orders have been scheduled. The default value
now
indicates the current point in time.- An absolute date, for example
2023-10-23T14:00:00
will affect all orders scheduled for execution before that date. - A relative date, for example
--date-to=-1d
(1 day back),--date-to=-2h
(2 hours back),--date-to=-30m
(30 minutes back).
- An absolute date, for example
- Dates and times can be calculated from the
date
command.--date-to="$(TZ=Europe/London date +'%Y-%m-%d')T00:00:00"
specifies orders scheduled for a date before the current day in the Europe/London time zone.--date-to="$(TZ=Europe/London date --date="1 day ago" +'%Y-%m-%d')T00:00:00"
specifies orders scheduled for execution before yesterday.
- Specifies the date and time in ISO format to which orders have been scheduled. The default value
--time-zone
- Specifies the time zone to be used for the
--date-to
option. By default the system time zone is used. - The time zone is specified from an identifier as explained by https://en.wikipedia.org/wiki/List_of_tz_database_time_zones, for example
--time-zone=Europe/London
.
- Specifies the time zone to be used for the
--states
- Specifies one or more states - separated by comma - for which orders should be cancelled. By default the
SCHEDULED
state is used. - Valid states are
PLANNED, PENDING, SCHEDULED, INPROGRESS, RUNNING, SUSPENDED, WAITING, PROMPTING, FAILED, BLOCKED, UNKNOWN
. - For example
--states=SCHEDULED,SUSPENDED,FAILED
will cancel orders holding any of the given states.
- Specifies one or more states - separated by comma - for which orders should be cancelled. By default the
--folders
- Specifies one or more JOC Cockpit inventory folders from absolute paths - separated by comma - holding workflows for which orders have been scheduled.
- For example
--folders=/ProductDemo/CyclicExecution,/ProductDemo/ScheduledExecution
will cancel orders scheduled for workflows in the given folders. - If the
--recursive
switch is used then sub-folders will be looked up recursively.
--workflows
- Specifies one or more workflows - separated by comma - for which orders have been scheduled.
- For example
--workflows=/ProductDemo/CyclicExecution/Cyclic-Check,/ProductDemo/ScheduledExecution/Daily-EOD
will consider orders scheduled for theCyclic-Check
andDaily-EOD
workflows from the given folders.
--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:
set_job_resourcecancel-orders.<yyyy>-<MM>-<dd>T<hh>-<mm>-<ss>.log
- For example:
set_job_resourcecancel-orders.2022-03-19T20-50-45.log
Switches
...
Code Block | ||||
---|---|---|---|---|
| ||||
./cancel-orders.sh \
--url=http://joc-2-0-primary:7446 \
--user=root \
--password=root \
--controller-id=controller \
--date-to="$(date +'%Y-%m-%d')T00:00:00"
# cancels orders scheduled for a date before begin of the current day
# limits cancellation to orders in the SCHEDULED state (default)
# implies that the system time zone is used (default) |
...
Code Block | ||||
---|---|---|---|---|
| ||||
./cancel-orders.sh \
--url=https://joc-2-0-primary:7443 \
--cacert=/home/sos/jstest/certs/root-ca.pem \
--user=root \
-p \
--controller-id=controller \
--date-to="$(TZ=Europe/London date --date="1 day ago" +'%Y-%m-%d')T00:00:00" \
--time-zone=Europe/London \
--states=FAILED,SUSPENDED
# cancels orders scheduled for a date before yesterday
# establishes the connection to JOC Cockpit by HTTPS and the Root CA Certificate is specified from the path to a .pem file
# asks the user for interactive keyboard input of the password used for the account specified
# specifies the date from an individual time zone
# limits cancellation to orders in the FAILED and SUSPENDED state |
...
Code Block | ||||
---|---|---|---|---|
| ||||
./cancel-orders.sh \
--url=http://joc-2-0-primary:7446 \
--user=root \
--password=root \
--controller-id=controller \
--date-to="$(date +'%Y-%m-%d')T00:00:00" \
--folders=/ProductDemo/CyclicExecution,/ProductDemo/ScheduledExecution \
--recursive
# cancels late orders scheduled for yesterday's Daily Plan date
# limits cancellation to orders in the SCHEDULED state (default) for workflows from the given folders
# looks up sub-folders recursively |
...
Code Block | ||||
---|---|---|---|---|
| ||||
./cancel-orders.sh \ --url=http://joc-2-0-primary:7446 \ --user=root \ --password=root \ --controller-id=controller \ --date-to="$(date +'%Y-%m-%d')T00:00:00" \ --workflows=/ProductDemo/CyclicExecution/Cyclic-Check,/ProductDemo/ScheduledExecution/Daily-EOD # cancels late orders scheduled for yesterday's Daily Plan date # limits cancellation to orders in the SCHEDULED state (default) for the given list of workflows |
Further Resources
- JS7 - How to clean up the Daily Plan from past Dependencies
- JS7 - How to cancel orders of the daily plan using the REST Web Service API from the Shell
- JS7 - How to delete notices using the REST Web Service API from the Shell
Overview
Content Tools