About templates

This section explains specific description methods, including Template syntax and format.

Template utilization method

The following procedure is required to create a service adaptor config using a Template.

  • Create Template

    First, input a desired name and create a “Template.”

    Create Template
  • Create Template config

    Specify a Module ID and create a “Template config.” You also can create a Template config for multiple Module IDs. Furthermore, the Template can be used only when the target module is in command line format.

    Create Template config

    Once created, enter the descriptions of the “Template Variables” and “Macro commands” (noted below), which serve as the source content for the config applied to the service adaptor.

    テンプレートコンフィグの記述
  • Service adaptor mapping

    Map the service adaptor to its assigned Template. Each service adaptor can be mapped to only a single Template.

    Service adaptor mapping
  • Set Template Variables

    Create the “Template Variables” that will be inserted when the Template is applied.

    テンプレート変数の作成

    Template Variables can be set as either default values or specific variables for each service adaptor.

    Set Template Variables
  • Reflect config

    Run the “Reflect config” operation to apply the Template content to the service adaptor. If a service adaptor is mapped to a Template, the Template content is reflected. If no service adaptor has been mapped, then the content of the Working config for the individual service adaptor is reflected.

    Reflect config

Template config syntax

You can describe “Macro commands” within the Template config. The syntax for macro commands is as follows.

if-else

Allows you to change the output character string based on specific parameters.

#if (evaluation formula 1)
  strings 1
#elseif (evaluation formula 2)
  strings 2
#else
  strings 3
#end

The evaluation formula compares template variable values. You can use “Match (==)” or “Nomatch (!=)” as the comparison condition. For example, to compare whether the value for template variable ${var_1} matches the character string value_1, the description is: “#if (${var_1} == “value_1”)”.

You can omit #elseif and #else. Also, you can describe multiple lines for #elseif.

foreach

Allows you to execute a loop process on all service adaptors mapped to the Template and extracts Template values in order.

#foreach(${<loop variable>} in ${<template name 1>})
  strings 1 ${<loop variable>.<template variable name 1>}
  strings 2 ${<loop variable>.<template variable name 2>}
  strings 3 ${<loop variable>.<template variable name 3>}
#end

“Loop Variables” are the Variables that are referenced only within the relevant foreach line. The loop Variable name can be any Variable name you desire.

The Template name can be specified as the name of the current Template or the name of a different Template.

Comment

You can freely insert comments inside the Template config.

## this line is comment

Comments are not output during Reflect config. This function also allows you to temporarily disable a specific line in the config.

Comments also may be added to the end of a line.

this is config ## this is comment

You also may insert comments that span multiple lines.

#* this line is comment
   and this line is comment too *#

Template Variable

“Template Variables” are the Variables that are referenced within the Template config text. Describing the Variable name in the text will result in the Variable being applied automatically during the Reflect config operation.

Template Variable descriptions are based on the following format.

${<template variable name>}

Template Variables includes “default values” and “specific values” for each service adaptor. If specific values exist for each service adaptor when the Template is applied, read priority is given to those values. If none exist, then the default values are read.

System defined variables

In addition to standard “Template Variables,” Templates also have predefined “system defined variables.” The types of system defined variables are as follows.

Loop counter

${loopCount}

Used only within the “foreach” macro command. Incremented for each macro process executed. The process starts from the default value of “0”.

SA code

${system.sa_code}

Outputs the “SA codes” for target service adaptors. Can be used as a unique identifier. Described as follows when using within the “foreach” macro command.

${<loop variable>.system.sa_code}

Working config

${sa_working_config_<module ID>}

Outputs the “Working config” set for the target service adaptor. Reads the “Working config” for the module with the ID specified in the ending “Module ID.” For example, describe as “${sa_working_config_0}” to read the Working config for the module with the Module ID 0. Compatible only with modules in command line format.

Escape sequence

Begin a description with “\” when you need to output character strings that are identical to defined Template Variables or macro commands within the Template config.

this is config and parameter is \${var}
this is config and parameter is \#if

CSV Import/Export

Among Template values, values for “Template Variables” and “Template Assigned SA” can be imported/exported using a CSV file. The exported CSV file can be edited using an application such as Excel or text editor. The values for “Template Variables” and “Template Assigned SA” are overwritten when you import the edited CSV file.

CSV file format

The CSV file format is as follows.

[name]    ,variableA   ,variableB   ,variableC   , ...
[default] ,defaultValue,defaultValue,defaultValue, ...
SA-code1  ,value       ,value       ,value       , ...
SA-code2  ,value       ,value       ,value       , ...
SA-code3  ,value       ,value       ,value       , ...
                          :
                          :

CSV editing example

The following is an example of a CSV file immediately after export. The following example explains the method for adding updates from this status.

[name],var_A,var_B,var_C
[default],default_A,,default_C
tssXXXXXXX1,A-1,B-1,C-1
tssXXXXXXX2,A-2,B-2,
tssXXXXXXX3,,B-3,
tssXXXXXXX4,,B-4,
tssXXXXXXX5,A-5,B-5,C-5

Changing Template Variable values

Updates are applied by overwriting the Variable values in the CSV file.

In the following example, Variable value A-1 is updated to A-1-modified.

[name],var_A,var_B,var_C
[default],default_A,,default_C
tssXXXXXXX1,A-1-modified,B-1,C-1
tssXXXXXXX2,A-2,B-2,
tssXXXXXXX3,,B-3,
tssXXXXXXX4,,B-4,
tssXXXXXXX5,A-5,B-5,C-5

We also newly set the specific value C-3 for the Template Variable var_C tssXXXXXXX3.

[name],var_A,var_B,var_C
[default],default_A,,default_C
tssXXXXXXX1,A-1-modified,B-1,C-1
tssXXXXXXX2,A-2,B-2,
tssXXXXXXX3,,B-3,C-3
tssXXXXXXX4,,B-4,
tssXXXXXXX5,A-5,B-5,C-5

Adding new Variables

You can add Variable definitions by adding Variable name strings to the [name] row. When you add or delete a string, you must make sure the number of elements is consistent in all rows.

In the following example, Variable var_D is newly added and both default and specific values are set.

[name],var_A,var_B,var_C,var_D
[default],default_A,,default_C,default_D
tssXXXXXXX1,A-1,B-1,C-1,D-1
tssXXXXXXX2,A-2,B-2,,D-2
tssXXXXXXX3,,B-3,,D-3
tssXXXXXXX4,,B-4,,
tssXXXXXXX5,A-5,B-5,C-5,

Updating service adaptor assignments

You can update the settings for an SA template assignment by adding or deleting an SA code row.

In the following example, the assignment tssXXXXXXX3 is deleted and the assignment tssXXXXXXX6 is newly added.

[name],var_A,var_B,var_C
[default],default_A,,default_C
tssXXXXXXX1,A-1,B-1,C-1
tssXXXXXXX2,A-2,B-2,
tssXXXXXXX4,,B-4,
tssXXXXXXX5,A-5,B-5,C-5
tssXXXXXXX6,A-6,B-6,C-6

Template setting example

The following is an example of settings applied when using a Template.

Create Template

For this example, we create the Template “template_set_1”.

Create Template config

Here, we assume that the service adaptor config is performed for module 0 and module 1. The following type of Template config is created for each module.

  • Module 0

    command_1 this is an example
    #if (${param_pattern} == "name_only")
    command_2 ${name}
    #elseif (${param_pattern} == "name_and_address")
    command_2 ${name} ${address}
    #end
    #foreach (${l} in ${template_set_1})
    command_3 ${l.name}_${loopCount} ${l.address}
    #end
    
  • Module 1

    #if (${use_module_1} == "true")
    <sample>
      <param_1>value_1</param_1>
      <param_2>value_2</param_2>
      <param_3>value_3</param_3>
    </sample>
    #end
    

Service adaptor mapping

The following three service adaptors are assigned to template_set_1.

SA code

Distribution ID

tssXXXXXXX1

0001-0000-0000-0000-0000-0000-0000-0001

tssXXXXXXX2

0001-0000-0000-0000-0000-0000-0000-0002

tssXXXXXXX3

0001-0000-0000-0000-0000-0000-0000-0003

Set Template Variables

The following Template Variables are created and both default and specific values are set.

-

address

name

param_pattern

use_module_1

Default value

name_only

true

tssXXXXXXX1

10.0.0.1

SA1

name_and_address

tssXXXXXXX2

10.0.0.2

SA2

tssXXXXXXX3

10.0.0.3

SA3

false

Reflect config

When Reflect config is run, the Template is applied and the following config is reflected in each service adaptor.

  • tssXXXXXXX1

    • Module 0

      command_1 this is an example
      command_2 SA1 10.0.0.1
      command_3 SA1_0 10.0.0.1
      command_3 SA2_1 10.0.0.2
      command_3 SA3_2 10.0.0.3
      
    • Module 1

      <sample>
        <param_1>value_1</param_1>
        <param_2>value_2</param_2>
        <param_3>value_3</param_3>
      </sample>
      
  • tssXXXXXXX2

    • Module 0

      command_1 this is an example
      command_2 SA2
      command_3 SA1_0 10.0.0.1
      command_3 SA2_1 10.0.0.2
      command_3 SA3_2 10.0.0.3
      
    • Module 1

      <sample>
        <param_1>value_1</param_1>
        <param_2>value_2</param_2>
        <param_3>value_3</param_3>
      </sample>
      
  • tssXXXXXXX3

    • Module 0

      command_1 this is an example
      command_2 SA3
      command_3 SA1_0 10.0.0.1
      command_3 SA2_1 10.0.0.2
      command_3 SA3_2 10.0.0.3
      
    • Module 1

      (N/A)
      

The explanations thus far note the basic operational flow for using a Template. After this process is complete, a config reflecting the edited content is output automatically when the config is reflected after assigning service adaptors or updating template variable values.