info Функционал commit/rollback в коммутаторах Extreme

Зачастую возникают ситуации когда в результате ошибочно введенных команд пропадает доступ на коммутатор, отключается порт или проблемы с ssh/telnet или ACL. В сообществе Extreme создали скрипт позволяющий избежать больших проблем. Введенная команда применяется сразу и запускается таймер, по истечении которого запрашивается применить или нет изменения, если ответа не последовало команда отменяется. Командой rollback можно сразу откатить изменения.

Пример использования:

****************************

 — You must enclose the next two commands in double quotes —

Enter Backout Command e.g. «disable port 1:1»

«disable port 25»

Enter Commit Command e.g. «enable port 1:1» [THIS WILL EXECUTE]

«enable port 25»

enable port 25 has been executed

A delay of 10000 miliseconds has been started

A delay of 10000 miliseconds has been stopped

Do you want to commit? y/N e.g. «y»

n

disable port 25 has been executed because a commit of y was not set

Notes

*******************************

- A delay variable is used to allow the commit command to finish. Set

this delay preference in miliseconds

- The idletimeout variable is used in the event the commit command terminates

your session. Set this idletimeout variable preference in seconds

- This script dynamically creates a failsafe upm profile. This profile is used

only in the event you were to lose your session with the switch

- The failsafe upm profile is only triggered from failsafe log filter. This

log filter is unique to your session IP address.

Credits: jpadilla@extremenetworks.com

Any issues please report the bug in the ExtremeXOS Forum.

Скрипт:

#@MetaDataStart

#@DetailDescriptionStart

###############################################################################

# Extreme Networks® CLI Script

#

# Script    : commit.xsf

# Revision   : 1.0

# Last Updated : 2010, July 21st

# Purpose   : This script executes a backout command in the event

#        your commit command fails or you were to lose your

#        telnet/ssh session.

# Author    : jpadilla@extremenetworks.com, Extreme Extensibility Team

# Contact          : info@extremenetworks.com

# Contact          : www.ethernation.net (ExtremeXOS Forums)

###############################################################################

# Change Log:

# 1.0 — 2010, July 21st

#   * First Revision

###############################################################################

###############################################################################

#@DetailDescriptionEnd

enable cli scripting

disable cli-config-logging

disable clipaging

create log entry «**********Starting CLI Script**********»

###############################################################################

#@ScriptDescription «Short Script Description»

# @VariableFieldLabel «When this script encounters errors, do you wish to abort or ignore (abort or ignore)»

set var ynCliModeAbortEnabled ignore

# @SeparatorLine

# Begin custom variable definitations

# Set the amount of time in miliseconds to allow the command to take affect

set var delay 10000

set var idletimeout 1

# End of custom variable definitations

#@MetaDataEnd

###############################################################################

# CONFIGURATION DETAIL

###############################################################################

# ERROR HANDLING

###############################################################################

if (!$match($ynCliModeAbortEnabled,ignore)) then

 create log entry «CLI mode set for Ignore on error»

 configure cli mode scripting ignore-error

else

 create log entry «CLI mode set for abort on error»

 configure cli mode scripting abort-on-error

endif

###############################################################################

# Start of CLI Script (Enter the custom script code below)

###############################################################################

 set var blank «»

 show var blank

 set var comment « — You must enclose the next two commands in double quotes — »

 show var comment

 show var blank

 set var backout $READ(Enter Backout Command e.g. «disable port 1:1»)

 save var key red backout

 show var blank

 # Verify we don't already have a failsafe upm

 set var CLI.OUT «»

 show upm profile

 set var inputA $TCL(list ${CLI.OUT})

 set var listA $TCL(split $inputA «\n»)

 set var countA $TCL(llength $listA)

 set var icountBack ($countA — 0)

 set var icount 0

while ($icount < $icountBack) do

 set var findIt $TCL(lindex $listA $icount)

 set var findUPM $TCL(regexp {failsafe} $findIt)

if ($findUPM == 1) then

 delete upm profile failsafe

endif

 set var icount ($icount + 1)

endwhile

 # create a failsafe upm

 # make sure there is no space before the «.» below

 create upm profile failsafe

 load var key red backout

 $(backout)

 create log entry «UPM failsafe has executed $(backout)»

 configure idletimeout 20

 disable log target upm «failsafe»

 delete log target upm «failsafe»

 delete log filter «failsafe»

 delete var key red

.

 # The above «.» should not have a space before it!

 # Grab the session IP Address

 set var CLI.OUT «»

 show session

 set var inputA $TCL(list ${CLI.OUT})

 set var listA $TCL(split $inputA «\n»)

 set var countA $TCL(llength $listA)

 set var icountBack ($countA — 0)

 set var icount 0

while ($icount < $icountBack) do

set var findIt $TCL(lindex $listA $icount)

set var findSessionIP $TCL(regexp {(\*[0-9]{1,}\s+.*.\s+)([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})} $findIt)

if ($findSessionIP == 1) then

 set var ipOnly $TCL(regexp -inline {(\*[0-9]{1,}\s+.*.\s+)([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})} $findIt)

 set var value1 $TCL(lindex $ipOnly 2)

endif

 set var icount ($icount + 1)

endwhile

 # Create the failsafe log filter

 create log filter failsafe

 configure log filter failsafe add events AAA.logout match string «$(value1)»

 create log target upm failsafe

 enable log target upm failsafe

 configure log target upm failsafe filter failsafe severity Info

 configure log target upm failsafe match Any

 set var command $READ(Enter Commit Command e.g. «enable port 1:1» [THIS WILL EXECUTE])

 show var blank

 # set upm timer so we can execute the failsafe upm in a timely manner

 configure idletimeout $idletimeout

 enable idletimeout

 $(command)

 set var comment «$(command) has been executed»

 show var comment

 create log entry «$(command)»

 set var comment «A delay of $(delay) miliseconds has been started»

 show var comment

 set var wait $TCL(after $delay)

 set var comment «A delay of $(delay) miliseconds has been stopped»

 show var comment

 set var commit $READ(Do you want to commit? y/N e.g. «y»)

 set var search $TCL(regexp {y} $commit)

if ($search == 1) then

 show var blank

 set var comment «You have successfully commit the $(command) command»

 show var comment

else

 $(backout)

 set var comment «$(backout) has been executed because a commit of y was not set»

 show var comment

 create log entry «$(backout) has been executed because a commit of y was not set»

endif

 configure idletimeout 20

 disable log target upm «failsafe»

 delete log target upm «failsafe»

 delete log filter «failsafe»

 delete var key red

 delete upm profile failsafe

if ($VAREXISTS(delay)) then

 delete var delay

endif

if ($VAREXISTS(backout)) then

 delete var backout

endif

if ($VAREXISTS(command)) then

 delete var command

endif

if ($VAREXISTS(wait)) then

 delete var wait

endif

if ($VAREXISTS(search)) then

 delete var search

endif

if ($VAREXISTS(CLI.OUT)) then                                                                     

 delete var CLI.OUT                                                                          

endif

if ($VAREXISTS(inputA)) then                                                                     

 delete var inputA                                                                          

endif

if ($VAREXISTS(verify)) then                                                                     

 delete var verify                                                                          

endif

if ($VAREXISTS(blackout)) then                                                                     

 delete var blackout                                                                          

endif

if ($VAREXISTS(blank)) then                                                                     

 delete var blank                                                                          

endif

if ($VAREXISTS(comment)) then                                                                     

 delete var comment                                                                          

endif

if ($VAREXISTS(commit)) then                                                                     

 delete var commit                                                                          

endif

if ($VAREXISTS(verifyCommand)) then                                                                     

 delete var verifyCommand                                                                          

endif

if ($VAREXISTS(failsafe)) then                                                                     

 delete var failsafe                                                                          

endif

if ($VAREXISTS(idletimeout)) then                                                                     

 delete var idletimeout

endif

if ($VAREXISTS(ynCliModeAbortEnabled)) then

 delete var ynCliModeAbortEnabled

endif

###############################################################################

# End of CLI Script

###############################################################################

create log entry «**********Finished running CLI Script**********»

enable clipaging

enable cli-config-logging

disable cli scripting