09-28-2018 03:39 PM - edited 09-29-2018 01:55 AM
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
09-28-2018 03:50 PM
More curious to understand what is the use case for this example ?
09-28-2018 04:03 PM - edited 09-28-2018 04:07 PM
@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.
09-28-2018 04:08 PM
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.
09-28-2018 04:11 PM
@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.
09-28-2018 04:14 PM
APIC-EM is FREEE ! that is good part. and it is easy i did in 2 hours time. all works charm.
09-28-2018 04:19 PM
@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?
09-29-2018 12:00 AM
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
09-29-2018 01:50 AM
@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.
09-29-2018 06:39 AM
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 |
10-04-2018 01:57 PM - edited 10-04-2018 01:59 PM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide