Source:Task Name Template – Backup: Difference between revisions
(Ready for review) |
(Marked this version for translation) |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude><div class="noprint"><languages /> | <noinclude><div class="noprint"><languages /> | ||
<br /> | |||
<translate>==Overview== <!--T:3--></translate> | |||
</div></noinclude><translate><!--T:8--> | |||
<div | As of [[Special:MyLanguage/SEP_sesam_Release_Versions|4.4.3 ''Beefalo V2'']], SEP sesam supports a higher level of automation for performing administrative work by generating administrative objects, such as backup tasks, based on a given template. | ||
<!--T:9--> | |||
Templates can be created to allow SEP sesam administrators to automatically create backup tasks by replacing specific information with variables, thus saving time and simplifying backup management. Templates can be configured in the SEP sesam GUI -> ''Configuration'' -> ''Defaults'' -> ''Extras'' -> ''Template'', as described in [[Special:MyLanguage/4_4_3_Beefalo:Configuration#extras|GUI Configuration options: Extras]].</translate> | |||
{| | =={{anchor|usage}}<translate><!--T:10--> | ||
Backup task name template usage== | |||
<!--T:11--> | |||
SEP sesam used the ''Mustache'' specification for a templating language to auto-generate the name of backup tasks while creating the task using the UI server’s REST API. Due to some limitations of the ''Mustache'' template, SEP sesam introduced a more flexible and powerful ''Rythm'' template engine. | |||
<!--T:12--> | |||
The ''Rythm'' template engine has the following advantages:</translate> | |||
*<translate><!--T:13--> Flexibility in writing template side code as it uses Java like syntax and allows embedding Java code snippets inside the template source.</translate> | |||
*<translate><!--T:14--> Easy to integrate into an existing Java application.</translate> | |||
*<translate><!--T:15--> Supports template inheritance as well as macros.</translate> | |||
*<translate><!--T:16--> | |||
Handling of complex data types. | |||
<!--T:17--> | |||
For more details, see [http://rythmengine.org/ ''Rythm templates'']. | |||
<!--T:88--> | |||
Note that you can also use the Rythm syntax to adopt the pre-configured ''report templates'' to suit your needs. For details, check the video [https://www.youtube.com/watch?v=Gddx24SouoE&feature=youtu.be Customized HTML Reports with SEP sesam].</translate> | |||
==={{anchor|mustache}}<translate><!--T:18--> | |||
Mustache syntax=== | |||
<!--T:19--> | |||
Currently, SEP sesam auto-generates the name of the backup task by using the ''Mustache'' specification for a templating language. For example, if the name property of the backup task is set to ''backup_task_<nowiki>{{client}}</nowiki>'' and the ''client'' property of the backup task evaluates to ''snowfix'', the UI server updates the name property of the backup task to ''backup_task_snowfix'' before committing this backup task to the database. | Currently, SEP sesam auto-generates the name of the backup task by using the ''Mustache'' specification for a templating language. For example, if the name property of the backup task is set to ''backup_task_<nowiki>{{client}}</nowiki>'' and the ''client'' property of the backup task evaluates to ''snowfix'', the UI server updates the name property of the backup task to ''backup_task_snowfix'' before committing this backup task to the database. | ||
The syntax used by ''Mustache'' to denote a placeholder for named property is: | <!--T:20--> | ||
{{<property name>}} | The syntax used by ''Mustache'' to denote a placeholder for named property is:</translate> | ||
{{<<translate><!--T:21--> property name</translate>>}} | |||
===Rythm syntax=== | ==={{anchor|rythm}}<translate><!--T:22--> | ||
The ''Rythm'' template engine uses a different syntax. The full ''Rythm template source'' for achieving the same result as in the example above is: | Rythm syntax=== | ||
<!--T:23--> | |||
The ''Rythm'' template engine uses a different syntax. The full ''Rythm template source'' for achieving the same result as in the example above is:</translate> | |||
@args String client | @args String client | ||
backup_task_@(client) | backup_task_@(client) | ||
{{note|There are no pre-configured templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for | {{note|<translate><!--T:25--> There are no pre-configured backup templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for backup tasks.</translate>}} | ||
==={{anchor|placeholder}}Using placeholders=== | ==={{anchor|placeholder}}<translate><!--T:26--> | ||
Using placeholders=== | |||
The following table lists placeholders that can be used in the backup task name template. | <!--T:27--> | ||
The following table lists placeholders that can be used in the backup task name template.</translate> | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" | Name | ! scope="col" | <translate><!--T:28--> Name</translate> | ||
! scope="col" | Type | ! scope="col" | <translate><!--T:29--> Type</translate> | ||
! scope="col" | Description | ! scope="col" | <translate><!--T:30--> Description</translate> | ||
|- | |- | ||
|<tt>client</tt> || <tt>string</tt>|| The name of the client associated with the backup task object. | |<tt>client</tt> || <tt>string</tt>|| <translate><!--T:31--> The name of the client associated with the backup task object.</translate> | ||
|- | |- | ||
|<tt>source</tt> || <tt>string</tt>|| The source property of the backup task object. | |<tt>source</tt> || <tt>string</tt>|| <translate><!--T:32--> The source property of the backup task object.</translate> | ||
|- | |- | ||
|<tt>count</tt> || <tt>string</tt>|| A number between 1 and 10000. Evaluates to the first number in this range leading to a unique task name. | |<tt>count</tt> || <tt>string</tt>|| <translate><!--T:33--> A number between 1 and 10000. Evaluates to the first number in this range leading to a unique task name.</translate> | ||
|- | |- | ||
|<tt>count_optional</tt> || <tt>string</tt>|| Equals the ''count'' token which is used when a task already exists. | |<tt>count_optional</tt> || <tt>string</tt>|| <translate><!--T:34--> Equals the ''count'' token which is used when a task already exists.</translate> | ||
|- | |- | ||
|<tt>task</tt> || <tt>tasks</tt>|| The backup task object.<br />'''''Note''': This placeholder can only be used together with a native Rythm template.'' | |<tt>task</tt> || <tt>tasks</tt>|| <translate><!--T:35--> The backup task object.</translate><br /><translate><!--T:36--> '''''Note''': This placeholder can only be used together with a native Rythm template.''</translate> | ||
|- | |- | ||
|} | |} | ||
==={{anchor|functions}}Functions (''Mustache'' syntax only)=== | ==={{anchor|functions}}<translate><!--T:37--> | ||
Functions (''Mustache'' syntax only)=== | |||
The following transformation functions are supported when using the ''Mustache'' syntax. | <!--T:38--> | ||
{{note|These functions cannot be combined when using ''Mustache''. If more complex transformations are required, use the ''Rythm'' syntax.}} | The following transformation functions are supported when using the ''Mustache'' syntax.</translate> | ||
{{note|<translate><!--T:40--> These functions cannot be combined when using ''Mustache''. If more complex transformations are required, use the ''Rythm'' syntax.</translate>}} | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" | Name | ! scope="col" | <translate><!--T:41--> Name</translate> | ||
! scope="col" | Description | ! scope="col" | <translate><!--T:42--> Description</translate> | ||
|- | |- | ||
|<tt>toLower</tt> || Converts all characters in the placeholder value to lower case. | |<tt>toLower</tt> || <translate><!--T:43--> Converts all characters in the placeholder value to lower case.</translate> | ||
|- | |- | ||
|<tt>toUpper</tt> || Converts all characters in the placeholder value to upper case. | |<tt>toUpper</tt> || <translate><!--T:44--> Converts all characters in the placeholder value to upper case.</translate> | ||
|- | |- | ||
|<tt>dashPrefix</tt> || Prepends a dash character ('''-''') to the placeholder value, if the value is not blank. | |<tt>dashPrefix</tt> || <translate><!--T:45--> Prepends a dash character ('''-''') to the placeholder value, if the value is not blank.</translate> | ||
|- | |- | ||
|<tt>dotPrefix</tt> || Prepends a dot character ('''.''') to the placeholder value, if the value is not blank. | |<tt>dotPrefix</tt> || <translate><!--T:46--> Prepends a dot character ('''.''') to the placeholder value, if the value is not blank.</translate> | ||
|- | |- | ||
|<tt>underPrefix</tt> || Prepends an underscore character ('''_''') to the placeholder value, if the value is not blank. | |<tt>underPrefix</tt> || <translate><!--T:47--> Prepends an underscore character ('''_''') to the placeholder value, if the value is not blank.</translate> | ||
|- | |- | ||
|<tt>substring (start,end)</tt> || Evaluates to a string that is a substring of the string representation of the placeholder value. The character indices start with ''0''. | |<tt>substring (start,end)</tt> || <translate><!--T:48--> Evaluates to a string that is a substring of the string representation of the placeholder value. The character indices start with ''0''.</translate> | ||
|- | |- | ||
|<tt>replace (target,replacement)</tt> || Evaluates to a string where the ''target character sequence'' is replaced by the ''replacement character sequence''. | |<tt>replace (target,replacement)</tt> || <translate><!--T:49--> Evaluates to a string where the ''target character sequence'' is replaced by the ''replacement character sequence''.</translate> | ||
|- | |- | ||
|<tt>trimUnderPrefix</tt> || Removes any ''leading'' underscore character ('''_''') from the placeholder value. | |<tt>trimUnderPrefix</tt> || <translate><!--T:50--> Removes any ''leading'' underscore character ('''_''') from the placeholder value.</translate> | ||
|- | |- | ||
|<tt>trimUnderTrailing</tt> || Removes any ''trailing'' underscore character ('''_''') from the placeholder value. | |<tt>trimUnderTrailing</tt> || <translate><!--T:51--> Removes any ''trailing'' underscore character ('''_''') from the placeholder value.</translate> | ||
|} | |} | ||
===={{anchor|examples}}Examples==== | ===={{anchor|examples}}<translate><!--T:52--> | ||
Examples==== | |||
In our example, the following placeholder values are used: | <!--T:53--> | ||
In our example, the following placeholder values are used:</translate> | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" | Name | ! scope="col" | <translate><!--T:54--> Name</translate> | ||
! scope="col" |Type | ! scope="col" |<translate><!--T:55--> Type</translate> | ||
! scope="col" | Value | ! scope="col" | <translate><!--T:56--> Value</translate> | ||
|- | |- | ||
|<tt>client</tt> || <tt>string</tt>|| <tt>SnowFix</tt> | |<tt>client</tt> || <tt>string</tt>|| <tt>SnowFix</tt> | ||
Line 117: | Line 124: | ||
|- | |- | ||
|} | |} | ||
=====Mustache===== | <translate>=====Mustache===== <!--T:57--> | ||
Using the ''Mustache'' syntax, the templates will evaluate as follows. | |||
<!--T:58--> | |||
Using the ''Mustache'' syntax, the templates will evaluate as follows.</translate> | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" | Name | ! scope="col" | <translate><!--T:59--> Name</translate> | ||
! scope="col" | Value | ! scope="col" | <translate><!--T:60--> Value</translate> | ||
|- | |- | ||
|<tt>sep-task-<nowiki>{{client}}</nowiki></tt> || <tt>sep-task-SnowFix</tt> | |<tt>sep-task-<nowiki>{{client}}</nowiki></tt> || <tt>sep-task-SnowFix</tt> | ||
Line 142: | Line 151: | ||
|} | |} | ||
=====Rythm===== | <translate>=====Rythm===== <!--T:61--> | ||
Using the ''Rythm'' syntax, the templates will evaluate as follows. | |||
<!--T:62--> | |||
Using the ''Rythm'' syntax, the templates will evaluate as follows.</translate> | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" | Name | ! scope="col" | <translate><!--T:63--> Name</translate> | ||
! scope="col" | Value | ! scope="col" | <translate><!--T:64--> Value</translate> | ||
|- | |- | ||
|<tt>@args String client | |<tt>@args String client;tasks_rythm_@(client)</tt> || <tt>tasks_rythm_SnowFix</tt> | ||
|- | |- | ||
|<tt>@args String client, String source | |<tt>@args String client, String source;tasks_rythm_@(client.toLowerCase())_@(source.substring(3,7).toUpperCase())</tt> || <tt>tasks_rythm_snowfix_WORK</tt> | ||
|} | |} | ||
==={{anchor|shortcuts}}Shortcuts for | ==={{anchor|shortcuts}}<translate><!--T:65--> | ||
Shortcuts for backup task’s virtualization attributes=== | |||
You can easily access all field names of the task attribute | <!--T:66--> | ||
You can easily access all field names of the backup task virtualization attribute by using shortcuts. Each shortcut represents a field name of the attribute. | |||
'''''Valid | <!--T:67--> | ||
'''''Valid virtualization attribute shortcuts:'''''</translate> | |||
''name'', ''isVCenter'', ''path'', ''datacenter'', ''moref'', ''powerState'', ''ipAddress'', ''hostName'', ''macAddress'', ''hostSystem'', ''cluster'', ''version'', ''guestFullName'', ''uuid'', ''sesamClient'', ''folder'', ''vapp'', ''taskGroupRef'', ''hostVersion'' | ''name'', ''isVCenter'', ''path'', ''datacenter'', ''moref'', ''powerState'', ''ipAddress'', ''hostName'', ''macAddress'', ''hostSystem'', ''cluster'', ''version'', ''guestFullName'', ''uuid'', ''sesamClient'', ''folder'', ''vapp'', ''taskGroupRef'', ''hostVersion'' | ||
''Example:'' | ''<translate><!--T:68--> Example:</translate>'' | ||
add task "@args de.sep.sesam.model.dto.VMDto vmDto;@ deb_ (vmDto.getMoRef())" … | add task "@args de.sep.sesam.model.dto.VMDto vmDto;@ deb_ (vmDto.getMoRef())" … | ||
is the same as | <translate><!--T:69--> is the same as</translate> | ||
add task "@args String moref;deb_@(moref)"… | add task "@args String moref;deb_@(moref)"… | ||
''Example with | ''<translate><!--T:70--> Example with direct virtualization attribute access:</translate>'' | ||
add taskgen "@args de.sep.sesam.model.dto.FileDto | add taskgen "@args de.sep.sesam.model.dto.FileDto | ||
fileDto;@(fileDto.getAdditionalInformationAsMap().get(\"Status\"))" "-c" "hypervdev" "-t" | fileDto;@(fileDto.getAdditionalInformationAsMap().get(\"Status\"))" "-c" "hypervdev" "-t" | ||
"Hyper-V" -s hyperV -f "c:\tmp\hyperv.txt" -G "hyperVGenGroup3 | "Hyper-V" -s hyperV -f "c:\tmp\hyperv.txt" -G "hyperVGenGroup3" | ||
add taskgen "@args de.sep.sesam.model.Tasks task;qs-@(task.getClient().getShortName())- | add taskgen "@args de.sep.sesam.model.Tasks task;qs-@(task.getClient().getShortName())- | ||
@(task.getShortType())_@(task.getSourceSegment(0))" -f d:\input.json -O remove_all -G vm-8 | @(task.getShortType())_@(task.getSourceSegment(0))" -f d:\input.json -O remove_all -G vm-8 | ||
==={{anchor|special_shortcuts}}Special shortcuts for easy access (without '' | ==={{anchor|special_shortcuts}}<translate><!--T:71--> | ||
Special shortcuts for easy access (without ''Rythm'' keywords)=== | |||
<!--T:72--> | |||
The ''Rythm'' syntax is not required when using special shortcuts in tags – curly braces, i.e., <tt>{{<shortcut>}}</tt>. | The ''Rythm'' syntax is not required when using special shortcuts in tags – curly braces, i.e., <tt>{{<shortcut>}}</tt>. | ||
'''''The name generation shortcuts''''' | <!--T:73--> | ||
'''''The name generation shortcuts'''''</translate> | |||
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | {| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #fcfcfc; border: 1px #aaa solid; border-collapse: collapse;" | ||
|- style="background:#FFCC01; color:#002F55" | |- style="background:#FFCC01; color:#002F55" | ||
! scope="col" |Shortcut | ! scope="col" |<translate><!--T:74--> Shortcut</translate> | ||
! scope="col" | Description | ! scope="col" | <translate><!--T:75--> Description</translate> | ||
|- | |- | ||
|<tt><nowiki>{{CLIENT_SHORT}}</nowiki></tt> || get client without domain | |<tt><nowiki>{{CLIENT_SHORT}}</nowiki></tt> || <translate><!--T:76--> get client without domain</translate> | ||
|- | |- | ||
|<tt><nowiki>{{TASK_TYPE_SHORT}}</nowiki></tt> || get short name of task type | |<tt><nowiki>{{TASK_TYPE_SHORT}}</nowiki></tt> || <translate><!--T:77--> get short name of task type</translate> | ||
|- | |- | ||
|<tt><nowiki>{{SOURCE_LAST_ITEM}}</nowiki></tt> || get last source segment separated by slash | |<tt><nowiki>{{SOURCE_LAST_ITEM}}</nowiki></tt> || <translate><!--T:78--> get last source segment separated by slash</translate> | ||
|- | |- | ||
|<tt><nowiki>{{SOURCE_ITEM[<pos>]}}</nowiki></tt> || get segment pos separated by slash (negative pos as pos from back) | |<tt><nowiki>{{SOURCE_ITEM[<pos>]}}</nowiki></tt> || <translate><!--T:79--> get segment pos separated by slash (negative pos as pos from back)</translate> | ||
|- | |- | ||
|<tt><nowiki>{{<field>}}</nowiki></tt> || use the description block field (''cli action dir last param'').<br /> | |<tt><nowiki>{{<field>}}</nowiki></tt> || <translate><!--T:80--> use the description block field (''cli action dir last param'').</translate><br /> | ||
''Example:'' | ''<translate><!--T:81--> Example:</translate>'' | ||
...Status=Running,OwnerNode=HYPERVDEV,Clustered=No,uuid=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC... | |||
'''''Note''''': You can use all description fields (''UUID'', ''folder'', ''Guest OS'',...) from output of the list (<tt>-f -</tt>) for task name. | |||
<nowiki>{{uuid}}</nowiki>=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC | |||
<translate><!--T:82--> '''''Note''''': You can use all description fields (''UUID'', ''folder'', ''Guest OS'',...) from output of the list (<tt>-f -</tt>) for task name.</translate> | |||
|} | |} | ||
'''''Examples''''' | '''''<translate><!--T:83--> Examples</translate>''''' | ||
< | *<translate><!--T:84--> Backup task with type ''Hyper-V'' from input stream:</translate> | ||
<nowiki>sm_cmd dir -F JSON client "/hypervdev.sep.de/Hyper-V:" | sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" –c hypervdev.sep.de -f - -O remove_all -G hv-5</nowiki> | <nowiki>sm_cmd dir -F JSON client "/hypervdev.sep.de/Hyper-V:" | sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" –c hypervdev.sep.de -f - -O remove_all -G hv-5</nowiki> | ||
< | *<translate><!--T:85--> Backup task with type ''Hyper-V'' from file:</translate> | ||
<nowiki>sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" -c hypervdev.sep.de -f d:\hyperv.json -O remove_all -G hv-5</nowiki> | <nowiki>sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" -c hypervdev.sep.de -f d:\hyperv.json -O remove_all -G hv-5</nowiki> | ||
< | *<translate><!--T:86--> Backup task with type ''Path'' from file:</translate> | ||
<nowiki>sm_cmd add taskgen "{{CLIENT_SHORT}}-{{TASK_TYPE_SHORT}}_{{SOURCE_LAST_ITEM}}" -G pathgroup -f c:\root\path.json –t “Path”</nowiki> | <nowiki>sm_cmd add taskgen "{{CLIENT_SHORT}}-{{TASK_TYPE_SHORT}}_{{SOURCE_LAST_ITEM}}" -G pathgroup -f c:\root\path.json –t “Path”</nowiki> | ||
<noinclude>{{Copyright}}</noinclude> | |||
Latest revision as of 10:49, 8 May 2023
As of 4.4.3 Beefalo V2, SEP sesam supports a higher level of automation for performing administrative work by generating administrative objects, such as backup tasks, based on a given template.
Templates can be created to allow SEP sesam administrators to automatically create backup tasks by replacing specific information with variables, thus saving time and simplifying backup management. Templates can be configured in the SEP sesam GUI -> Configuration -> Defaults -> Extras -> Template, as described in GUI Configuration options: Extras.
Backup task name template usage
SEP sesam used the Mustache specification for a templating language to auto-generate the name of backup tasks while creating the task using the UI server’s REST API. Due to some limitations of the Mustache template, SEP sesam introduced a more flexible and powerful Rythm template engine.
The Rythm template engine has the following advantages:
- Flexibility in writing template side code as it uses Java like syntax and allows embedding Java code snippets inside the template source.
- Easy to integrate into an existing Java application.
- Supports template inheritance as well as macros.
- Handling of complex data types.
For more details, see Rythm templates.
Note that you can also use the Rythm syntax to adopt the pre-configured report templates to suit your needs. For details, check the video Customized HTML Reports with SEP sesam.
Mustache syntax
Currently, SEP sesam auto-generates the name of the backup task by using the Mustache specification for a templating language. For example, if the name property of the backup task is set to backup_task_{{client}} and the client property of the backup task evaluates to snowfix, the UI server updates the name property of the backup task to backup_task_snowfix before committing this backup task to the database.
The syntax used by Mustache to denote a placeholder for named property is:
{{<property name>}}
Rythm syntax
The Rythm template engine uses a different syntax. The full Rythm template source for achieving the same result as in the example above is:
@args String client backup_task_@(client)
Note | |
There are no pre-configured backup templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for backup tasks. |
Using placeholders
The following table lists placeholders that can be used in the backup task name template.
Name | Type | Description |
---|---|---|
client | string | The name of the client associated with the backup task object. |
source | string | The source property of the backup task object. |
count | string | A number between 1 and 10000. Evaluates to the first number in this range leading to a unique task name. |
count_optional | string | Equals the count token which is used when a task already exists. |
task | tasks | The backup task object. Note: This placeholder can only be used together with a native Rythm template. |
Functions (Mustache syntax only)
The following transformation functions are supported when using the Mustache syntax.
Note | |
These functions cannot be combined when using Mustache. If more complex transformations are required, use the Rythm syntax. |
Name | Description |
---|---|
toLower | Converts all characters in the placeholder value to lower case. |
toUpper | Converts all characters in the placeholder value to upper case. |
dashPrefix | Prepends a dash character (-) to the placeholder value, if the value is not blank. |
dotPrefix | Prepends a dot character (.) to the placeholder value, if the value is not blank. |
underPrefix | Prepends an underscore character (_) to the placeholder value, if the value is not blank. |
substring (start,end) | Evaluates to a string that is a substring of the string representation of the placeholder value. The character indices start with 0. |
replace (target,replacement) | Evaluates to a string where the target character sequence is replaced by the replacement character sequence. |
trimUnderPrefix | Removes any leading underscore character (_) from the placeholder value. |
trimUnderTrailing | Removes any trailing underscore character (_) from the placeholder value. |
Examples
In our example, the following placeholder values are used:
Name | Type | Value |
---|---|---|
client | string | SnowFix |
source | string | C:\work\test |
count | string | 10 |
Mustache
Using the Mustache syntax, the templates will evaluate as follows.
Name | Value |
---|---|
sep-task-{{client}} | sep-task-SnowFix |
sep-task-{{toLower client}} | sep-task-snowfix |
sep-task-{{toUpper client}} | sep-task-SNOWFIX |
sep-task-{{client}}-{{source}} | sep-task-SnowFix_C_work_test |
sep-task-{{client}}-{{substring(3,7) source}} | sep-task-SnowFix-work |
sep-task-{{client}}-{{replace("test","folder") source}} | sep-task-SnowFix_C_work_folder |
sep-task{{underPrefix count}} | sep-task_10 |
sep-task{{dashPrefix count_optional}} | sep-task (not exist) sep-task-0 (already exists) |
Rythm
Using the Rythm syntax, the templates will evaluate as follows.
Name | Value |
---|---|
@args String client;tasks_rythm_@(client) | tasks_rythm_SnowFix |
@args String client, String source;tasks_rythm_@(client.toLowerCase())_@(source.substring(3,7).toUpperCase()) | tasks_rythm_snowfix_WORK |
Shortcuts for backup task’s virtualization attributes
You can easily access all field names of the backup task virtualization attribute by using shortcuts. Each shortcut represents a field name of the attribute.
Valid virtualization attribute shortcuts: name, isVCenter, path, datacenter, moref, powerState, ipAddress, hostName, macAddress, hostSystem, cluster, version, guestFullName, uuid, sesamClient, folder, vapp, taskGroupRef, hostVersion
Example:
add task "@args de.sep.sesam.model.dto.VMDto vmDto;@ deb_ (vmDto.getMoRef())" …
is the same as
add task "@args String moref;deb_@(moref)"…
Example with direct virtualization attribute access:
add taskgen "@args de.sep.sesam.model.dto.FileDto fileDto;@(fileDto.getAdditionalInformationAsMap().get(\"Status\"))" "-c" "hypervdev" "-t" "Hyper-V" -s hyperV -f "c:\tmp\hyperv.txt" -G "hyperVGenGroup3"
add taskgen "@args de.sep.sesam.model.Tasks task;qs-@(task.getClient().getShortName())- @(task.getShortType())_@(task.getSourceSegment(0))" -f d:\input.json -O remove_all -G vm-8
Special shortcuts for easy access (without Rythm keywords)
The Rythm syntax is not required when using special shortcuts in tags – curly braces, i.e., {{<shortcut>}}.
The name generation shortcuts
Shortcut | Description |
---|---|
{{CLIENT_SHORT}} | get client without domain |
{{TASK_TYPE_SHORT}} | get short name of task type |
{{SOURCE_LAST_ITEM}} | get last source segment separated by slash |
{{SOURCE_ITEM[<pos>]}} | get segment pos separated by slash (negative pos as pos from back) |
{{<field>}} | use the description block field (cli action dir last param). Example: ...Status=Running,OwnerNode=HYPERVDEV,Clustered=No,uuid=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC... {{uuid}}=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC Note: You can use all description fields (UUID, folder, Guest OS,...) from output of the list (-f -) for task name. |
Examples
- Backup task with type Hyper-V from input stream:
sm_cmd dir -F JSON client "/hypervdev.sep.de/Hyper-V:" | sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" –c hypervdev.sep.de -f - -O remove_all -G hv-5
- Backup task with type Hyper-V from file:
sm_cmd add taskgen "gen_{{TASK_TYPE_SHORT}}_{{SOURCE_ITEM[1]}}-{{SOURCE_ITEM[-1]}}-{{uuid}}" "-t" "Hyper-V" -c hypervdev.sep.de -f d:\hyperv.json -O remove_all -G hv-5
- Backup task with type Path from file:
sm_cmd add taskgen "{{CLIENT_SHORT}}-{{TASK_TYPE_SHORT}}_{{SOURCE_LAST_ITEM}}" -G pathgroup -f c:\root\path.json –t “Path”