r1214 + switchvlans gateway has learned to list MAC addresses from 2900 swithes
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 16 Oct 2007 08:48:09 +0000 (08:48 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 16 Oct 2007 08:48:09 +0000 (08:48 +0000)
gateways/switchvlans/cisco.connector
gateways/switchvlans/main

index d675a4c69acf9fb0f3fccd8b9ca2641a15255559..839ef2cd817a385f944f92bb1207fafed66244a8 100755 (executable)
@@ -37,11 +37,10 @@ prepare_connect_commands()
                        echo $line | cut -s -d' ' -f6 > $CMDS1
                        echo en >> $CMDS1
                        echo $line | cut -s -d' ' -f7 >> $CMDS1
-
                        # same for ports
-                       echo $line | cut -s -d' ' -f6 > $CMDS2
-                       echo en >> $CMDS2
-                       echo $line | cut -s -d' ' -f7 >> $CMDS2
+                       cat "$CMDS1" > "$CMDS2"
+                       # ...and MAC addresses
+                       cat "$CMDS1" > "$CMDS3"
                        break
                fi
        done < `dirname $0`/cisco.secrets.php
@@ -87,7 +86,11 @@ do_fetch()
        cat "$OUT1" | fgrep ' active    ' | sed -E 's/^([[:digit:]]+)[[:space:]]+(.+)[[:space:]]+ active    (.*)/\1=\2/;s/[[:space:]]+$//' > $FILE1
        cat "$OUT2" | egrep '^(Et|Fa|Gi|Te)' | sed -E 's/ +(notconnect|connected) +/=\1,/;s/,(trunk|([0-9]+)) .*$/,\1/' > $FILE2
        # FIXME
-#      cat "$OUT3" > "$FILE3" 
+       # Here we need to distinguish between different platforms and IOS version,
+       # cause they produce output in different formats.
+       if [ "$SW" = "Cisco+IOS+12.0" ]; then
+               cat "$OUT3" | tr -d '\r' | fgrep Dynamic | sed -E 's/ +Dynamic +([0-9]+) +(.+)/=\1@\2/;s/FastEthernet/Fa/;s/GigabitEthernet/Gi/' > "$FILE3"
+       fi
 }
 
 do_push()
index f5373330af3001f896dcc94f6a34ac8a2581b9ea..3934ef8dadcec79b33a6d2b254508ba96b364500 100755 (executable)
@@ -244,6 +244,13 @@ while read cmd args; do
                                echo 'ERR!Not connected'
                        fi
                        ;;
+               listmacs)
+                       if [ $CONNECTED = 1 ]; then
+                               do_listfile "$MACINFO"
+                       else
+                               echo 'ERR!Not connected'
+                       fi
+                       ;;
                set)
                        if [ $CONNECTED = 1 ]; then
                                do_set $args