Quite often, there arises a need to carry out changes to the running configuration of devices and at times, same set of changes need to be applied to multiple devices. Though network administrators can very well edit the configuration manually, the task can prove to be arduous due to the volume of changes and the repetitive nature of the work. DeviceExpert provides a simple solution for this by way of 'Configuration Templates', 'Scripts' and 'Advanced Scripts'.
As the name itself implies, Custom Templates are the ones defined
and created by the users themselves in accordance with their needs. A
custom template contains the commands (provided by the user) to be
executed on the device. A custom template can be created to configure
any feature on a device. For instance, you can create a template to
configure IGRP on a cisco router. The real power of a custom template
lies in reusing the template across multiple devices for bulk
configuration updates. For example, a single template could be used for
changing the passwords of multiple devices many times. Similarly, a
template for firmware upgrade could be used many
times for many devices.
To enhance the reusability of a template, 'Template Variables' are
defined. A template variable is a placeholder for a value. It can be
specified when the template is uploaded to the device. After creating
the template, when you wish to upload the changes to a particular
device or a number of devices, you just need to provide the values for
the template variables. Everything else is automatically taken care of
by DeviceExpert.
Note: Creating 'Template Variables' is optional. You may create
template variables if you want to enhance the reusability of the
template.
Custom templates offered by DeviceExpert are of two types:
The
following table provides
information about the each type of
custom template and when to use them:
TFTP Mode |
Simple Script Execution |
Advanced Script Execution |
TFTP mode is for uploading a partial configuration change to a device/devices through TFTP. Example:
In all the above case, TFTP mode of configuration upload could be used. In general, for carrying out changes to existing configuration, this mode could be used. For other cases like executing a command on device, Script execution mode has to be used.
|
To execute a single command on the CLI console. Example: Synchronizing Running & Startup Configurations. Through a single line in the script containing the command copy running-config startup-config, you can synchronize the startup and running configurations of any number of devices.Other Examples:
|
To execute a series of inter-connected commands on a device in command line. After the execution of one command, some input has to be provided before the next command is invoked. In such a situation, advanced scripting would be useful. When the execution of a command changes the prompt of the device or takes too much of time to execute or requires fine-grained control to track the flow, advanced script execution has to be used.Example: Backing up your current IOS image to a TFTP server. To do this, the following sequence would be used:
<command prompt=']?'>copy flash:/%SOURCE_FILE_NAME% tftp</command> <command prompt=']?'>%TFTP_SERVER_IP%</command> <command timeout='70'>%DESTINATION_FILE_NAME%</command>
Other Examples:
|
As stated above, the 'Advanced Script Execution Mode' is still more powerful as it provides the option to execute a series of inter-connected commands on a device in command line. To enable this, the commands to be executed are to be entered in specific format as detailed below:
Purpose |
Syntax |
Entering the commands to be executed in the command line |
<command>xyz</command>
Example: <command>copy startup-config tftp</command> |
Specifying the prompt that should appear after executing a command. This can be used in the scripts for firmware upgrade, OS image backup etc. |
<command prompt=']?'>xyz</command> Example: <command prompt=']?'>copy startup-config tftp</command> (Here, the prompt ? is placed within single quotes and following a closing square bracket) Note: If prompt is not given, default prompt will be used |
After executing a command, if you wish the application to wait for a few seconds, you can specify the time limit in seconds. This can be used in the scripts for firmware upgrade, OS image backup etc. |
<command timeout='70'>copy startup-config tftp</command> Example: <command timeout='70'>copy startup-config tftp</command> Note: Default timeout is 30 seconds |
After providing a response to query while executing a command, if the device does not expect the user to press "ENTER" after providing the response, this syntax has to be used <>For example, when the device expects a response (say) 'Y' or 'N' alone and NOT an "ENTER" after that, this syntax has to be used.This can be used in the scripts for firmware upgrade, OS image backup etc. |
<command suffix='$NO_ENTER'>y</command> Note: Default value for suffix is "ENTER", that is, new line |
Specifying the prompt that should appear after executing a command. This can be used in the scripts for firmware upgrade, OS image backup etc. |
<command prompt='confirm'>xyz</command> Example: <command prompt='confirm'>%DESTINATION_FILE_NAME%</command>
|
<>When the command sequence does
not
expect a response after the
execution of a command, this syntax has to be used. This has to used
coupled with a timeout value for waiting for sometime in between. Example: This can be used for setting banner messages in Cisco devices |
<command prompt='$NO_RESPONSE' timeout='5'>banner
%DELIMITING_CHAR%</command> Example: <command prompt='$NO_RESPONSE' timeout='5'>banner %DELIMITING_CHAR%</command> |
The list of all templates created by various users, are listed in the 'Custom Templates' page (Admin >> Device Management >> Custom Templates) along with other information such as who created the templates, description and timestamp of last modification.
If the mode of execution chosen by
you is TFTP, you will see the link 'Upload'
under
the column "Action". If the mode of execution is "Command Line" or
"Advanced Script Execution", you will see the link "Execute"
To upload the
template to device ,
Note: (1) Command line script execution is not supported for the devices with the protocol 'SNMP-TFTP' (2) The execution output of custom templates would be visible only to the users who executed the template. That means, users with the role 'Operator' will be able to view the output of the custom templates that are executed by them. They will not be able to view the output of the templates executed by other users. Administrators will be able to view the output all the templates and they will also be able to delete the output. |
Command line script execution of custom templates would prove to be a powerful tool for various bulk operations on multiple devices. Following are few practical applications of the same.
You rotate the passwords on multiple devices at one go using the command line script execution. Following is the typical template content that could be used for this purpose:
configure terminal
enable password xxxx
exit
You can even execute various commands to get hardware information from a single device or multiple devices. For example, with just the following command in the script, you get 'show version' output for multiple devices at one go:
show version
If you wish to update NTP server details in many details, all that you need to do is to create a template as the one below:
configure terminal
ntp server x.x.x.x
exit
Just through a single line in the script, you can synchronize the startup and running configurations of any number of devices.
copy
running-config startup-config
or
copy startup-config running-config
The above are just an indicative list to demonstrate how the scripts could be used. You may use it for a lot of other applications. Few more examples are available in our website. Please refer to them.
Uploading of OS images/firmware is one of the commonest operations performed by the administrators. Advanced Script Execution can be used to upload the images. The image files can be transferred via TFTP.
Following will be the sequence of command execution for OS image/firmware upload:The above sequence of command execution could be transformed into an advanced script as below:
<command prompt=']?'>copy tftp: flash:</command>
<command prompt=']?'>%TFTP_SERVER_IP%</command>
<command prompt=']?'>%SOURCE_FILE_NAME%</command>
<command prompt='confirm'>%DESTINATION_FILE_NAME%</command>
<command timeout='120' suffix='$NO_ENTER'>y</command>
In the above example, placeholders have been used for Source File Name, TFTP Server IP and Destination File Name. At the time of executing this advanced script, values could be provided for these placeholders. The script could be used for many devices at one go.
To backup your current IOS image to a TFTP server, the following sequence would be used:
<command prompt=']?'>copy flash:/%SOURCE_FILE_NAME% tftp</command>
<command prompt=']?'>%TFTP_SERVER_IP%</command>
<command timeout='70'>%DESTINATION_FILE_NAME%</command>
In the above example, placeholders have been used for Source File Name, TFTP Server IP and Destination File Name. At the time of executing this advanced script, values could be provided for these placeholders. The script could be used for many devices at one go.You can edit an existing banner message of a device or a group of devices using the advanced script execution. Users will be presented with this banner every time they attempt a connection with the device.
Normally, the desired banner message is entered within two delimiting characters. For example, within # and #. All the content between these two characters will appear as banner message. The delimiter will not be part of the banner message.
Following will be the sequence of command execution for configuring banner message:
The above sequence of command execution could be transformed into an advanced script as below:
<command>conf t</command>
<command prompt='$NO_RESPONSE' timeout='5'>banner %DELIMITING_CHAR%</command>
<command prompt='$NO_RESPONSE' timeout='5'>%BANNER_LINE_1%</command>
<command prompt='$NO_RESPONSE' timeout='5'>%BANNER_LINE_2%</command>
<command>%DELIMITING_CHAR%</command>
<command>end</command>
In the above example, placeholders have been used for Delimiting Character and Banner Message. At the time of executing this advanced script, values could be provided for these placeholders. The script could be used for many devices at one go.
Following will be the sequence of command execution for resetting the password:
The above sequence of command execution could be transformed into an advanced script as below:
<command>conf
t</command>
<command prompt='$NO_RESPONSE' timeout='5'>password
manager</command>
<command prompt='$NO_RESPONSE'
timeout='5'>%PASSWORD%</command>
<command prompt='$NO_RESPONSE'
timeout='5'>%PASSWORD%</command>
<command>end</command>
In the above example, placeholders have been used for entering and confirming the new password. At the time of executing this advanced script, values could be provided for these placeholders. The script could be used for many devices at one go.
Cisco IOS images are stored in Flash memory. So, when you to install a new IOS image, you need to make sure your device has enough flash memory to support the image. In case, the device is running short of memory, you will have to delete the files from flash. This can be achieved using an advanced script.
Following will be the sequence of command execution:
<command prompt=']?'>delete flash:/%FILE_NAME%</command>
<command prompt='confirm'>%FILE_NAME%</command>
<command suffix='$NO_ENTER'>y</command>
In the above example, placeholder has been used for the name of the file to be deleted. At the time of executing this advanced script, value could be provided for this placeholder. The script could be used for many devices at one go.
All the three types of custom templates - TFTP mode, script execution mode and advanced scripts could be scheduled for execution at a future point of time. Refer to the section under schedules for more details.
If you to view the contents of an already created template or you want to edit the template,