Commit 2a416e80 authored by Leigh Stoller's avatar Leigh Stoller

Add a "logical" flag to interfaces and wires.

Add "Unused" to type enum in the wires table.
Change a few critical wires/interfaces queries to avoid logical=1.
parent 203cafa4
#!/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;
......@@ -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