3 # This file is a part of RackTables, a datacenter and server room management
4 # framework. See accompanying file "COPYING" for the full copyright and
5 # licensing information.
7 # This gateway retrieves the output of "show run" command (or its
8 # equivalent) and prints it onto stdout. When run, it accepts the
9 # following commands on stdin:
11 # * get8021q <endpoint> <handler> <outputfile>
12 # (save remote config text into provided local file)
14 # * getcdpstatus <endpoint> <handler> <outputfile>
15 # (save remote status text into provided local file)
17 # * deploy <endpoint> <handler> <inputfile>
18 # (execute given text in privileged mode)
26 echo -n 'invalid connector args'
29 echo -n 'internal error 2'
32 echo -n 'password not found'
35 echo -n 'netcat failed'
38 echo -n 'cannot create temporary files'
41 echo -n 'command not supported by device'
44 echo -n "unknown error $1"
49 while read command endpoint handler conftext
; do
51 if [ -z "$endpoint" -o -z "$conftext" -o -z "$handler" -o -z "$command" ]; then
52 echo 'ERR!too few arguments in command'
55 [ -x "$MYDIR/$handler.connector" ] ||
{
56 echo "ERR!Connector '$handler' is not available"
59 "$MYDIR/$handler.connector" $endpoint $command "$conftext"
62 echo "OK!request '$command' complete for $endpoint"
64 echo -n "ERR!connector error ("
70 # all error messages have been sent to stdout