Commit 82bd80a6 authored by Robert Ricci's avatar Robert Ricci
Browse files

The -t function (and ONLY the -t function, not -m, etc.) now sets port

speeds and duplexes from the database.
parent d8c68764
......@@ -538,6 +538,7 @@ $port, $inoctets, $inunicast,$innunicast,$indiscards,$inerr, $inunk, $out
return 0;
}
#
# Creates all VLANs given. Looks up identifiers in the database to determine
# the membership.
......@@ -566,7 +567,29 @@ sub doVlansFromTables(@) {
#
$errors++;
} else {
$errors += $stack->setPortVlan($vlan,@ports);
my $setErrors = $stack->setPortVlan($vlan,@ports);
$errors += $setErrors;
#
# Set the speed and duplex of each interface depending on the
# value in the database
#
if (!$setErrors) {
foreach my $port (@ports) {
my ($speed,$duplex) = getInterfaceSettings($port);
#
# If either is not set, we do nothing. We could make
# a 0 mean 'auto'
#
if ($speed) {
my $cmd = $speed . "mbit";
$errors += $stack->portControl($cmd, $port);
}
if ($duplex) {
$errors += $stack->portControl($duplex, $port);
}
}
}
}
}
}
......
......@@ -9,7 +9,8 @@ use Exporter;
@ISA = ("Exporter");
@EXPORT = qw( macport portnum Dev vlanmemb vlanid
getTestSwitches getVlanPorts getExperimentVlans getDeviceNames
getDeviceType mapPortsToDevices getSwitchStack tbsort );
getDeviceType getInterfaceSettings mapPortsToDevices
getSwitchStack tbsort );
use English;
use libdb;
......@@ -246,6 +247,32 @@ sub getDeviceType ($) {
return $row[0];
}
#
# Returns (current_speed,duplex) for the given interface (in node:port form)
#
sub getInterfaceSettings ($) {
my ($interface) = @_;
$interface =~ /^(.+):(\d+)$/;
my ($node, $port) = ($1, $2);
if ((!defined $node) || (!defined $port)) {
die "getInterfaceSettings: Bad interface ($interface) given\n";
}
my $result =
DBQueryFatal("SELECT current_speed, duplex FROM interfaces " .
"WHERE node_id='$node' and card=$port");
my @row = $result->fetchrow();
# Sanity check - make sure the interface exists
if (!@row) {
die "No such interface: $interface\n";
}
return @row;
}
#
# Returns an array with then names of all switches identified as test switches
#
......
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