Kron non puo' cambiare la configurazione del router, non funziona a livello EXEC quindi uno script come quello a seguire NON funzionera'. Ecco cosa accade.
!
kron occurrence milanista in 1 oneshot
policy-list milanista
!
kron policy-list milanista
cli conf t
cli interface gigabit 0/1.4
cli no ip address
cli interface gigabit 0/0
cli ip address 1.1.1.1 255.255.255.0
cli end
!
Lo script viene eseguito ma ritorna una condizione di errore che si puo' vedere con il debug kron:
1941new#show kron schedule
Kron Occurrence Schedule
milanista inactive, will run once in 0 days 00:00:00
1941new#
*May 8 10:39:38.283: Major 1, Minor 0
*May 8 10:39:38.283: Timer Event milanista
*May 8 10:39:38.283: Call parse_cmd 'conf t'
*May 8 10:39:38.283: Kron CLI return 0
'
**CLI 'conf t':
Enter configuration commands, one per line. End with CNTL/Z.'
*May 8 10:39:38.283: Major 4, Minor 7
*May 8 10:39:38.283: Respond to end of CLI Process
*May 8 10:39:38.283: Call parse_cmd 'interface gigabit 0/1.4'
*May 8 10:39:38.283: Kron CLI return 2
''
*May 8 10:39:38.287: Major 4, Minor 7
*May 8 10:39:38.287: Respond to end of CLI Process
*May 8 10:39:38.287: Call parse_cmd 'no ip address'
*May 8 10:39:38.287: Kron CLI return 2
''
*May 8 10:39:38.287: Major 4, Minor 7
*May 8 10:39:38.287: Respond to end of CLI Process
*May 8 10:39:38.287: Call parse_cmd 'interface gigabit 0/0'
*May 8 10:39:38.291: Kron CLI return 2
''
*May 8 10:39:38.291: Major 4, Minor 7
*May 8 10:39:38.291: Respond to end of CLI Process
*May 8 10:39:38.291: Call parse_cmd 'ip address 1.1.1.1 255.255.255.0'
*May 8 10:39:38.295: Kron CLI return 2
''
*May 8 10:39:38.295: Major 4, Minor 7
*May 8 10:39:38.295: Respond to end of CLI Process
*May 8 10:39:38.295: Call parse_cmd 'end'
*May 8 10:39:38.295: Kron CLI return 2
''
*May 8 10:39:38.295: Major 4, Minor 7
*May 8 10:39:38.295: Respond to end of CLI Process
1941new_ilpicciolo#
*May 8 10:39:38.295: Forcing Removing Occur milanista
*May 8 10:39:38.295: Removing Occur milanista
*May 8 10:39:38.295: Removing Policy Name 'milanista'
*May 8 10:39:38.295: Finished Removing Occurrence milanista
1941new_ilpicciolo#
========================================================
Se volete modificare la configurazione del router dovete invece scrivere un applet event manager come quello a seguire. In questo particolare esempio dobbiamo cambiare l'IP della ethernet di un router e spostarlo in una interfaccia differente. Perdendo la connessione al router al primo cambiamento non potremmo farlo da remoto.
event manager applet test
event none
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface gigabit 0/1.3"
action 4.0 cli command "no ip address" <--- (1)
action 5.0 cli command "interface gigabit 0/0"
action 6.0 cli command "ip address 192.168.10.250 255.255.255.248"
!
end
1941new_ilpicciolo#event manager run test
EEM policy pippo not registered with event none Event Detector
Importante notare che, se sei collegato in telnet, ti cade il collegamento all'esecuzione dello script nel punto (1) tuttavia lo script sara' eseguito fino alla fine.
========================================================
Commenti
Posta un commento