cancel
Showing results for 
Search instead for 
Did you mean: 

Using EDP output in scripting

Using EDP output in scripting

Davor
New Contributor
I would like to use sh edp ports all in script to indentify trunk ports.
Created script, loaded it and got error in that line. Is there some limitation to this?

"
...

set var CLI.OUT " "
show edp ports all
set var inputA $TCL(list ${CLI.OUT})
set var listA $TCL(split $inputA "\n")
set var countA $TCL(llength $listA)

....

"

BR
Davor
18 REPLIES 18

Davor
New Contributor
Per the lawyers:

Any scripts that are written and posted on the Hub are provided “AS IS” with no warranty or representation as to its use. Any use should be carefully considered and be validated by the user. These scripts, regardless of who writes them, assume that the user accepts all of the risk and responsibility, and are not provided pursuant to any authorized services or professional services entitlement or obligation by Extreme Networks, its subsidiaries, agents or licensors. In no event shall the poster nor Extreme Networks be responsible for the functionality of the script nor are we responsible for any outages or network issues caused by use or integration of the script, including any degradation of functionality of Extreme products or technology. It is strongly recommended that any use of scripts or other technical information posted on this site must be validated before use in any production network by the user of the script.

With that said:
#@MetaDataStart#@DetailDescriptionStart
###############################################################################
#@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 abort
#@SeparatorLine
# Begin custom variable definitations
# set var addOrDelete $CLI.ARGV1
set var addOrDelete 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 CLI.OUT " "
show edp ports all
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 findTrunkPorts $TCL(regexp {(?![0-9:]+\s+)([A-Za-z0-9._+-]+\s+)([0-9:]+\s+)([0-9:]+\s+)([0-9]+\s+)([0-9]+\s+)} $findIt)
set var findEnd $TCL(regexp {configure\sqosprofile} $findIt)
#
if ($findTrunkPorts == 1) then
set var vlanNameOnly $TCL(regexp -inline {(?![0-9:]+\s+)([A-Za-z0-9._+-]+\s+)([0-9:]+\s+)([0-9:]+\s+)([0-9]+\s+)([0-9]+\s+)} $findIt)
set var value0 $TCL(lindex $vlanNameOnly 0)
set var value1 $TCL(lindex $vlanNameOnly 1)
set var value3 $TCL(lindex $vlanNameOnly 3)
if ($addOrDelete == 1) then
configure ports $(value0) display-string Trunk_$(value1)_$(value3)
endif
if ($addOrDelete == 0) then
create log entry "NO TURUNK PORTS"
endif
endif
#
if ($findEnd == 1) then
set var icount ($icountBack)
endif
set var icount ($icount + 1)
endwhile
#
if ($VAREXISTS(CLI.OUT)) then
delete var CLI.OUT
endif
if ($VAREXISTS(inputA)) then
delete var inputA
endif
if ($VAREXISTS(listA)) then
delete var listA
endif
if ($VAREXISTS(countA)) then
delete var countA
endif
if ($VAREXISTS(icount)) then
delete var icount
endif
if ($VAREXISTS(findEnd)) then
delete var findEnd
endif
if ($VAREXISTS(findIt)) then
delete var findIt
endif
if ($VAREXISTS(icountBack)) then
delete var icountBack
endif
if ($VAREXISTS(value0)) then
delete var value0
endif
if ($VAREXISTS(value1)) then
delete var value1
endif
if ($VAREXISTS(value3)) then
delete var value3
endif
if ($VAREXISTS(vlanNameOnly)) then
delete var vlanNameOnly
endif
if ($VAREXISTS(findTrunkPorts)) then
delete var findTrunkPorts
endif
if ($VAREXISTS(printCommand)) then
delete var printCommand
endif
if ($VAREXISTS(addOrDelete)) then
delete var addOrDelete
endif
if ($VAREXISTS(ynCliModeAbortEnabled)) then
delete var ynCliModeAbortEnabled
endif
###############################################################################
# End of CLI Script
###############################################################################
create log entry "**********Finshed running CLI Script**********"
enable clipaging
disable cli-config-logging
disable cli scripting

Matthew_Helm1
Extreme Employee
Davon,

I forgot that that was necessary on the trunk/DHCP server ports.

You should simply have to add the following after the "config trusted-port $p trust-for dhcp-server" line:

set var iv $TCL(lsearch $sp *VLAN\ cfg:*)
set var iv ($iv + 1)
set var ev $TCL(lsearch $sp *STP\ cfg:*)
set var ev ($ev - 1)
while ($iv < $ev) do
set var l $TCL(lindex $sp $iv)
set var v $TCL(lindex $l 1)
set var v $TCL(string map {, ""} $v)
enable ip-security dhcp-snooping vlan $v port $p violation-action none
set var iv ($iv + 2)
endwhile

I haven't tested it, but it should work. Let me know if there are problems with it.

Are there other issues with the script?

Davor
New Contributor
Hello,

Thanks for script you posted. I have tested it and found it has issues. Currently working on fixing your script and adding few more lines.

You did not added something like:
enable ip-security dhcp-snooping vlan xxx port xx violation-action none
, for trunk ports.

Will get back to you when solve issues i'm having.

I can post my semi-working script, based on Mr. Padilla's ELRPON script.

BR
Davor

Matthew_Helm1
Extreme Employee
Davor,

Per the lawyers:

Any scripts that are written and posted on the Hub are provided “AS IS” with no warranty or representation as to its use. Any use should be carefully considered and be validated by the user. These scripts, regardless of who writes them, assume that the user accepts all of the risk and responsibility, and are not provided pursuant to any authorized services or professional services entitlement or obligation by Extreme Networks, its subsidiaries, agents or licensors. In no event shall the poster nor Extreme Networks be responsible for the functionality of the script nor are we responsible for any outages or network issues caused by use or integration of the script, including any degradation of functionality of Extreme products or technology. It is strongly recommended that any use of scripts or other technical information posted on this site must be validated before use in any production network by the user of the script.

With that said:

disable clip
set var cli.out 0
show port no
set var s $TCL(split ${cli.out} "\n")
set var i 4
set var e $TCL(lsearch $s *D-Disabled*)
set var e ($e - 1)
while ($i < $e) do
set var l $TCL(lindex $s $i)
set var p $TCL(lindex $l 0)
set var cli.out 0
show edp port $p
set var se $TCL(split ${cli.out} "\n")
set var le $TCL(llength $se)
if ($le < 7) then
disable edp port $p
endif
set var cli.out 0
show port $p info detail
set var sp $TCL(split ${cli.out} "\n")
set var l $TCL(lsearch $sp *Trunking:*)
set var ln $TCL(lindex $sp $l)
set var t $TCL(regexp {Master} $ln)
if ($t == 1) then
config trusted-port $p trust-for dhcp-server
else
set var t $TCL(regexp {Cfg} $l)
if ($t != 1) then
set var iv $TCL(lsearch $sp *VLAN\ cfg:*)
set var iv ($iv + 1)
set var ev $TCL(lsearch $sp *STP\ cfg:*)
set var ev ($ev - 1)
while ($iv <$ev) do
set var l $TCL(lindex $sp $iv)
set var v $TCL(lindex $l 1)
set var v $TCL(string map {, ""} $v)
enable ip-security dhcp-snooping vlan $v port $p violation-action drop-packet block-mac permane
set var iv ($iv + 2)
endwhile
endif
endif
set var i ($i + 1)
endwhile
delete var cli.out
delete var s
delete var i
delete var e
delete var l
delete var p
delete var se
delete var le
delete var sp
delete var ln
delete var t
delete var iv
delete var ev
delete var v
disable clip

Matthew_Helm1
Extreme Employee
Sorry to be a pain. I have the script, but I'm waiting for legal boilerplate to post it. I apologize for the delay, Davor.
GTM-P2G8KFN