Commit 0a004176 authored by Leigh Stoller's avatar Leigh Stoller

Change the way that elabinelab communicates with the outer emulab.

Instead of passing along a set of arguments that needs to be turned
into command line arguments to the proxy, pass along an xmldoc
representing the arguments. This xmldoc is passed through the rpc
server to the snmpit proxy, where it reconstructs the arguments. This
avoids all that cruftiness in the rpc server (also error prone) and
make it easier to add new remote methods, say for supporting eventual
elabibelab firewalls. Note that there are currently two versions of
the proxy and two methods in the rpc server, so that existing emulabs
will work.

I also added support for port enable/disable/etc from the inner elab.
There is also the beginning of firewall support. I pass the stack
module argument along, but currently not actually doing control stack
operations from the proxy. Needs more work.

Oh, I copied the cvs repo file for the original proxy so that we do
not lose the cvs history.

See corresponding commitlog for snmpit for description of other
changes.
parent dd332ab4
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -38,7 +38,7 @@ SBIN_STUFF = resetvlans console_setup.proxy sched_reload named_setup \
newnode_reboot savelogs.proxy eventsys.proxy \
elabinelab snmpit.proxy panic node_attributes \
nfstrace plabinelab smbpasswd_setup smbpasswd_setup.proxy \
rmproj
rmproj snmpit.proxynew
ifeq ($(ISMAINSITE),1)
SBIN_STUFF += repos_daemon
endif
......
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2008 University of Utah and the Flux Group.
# Copyright (c) 2004-2009 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -12,8 +12,8 @@ package snmpit_remote;
use Exporter;
@ISA = ("Exporter");
@EXPORT = qw( RemoteDoVlansFromTables RemoteDoReset
RemoteDoTrunking RemoteDoList);
@EXPORT = qw( RemoteDoVlansFromTables RemoteDoReset RemoteDoPortControl
RemoteDoTrunking RemoteDoList RemoteMakeVlan RemoteDeleteVlan);
# Must come after package declaration!
use lib '@prefix@/lib';
......@@ -23,6 +23,7 @@ use libtestbed;
use snmpit_lib;
use Lan;
use libxmlrpc;
use RPC::XML;
# Configure variables
my $TB = "@prefix@";
......@@ -62,18 +63,29 @@ sub commonTail($$)
ConfigXMLRPC();
#
# Okay, the new approach is to pass an xml doc through the rpc server
# into the proxy, and let it get this exact same object. This is a
# lot easier then trying to parse this cruft in the python rpc server,
# so we can pass it on the command line, just to reinterpret it all
# over again.
#
my $args = {"op" => $op, "args" => $arg};
my ($obj) = RPC::XML::smart_encode($args);
my $response = libxmlrpc::CallMethod0("elabinelab", "vlansnew",
{"xmldoc" => $obj->as_string()});
# sklower is temporarily going to way violate layering
# and reach down into the internals of libxmlrpc to
# grab the returned output string, until he can figure out
# the proper python for returning a blob.
my $response = libxmlrpc::CallMethod0("elabinelab", "vlans",
{"op" => $op, "arg" => $arg});
if (($config{"verbose"} || $response->{"code"}) &&
defined($response->{"output"}) && $response->{"output"} ne "") {
print $response->{"output"};
}
#print $response->{"output"};
return $response;
}
......@@ -96,16 +108,17 @@ sub RemoteDoVlansFromTables(@)
foreach my $vlanid (@vlanids) {
my $vlan = VLan->Lookup($vlanid);
return -1
if (!defined($vlanid));
if (!defined($vlan));
$vlans{"$vlanid"} = $vlan;
}
foreach my $id (keys(%vlans)) {
my $vlan = $vlans{"$id"};
my $vlan = $vlans{"$id"};
my @members;
$vlantable->{$id} = {};
$vlantable->{$id}->{"virtual"} = $vlan->vname();
$vlantable->{$id}->{"stack"} = $vlan->GetStack();
$vlantable->{$id}->{"members"} = {};
if ($vlan->MemberList(\@members) != 0) {
......@@ -161,6 +174,7 @@ sub RemoteDoVlansFromTables(@)
if (!exists($vlans{$vlanid})) {
print STDERR "Bad vlanid $vlanid in returned vlan map\n";
$errors++;
next;
}
my $vlan = $vlans{$vlanid};
......@@ -168,8 +182,7 @@ sub RemoteDoVlansFromTables(@)
print STDERR "could not set vlan tag for $vlan\n";
$errors++;
}
VLan->RecordVlanInsertion($vlan->GetExperiment(),
$vlan->lanid(), $tag);
VLan->RecordVlanInsertion($vlan->GetExperiment(), $vlan->lanid());
}
}
else {
......@@ -178,16 +191,50 @@ sub RemoteDoVlansFromTables(@)
return $errors;
}
#
# Create a vlan and put some ports into it. For elabinelab, we are not
# going to allow arbitrary vlans, so they will always be associated
# with an experiment and thus a vlan object.
#
sub RemoteMakeVlan($$@)
{
my $stack = shift();
my $vlan_name = shift();
my @ports = @_;
$args->{"stack"} = $stack
if (defined($stack));
$args->{"vlan_name"} = $vlan_name;
$args->{"ports"} = [ @ports ];
my $response = commonTail("makevlan", $args);
return 1
if ($response->{"code"});
return 0;
}
sub RemoteDeleteVlan($)
{
my $vlan = shift();
return RemoteDoReset($vlan->id());
}
#
# Ask outer boss to tear down a bunch of vlans for an experiment.
#
sub RemoteDoReset(@)
{
my @vlans = @_;
my @vlans = @_;
return 0
if (! @vlans);
my $response = commonTail("destroy", join(",", @vlans));
my $arg = {};
$arg->{"vlans"} = [ @vlans ];
my $response = commonTail("destroy", $arg);
return 1
if ($response->{"code"});
......@@ -197,19 +244,53 @@ sub RemoteDoReset(@)
return 0;
}
#
# Ask outer boss to do portcontrol functions on a list of ports
#
sub RemoteDoPortControl($$@)
{
my $stack = shift();
my $command = shift();
my @ports = @_;
my $arg = {};
$arg->{"command"} = $command;
$arg->{"stack"} = $stack
if (defined($stack));
my $prefix = "" ;
TBGetSiteVar("federation/localprefix",\$prefix);
if ($prefix ne "") {
my @tmp = ();
foreach my $port (@ports) {
$port =~ s/$prefix// ;
push(@tmp, $port);
}
@ports = @tmp;
}
$arg->{"ports"} = [ @ports ];
my $response = commonTail("portcontrol", $arg);
return 1
if ($response->{"code"});
return 0;
}
#
# Ask outer boss to set a port into trunk mode (snmpit -T or -E )
# 1st arg (mode) is "-T" (dual), "-E" (regular i.e. normal or equal)
# or "-U" to reset to the usual un-trunked mode.
#
sub RemoteDoTrunking($$@)
sub RemoteDoTrunking($$$@)
{
my $stack = shift();
my $arg = {};
$arg->{"mode"} = shift();
my $port = shift();
my @vlans = @_;
$arg->{"vlans"} = @vlans ? join(",", @vlans) : "";
$arg->{"stack"} = $stack
if (defined($stack));
$arg->{"vlans"} = [ @vlans ];
my $prefix = "" ;
TBGetSiteVar("federation/localprefix",\$prefix);
......@@ -236,7 +317,9 @@ sub RemoteDoList(@)
my %Names = ();
my %Members = ();
my @list = ();
my $arg = @vlans ? join(",", @vlans) : "";
my $arg = {};
$arg->{"vlans"} = [ @vlans ];
my $response = commonTail("list",$arg);
return 1
......
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