vineri, 27 martie 2015

[Cisco] Shell Processing

I've recently discovered another way to automate you work load, through shell processing.

From Cisco doc:
To restore the default behavior of Cisco IOS Shell (IOS.sh) processing, use the shell processing command in global configuration mode.

Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#shell processing full
-> full is optional

A very good explanation can be found here


Examples on a Cisco ASR 903, right on the privileged mode:

I needed to configure the following set of commands on a list of interfaces:
   description UNUSED
   storm-control broadcast level pps 300
   storm-control multicast level pps 300
   storm-control action trap

Step1: First, I defined the following function right on the privileged mode:

function set_interface_storm-control_settings() {
 configure terminal
  interface $1
   description UNUSED
   storm-control broadcast level pps 300
   storm-control multicast level pps 300
   storm-control action trap
end
}

Step2: You can call the function for one particular interface:

Router#set_interface_storm-control_settings  GigabitEthernet0/2/2

or use it like this:

for i in GigabitEthernet0/2/2 GigabitEthernet0/2/3 GigabitEthernet0/2/4 GigabitEthernet0/2/5
 do
  set_interface_default_seting $i
 done

Parts of the logs after running the script:

Enter configuration commands, one per line.  End with CNTL/Z.
Trace info: Executed: configure terminal
Trace info: Executed: interface GigabitEthernet0/2/2
Trace info: Executed: description UNUSED
Trace info: Executed: storm-control broadcast level pps 300
Trace info: Executed: storm-control multicast level pps 300
Trace info: Executed: storm-control action trap
Trace info: Executed:       end


Requirements:
- Cisco IOS Release 15.1(4)M, 15.1(2)S, and later releases.
- Cisco IOS.sh must be configured and enabled to use the Cisco IOS.sh features and functions on your router.
- configuration rights with the user you logged in


Un comentariu: