Source:Task Name Template – Backup: Difference between revisions

From SEPsesam
(In progress.)
(Ready for review)
Line 22: Line 22:
| style="padding:0px 40px 0px 10px; color: grey; font-size: 90%; text-align:left;" |If you have a problem, check the [[Special:MyLanguage/Troubleshooting_Guide|Troubleshooting Guide]].
| style="padding:0px 40px 0px 10px; color: grey; font-size: 90%; text-align:left;" |If you have a problem, check the [[Special:MyLanguage/Troubleshooting_Guide|Troubleshooting Guide]].
|}</div></noinclude>
|}</div></noinclude>
As of [[Special:MyLanguage/SEP_sesam_Release_Versions|4.4.3 ''Beefalo V2'']], SEP sesam enables you to generate the backup tasks names automatically by using a backup task name template.
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.  


To generate your backup task names automatically, you have to specify a relevant template variable in the SEP sesam GUI -> ''Configuration'' -> ''Defaults'' -> ''Extras'' -> ''Template''. For details, see [[Special:MyLanguage/4_4_3_Beefalo:Configuration#extras|GUI Configuration options: Extras]].
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]].


==Backup task name template variables and their usage==  
==Backup task name template usage==  


The ''Mustache'' template engine is used for generating backup task names while the tasks are created by the UI server’s REST API. Note that for more complex transformations the ''Rythm'' template engine syntax has to be used.
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.


For example, if a name of the backup task to create is set to ''backup_task_<nowiki>{{client}}</nowiki>'' and the backup task-related client evaluates to ''snowfix'', than the UI server updates the name of the backup task to create to ''backup_task_snowfix'' before committing this backup task to the database.
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.


The syntax used by ''Mustache'' to denote the placeholders for named properties is:
===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_<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:
  {{<property name>}}
  {{<property name>}}


The ''Rythm'' template engine uses different syntax. The full ''Rythm template source'' for achieving the same result is:
===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
  @args String client
  backup_task_@(client)
  backup_task_@(client)


==={{anchor|placeholder}}Placeholder===
{{note|There are no pre-configured templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for bakup tasks.}}


The number of available placeholders that you can use in the backup task name template is very limited. The following table lists all usable placeholders.
==={{anchor|placeholder}}Using placeholders===
 
The following table lists placeholders that can be used in the backup task name template.


{| 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;"
Line 49: Line 59:
! scope="col" | Description
! scope="col" | Description
  |-
  |-
  |<tt>client</tt>  || <tt>String</tt>|| The client name related with the backup task.
  |<tt>client</tt>  || <tt>string</tt>|| The name of the client associated with the backup task object.
  |-
  |-
  |<tt>source</tt>  || <tt>String</tt>|| The source for the backup task.
  |<tt>source</tt>  || <tt>string</tt>|| The source property of the backup task object.
  |-
  |-
  |<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>|| A number between 1 and 10000. Evaluates to the first number in this range leading to a unique task name.
  |-
  |-
  |<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>|| Equals the ''count'' token which is used when a task already exists.
  |-
  |-
  |<tt>task</tt>  || <tt>Tasks</tt>|| The backup task.<br />'''''Note''': This placeholder can only be used together with a native Rythm template.''
  |<tt>task</tt>  || <tt>tasks</tt>|| The backup task object.<br />'''''Note''': This placeholder can only be used together with a native Rythm template.''
  |-
  |-
|}
|}


==={{anchor|functions}}Transformation functions (''Mustache'' syntax only)===  
==={{anchor|functions}}Functions (''Mustache'' syntax only)===  


You can use the following transformation functions with the ''Mustache'' syntax.
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.}}


{| 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;"
Line 89: Line 100:
|}
|}


==={{anchor|examples}}Examples===  
===={{anchor|examples}}Examples====  


In our example, the following placeholder values are used:
In our example, the following placeholder values are used:
Line 99: Line 110:
! scope="col" | Value
! scope="col" | Value
  |-
  |-
  |<tt>client</tt>  || <tt>String</tt>|| <tt>SnowFix</tt>
  |<tt>client</tt>  || <tt>string</tt>|| <tt>SnowFix</tt>
  |-
  |-
  |<tt>source</tt>  || <tt>String</tt>|| <tt>C:\work\test</tt>
  |<tt>source</tt>  || <tt>string</tt>|| <tt>C:\work\test</tt>
  |-
  |-
  |<tt>count</tt>  || <tt>String</tt>|| <tt>10</tt>
  |<tt>count</tt>  || <tt>string</tt>|| <tt>10</tt>
  |-
  |-
|}
|}
 
=====Mustache=====
The templates using the ''Mustache'' syntax evaluates as follows:
Using the ''Mustache'' syntax, the templates will evaluate as follows.


{| 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;"
Line 131: Line 142:
|}
|}


{{Note|With the ''Mustache'' syntax the transformation functions cannot be combined. For more complex transformations, you have to use the ''Rythm'' syntax.}}
=====Rythm=====
 
Using the ''Rythm'' syntax, the templates will evaluate as follows.
The templates using the ''Rythm'' syntax evaluates as follows:


{| 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;"
Line 147: Line 157:
==={{anchor|shortcuts}}Shortcuts for inner ''VMDto'' object===  
==={{anchor|shortcuts}}Shortcuts for inner ''VMDto'' object===  


You can easily access to all field names of the task attribute ''VMDto'' by using the shortcuts. Each shortcut represents a field name of the ''VMDto'' object.
You can easily access all field names of the task attribute ''VMDto'' by using shortcuts. Each shortcut represents a field name of the ''VMDto'' object.


'''''Valid VMDto shortcuts:'''''
'''''Valid VMDto shortcuts:'''''
Line 169: Line 179:
  @(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 easier access (''Mustache'' syntax only)===  
==={{anchor|special_shortcuts}}Special shortcuts for easy access (without ''rhythm'' keywords)===  


The ''Rythm'' syntax is not required when using special shortcuts surrounded by 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'''''
'''''The name generation shortcuts'''''
Line 180: Line 190:
! scope="col" | Description
! scope="col" | Description
  |-
  |-
  |<tt><nowiki>{{CLIENT_SHORT}}</nowiki></tt>  || Get a client without the domain.
  |<tt><nowiki>{{CLIENT_SHORT}}</nowiki></tt>  || get client without domain
  |-
  |-
  |<tt><nowiki>{{TASK_TYPE_SHORT}}</nowiki></tt>  || Get a short name of the task type.
  |<tt><nowiki>{{TASK_TYPE_SHORT}}</nowiki></tt>  || get short name of task type
|-
|-
  |<tt><nowiki>{{SOURCE_LAST_ITEM}}</nowiki></tt>  || Get a last source segment separated by slash.
  |<tt><nowiki>{{SOURCE_LAST_ITEM}}</nowiki></tt>  || get last source segment separated by slash
|-
|-
  |<tt><nowiki>{{SOURCE_ITEM[<pos>]}}</nowiki></tt>  || Get a segment ''pos'' separated by slash (negative ''pos'' as ''pos'' from back)
  |<tt><nowiki>{{SOURCE_ITEM[<pos>]}}</nowiki></tt>  || get segment pos separated by slash (negative pos as pos from back)
|-
|-
  |<tt><nowiki>{{<field>}}</nowiki></tt>  || Use the description block field (''cli action dir last param'').<br />
  |<tt><nowiki>{{<field>}}</nowiki></tt>  || use the description block field (''cli action dir last param'').<br />
''Example:''
''Example:''
  <nowiki>{{uuid}}</nowiki>Status=Running,OwnerNode=HYPERVDEV,Clustered=No,uuid=2E4120B2-C0FC-4D99-8737-21EC5C9D7BC
  <nowiki>{{uuid}}</nowiki>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 this task name.
'''''Note''''': You can use all description fields (''UUID'', ''folder'', ''Guest OS'',...) from output of the list (<tt>-f -</tt>) for task name.
|}
|}


'''''Examples'''''
'''''Examples'''''
<ul><li>Backup task with the type ''Hypervdev'' from input stream:</li>
<ul><li>Backup task with type ''Hypervdev'' from input stream:</li>
  <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>
<li>Backup task with the type ''Hypervdev'' from file:</li>
<li>Backup task with type ''Hypervdev'' from file:</li>
  <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>
<li>Backup task with the type ''Path'' from file:</li>
<li>Backup task with type ''Path'' from file:</li>
  <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>
</ul>
</ul>
<noinclude>
<noinclude>
==See also==
==See also==
[[Special:MyLanguage/4_4_3_Beefalo:Configuration#extras|GUI Configuration options: Extras]]</noinclude>
[[Special:MyLanguage/4_4_3_Beefalo:Configuration#extras|GUI Configuration options: Extras]]</noinclude>

Revision as of 14:46, 22 October 2020

Other languages:

Copyright © SEP AG 1999-2024. All rights reserved.

Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.

Draft.png WORK IN PROGRESS
This article is in the initial stage and may be updated, replaced or deleted at any time. It is inappropriate to use this document as reference material as it is a work in progress and should be treated as such.


Docs latest icon.png Welcome to the latest SEP sesam documentation version 4.4.3 Beefalo V2. For previous documentation version(s), check documentation archive.


Overview

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.

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)
Information sign.png Note
There are no pre-configured templates available for customization. Until you configure a template, SEP sesam uses the default auto-generated names for bakup 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.

Information sign.png 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\ntasks_rythm_@(client) tasks_rythm_SnowFix
@args String client, String source\ntasks_rythm_@(client.toLowerCase())_@(source.substring(3,7).toUpperCase()) tasks_rythm_snowfix_WORK

Shortcuts for inner VMDto object

You can easily access all field names of the task attribute VMDto by using shortcuts. Each shortcut represents a field name of the VMDto object.

Valid VMDto 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 GetAttribute:

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 rhythm 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:

{{uuid}}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 (-f -) for task name.

Examples

  • Backup task with type Hypervdev 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 Hypervdev 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”


See also

GUI Configuration options: Extras