Just discover this while going through the Cisco configuration guide “NX Fundamentals Configuration Guide” under the Chapter “Understanding the Command Line” at section “Configuring CLI Variables”.
What you can do is define persistent or non persistent variable to work with ! The persistent aspect depends if you configure the variable at EXEC or CONFIG modes.
By default there is two persistent variables defined :
N7K-2A# show cli variables
VSH Variable List (* = session vars)
—————–
SWITCHNAME=”N7K-2A”
TIMESTAMP=”2013-02-13-18.43.28″
You can call the variables like this :
N7K-2A# echo $(TIMESTAMP)
2013-02-13-18.51.37
N7K-2A#
And of course you can use these as variables in other commands like this :
N7K-2A# copy running-config $(SWITCHNAME)_$(TIMESTAMP)
Copy complete, now saving to disk (please wait)…
N7K-2A# dir
2330 Feb 13 18:53:12 2013 N7K-2A_2013-02-13-18.53.11
Custom variables can then be defined. If the variables is defined at CONFIG mode, the variables will be persistent :
N7K-2A(config)# cli var name OVERLAY1 overlay1
N7K-2A(config)# interface $(OVERLAY1)
N7K-2A(config-if-overlay)# sh run interface $(OVERLAY1)
!Command: show running-config interface Overlay1
!Time: Wed Feb 13 18:57:35 2013
version 5.2(1)
interface Overlay1
otv control-group 239.1.1.1
otv data-group 232.1.1.0/24
otv extend-vlan 100
no shutdown
This opens new ways of managing the device on the CLI but also with scripting as the NXOS supports Python.
Leave a Reply