cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2985
Views
5
Helpful
10
Replies

EEM applet to get switch model/version

derek-shnosh
Level 1
Level 1

Is there an elegant way to obtain the switch software version using an EEM applet?

On a 3850 running 3.7.4E, event manager info;

#show event man ver
Embedded Event Manager Version 4.00
Component Versions:
eem: (rel9)1.2.8
eem-gold: (rel1)1.0.2
eem-call-home: (rel2)1.0.4

 

Output from show version | i universal;

*    1 62    WS-C3850-12X48U    03.07.04E         cat3k_caa-universalk9 INSTALL
     2 62    WS-C3850-12X48U    03.07.04E         cat3k_caa-universalk9 INSTALL

 

Here's a gist of what I'm looking for;

event manager applet get_version
 event none
 action 1.00 cli command "enable"
 action 2.00 cli command "show version | i universal"
action 3.00 if model is 3850 action 4.00 if version is 3.x.x action 4.01 cli command "some-command" action 4.02 cli command "write erase" action 4.03 cli command "" action 4.04 cli command "reload" action 4.05 cli command "" action 5.00 end
action 6.00 end

 

Edit/Update: I did find the SNMP OID for the switch version, not sure if this can be used at all in the applet.

snmpwalk -v1 -c testing 172.17.250.6 iso.3.6.1.4.1.9.9.249.1.1.1.1.7.1000
10 Replies 10

balaji.bandi
Hall of Fame
Hall of Fame

More curious to understand what is the use case for this example ?

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help


@balaji.bandi wrote:

More curious to understand what is the use case for this example ?


ZTP... in short, see the ladder diagram here; for details scroll up to the ZTP Process - Step 3 section.

 

The switches are coming out of the box with 3.7.4E on them, unfortunately our use-case requires 16.3.6.

 

The issue is that smart-install cannot upgrade from 3.7.4E to 16.3.x (per bug CSCvd49193). Since that bug redirects to another bug, below is a screenshot as provided by TAC.

 

Anyways, my intent is to put this applet into the initial_config to see if I can interrupt the smart-install process with no vstack, but I only want it to interrupt if its a 3850 running version 3.x.

 

image.png

So you looking Auto provision the switch ? Why not consider Cisco APIC-EM 1.6 it is free and it does the work for you.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help


@balaji.bandi wrote:

So you looking Auto provision the switch ? Why not consider Cisco APIC-EM 1.6 it is free and it does the work for you.


I looked into APIC-EM, but due to resource limitations and the fact that we're already well invested in this solution, making the change for this project isn't feasible.

APIC-EM is FREEE ! that is good part. and it is easy i did in 2 hours time. all works charm.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help


@balaji.bandi wrote:

APIC-EM is FREEE ! that is good part. and it is easy i did in 2 hours time. all works charm.


With all due respect; I'd like to keep this discussion on topic. Do you have any suggestions in regards to the question as it was outlined?

 

 

In you case, after i look fresh mind. here is my suggestions.

 

If this is Zero touch provision, and you want parse the EEM Script, that means you have Device Access.

 

If you have already have device access then you do if statement to check what device and parse the image name based on the model.

 

https://github.com/PackeTsar/freeztp/blob/v1.0.1/ztp.py

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help


@balaji.bandi wrote:

In you case, after i look fresh mind. here is my suggestions.

 

If this is Zero touch provision, and you want parse the EEM Script, that means you have Device Access.

 

If you have already have device access then you do if statement to check what device and parse the image name based on the model.

 

https://github.com/PackeTsar/freeztp/blob/v1.0.1/ztp.py

 


That is exactly what I'm asking for assistance with, building the IF statements for the EEM applet to parse the output of show version.

Joe Clarke
Cisco Employee
Cisco Employee

In my ZTP application, I have to obtain the switch type, version, image file name, and SN.  While I do this using EEM Tcl, the same could be done with applets.  The full code is available at https://www.marcuscom.com/viewvc/viewvc.cgi/marcuscom/switch-ztp/trunk/eem/tm_sw_autoconf.tcl?revision=20559&view=markup .  The snippet that obtains device info is:

if { [catch {cli_exec $cli(fd) "show inventory"} result] } {
53 error $result $errorInfo
54 }
55  
56 if { ! [regexp {PID: (\S+)} $result -> pid] } {
57 puts "ERROR: Failed to find PID in '$result'"
58 exit 1
59 }
60  
61 if { ! [regexp {SN: (\S+)} $result -> sn] } {
62 puts "ERROR: Failed to find SN in '$result'"
63 exit 1
64 }
65  
66 if { [catch {cli_exec $cli(fd) "show version"} result] } {
67 error $result $errorInfo
68 }
69  
70 if { ! [regexp {Version ([^,\s]+)[,\s]} $result -> vers] } {
71 puts "ERROR: Failed to find version in '$result'"
72 exit 1
73 }
74  
75 if { ! [regexp {System image file is "([^:]+:[^"]+)"} $result -> imagepath] } { ;#"
76 puts "ERROR: Failed to find system image file in '$result'"
77 exit 1
78 }
79  
80 set fstype {flash:}
81 set rawimagef [file tail $imagepath]
82 set imaged [string trimright [file dirname $imagepath] "/"]
83 regexp {([^:]+:)} $imagepath -> fstype
84  

Apologies for the delayed response, and thanks for the link @Joe Clarke! I'm going to dig around that site a bit when time permits.

 

For now, I've worked around the issue with a couple simple applets as outlined here.

 

Disclaimer: I'm very new to scripting in any language, there is likely a more optimal way to accomplish this but this is what I came up with my very limited experience and short time frame.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco