r1122 + more dummy ports
[racktables] / gateways / switchvlans / main
1 #!/bin/bash
2
3 # This is a RackTables gateway for changing switch ports membership
4 # across VLANs. It works accordingly to the gateway protocol described
5 # in gateways.php and accepts the following commands on its stdin:
6 # * listvlans: list all VLANs found on the switch, propably filtering
7 # out those administratively prohibited. Only the VLANs from this
8 # list will be allowed as new destination for 'set' command.
9 # * listports: list all ports on the switch and their current status.
10 # Untagged (switchport mode access) ports will be shown with their
11 # VLAN ID and tagged ports will be shown as 'trunk' regardless of
12 # how many VLANs they are members of.
13
14 usage()
15 {
16 echo "Usage: $0 <endpoint> <hwtype> <swtype> <username>"
17 exit 1;
18 }
19
20 [ $# = 4 ] || usage
21
22 while read cmd arg; do
23 echo -n $cmd >> /tmp/main.log
24 date >> /tmp/main.log
25 case $cmd in
26 listvlans)
27 echo 'OK 200,204,203,202,201,205,333,334'
28 ;;
29 listports)
30 echo -n 'OK fa0/0/1=200,fa0/0/2=205,fa0/0/3=202,fa0/0/4=trunk,fa0/0/5=333,fa0/0/6=334,fa0/0/7=333,fa0/0/8=334,'
31 echo -n 'fa0/0/9=200,fa0/0/10=205,fa0/0/11=202,fa0/0/12=trunk,fa0/0/13=333,fa0/0/14=334,fa0/0/15=333,fa0/0/16=334,'
32 echo -n 'fa0/1/1=200,fa0/1/2=205,fa0/1/3=202,fa0/1/4=trunk,fa0/1/5=333,fa0/1/6=334,fa0/1/7=333,fa0/1/8=334,'
33 echo 'fa0/1/9=200,fa0/1/10=205,fa0/1/11=202,fa0/1/12=trunk,fa0/1/13=333,fa0/1/14=334,fa0/1/15=333,fa0/1/16=334'
34 ;;
35 set)
36 echo 'OK'
37 ;;
38 *)
39 echo "ERR 'unknown command $cmd'"
40 esac
41 done
42
43 exit 0