KBI 311793 Enhancement: Command Line Tool to Export and Import Job Templates in Argent Job Scheduler

Version

Argent Job Scheduler 2001-A and above

Date

Friday, 31 January 2020

Summary

A new command line tool has been introduced in Argent Job Scheduler to export Job Templates from one environment to another.

For example, this can be used to move Jobs from a test or development environment to a production environment.

Technical Background

ARGENT_JOB_EXPORT_IMPORT_CLI is a command line application to export Job Templates from one environment to another.

This process involves the following three steps:

  1. Export the required Job Templates from the source environment to an XML file
  2. Simulate the Import operation of the Job Templates in the target environment
  3. Import the new Job Templates in the target environment

When a Job Template is moved from one environment to another, the following parameters are likely to be changed:

  1. Path of Job File
  2. Paths of File Dependencies
  3. Queue Engine
  4. Job Class
  5. Log File Path

The CLI has the option to replace these attributes with the new values before importing to the target environment.

An Argent standard input file will be used to list OLD and NEW values for the above-mentioned attributes so that the utility can update them before the import operation is performed.

The following Job Attributes of the imported Job Templates may NOT be present in the target Scheduler:

  1. Queue Engine Macro
  2. Job Sequence Macro
  3. Alerts
  4. Calendar

If the target environment does not have the above-mentioned attributes of the imported Job Template, then the CLI will abort, listing all Job Templates with missing attributes in the log file.

This precaution maintains the integrity of the Argent product.

If the CLI is run at the target server accidently, it can make a production environment unstable.

An explicit command line switch, /EXECUTE, is used to prevent this from occurring.

The default is to simulate the import process. The /EXECUTE parameter needs be added for the CLI to import the data.

The simulation process must always run before /EXECUTE is used.

The timestamp of the simulate process is added to the exported XML file and is protected with a CRC.

Import files without this timestamp are considered invalid if the /EXECUTE switch is used.

Whenever /EXECUTE is used, the CLI takes a full backup of the database tables which will be affected by the import operation and appends a timestamp to the backup name.

The name of the backup also includes the name of the user running the CLI.

Sample INPUT File

The input file has the following two sections; only this file can be edited, NOT the generated XML.

1. The Job Templates to be exported. Wildcard characters (* and ?) are supported.


[JOB_TEMPLATE]

[QTLY_PAYROLL_01]

[PRD_SITE_FTP*]

[JOB_TEMPLATE_END]

2. The pairs of OLD and NEW strings to be replaced for the following Job Attributes

[REPLACE]

[JOB_CLASS_NAME]

[OLD] [ARGENT_SAMPLE_JOB_CLASS_01]

[NEW] [ARGENT_SAMPLE_JOB_CLASS_NEW_01]

[JOB_CLASS_NAME_END]

[JOB_NAME]

[OLD] [ARGENT_SAMPLE_JOB_01]

[NEW] [ARGENT_SAMPLE_JOB_NEW_01]

[JOB_NAME_END]

[QUEUE_ENGINE]

[OLD] [ARGENT_QE_TEST_01]

[NEW] [ARGENT_QE_PROD_01]

[QUEUE_ENGINE_END]

[JOB_FILE_PATH]

[OLD] [/opt/shelljobs/Argent_Sample_Job01.sh]

[NEW] [/opt/shelljobs/Argent_Sample_Job_prod_01.sh]

[JOB_FILE_PATH_END]

[DEPENDENCY_FILE_PATH]

[OLD] [//TEST_SVR//download.txt]

[NEW] [//PROD_FILE_SVR//download.txt]

[DEPENDENCY_FILE_PATH_END]

[LOG_FILE_PATH]

[OLD] [/opt/shelljobs/logs/Argent_Sample_Job01.log]

[NEW] [/opt/shelljobs/logs/Argent_Sample_Job_new_01.log]

[LOG_FILE_PATH_END]

[REPLACE_END]

[END]

[END]

[END]

Export and Import Files

The export and import files are written in XML file format with meaningful file extensions.

During the export, the following types of files are created based on the Job definition.

None of these files can be manually edited.

Thu_23_Jan_2020_07_58_30_129_A6B5_(UTC).EXPORT

This file contains the original data (before making any replacements) and can be used for debugging.

Thu_23_Jan_2020_07_58_30_169_57A4_(UTC).IMPORT

This file contains data after making the Job Attribute replacements and is used for the Import operation.

SCHEDULE_Thu_23_Jan_2020_07_58_30_169_57A4_(UTC).IMPORT

This file is generated only when an exported Job Template contains a schedule.

The security and debugging header of the generated XML files is shown below.



<ARGENT_JOB_EXPORT_IMPORT_CLI_HEADER>

<VERSION VALUE=”10.0-2001-A”/>

<ARGENT_CRC HIGH=”3494236786″ LOW=”3571543070″/>

<ARGENT_SERVER NAME =”UAT_SVR_AJ”/>

<ARGENT_USER NAME=”USR_TST”/>

<ARGENT_CREATE_TIMESTAMP VALUE=”Thu_23_Jan_2020_07_58_30_175″/>

<ARGENT_SIMULATE_TIMESTAMP VALUE=”Thu_23_Jan_2020_07_59_31_724″/>

</ARGENT_JOB_EXPORT_IMPORT_CLI_HEADER>

Manual editing of these IMPORT files is strictly protected through a CRC validation.

In order to update these files, edit the INPUT file and rerun the CLI to generate an updated IMPORT file.

ARGENT_JOB_EXPORT_IMPORT_CLI Usage

/OPERATION = IMPORT | EXPORT | CREATE_INPUT_TEMPLATE

/INPUT_FILE = Input file path

/OUTPUT_FOLDER = EXPORT file path

/IMPORT_FILE = IMPORT file generated

/EXECUTE

/OVERWRITE

Examples:

To export Jobs from a Database to an Export file:

ARGENT_JOB_EXPORT_IMPORT_CLI.EXE

/OPERATION=EXPORT

/INPUT_FILE=”C:\ARGENT\INPUT.TXT”

/OUTPUT_FOLDER=”C:\ARGENT\OUTPUT”

To simulate importing Jobs from the Import file:

ARGENT_JOB_EXPORT_IMPORT_CLI.EXE

/OPERATION=IMPORT

/IMPORT_FILE=Thu_12_Dec_2019_09_10_03_041_62F8_(UTC).IMPORT

To import Jobs from the Import file to a Database:

ARGENT_JOB_EXPORT_IMPORT_CLI.EXE

/OPERATION=IMPORT

/IMPORT_FILE=Thu_12_Dec_2019_09_10_03_041_62F8_(UTC).IMPORT

/EXECUTE

To import Jobs from the Import file to a Database and overwrite existing values:

ARGENT_JOB_EXPORT_IMPORT_CLI.EXE

/OPERATION=IMPORT

/IMPORT_FILE=Thu_12_Dec_2019_09_10_03_041_62F8_(UTC).IMPORT

/EXECUTE

/OVERWRITE

To create an input template file for the user in the source directory:

ARGENT_JOB_EXPORT_IMPORT_CLI.EXE /OPERATION=CREATE_INPUT_TEMPLATE

Prerequisites

  1. The CLI must run on the host server where Argent Job Scheduler is installed.
  2. The CLI should run under the Argent service account. (Although not recommended, the CLI can run as an administrator with a trusted connection and with read-write access to Argent Job Scheduler database.)
  3. Database table backup is done using the Microsoft SQL Server bcp utility. Make sure it is present on the machine.

Resolution

Upgrade to Argent Job Scheduler 2001-A or above