In the rules file we will specify for the purpose of this example only simple rules for checking and changing the folder definitions.
We will check, that the folder and job names start with 'D' for DEV, with 'T' for TEST and with 'P' for PROD. If a description for a folder or job is missing a warning shall be displayed.
On change we will change the folder and job names and datacenters accordingly to the environment in which the folder definition is being moved.
After creating the configuration file etc/hos_ctm_dev_test_prod_rules_config.php as a copy of the sample file etc/hos_ctm_rules_config.php.sample and editing it, the configuration file looks like this:
<?php
$hos_ctm_rules_config = array(
'check' => array(
array(
'element' => array('FOLDER', 'SCHED_TABLE', 'TABLE',
'SMART_FOLDER', 'SMART_TABLE',
'SCHED_GROUP'),
'variables' => array(
'stage_short' => 'substr(${stage}, 0, 1)',
),
),
array(
'warning' => true,
'element' => array('SMART_FOLDER', 'SMART_TABLE',
'SCHED_GROUP', 'SUB_FOLDER', 'SUB_TABLE',
'JOB'),
'mandatory-attribute' => 'DESCRIPTION',
),
array(
'attribute' => 'FOLDER_NAME',
'condition' => 'substr($, 0, 1) = ${stage_short}',
'message' => 'The folder name must start with the first character '
.'of the current stage (D~DEV, T~TEST, P~PROD)',
),
array(
'attribute' => 'JOBNAME',
'condition' => 'substr($, 0, 1) = ${stage_short}',
'message' => 'The job name must start with the first character '
.'of the current stage (D~DEV, T~TEST, P~PROD)',
),
),
'change' => array(
array(
'element' => array('FOLDER', 'SCHED_TABLE', 'TABLE',
'SMART_FOLDER', 'SMART_TABLE',
'SCHED_GROUP', 'DOFORCEJOB'),
'variables' => array(
'stage_short' => 'substr(${stage}, 0, 1)',
),
),
array(
'attribute' => 'DATACENTER',
'evaluate' => '\'CTM_\'.${stage_short}.substr($, 5)',
),
array(
'attribute' => array('FOLDER_NAME', 'TABLE_NAME', 'JOBNAME'),
'condition' => 'trim($) <> \'\'',
'evaluate' => '${stage_short}.substr($, 1)',
),
array(
'attribute' => array('PARENT_FOLDER', 'PARENT_TABLE'),
'condition' => 'trim($) <> \'\'',
'delimiter' => '/',
'evaluate' => '${stage_short}.substr($, 1)',
),
),
);
?>