Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
82bd80a6
Commit
82bd80a6
authored
Nov 29, 2001
by
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
tbsetup/snmpit.in
View file @
82bd80a6
...
...
@@ -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
);
}
}
}
}
}
}
...
...
tbsetup/snmpit_lib.pm
View file @
82bd80a6
...
...
@@ -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
#
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment