Commit bda3fcfc authored by Mike Hibler's avatar Mike Hibler

Plumb the arpinfo command through the perl code.

Also, fix a minor bug in the tmcd implementation.
parent 3124b925
......@@ -23,7 +23,7 @@ use Exporter;
gettraceconfig genhostsfile getmotelogconfig calcroutes fakejailsetup
getlocalevserver genvnodesetup getgenvnodeconfig stashgenvnodeconfig
getlinkdelayconfig getloadinfo getbootwhat getnodeattributes
forcecopy getnodeuuid
forcecopy getnodeuuid getarpinfo
getmanifest fetchmanifestblobs runbootscript runhooks
build_fake_macs
......@@ -3165,6 +3165,45 @@ sub getlocalevserver()
return $evserver;
}
sub getarpinfo($)
{
my ($rptr) = @_;
my %arpinfo = ();
my @tmccresults = ();
# don't cache
my %opthash = ( 'nocache' => 1 );
if (tmcc(TMCCCMD_ARPINFO, undef, \@tmccresults, %opthash) < 0) {
warn("*** WARNING: Could not get arpinfo from server!\n");
return -1;
}
#
# Example:
# SERVER=gw CNETIP=155.98.36.1 CNETMAC=00d0bcf414f8
# SERVER=subboss CNETIP=155.98.38.162 CNETMAC=001f29329224
# HOST=pc271 CNETIP=155.98.39.71 CNETMAC=001143e43be6
#
my $pat = q((HOST|SERVER)=([-\w]+) CNETIP=([\d\.]*) CNETMAC=([\da-f]{12}));
foreach my $line (@tmccresults) {
if ($line =~ /$pat/) {
my $type = $1;
my $name = $2;
my $ip = $3;
my $mac = $4;
$arpinfo{$name}{'type'} = $type;
$arpinfo{$name}{'ip'} = $ip;
$arpinfo{$name}{'mac'} = $mac;
} else {
warn("*** WARNING: Bad arpinfo info line ignored: '$line'\n");
}
}
%$rptr = %arpinfo;
return 0;
}
#
# Fork a process to exec a command. Return the pid to wait on.
#
......
......@@ -36,6 +36,7 @@ use Exporter;
TMCCCMD_LTMAP TMCCCMD_LTPMAP TMCCCMD_TOPOMAP TMCCCMD_LOADINFO
TMCCCMD_TPMBLOB TMCCCMD_TPMPUB TMCCCMD_DHCPDCONF TMCCCMD_MANIFEST
TMCCCMD_NODEUUID TMCCCMD_NODEATTRIBUTES TMCCCMD_DISKS
TMCCCMD_ARPINFO
);
# Must come after package declaration!
......@@ -199,6 +200,7 @@ my %commandset =
"nodeuuid" => {TAG => "nodeuuid"},
"nodeattributes" => {TAG => "nodeattributes"},
"disks" => {TAG => "disks"},
"arpinfo" => {TAG => "arpinfo"},
);
#
......@@ -261,17 +263,18 @@ sub TMCCCMD_MOTELOG() { $commandset{"motelog"}->{TAG}; }
sub TMCCCMD_PORTREGISTER(){ $commandset{"portregister"}->{TAG}; }
sub TMCCCMD_BOOTWHAT() { $commandset{"bootwhat"}->{TAG}; }
sub TMCCCMD_ROOTPSWD() { $commandset{"rootpswd"}->{TAG}; }
sub TMCCCMD_TOPOMAP(){ $commandset{"topomap"}->{TAG}; }
sub TMCCCMD_LTMAP() { $commandset{"ltmap"}->{TAG}; }
sub TMCCCMD_LTPMAP() { $commandset{"ltpmap"}->{TAG}; }
sub TMCCCMD_TPMBLOB() { $commandset{"tpmblob"}->{TAG}; }
sub TMCCCMD_TPMPUB() { $commandset{"tpmpubkey"}->{TAG}; }
sub TMCCCMD_TOPOMAP() { $commandset{"topomap"}->{TAG}; }
sub TMCCCMD_LTMAP() { $commandset{"ltmap"}->{TAG}; }
sub TMCCCMD_LTPMAP() { $commandset{"ltpmap"}->{TAG}; }
sub TMCCCMD_TPMBLOB() { $commandset{"tpmblob"}->{TAG}; }
sub TMCCCMD_TPMPUB() { $commandset{"tpmpubkey"}->{TAG}; }
sub TMCCCMD_LOADINFO() { $commandset{"loadinfo"}->{TAG}; }
sub TMCCCMD_DHCPDCONF() { $commandset{"dhcpdconf"}->{TAG}; }
sub TMCCCMD_DHCPDCONF() { $commandset{"dhcpdconf"}->{TAG}; }
sub TMCCCMD_MANIFEST() { $commandset{"manifest"}->{TAG}; }
sub TMCCCMD_NODEUUID() { $commandset{"nodeuuid"}->{TAG}; }
sub TMCCCMD_NODEATTRIBUTES() { $commandset{"nodeattributes"}->{TAG}; }
sub TMCCCMD_DISKS() { $commandset{"disks"}->{TAG}; }
sub TMCCCMD_NODEUUID() { $commandset{"nodeuuid"}->{TAG}; }
sub TMCCCMD_NODEATTRIBUTES() { $commandset{"nodeattributes"}->{TAG}; }
sub TMCCCMD_DISKS() { $commandset{"disks"}->{TAG}; }
sub TMCCCMD_ARPINFO() { $commandset{"arpinfo"}->{TAG}; }
#
# Caller uses this routine to set configuration of this library
......
......@@ -9649,8 +9649,8 @@ COMMAND_PROTOTYPE(doarpinfo)
res = mydb_query("select distinct i.node_id,i.IP,i.mac from "
"interfaces as i,subbosses as s where "
"s.node_id=i.node_id and "
"s.subboss_id='%s' and i.role='ctrl'",
3, reqp->nodeid);
"s.subboss_id='%s' and s.disabled=0 and "
"i.role='ctrl'", 3, reqp->nodeid);
if (!res) {
error("doarpinfo: %s: DB Error getting"
"control interface info\n", reqp->nodeid);
......
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