Commit 95ada2d1 authored by Leigh Stoller's avatar Leigh Stoller

Add support for disk agents. This is just the plumbing, Yathindra is

doing the real/hard work. Anyway, in your NS file you can do this:

	set newdisk [new Disk $ns]
	$newdisk set node $n0
	$newdisk set type foo
	$newdisk set mountpoint /qq
	$newdisk set parameters "foo bar fee"
	$newdisk set command "bla bla bla"

The parameters and command are optional and default to null. Then on
your node, tmcd returns:

	DISK DISKNAME=newdisk DISKTYPE='foo' MOUNTPOINT='/qq' MOUNTPOINT='foo bar fee' PARAMETERS='bla bla bla'

Note that there is no client support code in this commit.
parent 97371c70
......@@ -133,6 +133,7 @@ $EXPT_RESOURCESHOSED = 0;
"virt_vtypes",
"virt_programs",
"virt_node_attributes",
"virt_node_disks",
"virt_node_desires",
"virt_node_startloc",
"virt_simnode_attributes",
......
......@@ -63,6 +63,7 @@ my $debug = 0;
"virt_vtypes" => [ "name" ],
"virt_programs" => [ "vname", "vnode" ],
"virt_node_attributes" => [ "vname", "attrkey" ],
"virt_node_disks" => [ "vname", "diskname" ],
"virt_user_environment" => [ "name", "value" ],
"virt_bridges" => [ "vname", "vlink", "vport"],
"nseconfigs" => [ "vname" ],
......@@ -1156,6 +1157,11 @@ use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::virt_node_disks;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::virt_user_environment;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
......
......@@ -95,6 +95,9 @@ my %virtual_tables =
"virt_node_attributes" => { rows => undef,
tag => "virt_node_attributes",
row => "virt_node_attribute"},
"virt_node_disks" => { rows => undef,
tag => "virt_node_disks",
row => "virt_node_disk"},
"virt_user_environment" => { rows => undef,
tag => "user_environments",
row => "user_environment"},
......
......@@ -4413,6 +4413,25 @@ CREATE TABLE `virt_node_desires` (
UNIQUE KEY `pideid` (`pid`,`eid`,`vname`,`desire`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `virt_node_disks`
--
DROP TABLE IF EXISTS `virt_node_disks`;
CREATE TABLE `virt_node_disks` (
`pid` varchar(48) NOT NULL default '',
`eid` varchar(32) NOT NULL default '',
`exptidx` int(11) NOT NULL default '0',
`vname` varchar(32) NOT NULL default '',
`diskname` varchar(32) NOT NULL default '',
`disktype` varchar(32) NOT NULL default '',
`mountpoint` tinytext,
`parameters` tinytext,
`command` tinytext,
PRIMARY KEY (`exptidx`,`vname`,`diskname`),
UNIQUE KEY `pideid` (`pid`,`eid`,`vname`,`diskname`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `virt_node_motelog`
--
......
......@@ -168,6 +168,8 @@ REPLACE INTO event_objecttypes VALUES (14,'TOPOGRAPHY');
REPLACE INTO event_objecttypes VALUES (15,'LINKTRACE');
REPLACE INTO event_objecttypes VALUES (16,'EVPROXY');
REPLACE INTO event_objecttypes VALUES (17,'BGMON');
REPLACE INTO event_objecttypes VALUES (18,'DISK');
REPLACE INTO event_objecttypes VALUES (19,'CUSTOM');
--
-- Dumping data for table `exported_tables`
......@@ -846,6 +848,15 @@ REPLACE INTO table_regex VALUES ('virt_lans','layer','int','redirect','default:t
REPLACE INTO table_regex VALUES ('virt_lans','ofenabled','int','redirect','default:boolean',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','ofcontroller','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','eid','text','redirect','experiments:eid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','vname','text','redirect','virt_nodes:vname',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','diskname','text','regex','^[-\\w]+$',2,32,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','disktype','text','regex','^[-\\w]+$',2,32,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','mountpoint','text','redirect','default:tinytext',1,255,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','parameters','text','redirect','default:tinytext',1,255,NULL);
REPLACE INTO table_regex VALUES ('virt_node_disks','command','text','redirect','default:tinytext',1,255,NULL);
REPLACE INTO table_regex VALUES ('virt_node_attributes','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_attributes','eid','text','redirect','experiments:eid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_attributes','vname','text','redirect','virt_nodes:vname',0,0,NULL);
......
#
# virt disks
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (! DBTableExists("virt_node_disks")) {
DBQueryFatal("CREATE TABLE `virt_node_disks` ( ".
" `pid` varchar(48) NOT NULL default '', ".
" `eid` varchar(32) NOT NULL default '', ".
" `exptidx` int(11) NOT NULL default '0', ".
" `vname` varchar(32) NOT NULL default '', ".
" `diskname` varchar(32) NOT NULL default '', ".
" `disktype` varchar(32) NOT NULL default '', ".
" `mountpoint` tinytext, ".
" `parameters` tinytext, ".
" `command` tinytext, ".
" PRIMARY KEY (`exptidx`,`vname`,`diskname`), ".
" UNIQUE KEY `pideid` (`pid`,`eid`,`vname`,`diskname`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','pid','text','redirect', ".
" 'projects:pid',0,0,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','eid','text','redirect', ".
" 'experiments:eid',0,0,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','vname','text','redirect', ".
" 'virt_nodes:vname',0,0,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','diskname','text','regex',".
" '^[-\\\\w]+\$',2,32,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','disktype','text','regex', ".
" '^[-\\\\w]+\$',2,32,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','mountpoint','text','redirect', ".
" 'default:tinytext',1,255,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','parameters','text','redirect', ".
" 'default:tinytext',1,255,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('virt_node_disks','command','text','redirect', ".
" 'default:tinytext',1,255,NULL)");
DBQueryFatal("REPLACE INTO event_objecttypes VALUES (18,'DISK')");
return 0;
}
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -23,11 +23,10 @@ Disk instproc init {s} {
$self set sim $s
$self set node {}
$self set name {}
$self set type {}
$self set mountpoint {}
$self set params {}
$self set cmd {}
$self set parameters {}
$self set command {}
# Link simulator to this new object.
$s add_disk $self
......@@ -48,32 +47,32 @@ Disk instproc updatedb {DB} {
var_import ::GLOBALS::eid
var_import ::TBCOMPAT::objtypes
$self instvar node
$self instvar name
$self instvar type
$self instvar mountpoint
$self instvar params
$self instvar parameters
$self instvar sim
$self instvar cmd
$self instvar command
if {$node == {}} {
perror "\[updatedb] $self has no node."
return
perror "\[updatedb] $self has no node."
return
}
set progvnode $node
#
# if the attached node is a simulated one, we attach the
# program to the physical node on which the simulation runs
#
if {$progvnode != "ops"} {
if { [$node set simulated] == 1 } {
set progvnode [$node set nsenode]
}
set fields [list "vname" "diskname" "disktype" "mountpoint"]
set values [list $node $self $type $mountpoint]
if { $parameters != "" } {
lappend fields "parameters"
lappend values $parameters
}
if { $command != "" } {
lappend fields "command"
lappend values $command
}
# Update the DB
spitxml_data "virt_disk" [list "vnode" "vname" "name" "type" "mountpoint" "params" "cmd"] [list $progvnode $self $name $type $mountpoint $params $cmd]
spitxml_data "virt_node_disks" $fields $values
$sim spitxml_data "virt_agents" [list "vnode" "vname" "objecttype" ] [list $progvnode $self $objtypes(DISK) ]
$sim spitxml_data "virt_agents" [list "vnode" "vname" "objecttype" ] [list $node $self $objtypes(DISK) ]
}
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -179,6 +179,14 @@ Program instproc init {args} {
Program instproc unknown {m args} {
}
Class Disk
Disk instproc init {args} {
}
Disk instproc unknown {m args} {
}
Class Firewall
Firewall instproc init {sim args} {
......
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