Network Management

NCM - Device Templates - Inline send command condition

This goes over how to add inline send command condition to devices templates with case usage.

First published date

9/9/2020 3:54 PM

Last published date

9/9/2020 3:54 PM

Overview

Inline send command condition (NCM 8.0 and Newer):

NCM now gives control if the command should be sent to the device based on the output of the previous command.
To do so specify in the same line as command macro SendConditionRegEx. For example:

yes${SendConditionRegEx:Are you sure}

In this example, ‘yes’ command will be sent to the device only when device output from the previous command contain words ‘Are you sure’. If not, the command will be skipped and the next command will be sent if any remains.

Such inline command syntax will work when specifying commands in device template for config download/upload or even when use NCM execute script functionality

Real-world use case:

It is useful to use that macro for SCP config download for example. When SCP connection with the device is established for the first-time device ask a question to accept NCM host and expect the answer ‘yes’. When the connection is made for second time device no longer ask that question and ask SCP password instead.
This is experienced with F5 Big IP for the fingerprint.

Product section

Network Configuration Manager

Resolution

When such inline command is needed, make sure to copy the device template, modify the Command Line with the following sample:
 
yes${SendConditionRegEx:Are you sure}

You will need to add the following after the inline command if there are more commands to be entered such as the SCP password or another command prompt:
${CRLF} 

Here is a real example of the Device Template's Command lines in full:
<Command Name="DownloadConfigIndirectSCP" Value="${ConfigType}"/>

<Command Name="Running" Value="tmsh save /sys config file /var/local/scf/NCM.ucs no-passphrase${CRLF} ${TransferProtocol} /var/local/NCM.ucs ${SCPServerUserName}@${SCPStorageAddress}:${StorageFilename}${CRLF}yes${SendConditionRegEx:Are you sure}${CRLF}${SCPServerPassword}"/>

<Command Name="Startup" Value="tmsh save /sys ucs /var/local/NCM.ucs${CRLF}${TransferProtocol} /var/local/NCM.ucs ${SCPServerUserName}@${SCPStorageAddress}:${StorageFilename}${CRLF}yes${SendConditionRegEx:Are you sure}${CRLF}${SCPServerPassword}" IsBinary="true"/>