cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
714
Views
0
Helpful
1
Replies

Advanced templating with compliance reports?

Abdel el Anazi
Level 1
Level 1

Is it possible to use processing instruction in devices templates that are used by NSO compliance reports?

I am looking to validate configurations based on the platform model normally in a service template I would use:

 

<?set-root-node {/devices/device[name=$DEVICE]/platform}?>
<?if {contains(/model, 'ISR43')}?>
<tacacs-server xmlns="urn:ios">
<host>
<name>24.132.12.40</name>
<key>
<type>7</type>
<secret>107A1B1C0231005319</secret>
</key>
</host>
<host>
<name>195.34.130.108</name>
<key>
<type>7</type>
<secret>107A1B1C0231005319</secret>
</key>
</host>
<?else?>
<?if {contains(/model, '2851')}?>
.....

 

But when I load this template inside NSO using load merge I don't see the processing instruction:

 

abdel@ncs(config)# do show running-config devices template console-routers-golden-config ned-id cisco-ios-cli-6.59 config ios:tacacs-server | display xml

 

<config xmlns="http://tail-f.com/ns/config/1.0">
  <devices xmlns="http://tail-f.com/ns/ncs">
    <template>
      <name>console-routers-golden-config</name>
      <ned-id>
        <id xmlns:cisco-ios-cli-6.59="http://tail-f.com/ns/ned-id/cisco-ios-cli-6.59">cisco-ios-cli-6.59:cisco-ios-cli-6.59</id>
        <config>
          <tacacs-server xmlns="urn:ios">
            <host>
              <name>24.132.12.40</name>
              <key>
                <type>7</type>
                <secret>107A1B1C0231005319</secret>
              </key>
            </host>
            <host>
              <name>195.34.130.108</name>
              <key>
                <type>7</type>
                <secret>107A1B1C0231005319</secret>
              </key>
            </host>
            <timeout>10</timeout>
            <directed-request/>
            <key>
              <type>7</type>
              <secret>107A1B1C0231005319</secret>
            </key>
          </tacacs-server>
        </config>
      </ned-id>
    </template>
  </devices>
</config>

I read in nso_development-4.6.1.pdf that both $DEVICE and $TEMPLATE_NAME are set internally by NSO. Assuming my approach is valid to use /devices/device[name=$DEVICE]/platform/model to evaluate the device model. But when loading the template the processing instructions are not visible!

 

 

 

 

1 Accepted Solution

Accepted Solutions

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

I don't believe you can achieve what you want with processing-instructions. The section in the development guide you refer to has this sentence as introduction:

 

Two types of Templates exist, device-templates and config-templates. The former is invoked as an action, where the latter is invoked either because of changes to some service data or through a programmatic API (e.g Java). For more information about device-templates, refer to: the section called “Device Templates” in NSO 5.3.1.1 User Guide. The rest of the text in this chapter mainly describes config-templates.

 

The section on device templates does not reference any of the processing instructions.

 

The compliance section in the user guide indicates that you can use device template in the reports

 

What you could do to go forward in your situation is to have a device-group per platform/model and one device template for each model that would be used. 

 

View solution in original post

1 Reply 1

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

I don't believe you can achieve what you want with processing-instructions. The section in the development guide you refer to has this sentence as introduction:

 

Two types of Templates exist, device-templates and config-templates. The former is invoked as an action, where the latter is invoked either because of changes to some service data or through a programmatic API (e.g Java). For more information about device-templates, refer to: the section called “Device Templates” in NSO 5.3.1.1 User Guide. The rest of the text in this chapter mainly describes config-templates.

 

The section on device templates does not reference any of the processing instructions.

 

The compliance section in the user guide indicates that you can use device template in the reports

 

What you could do to go forward in your situation is to have a device-group per platform/model and one device template for each model that would be used.