Commit fe3f6f9a authored by Leigh B. Stoller's avatar Leigh B. Stoller

Two changes:

1. Redirect to outer emulab XMLRPC server when invoked from an inner
   emulab (as it is from the newnode web page). The XMLRPC server
   constructs the response using the interfaces and wires table
   entries for the nodes in the inner emulab.

2. Changes hardwired "experimental" and "control" strings to libdb
   defs (which are actually different strings, but since no one
   actually looks at that part of the switchmac return, the change is
   not going to bother anyone.
parent 80d3ea3d
......@@ -2,7 +2,7 @@
# Copyright (c) 2003 University of Utah and the Flux Group.
# Copyright (c) 2003, 2005 University of Utah and the Flux Group.
# All rights reserved.
......@@ -20,11 +20,12 @@
# <interface> is the <node>:<iface> of the interface that matches the MAC
# address, if any. 'unknown' if the MAC is not in our database
# <class> is 'experimental' or 'control', depending on the primary function
# of the switch the MAC address was learned from
# of the switch the MAC address was learned from.
use lib '@prefix@/lib';
use libdb;
use libxmlrpc;
use snmpit_lib;
use snmpit_cisco;
use snmpit_foundry;
......@@ -33,6 +34,10 @@ use SNMP;
use strict;
# We use SNMP directly, because we have to use some pretty dumb tricks that I
......@@ -42,8 +47,6 @@ my $mibpath = "/usr/local/share/snmp/mibs";
my @mibs = ("$mibpath/SNMPv2-SMI.txt", "$mibpath/SNMPv2-TC.txt",
"$mibpath/SNMPv2-MIB.txt", "$mibpath/IANAifType-MIB.txt",
"$mibpath/IF-MIB.txt", "$mibpath/BRIDGE-MIB.txt");
# Don't know what damage users could do with this script, but why not, let's be
......@@ -57,6 +60,40 @@ if (@ARGV) {
die "usage: $0\n";
# ElabinElab is special; Ask outer boss for the info.
libxmlrpc::Config({"server" => $RPCSERVER,
"verbose" => 0,
"cert" => $RPCCERT,
"portnum" => $RPCPORT});
my $rval = libxmlrpc::CallMethod("elabinelab", "switchmac", {});
if (!defined($rval)) {
# Convert the stuff the RPC server back into the proper string format.
foreach my $mac (keys(%{ $rval })) {
my $aref = $rval->{$mac};
my $iface = $aref->{"iface"};
my $role = $aref->{"role"};
my $switch_id = $aref->{"switch_id"};
my $switch_card = $aref->{"switch_card"};
my $switch_port = $aref->{"switch_port"};
print "${mac},${switch_id}/${switch_card}.${switch_port},".
# Yeah, it's slow, but we want to use all the test switches so that we don't
# have to worry about missing something, and don't have to get the user to
......@@ -93,6 +130,9 @@ foreach my $switchref (@switches) {
my ($switch, $class) = @$switchref;
DEBUG "Looking at switch $switch, class $class\n";
my $class_str = (($class eq "experimental") ?
# I have _no_ idea if this will work on other switches!
......@@ -344,7 +384,7 @@ SWITCH:
next if ((!$realports{$index}) ||
($realports{$index} =~ /ifIndex/));
print "$MACs{$index},$realports{$index},$vlan_number,".
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment