Commit 179ab667 authored by Leigh Stoller's avatar Leigh Stoller

Add "isswitch" to node_types table, and mark all existing switch types

(class is switch or role is testswitch). Also add a node_type
attribute for all existing switch types: forwarding_protocols=ethernet
parent 4f888896
......@@ -1191,6 +1191,7 @@ sub issimnode($) { return NodeTypeInfo($_[0])->issimnode(); }
sub isgeninode($) { return NodeTypeInfo($_[0])->isgeninode(); }
sub isfednode($) { return NodeTypeInfo($_[0])->isfednode(); }
sub isdedicatedremote($) { return NodeTypeInfo($_[0])->isdedicatedremote(); }
sub isswitch($) { return NodeTypeInfo($_[0])->isswitch(); }
#
# And these are the less common attributes, but still common enough to
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005-2009 University of Utah and the Flux Group.
# Copyright (c) 2005-2010 University of Utah and the Flux Group.
# All rights reserved.
#
package NodeType;
......@@ -82,6 +82,7 @@ sub isplabphysnode($) { return field($_[0], 'isplabphysnode'); }
sub issimnode($) { return field($_[0], 'issimnode'); }
sub isgeninode($) { return field($_[0], 'isgeninode'); }
sub isfednode($) { return field($_[0], 'isfednode'); }
sub isswitch($) { return field($_[0], 'isswitch'); }
#
# Force a reload of the data.
......
......@@ -2184,6 +2184,7 @@ CREATE TABLE `node_types` (
`issimnode` tinyint(4) NOT NULL default '0',
`isgeninode` tinyint(4) NOT NULL default '0',
`isfednode` tinyint(4) NOT NULL default '0',
`isswitch` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......
......@@ -948,6 +948,7 @@ REPLACE INTO table_regex VALUES ('os_info','version','text','regex','^[-\\w\\.]*
REPLACE INTO table_regex VALUES ('os_info','path','text','regex','^[-\\w\\.\\/:]*$',1,256,NULL);
REPLACE INTO table_regex VALUES ('os_info','magic','text','redirect','default:tinytext',0,256,NULL);
REPLACE INTO table_regex VALUES ('os_info','shared','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('os_info','mfs','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('os_info','mustclean','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('os_info','osfeatures','text','regex','^[-\\w,]*$',1,128,NULL);
REPLACE INTO table_regex VALUES ('os_info','op_mode','text','regex','^[-\\w]*$',1,20,NULL);
......
use strict;
use libdb;
#
# MLE stuff
#
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
#
# There is some stuff about switches that is currently implicit.
# Lets make it explicit.
#
if (!DBSlotExists("node_types", "isswitch")) {
DBQueryFatal("alter table node_types add ".
" `isswitch` tinyint(4) not null default 0");
}
#
# It appears that node_type entries do not exist for some
# switch types. Create them and warn the user.
#
my $query_result =
DBQueryFatal("select distinct n.type from nodes as n ".
"left join node_types as t on t.type=n.type ".
"where role='testswitch' and class is null");
while (my ($type) = $query_result->fetchrow_array()) {
print STDERR "Missing node_types entry for switch type $type; ".
"making it now\n";
DBQueryFatal("insert into node_types set ".
" type='$type',class='switch',isswitch=1");
}
# Existing switches get marked.
DBQueryFatal("update node_types as t left join nodes as n on ".
" t.type=n.type ".
"set t.isswitch='1' ".
"where n.role='testswitch'");
DBQueryFatal("update node_types set isswitch=1 where class='switch'");
# All existing switches forward packets at layer 2.
DBQueryFatal("insert ignore into node_type_attributes ".
" (type,attrkey,attrvalue,attrtype) ".
"select distinct type, ".
" 'forwarding_protocols','ethernet','string' ".
"from node_types where isswitch=1");
# Add another missing regex entry for os_info table.
DBQueryFatal("replace into table_regex values ".
" ('os_info','mfs','int','redirect',".
" 'default:tinyint',0,1,NULL)");
return 0;
}
1;
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