remove old gateways code
authorDenis Ovsienko <infrastation@yandex.ru>
Wed, 17 Oct 2012 09:31:23 +0000 (13:31 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Wed, 17 Oct 2012 09:31:23 +0000 (13:31 +0400)
This change removes the following code:

* gateways/sendfile/
* gateways/deviceconfig/
* gateways/switchvlans/
* queryGateway()
* getSwitchVLANs()
* setSwitchVLANs()
* gwSendFile()
* gwRecvFile()
* gwSendFileToObject()
* gwRecvFileFromObject()
* gwRetrieveDeviceConfig()
* gwDeployDeviceConfig()
* renderVLANMembership()
* setPortVLAN()
* trigger_livevlans()

The "sendfile" and "deviceconfig" are completely obsoleted by the
current gateways API. The "switchvlans" and associated "Live VLANs"
feature is moved to the racktables-contribs repository, since "802.1Q"
feature is sufficient for most use cases.

23 files changed:
.gitignore
ChangeLog
gateways/deviceconfig/fdry5.connector [deleted file]
gateways/deviceconfig/ios12.connector [deleted file]
gateways/deviceconfig/jun10.connector [deleted file]
gateways/deviceconfig/main [deleted file]
gateways/deviceconfig/nc.pl [deleted file]
gateways/deviceconfig/nxos4.connector [deleted file]
gateways/deviceconfig/switch.secrets.php-sample [deleted file]
gateways/deviceconfig/vrp53.connector [deleted file]
gateways/deviceconfig/vrp55.connector [deleted file]
gateways/deviceconfig/xos12.connector [deleted file]
gateways/sendfile/main [deleted file]
gateways/switchvlans/cisco.connector [deleted file]
gateways/switchvlans/cisco.secrets.php-sample [deleted file]
gateways/switchvlans/main [deleted file]
gateways/switchvlans/vlandecoder-sample [deleted file]
gateways/switchvlans/vlantable-sample [deleted file]
wwwroot/inc/gateways.php
wwwroot/inc/interface.php
wwwroot/inc/navigation.php
wwwroot/inc/ophandlers.php
wwwroot/inc/triggers.php

index d09f9bb..519328a 100644 (file)
@@ -1,8 +1,4 @@
 wwwroot/inc/secret.php
 wwwroot/inc/local.php
-gateways/switchvlans/changes.log
-gateways/switchvlans/cisco.secrets.php
-gateways/switchvlans/vlandecoder
-gateways/switchvlans/vlantable
 /.project
 tags
index 6f45505..66617dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        bugfix: improve UCS error handling
        bugfix: proper handling of VLAN 1 in Huawei VRP 5.7 802.1Q gateway
        update: SLB: ability to specify multiple RS ports
+       update: remove old gateways code, including Live VLANs
        new feature: abstract tags, which cannot be assigned (#577)
 0.20.1 2012-10-04
        bugfix: restore D-Link (#533) and Linux (#541) gateway support
diff --git a/gateways/deviceconfig/fdry5.connector b/gateways/deviceconfig/fdry5.connector
deleted file mode 100755 (executable)
index b54a09e..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 3 ] || exit 1
-
-ENDPOINT=$1
-COMMAND=$2
-WORKFILE=$3
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no MYDIR=`dirname $0`
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # ignore comments
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > "$SESSION"
-                       # access password
-                       access_password=`echo $line | cut -s -d' ' -f6`
-                       [ "$access_password" != "-" ] && echo "$access_password" >> "$SESSION"
-                       printf "en\r\n" >> "$SESSION"
-                       enable_password=`echo $line | cut -s -d' ' -f7`
-                       [ "$enable_password" != "-" ] && echo $enable_password >> "$SESSION"
-                       break
-               fi
-       done < "$MYDIR/switch.secrets.php"
-       [ "$found" = "yes" ] && return
-       exit 3
-}
-
-MYNAME=`basename $0`
-SESSION=`mktemp /tmp/$MYNAME.XXXXXX`
-[ -f "$SESSION" ] || exit 5
-prepare_connect_commands $ENDPOINT
-case $COMMAND in
-get8021q)
-       printf 'skip-page-display\r\nshow running-config\r\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-deploy)
-       cat "$WORKFILE" >> "$SESSION"
-       outfile=/dev/null
-       ;;
-*)
-       rm -f "$SESSION"
-       exit 6
-       ;;
-esac
-printf 'exit\r\nexit\r\n' >> "$SESSION"
-rc=0
-nc -w 30 -i 1 $ENDPOINT 23 < "$SESSION" > "$outfile" || rc=4
-rm -f "$SESSION"
-exit $rc
diff --git a/gateways/deviceconfig/ios12.connector b/gateways/deviceconfig/ios12.connector
deleted file mode 100755 (executable)
index 0f30adb..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 3 ] || exit 1
-
-ENDPOINT=$1
-COMMAND=$2
-WORKFILE=$3
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no MYDIR=`dirname $0`
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # ignore comments
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > $SESSION
-                       # access password
-                       echo $line | cut -s -d' ' -f6 >> $SESSION
-                       enable_password=`echo $line | cut -s -d' ' -f7`
-                       [ "$enable_password" != "-" ] && {
-                               echo en >> $SESSION
-                               echo $enable_password >> $SESSION
-                       }
-                       break
-               fi
-       done < "$MYDIR/switch.secrets.php"
-       [ "$found" = "yes" ] && return
-       exit 3
-}
-
-MYNAME=`basename $0`
-SESSION=`mktemp /tmp/$MYNAME.XXXXXX`
-[ -f "$SESSION" ] || exit 5
-prepare_connect_commands $ENDPOINT
-case $COMMAND in
-get8021q)
-       printf 'term len 0\nshow run\n! END OF CONFIG\nshow vlan brief\n! END OF VLAN LIST\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getcdpstatus)
-       printf 'term len 0\nshow cdp neighbors detail\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getlldpstatus)
-       printf 'term len 0\nshow lldp neighbors\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getportstatus)
-       printf 'term len 0\nshow int status\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getmaclist)
-       printf 'term len 0\nshow mac address-table dynamic\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-deploy)
-       cat "$WORKFILE" >> "$SESSION"
-       outfile=/dev/null
-       ;;
-*)
-       rm -f "$SESSION"
-       exit 6
-       ;;
-esac
-printf 'quit\n' >> "$SESSION"
-rc=0
-nc -w 30 $ENDPOINT 23 < "$SESSION" > "$outfile" || rc=4
-rm -f "$SESSION"
-exit $rc
diff --git a/gateways/deviceconfig/jun10.connector b/gateways/deviceconfig/jun10.connector
deleted file mode 100755 (executable)
index e94118f..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/perl
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-use strict;
-use File::FnMatch qw(:fnmatch);
-use Net::Telnet::Cisco;
-@ARGV == 3 or @ARGV == 4 or die "usage: $0 endpoint command workfile";
-
-my ($endpoint, $command, $workfile, $sudo_call) = @ARGV;
-
-$0 =~ m,^(.*)/[^/]+$,;
-my $mydir = $1;
-open(SECRETS, "<$mydir/switch.secrets.php") || die "switch.secrets.php: $!";
-my $skip = 1;
-my ($protocol, $username, $password, $enable_password, $sudo_username);
-while (<SECRETS>) {
-    chomp;
-    if ($skip && ($_ eq "# S-T-A-R-T")) {
-        $skip = 0;
-        next;
-    }
-    if (!$skip && ($_ eq "# S-T-O-P")) {
-        $skip = 1;
-        next;
-    }
-    next if ($skip);
-    next if m,^\s*(#.*)?$,;
-    my @f = split;
-    if (fnmatch($f[0], $endpoint)) {
-               $protocol = $f[1];
-        $username = $f[4];
-        $password = $f[5];
-        $enable_password = $f[6];
-               $sudo_username = $f[7];
-        last;
-    }
-}
-
-if (!defined($username)) {
-    exit(3);
-}
-
-my $is_reader = ($command =~ /deploy/);
-my $is_writer = ($command =~ /get8021q/);
-
-my $current_user = scalar getpwuid $<;
-if ($sudo_username and $sudo_username ne '-' and $current_user ne $sudo_username) {
-       if ($sudo_call) {
-               die "cant sudo as $sudo_username";
-       }
-       else {
-               my $child_command = "sudo -u '$sudo_username' '$0' @ARGV sudo_call";
-               my $code;
-               if ($is_reader) {
-                       $code = system("$child_command <'$workfile'");
-               }
-               elsif ($is_writer) {
-                       $code = system("$child_command >'$workfile'");
-               }
-               exit ($code >> 8);
-       }
-}
-
-if ($is_reader) {
-       if ($sudo_call) {
-               open (WORKFILE, "<&STDIN");
-       }
-       else {
-               open(WORKFILE, "<$workfile") || die "$workfile: $!";
-       }
-}
-elsif ($is_writer) {   
-       if ($sudo_call) {
-               open(WORKFILE, ">&STDOUT");
-       }
-       else {
-               open(WORKFILE, ">$workfile") || die "$workfile: $!";
-       }
-}
-
-if ($protocol eq 'telnet') {
-       my $session = Net::Telnet->new('Host' => $endpoint, 
-         Prompt => '/\S+\@\S+[>#] $/',
-         Timeout => 40,
-       );
-       $session->login($username, $password);
-       if ($command eq "get8021q") {
-               $session->cmd ('set cli screen-length 0');
-               print WORKFILE $session->cmd ('show vlans detail'), "# END OF VLAN LIST\n";
-               print WORKFILE $session->cmd ('show configuration groups'), "# END OF GROUP LIST\n";
-               print WORKFILE $session->cmd ('show configuration interfaces'), "# END OF CONFIG\n";
-               exit(0);
-       }
-       elsif ($command eq "deploy") {
-               while (my $cmd = <WORKFILE>) {
-                       $cmd =~ s/[\r\n]//g;
-                       my $result = join '', $session->cmd ($cmd);
-                       if ($result =~ /\berror:\b/si) {
-                               die "error saving configuration";
-                       }
-               }
-               exit(0);
-       }
-}
-elsif ($protocol eq 'ssh') {
-       # open filehandles
-       if ($is_writer and ! $sudo_call) {
-               close STDOUT;
-               open (STDOUT, ">&WORKFILE");
-       }
-       open(SSH, "| ssh -T -o StrictHostKeyChecking=no '$username'\@'$endpoint'" . ($is_reader ? ' >/dev/null' : '')) or die "cant run ssh: $!";
-
-       if ($command eq "get8021q") {
-               print SSH "set cli screen-length 0\n";
-               print SSH "show vlans detail\n", "# END OF VLAN LIST\n";
-               print SSH "show configuration groups\n", "# END OF GROUP LIST\n";
-               print SSH "show configuration interfaces\n", "# END OF CONFIG\n";
-               exit(0);
-       }
-       elsif ($command eq "deploy") {
-               while (my $cmd = <WORKFILE>) {
-                       $cmd =~ s/[\r\n]//g;
-                       print SSH $cmd, "\n";
-               }
-               exit(0);
-       }
-}
diff --git a/gateways/deviceconfig/main b/gateways/deviceconfig/main
deleted file mode 100755 (executable)
index afd16fe..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-#
-# This gateway retrieves the output of "show run" command (or its
-# equivalent) and prints it onto stdout. When run, it accepts the
-# following commands on stdin:
-#
-# * get8021q <endpoint> <handler> <outputfile>
-#   (save remote config text into provided local file)
-#
-# * getcdpstatus <endpoint> <handler> <outputfile>
-#   (save remote status text into provided local file)
-#
-# * deploy <endpoint> <handler> <inputfile>
-#   (execute given text in privileged mode)
-
-MYDIR=`dirname $0`
-
-decode_error()
-{
-       case "$1" in
-               1)
-                       echo -n 'invalid connector args'
-               ;;
-               2)
-                       echo -n 'internal error 2'
-               ;;
-               3)
-                       echo -n 'password not found'
-               ;;
-               4)
-                       echo -n 'netcat failed'
-               ;;
-               5)
-                       echo -n 'cannot create temporary files'
-               ;;
-               6)
-                       echo -n 'command not supported by device'
-               ;;
-               *)
-                       echo -n "unknown error $1"
-               ;;
-       esac
-}
-
-while read command endpoint handler conftext; do
-       # sanity checks
-       if [ -z "$endpoint" -o -z "$conftext" -o -z "$handler" -o -z "$command" ]; then
-               echo 'ERR!too few arguments in command'
-               return
-       fi
-       [ -x "$MYDIR/$handler.connector" ] || {
-               echo "ERR!Connector '$handler' is not available"
-               exit 1
-       }
-       "$MYDIR/$handler.connector" $endpoint $command "$conftext"
-       ret=$?
-       if [ $ret = 0 ]; then
-               echo "OK!request '$command' complete for $endpoint"
-       else
-               echo -n "ERR!connector error ("
-               decode_error $ret
-               echo ')'
-       fi
-done
-
-# all error messages have been sent to stdout
-exit 0
diff --git a/gateways/deviceconfig/nc.pl b/gateways/deviceconfig/nc.pl
deleted file mode 100755 (executable)
index 62d4748..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/perl -w
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-use strict;
-use Getopt::Long qw(:config pass_through);;
-use Fcntl;
-use IPC::Open2;
-my $NC_EXEC = 'nc';
-
-my ($marker, $marker_halt);
-my $wait_for;
-my $help;
-GetOptions ("stopwhen=s" => \$marker,
-                       "haltwhen=s" => \$marker_halt,
-                       "putwhen=s" => \$wait_for,
-                       "help|h" => \$help);
-if ($help) {
-       print <<END;
-Wrapper around nc for non-interactive sessions.
-It can close session when it sees the regexp-matching string in session output.
-It can wait for command prompt to push the next command to remote side.
-It DOES NOT directly link its standard input with nc`s standard input.
-
-Additional options availivle:
---help, -h           This help message
---stopwhen=<regexp>  Close nc when this string is seen in the output
---putwhen=<regexp>   Put next line only if last output line complies to regexp
-
-Original nc options:
-END
-       exec($NC_EXEC);
-       exit;
-}
-
-my $hostname = 'unknown';
-if (@ARGV >= 2) {
-       $hostname = $ARGV[$#ARGV - 1];
-}
-my ($break_re, $prompt_re, $halt_re);
-if ($marker) {
-       $break_re = qr/($marker)/m;
-}
-if ($marker_halt) {
-       $halt_re = qr/($marker_halt)/m;
-}
-if ($wait_for) {
-       $prompt_re = qr/$wait_for/;
-}
-$| = 1;
-
-my @cmds = <STDIN>;
-
-my $log = '';
-local (*Reader, *Writer);
-my $pid = open2(\*Reader, \*Writer, $NC_EXEC, @ARGV) or die "cant start $NC_EXEC: $!\n";
-my $stdin_ended = 0;
-
-my $total_read = 0;
-my $vec = '';
-while () {
-       vec($vec, fileno(Reader), 1) = 1;
-       select($vec, undef, undef, undef);
-
-       my $buff;
-       my $nb = sysread(Reader, $buff, 64 * 1024);
-       $total_read += $nb;
-       print $buff if $nb; # echo to STDOUT
-       if (! $nb) {
-               if (@cmds and $total_read) {
-                       print STDERR "$hostname: connection interrupted by remote side.\n";
-               }
-               last; # exit if nc closed connection
-       }
-
-       $log .= $buff;
-       my $halt_matched = $halt_re && $log =~ $halt_re;
-       if ($halt_matched or $break_re && $log =~ $break_re) {
-               if ($halt_matched) {
-                       chomp $log;
-                       $log =~ s/.*\n//;
-                       $log =~ s/[^ -~]//g;
-                       print STDERR "$hostname: Matched line '$log', connection interrupted.\n";
-                       exit 1;
-               }
-               else {
-                       exit 0;
-               }
-       }
-       $log =~ s/.*\n//s; # keep only last line in log
-
-       if ($prompt_re and $log =~ $prompt_re) { # if interative mode and pending commands
-               if (@cmds) {
-                       print Writer shift @cmds; # push one command
-                       $log = '';
-               }
-               else { # if interactive mode and no more commands, exit
-                       last;
-               }
-       }
-       elsif (! $prompt_re and @cmds) { # if non-interactive mode and pending commands, push them all
-               print Writer @cmds;
-               undef @cmds;
-       }
-}
-close Reader;
-close Writer;
-waitpid( $pid, 0 );
-exit $? >> 8;
diff --git a/gateways/deviceconfig/nxos4.connector b/gateways/deviceconfig/nxos4.connector
deleted file mode 100755 (executable)
index 3f8d253..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/perl
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-#
-# a working NX-OS connector for RackTables by Dmitry Tejblum
-
-use strict;
-use File::FnMatch qw(:fnmatch);
-use Net::Telnet::Cisco;
-$#ARGV == 2 or die "usage";
-my $endpoint = shift @ARGV;
-my $command = shift @ARGV;
-my $workfile = shift @ARGV;
-
-$0 =~ m,^(.*)/[^/]+$,;
-my $mydir = $1;
-open(SECRETS, "<$mydir/switch.secrets.php") || die "switch.secrets.php: $!";
-my $skip = 1;
-my ($username, $password, $enable_password);
-while (<SECRETS>) {
-    chomp;
-    if ($skip && ($_ eq "# S-T-A-R-T")) {
-        $skip = 0;
-        next;
-    }
-    if (!$skip && ($_ eq "# S-T-O-P")) {
-        $skip = 1;
-        next;
-    }
-    next if ($skip);
-    next if m,^\s*(#.*)?$,;
-    my @f = split;
-    if (fnmatch($f[0], $endpoint)) {
-        $username = $f[4];
-        $password = $f[5];
-        $enable_password = $f[6];
-        last;
-    }
-}
-
-if (!defined($username)) {
-    exit(3);
-}
-
-my $session = Net::Telnet::Cisco->new('Host' => $endpoint, 
-  Prompt => ' /(?:^|[\x0a\x0d0\0]+)[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$/',
-);
-$session->more_prompt('/(?:^|[\x0a\x0d\0]+)\s*(?:\x1b\S{1,3})?\s*--More--/');
-$session->login($username, $password);
-if ($enable_password ne "-") {
-    $session->enable($enable_password);
-}
-if ($command eq "get8021q") {
-    open(WORKFILE, ">$workfile") || die "$workfile: $!";
-    $session->cmd ('terminal length 0');
-    $session->cmd ('terminal no monitor');
-    my @r = $session->cmd ('show running-config vlan 1-4094');
-    print WORKFILE @r, "\n\n";
-    @r = $session->cmd('show running-config interface');
-    print WORKFILE @r, "\n\n";;
-    exit(0);
-}
-if ($command eq "getcdpstatus") {
-    open(WORKFILE, ">$workfile") || die "$workfile: $!";
-    $session->cmd ('terminal length 0');
-    $session->cmd ('terminal no monitor');
-    my @r = $session->cmd ('show cdp neighbors detail');
-    print WORKFILE @r, "\n\n";;
-    exit(0);
-}
-if ($command eq "getportstatus") {
-    open(WORKFILE, ">$workfile") || die "$workfile: $!";
-    $session->cmd ('terminal length 0');
-    $session->cmd ('terminal no monitor');
-    my @r = $session->cmd ('show int status');
-    print WORKFILE @r, "\n\n";;
-    exit(0);
-}
-if ($command eq "getmaclist") {
-    open(WORKFILE, ">$workfile") || die "$workfile: $!";
-    $session->cmd ('terminal length 0');
-    $session->cmd ('terminal no monitor');
-    my @r = $session->cmd ('show mac address-table dynamic');
-    print WORKFILE @r, "\n\n";;
-    exit(0);
-}
-if ($command eq "getlldpstatus") {
-    open(WORKFILE, ">$workfile") || die "$workfile: $!";
-    $session->cmd ('terminal length 0');
-    $session->cmd ('terminal no monitor');
-    my @r = $session->cmd ('show lldp neighbors detail');
-    print WORKFILE @r, "\n\n";;
-    exit(0);
-}
-if ($command eq "deploy") {
-    open(WORKFILE, "<$workfile") || die "$workfile: $!";
-    while (<WORKFILE>) {
-               my $prev_timeout;
-               if ($_ =~ /^copy running-config startup-config/) {
-                       $prev_timeout = $session->timeout(60);
-               }
-
-               $session->cmd($_);
-
-               if (defined $prev_timeout) {
-                       $session->timeout($prev_timeout);
-               }
-    }
-    exit(0);
-}
diff --git a/gateways/deviceconfig/switch.secrets.php-sample b/gateways/deviceconfig/switch.secrets.php-sample
deleted file mode 100644 (file)
index 5bcc135..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php ob_start(); ?>
-
-# Syntax:
-# <endpoint|*> <telnet|ssh> <hostname|-> <port|-> <username|-> <line password> <enable password> <sudo username|->
-# Note: ssh protocol is only available with JunOS10 devices
-# FIXME: <endpoint|*> <rsh> <username>
-
-# S-T-A-R-T
-switch1 telnet - - - password2 enablepassword -
-switch2 telnet - - - password enablepassword -
-switch3 telnet - - username3 password3 enablepassword3 -
-# S-T-O-P
-
-<?php ob_end_clean(); ?>
diff --git a/gateways/deviceconfig/vrp53.connector b/gateways/deviceconfig/vrp53.connector
deleted file mode 100755 (executable)
index 93de2cb..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 3 ] || exit 1
-
-ENDPOINT=$1
-COMMAND=$2
-WORKFILE=$3
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no MYDIR=`dirname $0`
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # ignore comments
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > "$SESSION"
-                       # access password
-                       access_password=`echo $line | cut -s -d' ' -f6`
-                       [ "$access_password" != "-" ] && echo "$access_password" >> "$SESSION"
-                       printf "super\n" >> "$SESSION"
-                       enable_password=`echo $line | cut -s -d' ' -f7`
-                       [ "$enable_password" != "-" ] && echo $enable_password >> "$SESSION"
-                       break
-               fi
-       done < "$MYDIR/switch.secrets.php"
-       [ "$found" = "yes" ] && return
-       exit 3
-}
-
-MYNAME=`basename $0`
-SESSION=`mktemp /tmp/$MYNAME.XXXXXX`
-[ -f "$SESSION" ] || exit 5
-prepare_connect_commands $ENDPOINT
-case $COMMAND in
-get8021q)
-       printf 'display current-configuration\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getlldpstatus)
-       printf 'display lldp neighbor\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getportstatus)
-       printf 'display interface brief\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getmaclist)
-       printf 'display mac-address dynamic\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-deploy)
-       cat "$WORKFILE" >> "$SESSION"
-       outfile=/dev/null
-       ;;
-*)
-       rm -f "$SESSION"
-       exit 6
-       ;;
-esac
-printf 'quit\n' >> "$SESSION"
-rc=0
-nc -w 30 $ENDPOINT 23 < "$SESSION" > "$outfile" || rc=4
-rm -f "$SESSION"
-exit $rc
diff --git a/gateways/deviceconfig/vrp55.connector b/gateways/deviceconfig/vrp55.connector
deleted file mode 100755 (executable)
index 501ecec..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 3 ] || exit 1
-
-ENDPOINT=$1
-COMMAND=$2
-WORKFILE=$3
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no MYDIR=`dirname $0`
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # ignore comments
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > "$SESSION"
-                       # access password
-                       access_password=`echo $line | cut -s -d' ' -f6`
-                       [ "$access_password" != "-" ] && echo "$access_password" >> "$SESSION"
-                       printf "super\n" >> "$SESSION"
-                       enable_password=`echo $line | cut -s -d' ' -f7`
-                       [ "$enable_password" != "-" ] && echo $enable_password >> "$SESSION"
-                       break
-               fi
-       done < "$MYDIR/switch.secrets.php"
-       [ "$found" = "yes" ] && return
-       exit 3
-}
-
-MYNAME=`basename $0`
-MYDIR=`dirname $0`
-SESSION=`mktemp /tmp/$MYNAME.XXXXXX`
-[ -f "$SESSION" ] || exit 5
-prepare_connect_commands $ENDPOINT
-printf 'screen-length 0 temporary\n' >> "$SESSION"
-case $COMMAND in
-get8021q)
-       printf 'display current-configuration\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getlldpstatus)
-       printf 'display lldp neighbor\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getportstatus)
-       printf 'display interface brief\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getmaclist)
-       printf 'display mac-address dynamic\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-deploy)
-       cat "$WORKFILE" >> "$SESSION"
-       outfile=/dev/null
-       ;;
-*)
-       rm -f "$SESSION"
-       exit 6
-       ;;
-esac
-printf 'quit\n' >> "$SESSION"
-rc=0
-$MYDIR/nc.pl --putwhen='(^Username:$|^Password:$)|^<[^<>]*>$|^\[[^\[\]]*\]$' --stopwhen='^Now saving the current configuration' -w 30 $ENDPOINT 23 < "$SESSION" > "$outfile" || rc=4
-rm -f "$SESSION"
-exit $rc
diff --git a/gateways/deviceconfig/xos12.connector b/gateways/deviceconfig/xos12.connector
deleted file mode 100755 (executable)
index 5184252..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 3 ] || exit 1
-
-ENDPOINT=$1
-COMMAND=$2
-WORKFILE=$3
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no MYDIR=`dirname $0`
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # ignore comments
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > "$SESSION"
-                       # access password
-                       access_password=`echo $line | cut -s -d' ' -f6`
-                       [ "$access_password" != "-" ] && echo "$access_password" >> "$SESSION"
-                       break
-               fi
-       done < "$MYDIR/switch.secrets.php"
-       [ "$found" = "yes" ] && return
-       exit 3
-}
-
-MYNAME=`basename $0`
-SESSION=`mktemp /tmp/$MYNAME.XXXXXX`
-[ -f "$SESSION" ] || exit 5
-prepare_connect_commands $ENDPOINT
-case $COMMAND in
-get8021q)
-       printf 'disable clipaging\nshow configuration "vlan"\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-getlldpstatus)
-       printf 'disable clipaging\nshow lldp neighbors detailed\n' >> "$SESSION"
-       outfile="$WORKFILE"
-       ;;
-deploy)
-       cat "$WORKFILE" >> "$SESSION"
-       outfile=/dev/null
-       ;;
-*)
-       rm -f "$SESSION"
-       exit 6
-       ;;
-esac
-# quit, but don't save, if asked
-printf 'quit\nn\n' >> "$SESSION"
-rc=0
-nc -w30 -i1 $ENDPOINT 23 < "$SESSION" > "$outfile" || rc=4
-rm -f "$SESSION"
-exit $rc
diff --git a/gateways/sendfile/main b/gateways/sendfile/main
deleted file mode 100755 (executable)
index 2791842..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-#
-# This is a RackTables gateway for arbitrary file export. File contents doesn't
-# matter here and will only be somehow sent to the remote host for further
-# processing.
-#
-# The only supported command is:
-#
-# * submit <username> <endpoint> <handler name> [filename1] [filename2] [...] 
-#
-# Handler name can be any string used to distinguish different file processors.
-# The temporary file will be passed to a script in current directory, if it exists.
-# Script name is "<handlername>.install"
-
-user=
-endpoint=
-cfgfile=
-MYDIR=`dirname $0`
-
-do_submit()
-{
-       user=$1
-       endpoint=$2
-       handler=$3
-       # 0 or more files
-       files=$4
-       # sanity checks
-       if [ -z "$user" -o -z "$endpoint" -o -z "$handler" ]; then
-               echo 'ERR!invalid arguments'
-               return
-       fi
-       for cfgfile in $files; do
-               if [ ! -f "$cfgfile" ]; then
-                       echo "ERR!File $cfgfile is missing."
-                       return
-               fi
-       done
-       if [ ! -x "$MYDIR/$handler.install" ]; then
-               echo "ERR!Cannot execute $MYDIR/$handler.install"
-               return
-       fi
-       message=$("$MYDIR/$handler.install" "$user" "$endpoint" $files)
-       ret=$?
-       if [ $ret = 0 ]; then
-               echo "OK!" "$message"
-       else
-               echo "ERR!Main dispatcher: handler '$handler' returned code $ret"
-       fi
-}
-
-# main loop
-while read cmd arg1 arg2 arg3 arg4; do
-       case $cmd in
-               submit)
-                       do_submit "$arg1" "$arg2" "$arg3" "$arg4"
-                       ;;
-               *)
-                       echo "ERR!unknown command $cmd"
-       esac
-done
-
-exit 0
diff --git a/gateways/switchvlans/cisco.connector b/gateways/switchvlans/cisco.connector
deleted file mode 100755 (executable)
index 5e7d4a6..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-
-[ $# = 7 ] || exit 1
-
-ENDPOINT=$1
-HW=$2
-SW=$3
-COMMAND=$4
-FILE1=$5
-FILE2=$6
-FILE3=$7
-MYDIR=`dirname $0`
-ostype=`uname -s`
-case "$ostype" in
-       Linux)
-       SEDFLAG='-r'
-       ;;
-       FreeBSD)
-       SEDFLAG='-E'
-       ;;
-       *)
-       exit 7
-esac
-
-
-prepare_connect_commands()
-{
-       [ $# = 1 ] || exit 2
-       local skip=yes cval found=no
-       while read line; do
-               if [ "$skip" = "yes" -a "$line" = "# S-T-A-R-T" ]; then
-                       skip=no
-                       continue
-               fi
-               if [ "$skip" = "no" -a "$line" = "# S-T-O-P" ]; then
-                       skip=yes
-                       continue
-               fi
-               [ "$skip" = "yes" ] && continue
-               # Allow comments.
-               [ -z "${line###*}" ] && continue
-
-               # First endpoint string/regexp match is sufficient for us.
-               cval=`echo $line | cut -s -d' ' -f1`
-               if [ -z "${1##$cval}" ]; then
-                       found=yes
-                       # Don't be too smart at the moment, just be able to handle
-                       # the known-good case ;-)
-
-                       username=`echo $line | cut -s -d' ' -f5`
-                       [ "$username" != "-" ] && echo $username > $CMDS1
-                       # access password
-                       echo $line | cut -s -d' ' -f6 >> $CMDS1
-                       enable_password=`echo $line | cut -s -d' ' -f7`
-                       [ "$enable_password" != "-" ] && {
-                               echo en >> $CMDS1
-                               echo $enable_password >> $CMDS1
-                       }
-                       # same for ports
-                       cat "$CMDS1" > "$CMDS2"
-                       # ...and MAC addresses
-                       cat "$CMDS1" > "$CMDS3"
-                       break
-               fi
-       done < "$MYDIR/cisco.secrets.php"
-       [ "$found" = "yes" ] && return
-       echo "E!connector could not find credentials for $1" >> "$FILE2"
-       exit 3
-}
-
-prepare_fetch_commands()
-{
-       printf 'term len 0\nshow vlan brief\nquit\n' >> $CMDS1
-       printf 'term len 0\nshow int status\nquit\n' >> $CMDS2
-       printf 'term len 0\nshow mac-address-table\nquit\n' >> $CMDS3
-}
-
-prepare_push_commands()
-{
-       printf 'term len 0\nconf t\n' >> $CMDS1
-       while read portname vlanid; do
-               if [ -z "$portname" -o -z "$vlanid" ]; then
-                       echo "E!could not parse input in connector" >> "$FILE2"
-                       continue
-               fi
-               if [ "$vlanid" = "trunk" ]; then
-                       echo "E!trunking is not allowed" >> "$FILE2"
-                       continue
-               fi
-               printf "int $portname\n" >> $CMDS1
-               if [ $vlanid -lt 4096 ]; then
-                       printf "no description\n" >> $CMDS1
-               else
-                       printf "descr VLAN$vlanid\n" >> $CMDS1
-               fi
-               "$MYDIR/vlandecoder" $vlanid >> $CMDS1
-               printf "exit\n" >> $CMDS1
-               echo "I!Port $portname@$ENDPOINT has been assigned to VLAN $vlanid" >> "$FILE2"
-       done < "$FILE1"
-       printf "end\nwri\nquit\n" >> $CMDS1
-}
-
-do_fetch()
-{
-       local tmp_ifname tmp_ifdescr tmp_status tmp_vlanid
-       nc $ENDPOINT 23 < $CMDS1 > "$OUT1"
-       if fgrep -q '% Bad passwords' "$OUT1"; then
-               echo "E!password mismatch while trying to connect to $ENDPOINT" >> "$FILE2"
-               exit 4
-       fi
-       nc $ENDPOINT 23 < $CMDS2 > "$OUT2a"
-       nc $ENDPOINT 23 < $CMDS3 > "$OUT3"
-       cat "$OUT1" | fgrep ' active    ' | sed $SEDFLAG 's/^([[:digit:]]+)[[:space:]]+(.+)[[:space:]]+active    (.*)/\1=\2/;s/[[:space:]]+$//' > $FILE1
-       # Add trunk data, if appropriate.
-       [ -s "$MYDIR/vlantable" ] && cat "$MYDIR/vlantable" >> $FILE1
-
-       # First extract structured info about VLAN membership, then map
-       # special descriptions into VLAN IDs.
-       cat "$OUT2a" | egrep '^(Et|Fa|Gi|Te)' | sed $SEDFLAG 's/[~%]/__RTTMP_percent_sign__/g;s/^([A-Za-z/0-9]+) +(.*) +(connected|notconnect|disabled|err-disabled|monitoring|suspended) +/\1~\2%\3%/;s/%(trunk|routed|([0-9]+)) .*$/%\1/;s/%(monitoring|suspended)%/%connected%/;s/%(err-disabled)%/%disabled%/;s/ +%/%/;s/~/%/' > $OUT2b
-       while read line; do
-               tmp_ifname=`echo $line | cut -d% -f1`
-               tmp_ifdescr=`echo $line | cut -d% -f2`
-               tmp_status=`echo $line | cut -d% -f3`
-               tmp_vlanid=`echo $line | cut -d% -f4`
-               # If the port has a description pretending to be a martian VLAN, map it onto the VLAN ID.
-               if [ -n "$tmp_ifdescr" -a -z "${tmp_ifdescr##VLAN*}" ]; then
-                       tmp_vlanid=${tmp_ifdescr##VLAN}
-               fi
-               echo "$tmp_ifname=$tmp_status,$tmp_vlanid" >> $FILE2
-       done < $OUT2b
-       # FIXME
-       # 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" | LC_ALL=C tr -d '\r' | fgrep Dynamic | sed $SEDFLAG 's/ +Dynamic +([0-9]+) +(.+)/=\1@\2/;s/FastEthernet/Fa/;s/GigabitEthernet/Gi/' > "$FILE3"
-       elif [ "$SW" = "Cisco+IOS+12.2" -o "$SW" = "Cisco+IOS+12.1" ]; then
-               case "$HW" in
-                       Cisco+Catalyst+35*|Cisco+Catalyst+37*|Cisco+Catalyst+29*)
-                               cat "$OUT3" | LC_ALL=C tr -d '\r' | egrep 'STATIC|DYNAMIC' | \
-                               sed $SEDFLAG 's/ +([0-9]+|All) +(.+)    (DYNAMIC|STATIC) +(.+)/\2=\1@\4/;s/FastEthernet/Fa/;s/GigabitEthernet/Gi/' > "$FILE3"
-                       ;;
-                       Cisco+Catalyst+49*)
-                               cat "$OUT3" | LC_ALL=C tr -d '\r' | fgrep dynamic | \
-                               sed $SEDFLAG 's/ +([0-9]+) +([0-9a-f\.]+)   dynamic ip +([a-zA-Z/0-9]+) */\2=\1@\3/;s/FastEthernet/Fa/;s/GigabitEthernet/Gi/;s/TenGi/Te/' > "$FILE3"
-                       ;;
-               esac
-       fi
-}
-
-do_push()
-{
-       nc $ENDPOINT 23 < $CMDS1 >/dev/null
-}
-
-remove_tempfiles()
-{
-       [ -f "$CMDS1" ] && rm -f "$CMDS1"
-       [ -f "$CMDS2" ] && rm -f "$CMDS2"
-       [ -f "$CMDS3" ] && rm -f "$CMDS3"
-       [ -f "$OUT1" ] && rm -f "$OUT1"
-       [ -f "$OUT2a" ] && rm -f "$OUT2a"
-       [ -f "$OUT2b" ] && rm -f "$OUT2b"
-       [ -f "$OUT3" ] && rm -f "$OUT3"
-}
-
-create_tempfiles()
-{
-       # This one is for VLAN list.
-       CMDS1=`mktemp /tmp/cisco.connector.XXXXXX`
-       # And this one holds ports list...
-       CMDS2=`mktemp /tmp/cisco.connector.XXXXXX`
-       # ...and one more for MAC address table
-       CMDS3=`mktemp /tmp/cisco.connector.XXXXXX`
-       # The following are buffers to hold the whole switch output
-       # before filtering.
-       OUT1=`mktemp /tmp/cisco.connector.XXXXXX`
-       OUT2a=`mktemp /tmp/cisco.connector.XXXXXX`
-       OUT2b=`mktemp /tmp/cisco.connector.XXXXXX`
-       OUT3=`mktemp /tmp/cisco.connector.XXXXXX`
-       [ -f "$CMDS1" -a -f "$CMDS2" -a -f "$CMDS3" -a -f "$OUT1" -a -f "$OUT2a" -a -f "$OUT2b" -a -f "$OUT3" ] && return
-       echo "E!connector cannot create tempfiles" >> "$FILE2"
-       remove_tempfiles
-       exit 5
-}
-
-case $COMMAND in
-       fetch)
-               create_tempfiles
-               prepare_connect_commands $ENDPOINT
-               prepare_fetch_commands
-               do_fetch
-               remove_tempfiles
-       ;;
-       push)
-               create_tempfiles
-               prepare_connect_commands $ENDPOINT
-               prepare_push_commands
-               do_push
-               remove_tempfiles
-       ;;
-       *)
-               echo "E!unknown command for connector" >> "$FILE2"
-               exit 6
-       ;;
-esac
-
-exit 0
diff --git a/gateways/switchvlans/cisco.secrets.php-sample b/gateways/switchvlans/cisco.secrets.php-sample
deleted file mode 100644 (file)
index e716f54..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php ob_start(); ?>
-
-# Syntax:
-# <endpoint|*> <telnet> <hostname|-> <port|-> <username|-> <line password> <enable password>
-# FIXME: <endpoint|*> <rsh> <username>
-
-# S-T-A-R-T
-switch1 telnet - - - password2 enablepassword
-switch2 telnet - - - password enablepassword
-switch3 telnet - - username3 password3 enablepassword3
-# S-T-O-P
-
-<?php ob_end_clean(); ?>
diff --git a/gateways/switchvlans/main b/gateways/switchvlans/main
deleted file mode 100755 (executable)
index 8149443..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-#!/bin/sh
-
-# This file is a part of RackTables, a datacenter and server room management
-# framework. See accompanying file "COPYING" for the full copyright and
-# licensing information.
-#
-# 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:
-#
-# * connect: connect to a switch, fetch all necessary data, store and
-#   disconnect
-#
-# * 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.
-#
-# * listmacs: output unsorted list of all dynamically learned MAC
-#   addresses present on the switch
-
-endpoint=
-hw=
-sw=
-user=
-handler=
-CONNECTED=0
-MYDIR=`dirname $0`
-
-decode_error()
-{
-       case "$1" in
-               0)
-                       echo -n 'success'
-               ;;
-               1)
-                       echo -n 'internal error 1'
-               ;;
-               2)
-                       echo -n 'internal error 2'
-               ;;
-               3)
-                       echo -n 'password not found'
-               ;;
-               4)
-                       echo -n 'invalid password'
-               ;;
-               5)
-                       echo -n 'cannot create temporary files'
-               ;;
-               6)
-                       echo -n 'invalid command'
-               ;;
-               7)
-                       echo -n 'unknown host OS'
-               ;;
-               *)
-                       echo -n 'unknown error'
-               ;;
-       esac
-}
-
-# Not only connect, but gather all the data at once and remember the context.
-do_connect()
-{
-       endpoint=`echo $args | cut -s -d' ' -f1`
-       hw=`echo $args | cut -s -d' ' -f2`
-       sw=`echo $args | cut -s -d' ' -f3`
-       user=`echo $args | cut -s -d' ' -f4`
-       # sanity checks
-       if [ -z "$endpoint" -o -z "$hw" -o -z "$sw" -o -z "$user" ]; then
-               echo 'ERR!too few arguments to connect'
-               return
-       fi
-       case "$sw" in
-               Cisco+IOS+12.0|Cisco+IOS+12.1|Cisco+IOS+12.2)
-                       handler=cisco
-               ;;
-               *)
-                       echo "ERR!Don't know how to handle $sw on $endpoint"
-                       return
-               ;;
-       esac
-
-       # prepare temp files
-       PORTINFO=`mktemp /tmp/racktables.XXXXXX`
-       if ! [ -f "$PORTINFO" ]; then
-               echo 'ERR!could not create portinfo tmpfile'
-               return
-       fi
-       VLANINFO=`mktemp /tmp/racktables.XXXXXX`
-       if ! [ -f "$VLANINFO" ]; then
-               echo 'ERR!could not create vlaninfo tmpfile'
-               rm -f "$PORTINFO"
-               return
-       fi
-       MACINFO=`mktemp /tmp/racktables.XXXXXX`
-       if ! [ -f "$MACINFO" ]; then
-               echo 'ERR!could not create MACinfo tmpfile'
-               rm -f "$PORTINFO" "$VLANINFO"
-               return
-       fi
-
-       # get the data
-       "$MYDIR/$handler.connector" $endpoint $hw $sw fetch "$VLANINFO" "$PORTINFO" "$MACINFO"
-       ret=$?
-       if [ $ret = 0 ]; then
-               CONNECTED=1
-               echo "OK!connected to $endpoint";
-       else
-               echo -n "ERR!Cannot connect to $endpoint ("
-               decode_error $ret
-               echo ')'
-       fi
-}
-
-do_listfile()
-{
-       local F=$1
-       if ! [ -f "$F" ]; then
-               echo "ERR!Lost temp file '$F' on the way"
-               return
-       fi
-       echo -n 'OK!'
-       local semicolon=''
-       # tr might do the work, but use our chance to perform filtering once more
-       cat "$F" | while read line; do
-               [ "$line" = "" ] && continue
-               echo -n "$semicolon$line"
-               semicolon=';'
-       done
-       echo
-}
-
-do_set()
-{
-       # sanity checks
-       local setline=$1
-       if [ -z "$setline" ]; then
-               echo 'ERR!missing set argument'
-               return
-       fi
-       local REQUESTS=`mktemp /tmp/racktables.XXXXXX`
-       local REPLIES=`mktemp /tmp/racktables.XXXXXX`
-       echo $1 | tr ';' '\n' | while read setexpr; do
-               portname=`echo $setexpr | cut -s -d'=' -f1`
-               newvlan=`echo $setexpr | cut -s -d'=' -f2`
-               curvlan=`egrep "^$portname=" $PORTINFO | cut -s -d'=' -f2 | cut -d',' -f2`
-               if [ -z "$curvlan" ]; then
-                       echo "E!Could not find port $portname" >> "$REPLIES"
-                       continue
-               fi
-               if [ "$curvlan" = "trunk" ]; then
-                       echo "E!Port $portname is a trunk" >> "$REPLIES"
-                       continue
-               fi
-               [ "$curvlan" = "$newvlan" ] && continue
-               echo "$portname $newvlan" >> "$REQUESTS"
-               cmembers=`grep -c ",$newvlan$" "$PORTINFO"`
-               if [ "$cmembers" = "0" -a $newvlan -lt 4096 ]; then
-                       echo "W!Port $portname seems to be the first in VLAN $newvlan at this switch" >> "$REPLIES"
-                       echo "W!Check uplink/downlink configuration for proper operation" >> "$REPLIES"
-               fi
-       done
-       nr=`egrep -c '^E!.' "$REPLIES"`
-       if [ "$nr" -ge 1 ]; then
-               echo "W!$nr change request(s) have been ignored" >> "$REPLIES"
-       fi
-
-       nq=`egrep -c '^.' "$REQUESTS"`
-       if [ "$nq" -ge 1 ]; then
-               # Go!
-               "$MYDIR/$handler.connector" $endpoint $hw $sw push "$REQUESTS" "$REPLIES" "$MACINFO"
-               local ret=$?
-
-               if [ $ret != 0 ]; then
-                       echo "ERR!Failed to configure $endpoint, connector returned code $ret"
-                       return
-               fi
-               echo "I!$nq change request(s) have been processed" >> "$REPLIES"
-       fi
-       echo -n 'OK!'
-       local SEMICOLON=
-       while read reply; do
-               echo -n $SEMICOLON$reply
-               SEMICOLON=';'
-               timestamp=`date '+%Y-%m-%d %H:%M:%S'`
-               [ -w "$MYDIR/changes.log" ] && echo "$timestamp $user@$endpoint $reply" >> "$MYDIR/changes.log"
-       done < "$REPLIES"
-       echo
-       rm -f "$REQUESTS" "$REPLIES"
-}
-
-# main loop
-while read cmd args; do
-       case $cmd in
-               connect)
-                       if [ $CONNECTED = 1 ]; then
-                               echo 'ERR!Already connected'
-                       else
-                               do_connect $args
-                       fi
-                       ;;
-               listvlans)
-                       if [ $CONNECTED = 1 ]; then
-                               do_listfile "$VLANINFO"
-                       else
-                               echo 'ERR!Not connected'
-                       fi
-                       ;;
-               listports)
-                       if [ $CONNECTED = 1 ]; then
-                               do_listfile "$PORTINFO"
-                       else
-                               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
-                       else
-                               echo 'ERR!Not connected'
-                       fi
-                       ;;
-               *)
-                       echo "ERR!unknown command $cmd"
-       esac
-done
-
-rm -f "$PORTINFO" "$VLANINFO" "$MACINFO"
-exit 0
diff --git a/gateways/switchvlans/vlandecoder-sample b/gateways/switchvlans/vlandecoder-sample
deleted file mode 100755 (executable)
index e1cdf39..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-[ $# = 1 ] || exit 1
-
-case $1 in
-       6001)
-               NATIVE=100
-               ;;
-       6002)
-               NATIVE=200
-               ;;
-       *)
-               exit 2
-               ;;
-esac
-VOICE=300
-
-echo switchport trunk native vlan $NATIVE
-echo switchport trunk allowed vlan $NATIVE,$VOICE
-echo switchport voice vlan $VOICE
-echo spanning-tree portfast trunk
diff --git a/gateways/switchvlans/vlantable-sample b/gateways/switchvlans/vlantable-sample
deleted file mode 100644 (file)
index 7ece953..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-6001=tech-and-phone
-6002=mgmt-and-phone
index 6d98cee..2e8609c 100644 (file)
@@ -4,20 +4,6 @@
 # framework. See accompanying file "COPYING" for the full copyright and
 # licensing information.
 
-/*
-*
-*  This file contains gateway functions for RackTables.
-*  A gateway is an external executable, which provides
-*  read-only or read-write access to some external entities.
-*  Each gateway accepts its own list of command-line args
-*  and then reads its stdin for requests. Each request consists
-*  of one line and results in exactly one line of reply.
-*  The replies must have the following syntax:
-*  OK<space>any text up to the end of the line
-*  ERR<space>any text up to the end of the line
-*
-*/
-
 // translating functions maps
 $breedfunc = array
 (
@@ -107,249 +93,6 @@ $breedfunc = array
        'ucs-getinventory-main'    => 'ucsReadInventory',
 );
 
-// This function launches specified gateway with specified
-// command-line arguments and feeds it with the commands stored
-// in the second arg as array.
-// The answers are stored in another array, which is returned
-// by this function. In the case when a gateway cannot be found,
-// finishes prematurely or exits with non-zero return code,
-// a single-item array is returned with the only "ERR" record,
-// which explains the reason.
-function queryGateway ($gwname, $questions)
-{
-       global $racktables_gwdir;
-       $execpath = "${racktables_gwdir}/{$gwname}/main";
-       $dspec = array
-       (
-               0 => array ("pipe", "r"),
-               1 => array ("pipe", "w"),
-               2 => array ("file", "/dev/null", "a")
-       );
-       $pipes = array();
-       $gateway = proc_open ($execpath, $dspec, $pipes);
-       if (!is_resource ($gateway))
-               return array ('ERR proc_open() failed in ' . __FUNCTION__);
-
-// Dialogue starts. Send all questions.
-       foreach ($questions as $q)
-               fwrite ($pipes[0], "$q\n");
-       fclose ($pipes[0]);
-
-// Fetch replies.
-       $answers = array ();
-       while (!feof($pipes[1]))
-       {
-               $a = fgets ($pipes[1]);
-               if (!strlen ($a))
-                       continue;
-               // Somehow I got a space appended at the end. Kick it.
-               $answers[] = trim ($a);
-       }
-       fclose($pipes[1]);
-
-       $retval = proc_close ($gateway);
-       if ($retval != 0)
-               throw new RTGatewayError ("gateway failed with code ${retval}");
-       if (!count ($answers))
-               throw new RTGatewayError ('no response from gateway');
-       if (count ($answers) != count ($questions))
-               throw new RTGatewayError ('protocol violation');
-       foreach ($answers as $a)
-               if (strpos ($a, 'OK!') !== 0)
-                       throw new RTGatewayError ("subcommand failed with status: ${a}");
-       return $answers;
-}
-
-// This functions returns an array for VLAN list, and an array for port list (both
-// form another array themselves) and another one with MAC address list.
-// The ports in the latter array are marked with either VLAN ID or 'trunk'.
-// We don't sort the port list, as the gateway is believed to have done this already
-// (or at least the underlying switch software ought to). This is important, as the
-// port info is transferred to/from form not by names, but by numbers.
-function getSwitchVLANs ($object_id = 0)
-{
-       global $remote_username;
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       $hwtype = $swtype = 'unknown';
-       foreach (getAttrValues ($object_id) as $record)
-       {
-               if ($record['name'] == 'SW type' && strlen ($record['o_value']))
-                       $swtype = str_replace (' ', '+', execGMarker ($record['o_value']));
-               if ($record['name'] == 'HW type' && strlen ($record['o_value']))
-                       $hwtype = str_replace (' ', '+', execGMarker ($record['o_value']));
-       }
-       $endpoint = str_replace (' ', '+', $endpoints[0]);
-       $commands = array
-       (
-               "connect ${endpoint} ${hwtype} ${swtype} ${remote_username}",
-               'listvlans',
-               'listports',
-               'listmacs'
-       );
-       $data = queryGateway ('switchvlans', $commands);
-       if (strpos ($data[0], 'OK!') !== 0)
-               throw new RTGatewayError ("gateway failed with status: ${data[0]}.");
-       // Now we have VLAN list in $data[1] and port list in $data[2]. Let's sort this out.
-       $tmp = array_unique (explode (';', substr ($data[1], strlen ('OK!'))));
-       if (count ($tmp) == 0)
-               throw new RTGatewayError ('gateway returned no records');
-       $vlanlist = array();
-       foreach ($tmp as $record)
-       {
-               list ($vlanid, $vlandescr) = explode ('=', $record);
-               $vlanlist[$vlanid] = $vlandescr;
-       }
-       $portlist = array();
-       foreach (explode (';', substr ($data[2], strlen ('OK!'))) as $pair)
-       {
-               list ($portname, $pair2) = explode ('=', $pair);
-               list ($status, $vlanid) = explode (',', $pair2);
-               $portlist[] = array ('portname' => $portname, 'status' => $status, 'vlanid' => $vlanid);
-       }
-       if (count ($portlist) == 0)
-               throw new RTGatewayError ('gateway returned no records');
-       $maclist = array();
-       foreach (explode (';', substr ($data[3], strlen ('OK!'))) as $pair)
-               if (preg_match ('/^([^=]+)=(.+)/', $pair, $m))
-               {
-                       $macaddr = $m[1];
-                       list ($vlanid, $ifname) = explode ('@', $m[2]);
-                       $maclist[$ifname][$vlanid][] = $macaddr;
-               }
-       return array ($vlanlist, $portlist, $maclist);
-}
-
-function setSwitchVLANs ($object_id = 0, $setcmd)
-{
-       global $remote_username;
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       $hwtype = $swtype = 'unknown';
-       foreach (getAttrValues ($object_id) as $record)
-       {
-               if ($record['name'] == 'SW type' && strlen ($record['o_value']))
-                       $swtype = strtr (execGMarker ($record['o_value']), ' ', '+');
-               if ($record['name'] == 'HW type' && strlen ($record['o_value']))
-                       $hwtype = strtr (execGMarker ($record['o_value']), ' ', '+');
-       }
-       $endpoint = str_replace (' ', '+', $endpoints[0]);
-       $data = queryGateway
-       (
-               'switchvlans',
-               array ("connect ${endpoint} ${hwtype} ${swtype} ${remote_username}", $setcmd)
-       );
-       // Finally we can parse the response into message array.
-       foreach (explode (';', substr ($data[1], strlen ('OK!'))) as $text)
-       {
-               $message = 'gw: ' . substr ($text, 2);
-               if (strpos ($text, 'I!') === 0)
-                       showSuccess ($message); // generic gateway success
-               elseif (strpos ($text, 'W!') === 0)
-                       showWarning ($message); // generic gateway warning
-               elseif (strpos ($text, 'E!') === 0)
-                       showError ($message); // generic gateway error
-               else // All improperly formatted messages must be treated as error conditions.
-                       showError ('unexpected line from gw: ' . $text);
-       }
-}
-
-// Drop a file off RackTables platform. The gateway will catch the file and pass it to the given
-// installer script.
-// On success returns the text string printed by sendfile handler
-// On failure throws an exception
-function gwSendFile ($endpoint, $handlername, $filetext = array())
-{
-       $result = '';
-       if (! is_array ($filetext))
-               throw new InvalidArgException ('filetext', '(suppressed)', 'is not an array');
-       global $remote_username;
-       $tmpnames = array();
-       $endpoint = str_replace (' ', '\ ', $endpoint); // the gateway dispatcher uses read (1) to assign arguments
-       $command = "submit ${remote_username} ${endpoint} ${handlername}";
-       foreach ($filetext as $text)
-       {
-               $name = tempnam ('', 'RackTables-sendfile-');
-               $tmpnames[] = $name;
-               if (FALSE === $name or FALSE === file_put_contents ($name, $text))
-               {
-                       foreach ($tmpnames as $name)
-                               unlink ($name);
-                       throw new RTGatewayError ('failed to write to temporary file');
-               }
-               $command .= " ${name}";
-       }
-       try
-       {
-               $answers = queryGateway ('sendfile', array ($command));
-               $result = preg_replace ('/^OK!\s*/', '', array_shift ($answers));
-               foreach ($tmpnames as $name)
-                       unlink ($name);
-       }
-       catch (RTGatewayError $e)
-       {
-               foreach ($tmpnames as $name)
-                       unlink ($name);
-               throw new RTGatewayError ("Sending $handlername to $endpoint: " . $e->getMessage());
-       }
-       return $result;
-}
-
-// Query something through a gateway and get some text in return. Return that text.
-function gwRecvFile ($endpoint, $handlername, &$output)
-{
-       global $remote_username;
-       $tmpfilename = tempnam ('', 'RackTables-sendfile-');
-       $endpoint = str_replace (' ', '\ ', $endpoint); // the gateway dispatcher uses read (1) to assign arguments
-       try
-       {
-               queryGateway ('sendfile', array ("submit ${remote_username} ${endpoint} ${handlername} ${tmpfilename}"));
-               $output = file_get_contents ($tmpfilename);
-               unlink ($tmpfilename);
-       }
-       catch (RTGatewayError $e)
-       {
-               unlink ($tmpfilename);
-               throw $e;
-       }
-       if ($output === FALSE)
-               throw new RTGatewayError ('failed to read temporary file');
-}
-
-function gwSendFileToObject ($object_id, $handlername, $filetext = '')
-{
-       if (!mb_strlen ($handlername))
-               throw new InvalidArgException ('$handlername');
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       return gwSendFile (str_replace (' ', '+', $endpoints[0]), $handlername, array ($filetext));
-}
-
-function gwRecvFileFromObject ($object_id, $handlername, &$output)
-{
-       if (!mb_strlen ($handlername))
-               throw new InvalidArgException ('$handlername');
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       gwRecvFile (str_replace (' ', '+', $endpoints[0]), $handlername, $output);
-}
-
 function detectDeviceBreed ($object_id)
 {
        $breed_by_swcode = array
@@ -420,64 +163,4 @@ function assertBreedFunction ($breed, $command)
                throw new RTGatewayError ('unsupported command for this breed');
 }
 
-function gwRetrieveDeviceConfig ($object_id, $command)
-{
-       require_once 'deviceconfig.php';
-       global $breedfunc;
-       $breed = detectDeviceBreed ($object_id);
-       assertBreedFunction ($breed, $command);
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       $endpoint = str_replace (' ', '\ ', str_replace (' ', '+', $endpoints[0]));
-       $tmpfilename = tempnam ('', 'RackTables-deviceconfig-');
-       try
-       {
-               queryGateway ('deviceconfig', array ("${command} ${endpoint} ${breed} ${tmpfilename}"));
-               $configtext = file_get_contents ($tmpfilename);
-               unlink ($tmpfilename);
-       }
-       catch (RTGatewayError $e)
-       {
-               unlink ($tmpfilename);
-               throw $e;
-       }
-       if ($configtext === FALSE)
-               throw new RTGatewayError ('failed to read temporary file');
-       // Being here means it was alright.
-       return $breedfunc["${breed}-${command}-main"] (dos2unix ($configtext));
-}
-
-function gwDeployDeviceConfig ($object_id, $breed, $text)
-{
-       if ($text == '')
-               throw new InvalidArgException ('text', '', 'deploy text is empty');
-       $objectInfo = spotEntity ('object', $object_id);
-       $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
-       if (count ($endpoints) == 0)
-               throw new RTGatewayError ('no management address set');
-       if (count ($endpoints) > 1)
-               throw new RTGatewayError ('cannot pick management address');
-       $endpoint = str_replace (' ', '\ ', str_replace (' ', '+', $endpoints[0]));
-       $tmpfilename = tempnam ('', 'RackTables-deviceconfig-');
-       if (FALSE === file_put_contents ($tmpfilename, $text))
-       {
-               unlink ($tmpfilename);
-               throw new RTGatewayError ('failed to write to temporary file');
-       }
-       try
-       {
-               queryGateway ('deviceconfig', array ("deploy ${endpoint} ${breed} ${tmpfilename}"));
-               unlink ($tmpfilename);
-       }
-       catch (RTGatewayError $e)
-       {
-               unlink ($tmpfilename);
-               throw $e;
-       }
-}
-
 ?>
index 02fdca6..14e72a8 100644 (file)
@@ -4593,184 +4593,6 @@ function renderUIConfigEditForm ()
        finishPortlet();
 }
 
-// This function queries the gateway about current VLAN configuration and
-// renders a form suitable for submit. Ah, and it does submit processing as well.
-function renderVLANMembership ($object_id)
-{
-       try
-       {
-               $data = getSwitchVLANs ($object_id);
-       }
-       catch (RTGatewayError $re)
-       {
-               showWarning ('Device configuration unavailable:<br>' . $re->getMessage());
-               return;
-       }
-       list ($vlanlist, $portlist, $maclist) = $data;
-       $vlanpermissions = array();
-       foreach ($portlist as $port)
-       {
-               if (array_key_exists ($port['vlanid'], $vlanpermissions))
-                       continue;
-               $vlanpermissions[$port['vlanid']] = array();
-               foreach (array_keys ($vlanlist) as $to)
-                       if
-                       (
-                               permitted (NULL, NULL, 'setPortVLAN', array (array ('tag' => '$fromvlan_' . $port['vlanid']), array ('tag' => '$vlan_' . $port['vlanid']))) and
-                               permitted (NULL, NULL, 'setPortVLAN', array (array ('tag' => '$tovlan_' . $to), array ('tag' => '$vlan_' . $to)))
-                       )
-                               $vlanpermissions[$port['vlanid']][] = $to;
-       }
-
-       if (isset ($_REQUEST['hl_port_id']))
-       {
-               assertUIntArg ('hl_port_id');
-               $hl_port_id = intval ($_REQUEST['hl_port_id']);
-               $object = spotEntity ('object', $object_id);
-               amplifyCell ($object);
-               foreach ($object['ports'] as $port)
-                       if (mb_strlen ($port['name']) && $port['id'] == $hl_port_id)
-                       {
-                               $hl_port_name = $port['name'];
-                               break;
-                       }
-       }
-
-       echo '<table border=0 width="100%"><tr><td colspan=3>';
-       startPortlet ('Current status');
-       echo "<table class=widetable cellspacing=3 cellpadding=5 align=center width='100%'><tr>";
-       printOpFormIntro ('setPortVLAN');
-       $portcount = count ($portlist);
-       echo "<input type=hidden name=portcount value=" . $portcount . ">\n";
-       $portno = 0;
-       $ports_per_row = getConfigVar ('PORTS_PER_ROW');
-       foreach ($portlist as $port)
-       {
-               // Don't let wide forms break our fancy pages.
-               if ($portno % $ports_per_row == 0)
-               {
-                       if ($portno > 0)
-                               echo "</tr>\n";
-                       echo "<tr><th>" . ($portno + 1) . "-" . ($portno + $ports_per_row > $portcount ? $portcount : $portno + $ports_per_row) . "</th>";
-               }
-               $td_class = 'port_';
-               if ($port['status'] == 'notconnect')
-                       $td_class .= 'notconnect';
-               elseif ($port['status'] == 'disabled')
-                       $td_class .= 'disabled';
-               elseif ($port['status'] != 'connected')
-                       $td_class .= 'unknown';
-               elseif (!isset ($maclist[$port['portname']]))
-                       $td_class .= 'connected_none';
-               else
-               {
-                       $maccount = 0;
-                       foreach ($maclist[$port['portname']] as $vlanid => $addrs)
-                               $maccount += count ($addrs);
-                       if ($maccount == 1)
-                               $td_class .= 'connected_single';
-                       else
-                               $td_class .= 'connected_multi';
-               }
-               if (isset ($hl_port_name) and strcasecmp ($hl_port_name, $port['portname']) == 0)
-                       $td_class .= (strlen($td_class) ? ' ' : '') . 'border_highlight';
-               echo "<td class='$td_class'>" . $port['portname'] . '<br>';
-               echo "<input type=hidden name=portname_${portno} value=" . $port['portname'] . '>';
-               if ($port['vlanid'] == 'trunk')
-               {
-                       echo "<input type=hidden name=vlanid_${portno} value='trunk'>";
-                       echo "<select disabled multiple='multiple' size=1><option>TRUNK</option></select>";
-               }
-               elseif ($port['vlanid'] == 'routed')
-               {
-                       echo "<input type=hidden name=vlanid_${portno} value='routed'>";
-                       echo "<select disabled multiple='multiple' size=1><option>ROUTED</option></select>";
-               }
-               elseif (!array_key_exists ($port['vlanid'], $vlanpermissions) or !count ($vlanpermissions[$port['vlanid']]))
-               {
-                       echo "<input type=hidden name=vlanid_${portno} value=${port['vlanid']}>";
-                       echo "<select disabled name=vlanid_${portno}>";
-                       echo "<option value=${port['vlanid']} selected>${port['vlanid']}</option>";
-                       echo "</select>";
-               }
-               else
-               {
-                       echo "<select name=vlanid_${portno}>";
-                       // A port may belong to a VLAN, which is absent from the VLAN table, this is normal.
-                       // We must be able to render its SELECT properly at least.
-                       $in_table = FALSE;
-                       foreach ($vlanpermissions[$port['vlanid']] as $v)
-                       {
-                               echo "<option value=${v}";
-                               if ($v == $port['vlanid'])
-                               {
-                                       echo ' selected';
-                                       $in_table = TRUE;
-                               }
-                               echo ">${v}</option>\n";
-                       }
-                       if (!$in_table)
-                               echo "<option value=${port['vlanid']} selected>${port['vlanid']}</option>\n";
-                       echo "</select>";
-               }
-               $portno++;
-               echo "</td>";
-       }
-       echo "</tr><tr><td colspan=" . ($ports_per_row + 1) . "><input type=submit value='Save changes'></form></td></tr></table>";
-       finishPortlet();
-
-       echo '</td></tr><tr><td class=pcleft>';
-       startPortlet ('VLAN table');
-       echo '<table class=cooltable cellspacing=0 cellpadding=5 align=center width="100%">';
-       echo "<tr><th>ID</th><th>Description</th></tr>";
-       $order = 'even';
-       global $nextorder;
-       foreach ($vlanlist as $id => $descr)
-       {
-               echo "<tr class=row_${order}><td class=tdright>${id}</td><td class=tdleft>${descr}</td></tr>";
-               $order = $nextorder[$order];
-       }
-       echo '</table>';
-       finishPortlet();
-
-       echo '</td><td class=pcright>';
-
-       startPortlet ('Color legend');
-       echo '<table>';
-       echo "<tr><th>port state</th><th>color code</th></tr>";
-       echo "<tr><td>not connected</td><td class=port_notconnect>SAMPLE</td></tr>";
-       echo "<tr><td>disabled</td><td class=port_disabled>SAMPLE</td></tr>";
-       echo "<tr><td>unknown</td><td class=port_unknown>SAMPLE</td></tr>";
-       echo "<tr><td>connected with none MAC addresses active</td><td class=port_connected_none>SAMPLE</td></tr>";
-       echo "<tr><td>connected with 1 MAC addresses active</td><td class=port_connected_single>SAMPLE</td></tr>";
-       echo "<tr><td>connected with 1+ MAC addresses active</td><td class=port_connected_multi>SAMPLE</td></tr>";
-       echo '</table>';
-       finishPortlet();
-
-       echo '</td><td class=pcright>';
-
-       if (count ($maclist))
-       {
-               startPortlet ('MAC address table');
-               echo '<table border=0 class=cooltable align=center cellspacing=0 cellpadding=5>';
-               echo "<tr><th>Port</th><th>VLAN ID</th><th>MAC address</th></tr>\n";
-               $order = 'even';
-               foreach ($maclist as $portname => $portdata)
-                       foreach ($portdata as $vlanid => $addrgroup)
-                               foreach ($addrgroup as $addr)
-                               {
-                                       echo "<tr class=row_${order}><td class=tdleft>$portname</td><td class=tdleft>$vlanid</td>";
-                                       echo "<td class=tdleft>$addr</td></tr>\n";
-                                       $order = $nextorder[$order];
-                               }
-               echo '</table>';
-               finishPortlet();
-       }
-
-       // End of main table.
-       echo '</td></tr></table>';
-}
-
 function renderSNMPPortFinder ($object_id)
 {
        if (!extension_loaded ('snmp'))
index ae4b0a2..488ee4a 100644 (file)
@@ -151,7 +151,6 @@ $tab['object']['rackspace'] = 'Rackspace';
 $tab['object']['ports'] = 'Ports';
 $tab['object']['ip'] = 'IP';
 $tab['object']['nat4'] = 'NATv4';
-$tab['object']['livevlans'] = 'Live VLANs';
 $tab['object']['liveports'] = 'Live ports';
 $tab['object']['livecdp'] = 'Live CDP';
 $tab['object']['livelldp'] = 'Live LLDP';
@@ -173,7 +172,6 @@ $tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
 $tabhandler['object']['ports'] = 'renderPortsForObject';
 $tabhandler['object']['ip'] = 'renderIPForObject';
 $tabhandler['object']['nat4'] = 'renderNATv4ForObject';
-$tabhandler['object']['livevlans'] = 'renderVLANMembership';
 $tabhandler['object']['liveports'] = 'renderPortsInfo';
 $tabhandler['object']['livecdp'] = 'renderDiscoveredNeighbors';
 $tabhandler['object']['livelldp'] = 'renderDiscoveredNeighbors';
@@ -192,7 +190,6 @@ $trigger['object']['rackspace'] = 'trigger_rackspace';
 $trigger['object']['ports'] = 'trigger_ports';
 $trigger['object']['ip'] = 'trigger_ip';
 $trigger['object']['nat4'] = 'trigger_natv4';
-$trigger['object']['livevlans'] = 'trigger_livevlans';
 $trigger['object']['liveports'] = 'trigger_liveports';
 $trigger['object']['livecdp'] = 'trigger_LiveCDP';
 $trigger['object']['livelldp'] = 'trigger_LiveLLDP';
@@ -228,7 +225,6 @@ $ophandler['object']['log']['del'] = 'tableHandler';
 $ophandler['object']['nat4']['addNATv4Rule'] = 'addPortForwarding';
 $ophandler['object']['nat4']['delNATv4Rule'] = 'delPortForwarding';
 $ophandler['object']['nat4']['updNATv4Rule'] = 'updPortForwarding';
-$ophandler['object']['livevlans']['setPortVLAN'] = 'setPortVLAN';
 $ophandler['object']['livecdp']['importDPData'] = 'importDPData';
 $ophandler['object']['livelldp']['importDPData'] = 'importDPData';
 $ophandler['object']['autoports']['generate'] = 'generateAutoPorts';
@@ -255,7 +251,6 @@ $ophandler['object']['cacti']['del'] = 'tableHandler';
 $ophandler['object']['ucs']['autoPopulateUCS'] = 'autoPopulateUCS';
 $ophandler['object']['ucs']['cleanupUCS'] = 'cleanupUCS';
 $delayauth['object-8021qports-save8021QConfig'] = TRUE;
-$delayauth['object-livevlans-setPortVLAN'] = TRUE;
 $delayauth['object-8021qorder-add'] = TRUE;
 $delayauth['object-8021qorder-del'] = TRUE;
 
index 279e5f9..262e32b 100644 (file)
@@ -1779,72 +1779,6 @@ function saveRackCode ()
        return showFuncMessage (__FUNCTION__, 'OK');
 }
 
-$msgcode['setPortVLAN']['ERR'] = 164;
-// This handler's context is pre-built, but not authorized. It is assumed, that the
-// handler will take existing context and before each commit check authorization
-// on the base chain plus necessary context added.
-function setPortVLAN ()
-{
-       assertUIntArg ('portcount');
-       try
-       {
-               $data = getSwitchVLANs ($_REQUEST['object_id']);
-       }
-       catch (RTGatewayError $re)
-       {
-               return showFuncMessage (__FUNCTION__, 'ERR', array ($re->getMessage()));
-       }
-       list ($vlanlist, $portlist) = $data;
-       // Here we just build up 1 set command for the gateway with all of the ports
-       // included. The gateway is expected to filter unnecessary changes silently
-       // and to provide a list of responses with either error or success message
-       // for each of the rest.
-       $nports = $_REQUEST['portcount'];
-       $prefix = 'set ';
-       $setcmd = '';
-       for ($i = 0; $i < $nports; $i++)
-       {
-               genericAssertion ('portname_' . $i, 'string');
-               genericAssertion ('vlanid_' . $i, 'string');
-               if ($_REQUEST['portname_' . $i] != $portlist[$i]['portname'])
-                       throw new InvalidRequestArgException ('portname_' . $i, $_REQUEST['portname_' . $i], 'expected to be ' . $portlist[$i]['portname']);
-               if
-               (
-                       $_REQUEST['vlanid_' . $i] == $portlist[$i]['vlanid'] ||
-                       $portlist[$i]['vlanid'] == 'TRUNK'
-               )
-                       continue;
-               $portname = $_REQUEST['portname_' . $i];
-               $oldvlanid = $portlist[$i]['vlanid'];
-               $newvlanid = $_REQUEST['vlanid_' . $i];
-               if
-               (
-                       !permitted (NULL, NULL, NULL, array (array ('tag' => '$fromvlan_' . $oldvlanid), array ('tag' => '$vlan_' . $oldvlanid))) or
-                       !permitted (NULL, NULL, NULL, array (array ('tag' => '$tovlan_' . $newvlanid), array ('tag' => '$vlan_' . $newvlanid)))
-               )
-               {
-                       showOneLiner (159, array ($portname, $oldvlanid, $newvlanid));
-                       continue;
-               }
-               $setcmd .= $prefix . $portname . '=' . $newvlanid;
-               $prefix = ';';
-       }
-       // Feed the gateway and interpret its (non)response.
-       if ($setcmd == '')
-               showOneLiner (201);
-       else
-       {
-               try
-               {
-                       setSwitchVLANs ($_REQUEST['object_id'], $setcmd); // shows messages by itself
-               }
-               catch (RTGatewayError $e)
-               {
-                       showFuncMessage (__FUNCTION__, 'ERR', array ($e->getMessage()));
-               }
-       }
-}
-
 function submitSLBConfig ()
 {
        showNotice ("You should redefine submitSLBConfig ophandler in your local extension to install SLB config");
index 38a14c3..736bcad 100644 (file)
@@ -68,22 +68,6 @@ function checkTypeAndAttribute ($object_id, $type_id, $attr_id, $values, $hit =
        return '';
 }
 
-// This trigger filters out everything except switches with known-good
-// software.
-function trigger_livevlans ()
-{
-       return checkTypeAndAttribute
-       (
-               getBypassValue(),
-               8, // network switch
-               4, // SW type
-               // Cisco IOS 12.0
-               // Cisco IOS 12.1
-               // Cisco IOS 12.2
-               array (244, 251, 252)
-       );
-}
-
 // This trigger is on when any of the (get_mac_list, get_link_status) ops permitted
 function trigger_liveports ()
 {