Commit 02661f36 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Various changes to support shared nodes (a node that can be shared

between experiments and projects using VMs (jail, vservers, openvz,
etc).

* Add new slot to virt_nodes called "sharing_mode". Only admins can set
  this, via the NS file, to create an experiment consisting of nodes
  that are shared. A text string, in case we want to support different
  kinds of sharing modes.

* Add new slot to reserved called "sharing_mode". This is copied from
  the virt_nodes table as above. Also, virtnodes that are currently
  allocated to a shared node, get this slot set, so that the rest of
  the system knows.

* Add a toklen to the "erole" slot of the reserved table, called
  "sharedhost"; erole is returned to the client when it boots, and
  this is how the client knows it is acting as a shared host. We could
  probably compute this value in tmcd, but I did not want to change
  that now.

* Add new slot to interfaces called "trunk". This is set when an
  interface should be set to trunking by "snmpit -t". We previously
  used the vinterfaces table to determine this, but there are other
  cases when we want an interface to be trunked.

  Aside: there is a problem with this approach I realized later;
  trunked interfaces are essentially shared resources of multiple
  vlans, which does not play well with the vlan optimizations in
  swapmod.

* Add new slot to vinterfaces called "bandwidth"; this is the amount
  of bandwidth that link is defined to use (via the NS file). This is
  used in resource scheduling of link bandwidth.

* Add new slot to interface_state called "remaining_bandwidth". For a
  shared node, we have to reserve both the nodes and the link bandwidth.
  We use this slot (with locking) from the mapper_wrapper to make sure that
  the link has not been consumed already by another assignment running at
  the same time.

* Add new tokens "veth-ne", "veth-en", and "vlans" to the osfeatures slot
  of the os_info table. veth-en (encap) and veth-ne (no-encap) are intended
  to replace the current "veths" feature. "vlans" is set for OSs that
  support vlan devices.

* Fix the primary key on the linkdelays table; it needed to have the
  exptidx in the key so that we can allocated linkdelays for different
  experiments to the same node.
parent 6b16cd35
......@@ -1499,6 +1499,7 @@ CREATE TABLE `interface_state` (
`iface` varchar(32) NOT NULL,
`enabled` tinyint(1) default '1',
`tagged` tinyint(1) default '0',
`remaining_bandwidth` int(11) NOT NULL default '0',
PRIMARY KEY (`node_id`,`card`,`port`),
KEY `nodeiface` (`node_id`,`iface`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -1540,6 +1541,7 @@ CREATE TABLE `interfaces` (
`rtabid` smallint(5) unsigned NOT NULL default '0',
`vnode_id` varchar(32) default NULL,
`whol` tinyint(4) NOT NULL default '0',
`trunk` tinyint(1) NOT NULL default '0',
`uuid` varchar(40) NOT NULL default '',
PRIMARY KEY (`node_id`,`card`,`port`),
KEY `mac` (`mac`),
......@@ -1712,7 +1714,7 @@ CREATE TABLE `linkdelays` (
`q_droptail` int(11) default '0',
`q_red` tinyint(4) default '0',
`q_gentle` tinyint(4) default '0',
PRIMARY KEY (`node_id`,`vlan`,`vnode`),
PRIMARY KEY (`exptidx`,`node_id`,`vlan`,`vnode`),
KEY `id` (`pid`,`eid`),
KEY `exptidx` (`exptidx`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
......@@ -2446,7 +2448,7 @@ CREATE TABLE `os_info` (
`path` tinytext,
`magic` tinytext,
`machinetype` varchar(30) NOT NULL default '',
`osfeatures` set('ping','ssh','ipod','isup','veths','mlinks','linktest','linkdelays') default NULL,
`osfeatures` set('ping','ssh','ipod','isup','veths','veth-ne','veth-en','mlinks','linktest','linkdelays','vlans') default NULL,
`ezid` tinyint(4) NOT NULL default '0',
`shared` tinyint(4) NOT NULL default '0',
`mustclean` tinyint(4) NOT NULL default '1',
......@@ -3029,7 +3031,7 @@ CREATE TABLE `reserved` (
`exptidx` int(11) NOT NULL default '0',
`rsrv_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`vname` varchar(32) default NULL,
`erole` enum('node','virthost','delaynode','simhost','modelnet-core','modelnet-edge') NOT NULL default 'node',
`erole` enum('node','virthost','delaynode','simhost','sharedhost') NOT NULL default 'node',
`simhost_violation` tinyint(3) unsigned NOT NULL default '0',
`old_pid` varchar(12) NOT NULL default '',
`old_eid` varchar(32) NOT NULL default '',
......@@ -3042,7 +3044,7 @@ CREATE TABLE `reserved` (
`mustwipe` tinyint(4) NOT NULL default '0',
`genisliver_idx` int(10) unsigned default NULL,
`tmcd_redirect` tinytext,
`sharing_mode` tinytext,
`sharing_mode` varchar(32) default NULL,
PRIMARY KEY (`node_id`),
UNIQUE KEY `vname` (`pid`,`eid`,`vname`),
UNIQUE KEY `vname2` (`exptidx`,`vname`),
......@@ -3566,6 +3568,7 @@ CREATE TABLE `vinterfaces` (
`exptidx` int(10) NOT NULL default '0',
`virtlanidx` int(11) NOT NULL default '0',
`vlanid` int(11) NOT NULL default '0',
`bandwidth` int(10) NOT NULL default '0',
PRIMARY KEY (`node_id`,`unit`),
KEY `bynode` (`node_id`,`iface`),
KEY `type` (`type`)
......@@ -3789,6 +3792,7 @@ CREATE TABLE `virt_nodes` (
`plab_role` enum('plc','node','none') NOT NULL default 'none',
`plab_plcnet` varchar(32) NOT NULL default 'none',
`numeric_id` int(11) default NULL,
`sharing_mode` varchar(32) default NULL,
PRIMARY KEY (`exptidx`,`vname`),
UNIQUE KEY `pideid` (`pid`,`eid`,`vname`),
KEY `pid` (`pid`,`eid`,`vname`)
......
......@@ -689,6 +689,7 @@ REPLACE INTO table_regex VALUES ('virt_nodes','type','text','regex','^[-\\w]*$',
REPLACE INTO table_regex VALUES ('virt_nodes','failureaction','text','regex','^(fatal|nonfatal|ignore)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_nodes','routertype','text','regex','^(none|ospf|static|manual|static-ddijk|static-old)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_nodes','fixed','text','regex','^[-\\w]*$',0,32,NULL);
REPLACE INTO table_regex VALUES ('virt_nodes','sharing_mode','text','regex','^[-\\w]+$',1,32,NULL);
REPLACE INTO table_regex VALUES ('virt_programs','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_programs','eid','text','redirect','experiments:eid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_programs','vnode','text','redirect','virt_nodes:vname',0,0,NULL);
......
#
# Add slot to the virt_nodes table.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("virt_nodes", "sharing_mode")) {
DBQueryFatal("alter table virt_nodes add ".
"sharing_mode varchar(32) default NULL");
}
if (!DBSlotExists("interfaces", "trunk")) {
DBQueryFatal("alter table interfaces add ".
"trunk tinyint(1) NOT NULL default '0' after whol");
}
# Initialize new trunk field from vinterfaces table.
my $query_result =
DBQueryFatal("select v.node_id,v.iface from vinterfaces as v " .
"where v.type='vlan' and v.iface is not NULL");
while (my ($nodeid,$iface) = $query_result->fetchrow_array()) {
DBQueryFatal("update interfaces set trunk=1 ".
"where node_id='$nodeid' and iface='$iface'");
}
if (!DBSlotExists("interface_state", "remaining_bandwidth")) {
DBQueryFatal("alter table interface_state add ".
"remaining_bandwidth int(11) NOT NULL default '0'");
}
if (!DBSlotExists("vinterfaces", "bandwidth")) {
DBQueryFatal("alter table vinterfaces add ".
"bandwidth int(10) NOT NULL default '0'");
}
DBQueryFatal("alter table reserved change `erole` ".
" `erole` enum('node','virthost','delaynode','simhost', ".
" 'sharedhost') NOT NULL default 'node'");
DBQueryFatal("alter table os_info change osfeatures osfeatures ".
" set('ping','ssh','ipod','isup','veths','veth-ne', ".
" 'veth-en','mlinks','linktest','linkdelays','vlans') ".
" default NULL");
$query_result =
DBQueryFatal("select osid,osfeatures from os_info ".
"where FIND_IN_SET('veths',osfeatures) != 0 and ".
" FIND_IN_SET('veth-en',osfeatures) = 0");
while (my ($osid,$osfeatures) = $query_result->fetchrow_array()) {
DBQueryFatal("update os_info set ".
" osfeatures='$osfeatures,veth-ne,veth-en,vlans' ".
"where osid='$osid'");
}
DBQueryFatal("alter table linkdelays drop primary key");
DBQueryFatal("alter table linkdelays add primary key ".
"(`exptidx`,`node_id`,`vlan`,`vnode`)");
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