Commit 44cfabfd authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Merge branch 'master' into portmerge

parents fc823945 4e775b00
......@@ -23,10 +23,11 @@ use strict;
use Getopt::Std;
my %opt;
my $optlist = "ltL:evDnrs";
my $optlist = "ltL:evDnrRsa";
if (!getopts($optlist,\%opt)){
warn "Usage: $0 [-r] [-l] [-e] [-t] [-L limit] [-v] [-D] [-n] [-s]\n";
warn "Usage: $0 [-r] [-R] [-l] [-e] [-t] [-L limit] [-v] [-D] [-n] [-s]\n";
warn " -r Remove any files that fail the check\n";
warn " -R Rename any files that fail the check\n";
warn " -l List files that pass the check to stdout\n";
warn " -e Print parse errors from failed files to stderr\n";
warn " -t When finished, dump information about all types and\n";
......@@ -38,6 +39,7 @@ if (!getopts($optlist,\%opt)){
warn " private information\n";
warn " -s Strict checking - only pass files that would be parsed by\n";
warn " latest version of assign\n";
warn " -a Enable anonymization\n";
exit 1;
}
......@@ -68,6 +70,14 @@ my %top_linkflags = (
#
sub is_feature_okay($) {
my ($feature) = @_;
# If we are not anonymizing, all features are considered okay
if (!$opt{a}) {
return 1;
}
# If anyonymizing, don't let through OS features that expose the project
# name
if ($feature =~ /^OS-/) {
# OSes in the emulab-ops project are okay, as are ones that are just
# specified with a numeric ID
......@@ -160,7 +170,7 @@ sub check_node_type($) {
#
sub normalize_ptop($) {
my ($ptop) = @_;
my ($nodes, $links, $limits) = @$ptop;
my ($nodes, $links, $limits,$policies) = @$ptop;
foreach my $node (@$nodes) {
#print "Normalizing $node->{name}\n";
if (!$node->{types}) {
......@@ -209,12 +219,12 @@ sub normalize_ptop($) {
}
}
# Nothing to do for limits, for now
# Nothing to do for limits or policies, for now
}
sub write_normalized_ptop($$) {
my ($outfile, $ptop) = @_;
my ($nodes, $links, $limits) = @$ptop;
my ($nodes, $links, $limits, $policies) = @$ptop;
open (OF,">$outfile") or die "Unable to open $outfile for writing";
foreach my $node (@$nodes) {
......@@ -260,6 +270,10 @@ sub write_normalized_ptop($$) {
print OF "set-type-limit $type $count\n";
}
foreach my $policy (@$policies) {
print OF "policy " . join(" ",@$policy) . "\n";
}
close(OF);
}
......@@ -410,7 +424,7 @@ sub parse_ptop($) {
my %local_seen_link_types;
my %local_seen_fds;
my (@nodes, @links, @limits);
my (@nodes, @links, @limits, @policies);
my $line_no = 0;
while (my $line = <PT>) {
......@@ -541,6 +555,11 @@ sub parse_ptop($) {
my %limit = (type => $type, limit => $limit);
push @limits, \%limit;
} elsif ($line_type eq "policy") {
# For now, we are just going to pass the rest of the string
# along rather than parsing it carefully, since we don't support
# fancy policies in any ptop version yet
push @policies, [@tokens];
} else {
die "Unknown line type '$line_type' on $ptop line $line_no\n";
}
......@@ -558,7 +577,7 @@ sub parse_ptop($) {
close PT;
return [\@nodes, \@links, \@limits];
return [\@nodes, \@links, \@limits,\@policies];
}
sub parse_top($) {
......@@ -635,7 +654,14 @@ sub parse_top($) {
check_type("string",$link{dstiface});
$link{bw} = shift @tokens;
check_type("int",$link{bw});
#
# The bandwidth should be either the string '*' (which means
# 'native speed') or an int
#
if ($link{bw} ne "*") {
check_type("int",$link{bw});
}
# This is a bit tricky - figure out if there are delay and
# loss present on the line
......@@ -745,22 +771,9 @@ chomp @dirs;
my $processed_files = 0;
my $passed_files = 0;
foreach my $dir (@dirs) {
#my @ptopfiles = `ls -1 $dir/\*.ptop`;
#my @ptopfiles = ();
#my @topfiles = `ls -1 $dir/\*.top`;
my @topfiles;
my @ptopfiles;
opendir DIR, "$dir" or die "Unable to open $dir: $!\n";
while (my $file = readdir DIR) {
if ($file =~ /\.ptop$/) {
push @ptopfiles, "$dir/$file";
}
if ($file =~ /\.top$/) {
push @topfiles, "$dir/$file";
}
}
my @topfiles = `find $dir/ -name \*.vtop`;
my @ptopfiles = `find $dir/ -name \*.ptop`;
chomp @ptopfiles;
chomp @topfiles;
......@@ -770,19 +783,26 @@ foreach my $dir (@dirs) {
}
$processed_files++;
my $ptop_data = eval { parse_ptop($ptop); };
#if (eval { parse_ptop($ptop); }) {
if (!$@) {
$passed_files++;
if ($opt{l}) {
print "$ptop\n";
}
if ($opt{n}) {
# Grab timestamps so that we can preserve them
my ($atime, $mtime) = (stat($ptop))[8,9];
normalize_ptop($ptop_data);
write_normalized_ptop($ptop,$ptop_data);
# Restore timestamp
utime $atime, $mtime, $ptop;
}
} else {
if ($opt{r}) {
system "rm $ptop";
} elsif ($opt{R}) {
system "mv $ptop $ptop.failed";
}
if ($opt{e}) {
print "*** FAILED: $ptop: $@\n";
......@@ -799,22 +819,28 @@ foreach my $dir (@dirs) {
if ($opt{D}) {
print "Checking top file $top\n";
}
#parse_top($top);
$processed_files++;
my $top_data = eval { parse_top($top); };
#if (eval { parse_top($top); }) {
if (!$@) {
$passed_files++;
if ($opt{l}) {
print "$top\n";
}
if ($opt{n}) {
# Grab timestamps so that we can preserve them
my ($atime, $mtime) = (stat($top))[8,9];
normalize_top($top_data);
write_normalized_top($top,$top_data);
# Restore timestamp
utime $atime, $mtime, $top;
}
} else {
if ($opt{r}) {
system "rm $top";
} elsif ($opt{R}) {
system "mv $top $top.failed";
}
if ($opt{e}) {
print "*** FAILED: $top: $@\n";
......
......@@ -916,7 +916,6 @@ outfiles="$outfiles Makeconf GNUmakefile \
tbsetup/eventsys.proxy \
tbsetup/snmpit.proxy tbsetup/snmpit_remote.pm \
tbsetup/snmpit tbsetup/ns2ir/GNUmakefile \
tbsetup/new_snmpit \
tbsetup/ns2ir/parse.tcl tbsetup/ns2ir/tb_compat.tcl \
tbsetup/ns2ir/parse-ns tbsetup/ns2ir/parse.proxy \
tbsetup/ns2ir/sim.tcl tbsetup/nseswap tbsetup/nseparse/GNUmakefile \
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005-2010 University of Utah and the Flux Group.
# Copyright (c) 2005-2011 University of Utah and the Flux Group.
# All rights reserved.
#
package Interface;
......@@ -59,7 +59,7 @@ sub LookupAll($$$)
my $query_result =
DBQueryWarn("select * from interfaces ".
"where node_id='$nodeid'");
"where node_id='$nodeid' and logical=0");
return -1
if (!$query_result);
......
......@@ -588,7 +588,8 @@ sub LookupByWireType($$)
my @ports = ();
my $result = DBQueryFatal("SELECT node_id1, card1, port1, " .
"node_id2, card2, port2 FROM wires WHERE type='$wt'");
"node_id2, card2, port2 FROM wires ".
"WHERE type='$wt' and logical=0");
if ($result) {
while (my @row = $result->fetchrow()) {
......
......@@ -1777,6 +1777,7 @@ CREATE TABLE `interfaces` (
`whol` tinyint(4) NOT NULL default '0',
`trunk` tinyint(1) NOT NULL default '0',
`uuid` varchar(40) NOT NULL default '',
`logical` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`node_id`,`card`,`port`),
KEY `mac` (`mac`),
KEY `IP` (`IP`),
......@@ -4728,13 +4729,14 @@ DROP TABLE IF EXISTS `wires`;
CREATE TABLE `wires` (
`cable` smallint(3) unsigned default NULL,
`len` tinyint(3) unsigned NOT NULL default '0',
`type` enum('Node','Serial','Power','Dnard','Control','Trunk','OuterControl') NOT NULL default 'Node',
`type` enum('Node','Serial','Power','Dnard','Control','Trunk','OuterControl','Unused') NOT NULL default 'Node',
`node_id1` char(32) NOT NULL default '',
`card1` tinyint(3) unsigned NOT NULL default '0',
`port1` tinyint(3) unsigned NOT NULL default '0',
`node_id2` char(32) NOT NULL default '',
`card2` tinyint(3) unsigned NOT NULL default '0',
`port2` tinyint(3) unsigned NOT NULL default '0',
`logical` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`node_id1`,`card1`,`port1`),
KEY `node_id2` (`node_id2`,`card2`),
KEY `dest` (`node_id2`,`card2`,`port2`),
......
#
# Add "logical" wire support, used for layer one switch support.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
my $slottype = DBSlotType("wires", "type");
if (!$slottype) {
Fatal("No 'type' slot in 'wires' table");
}
if (! ($slottype =~ /Unused/)) {
DBQueryFatal("alter table wires change `type` `type` ".
" enum('Node','Serial','Power','Dnard','Control',".
" 'Trunk','OuterControl','Unused') ".
" NOT NULL default 'Node'");
}
if (!DBSlotExists("wires", "logical")) {
DBQueryFatal("alter table wires add `logical` ".
" tinyint(1) unsigned NOT NULL default '0'");
}
if (!DBSlotExists("interfaces", "logical")) {
DBQueryFatal("alter table interfaces add `logical` ".
" tinyint(1) unsigned NOT NULL default '0'");
}
return 0;
}
1;
......@@ -21,7 +21,7 @@ ifeq ($(NSVERIFY),1)
SUBDIRS += nsverify
endif
BIN_STUFF = power snmpit snmpit_new tbend tbprerun tbreport new_snmpit \
BIN_STUFF = power snmpit snmpit_new tbend tbprerun tbreport \
os_load endexp batchexp swapexp \
node_reboot nscheck node_update savelogs node_control \
portstats checkports eventsys_control os_select tbrestart \
......@@ -83,8 +83,6 @@ LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_cisco_stack.pm snmpit_intel_stack.pm power_sgmote.pm \
snmpit_foundry.pm snmpit_stack.pm snmpit_remote.pm \
snmpit_nortel.pm snmpit_hp.pm snmpit_apcon.pm\
new_snmpit_lib.pm new_snmpit_stack.pm new_snmpit_apcon.pm \
new_snmpit_hp.pm new_snmpit_cisco.pm \
libaudit.pm libreboot.pm libosload.pm libtestbed.py \
libadminmfs.pm libtblog.pm libtblog_simple.pm libArchive.pm \
power_mail.pm power_whol.pm Template.pm power_rmcp.pm \
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -250,8 +250,8 @@ my %interfaceips = ();
# Read interfaces
my $result =
DBQueryFatal("SELECT node_id,card,port,iface,interface_type,role,IP" .
" from interfaces " .
($genimode ne $NO_GENI ? "where role!='gw'" : ""));
" from interfaces where logical=0 " .
($genimode ne $NO_GENI ? "and role!='gw'" : ""));
while (($node,$card,$port,$iface,$type,$role,$ip) = $result->fetchrow_array) {
push @{ $nodetointerface{"$node"} }, $iface;
......@@ -719,7 +719,7 @@ while (($node,$type,$physnode,$class,$issubnode,$def_boot_osid,$reserved,
# features
#
$result = DBQueryFatal("SELECT DISTINCT node_id1, node_id2 " .
" FROM wires");
" FROM wires where logical=0");
my %connections = ();
while (my ($node_id1, $node_id2) = $result->fetchrow()) {
foreach my $nodes ([$node_id1, $node_id2], [$node_id2, $node_id1]) {
......@@ -1276,7 +1276,8 @@ while (($type,$capkey,$capval) = $result->fetchrow_array) {
# Read interface switches
$result = DBQueryFatal("SELECT node_id1, iface, node_id2 FROM wires AS w " .
"LEFT JOIN interfaces as i ON w.node_id1=i.node_id AND w.card1=i.card");
"LEFT JOIN interfaces as i ON w.node_id1=i.node_id AND w.card1=i.card ".
"where w.logical=0");
while (($node,$iface,$switch) = $result->fetchrow_array) {
if ($node && $iface) {
......@@ -1286,7 +1287,7 @@ while (($node,$iface,$switch) = $result->fetchrow_array) {
# Read interface cards and ports
$result = DBQueryFatal("SELECT node_id, iface, card, port, IP ".
"FROM interfaces");
"FROM interfaces where logical=0");
while (($node,$iface,$card,$port,$IP) = $result->fetchrow_array) {
next
......@@ -1344,7 +1345,8 @@ if (defined($experiment)) {
}
$result = DBQueryFatal("SELECT node_id1,card1,port1,node_id2,card2,port2" .
" from wires where type=\"Node\" or type=\"Trunk\"");
" from wires where logical=0 and ".
" (type=\"Node\" or type=\"Trunk\")");
while (($node1,$card1,$port1,$node2,$card2,$port2) =
$result->fetchrow_array) {
if ((defined($nodes{$node1}) || defined($switches{$node1})) &&
......
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