scripting on xos switchen

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi, i have a problem.
I want to configure the elrp client on all  my extreme xos switche.( more then 1000 )
with al lot off dificulti vlan names.
I don ́t want log in seperatly in every switch to do it on the cli.
Can i do this configuration wih a script?
Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Patrick Voss

Patrick Voss, Alum

  • 11,594 Points 10k badge 2x thumb
Hello Thomas,

Depending on what version of code you are running you can utilize python to achieve this. A script might already be written to achieve something similiar on the website below:

https://github.com/extremenetworks/

You can then tftp the py file to the switch and utilize the command "run script <script name>.py"

The switches must be on 15.6 or higher in order to run python scripts.
Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb
Thank you very much for the info and our version on the switches are 16.x
I am a newie in scripting an i hope its not to dificulti for me
thx
Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb
I have one question,

how can i download the files?
or what i must du to copy this files on my switch
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
So, the best way to xfer files is probably TFTP. Here is an example for a config file but the principle is the same for .xsf and .py files.

Once you have the .xsf or .py file on your switch, you would issue the command "load script {scriptname}" where the script file name is given without the suffix.

That said, you could also simply vi a file and type i for insert and then copy and paste the script contents into your terminal session. Then wq! to write to the file and quit the vi editor.

Also here is some code that when run in a script does an ELRP one-shot on every VLAN, every port and reports loops. You could probably modify it to do what you want.

#usage: load script elrp_oneshot
# USE THIS SCRIPT AT YOUR OWN RISK

disable cli prompting
disable clipaging
enable elrp-client
set var sv "#ELRP POLL STARTED#"
show var sv
set var cli.out 0
show vlan
set var sv $TCL(split ${cli.out} "\n")
set var e $TCL(lsearch $sv *(B)*)
set var i 5
set var e ($e - 1)
while ($i < $e) do
   set var cli.out 0
   set var v $TCL(lindex $sv $i)
   set var vn $TCL(lindex $v 0)
   set var z $TCL(regexp {Mgmt} $vn)
   if ($z == 0) then
         conf elrp-client one-shot $vn port all print
         set var p $TCL(split ${cli.out} "\n")
         set var p1 $TCL(lsearch $p *NO*)
         if ($p1 == -1) then
            set var p1 $TCL(lindex $p 2)
            set var p2 $TCL(lindex $p1 9)
            set var p1 $TCL(lrange $p1 0 6)
            set var p1 $TCL(concat $p1 $p2)
            set var p2 $TCL(lindex $p 3)
            set var p2 $TCL(lrange $p2 5 7)
            set var p $TCL(concat $p1 $p2)
            show var p
         else
            set var p1 $TCL(lindex $p 2)
            set var p2 $TCL(lindex $p1 10)
            set var p1 $TCL(lrange $p1 0 7)
            set var p1 $TCL(concat $p1 $p2)
            show var p1
         endif
   endif
   set var i ($i + 1)
endwhile
disable elrp-client
set var sv "#ELRP POLL COMPLETED#"
show var sv
enable clipaging
enable cli prompting
Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb
Good Morning,

thank you for your help in scripting under  xos software
How i download a file to my swiches is not the problem, wie do it often with Netsight or
with my own tftp server.
i don`t know ho i download the phyton files from the homepage

https://github.com/extremenetworks/


Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb
I want to give a feedback.
This script works exelent with our xos switche.
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
Good to hear. Thanks.
Photo of dr.watson

dr.watson

  • 332 Points 250 badge 2x thumb
Yes, it works good.
But who can me explain what this Scripr do?
I know it is very difficulty for me to understand this.
I  want to write a script which configure me the elrp protocoll on the switch. witch multiple vlans.
iI our networks we have ovver 1100 Extreme router or switche and i must
configue elrp to remove a loop in my network.
Photo of Matthew Helm

Matthew Helm, Employee

  • 1,852 Points 1k badge 2x thumb
The script I posted is a "one-shot" elrp script that runs ELRP once on every VLAN every port to detect a loop.

It could be modified (and simplified) to instead enable ELRP on every VLAN every port permanently.

However, I would advise you to check with GTAC on the scale limits for ELRP based on switched configuration as having a large number of VLANs with a large number of ports in use with ELRP could overrun the CPU.
Photo of Peter

Peter

  • 1,018 Points 1k badge 2x thumb
You can do this even with "Execute Command-Script" on Netsight. When you use XOS  >21.x you can use vlan-id in some commands and not only vlan-names. I'm not sure, if this is included in elrp commands and XOS 16.x
Photo of Grosjean, Stephane

Grosjean, Stephane, Employee

  • 13,348 Points 10k badge 2x thumb
nope, it doesn't include elrp. But the vlan name is easier to automate anyway, as it's VLAN_<4 digit vid> (for example: VLAN_0010 for vid 10).

if running 21.x+ I would imagine an App connecting to the switches, finding the vlans in use (with some criteria) and then apply the adequate config. Working with Python, json objects and jsonrpc could make it "easy".