r1119 + initial VLAN gateway, a little dummy atm, but the protocol look implemented
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 4 Sep 2007 11:05:12 +0000 (11:05 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 4 Sep 2007 11:05:12 +0000 (11:05 +0000)
gateways/switchvlans/main [new file with mode: 0755]

diff --git a/gateways/switchvlans/main b/gateways/switchvlans/main
new file mode 100755 (executable)
index 0000000..8a11b81
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# This is a RackTables gateway for changing switch ports membership
+# across VLANs. It works accordingly to the gateway protocol described
+# in gateways.php and accepts the following commands on its stdin:
+# * listvlans: list all VLANs found on the switch, propably filtering
+# out those administratively prohibited. Only the VLANs from this
+# list will be allowed as new destination for 'set' command.
+# * listports: list all ports on the switch and their current status.
+# Untagged (switchport mode access) ports will be shown with their
+# VLAN ID and tagged ports will be shown as 'trunk' regardless of
+# how many VLANs they are members of.
+
+usage()
+{
+       echo "Usage: $0 <endpoint> <hwtype> <swtype> <username>"
+       exit 1;
+}
+
+[ $# = 4 ] || usage
+
+while read cmd arg; do
+       echo -n $cmd >> /tmp/main.log
+       date >> /tmp/main.log
+       case $cmd in
+               listvlans)
+                       echo 'OK 200,201,202,203,204,205'
+                       ;;
+               listports)
+                       echo 'OK fa0/0/1=200,fa0/0/2=201,fa0/0/3=202,fa0/0/4=trunk'
+                       ;;
+               set)
+                       echo 'OK'
+                       ;;
+               *)
+                       echo "ERR 'unknown command $cmd'"
+       esac
+done
+
+exit 0