cancel
Showing results for 
Search instead for 
Did you mean: 

how can i create and import a list in a CLI script

how can i create and import a list in a CLI script

skyvana
New Contributor III
hi,

Currently, I am working in a project to create a Script to detect Vendor Mac Address and put into appropriate vlan according to their mac address.

I have a question, is it possible to create a list with some variables (all allowed mac addresses) and then import these variable in a CLI script .xsf ?

Thank for your help, I hope I am understandable, and sorry for my bad english ...

Alex
6 REPLIES 6

skyvana
New Contributor III
I expose my solutions in case of someone has the same problem as me.

I find a solutions to my problem, that the ftp crash my script (loopback condition), if the tftp server not responding.

I use a script that i run in my principal script, to check if the tftp server ping, if he ping i run tftp if not he informe me about the error .



code:
set var check "4 packets received"
set var CLI.OUT " "
ping 192.168.64.1

set var list1 $TCL(split ${CLI.OUT} \n)
set var list2 $TCL(lindex $(list1) 7)
set var list3 $TCL(string range $(list2) 23 40)

#test if the switch ping the TFTP server address / if yes launches tftp

if (!$match($check, $list3)) then
tftp get 192.168.64.1 vr "VR-Default" mac.xsf
create log message "TFTP OK"
else
create log message "WARNING TFTP do not ping"
endif



My question was maybe very focused and inaccurate, I may have done a monologue (a discussion between myself) but thank you as well.

skyvana
New Contributor III
hello everybody,

I find a solution,

1 - I create a script mac.xsf that i put in my server.
code:
  set var mylist $TCL(list 00:0c:29:ce:6c:c6 00:0c:29:dd:6d:59 )
save var key mylist

Where i list my authorized mac address, and that i export (var key).

2 - In my primary script in my Switch i add
code:
	tftp get IPmyserver vr "VR-Default" mac.xsf

which allow me to import my authorized mac in my switch

3 - In my primary script in my Switch i also add
code:
	load script mac.xsf
load var key mylist

which allow me to import my authorized mac in my primary script

4 - I can finally use my mac address to put into appropriate vlan according to their mac address

code:
	set var control -1
#Check if the mac address ($myvariable) is part of the list ($list) / if yes #search not egals to -1 $control
set var search $TCL(lsearch -glob $mylist $myvariable)
#Check if search is not equal to control (control = -1)
if ($match($search, $control)) then
configure vlan default del port $EVENT.LOG_PARAM_0
configure vlan "myVLAN" add port $EVENT.LOG_PARAM_0



BUT, beacause ther is always a but, if TFTP get do not run/work, that makes my program crash, I would like that the programs always run because the file that tftp import it already in my switch.

I hope that you can help my, and that I am understandable, sorry for my bad english ...

skyvana
New Contributor III
Hi Stephane thank for your answer,

I already use a big CLI script .xsf in a UPM script to detect Vendor Mac Address and put into appropriate vlan according to their mac address, my question is, who can i create liste because for the moment i use variable for each mac address, which is not very suitable, so can i use pyhton in that script to create liste, which i browse for a if condition, or is there another way ?

Thank for your help, I hope I am understandable, and sorry for my bad english ...

Alex

Stephane_Grosj1
Extreme Employee
Hi,

you create a python script doing what is needed. If you need some variable from the system (UPM), consider them as parameters.

In your UPM script, you simply call the script (run script xxxxx) with the required variables as parameters.

for example:

code:
X440-8p.6 # create upm profile lldp-detect
Start typing the profile and end with a . as the first and the only character on a line. Use - edit upm profile - for block mode capability
run script lldp-device $EVENT.NAME $EVENT.USER_PORT
.
X440-8p.7 # configure upm event device-detect profile lldp-detect ports 1-8 X440-8p.8 # configure upm event device-undetect profile lldp-detect ports 1-8
GTM-P2G8KFN