I feel your pain. I started trying to create a template today and I'm having a hard time trying to figure out how to do something that should be simple. I wish there was more detailed documentation for the language. I have no problem with SW creating their own scripting language for NCM but they really need to provide more documentation that a section in the admin guide. For example:
You can use the functions substring, strlength, indexof, setoctet, getoctet to manipulate strings within your config change template scripts."
Ok, so I can use those functions to manipulate a string but how do I use them? In the example it provides a way to use setoctet. It would be nice if we had documentation that showed each function, the parameters it takes, and how to use it.
In my example, I want to enter one command for a device that's running IOS 12 and another command for IOS 15.
I've just written my first CCT, but it was difficult.
Only way I was able to figure some things out was to look at other templates. Not sure how the authors figured it out...
Lack of a NOT operator was a problem - I have several empty if statements, with code in the else section because I wanted to do something on an interface that did not have a particular CDP neighbour.
Hopefully, the functionality will expand
I totally agree on better docs. You almost have to try stuff and see what happens.
Here's a sample of the HP Procurve script I use to get them into compliance.
Note: I do a "write memory" as a separate CCT after I'm sure everything still works.
Update HP ProCurve 2510 switch configuration.
HP ProCurve 2510 Models j9019, j9020, J9279, J9280
The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.
Zulu Date (UTC).
Enter the date at Zulu (UTC) in form MM/DD/YYYY.
Zulu Time (UTC).
Enter the time at Zulu (UTC) in form HH:MM (24-hour format).
string @UTCTime )
If (@ContextNode.MachineType startsWith 'ProCurve Switch 25')
//This sets all the base configuration after running the initial configuration wizard.
clock set @UTCDate
clock set @UTCTime
no banner motd
... other commands
//Allow auto loading of firmware during booting. Load latest release on tftp server, and replace version with xx.
If (@ContextNode.SysDescr contains 'J9019')
auto-tftp 10.x.x.x "/procurve/Q_11_xx.swi"
If (@ContextNode.SysDescr contains 'j9020')
... another command
//Exit configuration mode
I agree there is space for improvement for the CCT language, examples etc.
Specifically for the string manipulation functions (new in 7.1), you may want to check Better support for ACL manipulation in NCM.
For general CCT introduction, there is another blog post: More Automation in NCM: Usage of Variables and Custom Properties in Command Scripts and Config Change Templates.