Configuration Templates

Configuration templates allow some parts of the configuration datastore to be pre-configured.

This can be done to pre-populate vendor or site-specific values, allowing the actual configuration to be simpler and more generic.

Configuration templates are stored in the running configuration in list “/templates/template”. There are only 3 fields in a template:

  • name: the name of the template (list key)

  • data-target: path of the container or list that matches the template

  • data: anydata wrapper for the configuration template data

A template is used by specifying the <with-template> parameter in the <edit-config> operation.

Multiple instances of this parameter can be present, allowing multiple templates to be applied or attempted.

If a template does not apply it is ignored.

If a template does apply, then the child nodes specified in the template are applied if they are not already present in the edit request. Templates are only applied to “create” operations. The values are expanded on first use of the configuration data indicated by the <data-target> field in the template. If this data represents a list entry, this this data must specify all key values.

If list keys are present in the configuration template then the template will only be applied if these values match the same key leaf value in the target data.

Refer to the yumaworks-templates.yang section for additional details on this YANG module.

Configuration Template Example: NACM group

Example template “t1”:

<templates xmlns="http://yumaworks.com/ns/yumaworks-templates">
  <template>
    <name>t1</name>
    <data-target>/nacm/groups/group</data-target>
    <data>
      <group xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
        <name>admin</name>
        <user-name>andy</user-name>
        <user-name>test1</user-name>
        <user-name>test2</user-name>
      </group>
    </data>
  </template>
</templates>

Example <edit-config> request using <with-template> parameter:

<?xml version="1.0" encoding="UTF-8"?>
<rpc message-id="8" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
     <target><candidate/></target>
     <config>
       <nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
        <groups>
          <group>
            <name>admin</name>
          </group>
        </groups>
       </nacm>
      </config>
      <with-template
        xmlns="http://yumaworks.com/ns/yumaworks-templates">t1</with-template>
   </edit-config>
</rpc>

The following data will be created after template “t1” is applied

<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
  <groups>
    <group>
      <name>admin</name>
      <user-name>andy</user-name>
      <user-name>test1</user-name>
      <user-name>test2</user-name>
    </group>
  </groups>
</nacm>