Skip to content

Commit 2e1bbc0

Browse files
author
Jason Frazier
committed
Added EEM example
1 parent 27eabe8 commit 2e1bbc0

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright (c) 2017 Jason Frazier <[email protected]>
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions
8+
# are met:
9+
# 1. Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# 2. Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25+
# SUCH DAMAGE.
26+
#
27+
# This script retrieves entire configuration from a network element via NETCONF
28+
# prints it out in a "pretty" XML tree.
29+
30+
# importing the cli module is necessary to run
31+
# config or exec commands on the host.
32+
import cli
33+
# importing the time module works well in
34+
# this script, as we are pacing some of the execution.
35+
36+
import time
37+
# importing the time module works well in this script, as we are pacing
38+
# some of the execution.
39+
40+
cli.configure('no ip route 10.10.1.2 255.255.255.255 10.90.1.1');
41+
time.sleep(2)
42+
cli.configure('ip route 10.10.1.2 255.255.255.255 10.90.1.65');

EEM-interface-move-routes/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EEM interface-move-routes.py
2+
3+
This is an example Python script utilizing EEM integration.
4+
5+
The example EEM is below:
6+
event manager applet INTERFACE-DOWN
7+
event syslog pattern "LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to down"
8+
action 0.0 cli command "en"
9+
action 1.0 cli command "guestshell run python EEM-interface-routes.py"
10+
11+
As you can see, this EEM policy named "INTERFACE-DOWN" looks for a syslog pattern. In this example case, it is a syslog pattern for a specifc interface going down. When EEM sees this, it triggers an exec CLI that executes the onbox Python script named "EEM-interface-routes.py"
12+
13+
No verification has been built into this, but the script could be extednded as well.
14+
15+
# requirements
16+
-- IOS-XE running >/= 16.5.1 also enabled for GuestShell
17+
18+
# running
19+
-- onbox

0 commit comments

Comments
 (0)