Commit bb243a68 authored by Mike Hibler's avatar Mike Hibler

First crack at getting elabinelab attributes (options) from end to end.

Add all the NS parsing and DB foo.
parent c1ecb12c
...@@ -108,6 +108,7 @@ my $EXPT_RESOURCESHOSED = 0; ...@@ -108,6 +108,7 @@ my $EXPT_RESOURCESHOSED = 0;
"event_groups", "event_groups",
"virt_firewalls", "virt_firewalls",
"firewall_rules", "firewall_rules",
"elabinelab_attributes",
"virt_tiptunnels", "virt_tiptunnels",
"ipsubnets"); "ipsubnets");
......
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2009 University of Utah and the Flux Group. # Copyright (c) 2009, 2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
package VirtExperiment; package VirtExperiment;
...@@ -69,6 +69,7 @@ my $debug = 0; ...@@ -69,6 +69,7 @@ my $debug = 0;
"event_groups" => [ "group_name", "agent_name" ], "event_groups" => [ "group_name", "agent_name" ],
"virt_firewalls" => [ "fwname", "type", "style" ], "virt_firewalls" => [ "fwname", "type", "style" ],
"firewall_rules" => [ "fwname", "ruleno", "rule" ], "firewall_rules" => [ "fwname", "ruleno", "rule" ],
"elabinelab_attributes" => [ "role", "attrkey", "order" ],
"virt_tiptunnels" => [ "host", "vnode" ], "virt_tiptunnels" => [ "host", "vnode" ],
"virt_parameters" => [ "name", "value" ], "virt_parameters" => [ "name", "value" ],
); );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group. # Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -110,6 +110,9 @@ my %virtual_tables = ...@@ -110,6 +110,9 @@ my %virtual_tables =
"firewall_rules" => { rows => undef, "firewall_rules" => { rows => undef,
tag => "firewall_rules", tag => "firewall_rules",
row => "firewall_rule"}, row => "firewall_rule"},
"elabinelab_attributes" => { rows => undef,
tag => "elabinelab_attributes",
row => "attribute"},
"virt_tiptunnels" => { rows => undef, "virt_tiptunnels" => { rows => undef,
tag => "tiptunnels", tag => "tiptunnels",
row => "tiptunnel"}, row => "tiptunnel"},
......
...@@ -421,6 +421,21 @@ CREATE TABLE `deltas` ( ...@@ -421,6 +421,21 @@ CREATE TABLE `deltas` (
PRIMARY KEY (`delta_id`) PRIMARY KEY (`delta_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `elabinelab_attributes`
--
CREATE TABLE `elabinelab_attributes` (
`pid` varchar(12) NOT NULL default '',
`eid` varchar(32) NOT NULL default '',
`exptidx` int(11) NOT NULL default '0',
`role` enum('boss','router','ops','fs','node') NOT NULL default 'node',
`attrkey` varchar(32) NOT NULL default '',
`attrvalue` tinytext NOT NULL,
`order` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`exptidx`,`role`,`attrkey`,`order`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --
-- Table structure for table `elabinelab_vlans` -- Table structure for table `elabinelab_vlans`
-- --
......
#
# Add the elabinelab_attributes table.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBTableExists("elabinelab_attributes")) {
DBQueryFatal("CREATE TABLE `elabinelab_attributes` ( ".
" `pid` varchar(12) NOT NULL default '', ".
" `eid` varchar(32) NOT NULL default '', ".
" `exptidx` int(11) NOT NULL default '0', ".
" `role` enum('boss','router','ops','fs','node') NOT NULL default 'node', ".
" `attrkey` varchar(32) NOT NULL default '', ".
" `attrvalue` tinytext NOT NULL, ".
" `order` smallint(5) unsigned NOT NULL default '0', ".
" PRIMARY KEY (`exptidx`,`role`,`attrkey`,`order`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
# Initialize new table.
return 0;
}
1;
# -*- tcl -*- # -*- tcl -*-
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2004, 2005 University of Utah and the Flux Group. # Copyright (c) 2004, 2005, 2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -148,8 +148,6 @@ Firewall instproc child-of {pfw} { ...@@ -148,8 +148,6 @@ Firewall instproc child-of {pfw} {
# updatedb DB # updatedb DB
Firewall instproc updatedb {DB} { Firewall instproc updatedb {DB} {
var_import ::GLOBALS::pid
var_import ::GLOBALS::eid
$self instvar rules $self instvar rules
$self instvar sim $self instvar sim
$self instvar type $self instvar type
......
# -*- tcl -*- # -*- tcl -*-
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group. # Copyright (c) 2000-2007, 2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
...@@ -398,6 +398,7 @@ Simulator instproc run {} { ...@@ -398,6 +398,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::elabinelab_eid var_import ::GLOBALS::elabinelab_eid
var_import ::GLOBALS::elabinelab_cvstag var_import ::GLOBALS::elabinelab_cvstag
var_import ::GLOBALS::elabinelab_singlenet var_import ::GLOBALS::elabinelab_singlenet
var_import ::TBCOMPAT::elabinelab_attributes
var_import ::GLOBALS::security_level var_import ::GLOBALS::security_level
var_import ::GLOBALS::explicit_firewall var_import ::GLOBALS::explicit_firewall
var_import ::GLOBALS::sourcefile_list var_import ::GLOBALS::sourcefile_list
...@@ -700,6 +701,19 @@ Simulator instproc run {} { ...@@ -700,6 +701,19 @@ Simulator instproc run {} {
$self spitxml_data "external_sourcefiles" [list "pathname" ] [list $sourcefile ] $self spitxml_data "external_sourcefiles" [list "pathname" ] [list $sourcefile ]
} }
if {$elab_in_elab} {
foreach attr $elabinelab_attributes {
set fields [list "role" "attrkey" "attrvalue" "order"]
set values [split $attr ","]
# XXX this shouldn't be needed
lappend fields [list "pid" "eid"]
lappend values [list $pid $eid]
$self spitxml_data "elabinelab_attributes" $fields $values
}
}
$self spitxml_finish $self spitxml_finish
} }
......
...@@ -132,7 +132,7 @@ namespace eval TBCOMPAT { ...@@ -132,7 +132,7 @@ namespace eval TBCOMPAT {
# Elabinelab attribute stuff. # Elabinelab attribute stuff.
variable elabinelab_attributes variable elabinelab_attributes
array set elabinelab_attributes {} set elabinelab_attributes {}
variable EINEROLE {^(boss|ops|fs|router)$} variable EINEROLE {^(boss|ops|fs|router)$}
variable EINEKEY {^(\w[-\w\.]+)$} variable EINEKEY {^(\w[-\w\.]+)$}
variable EINEVALUE {^([-\w\s\.\,\/]+)$} variable EINEVALUE {^([-\w\s\.\,\/]+)$}
...@@ -1760,8 +1760,14 @@ proc tb-elabinelab-singlenet {args} { ...@@ -1760,8 +1760,14 @@ proc tb-elabinelab-singlenet {args} {
# tb-unset-elabinelab-attribute <role> <key> # tb-unset-elabinelab-attribute <role> <key>
# #
proc tb-set-elabinelab-attribute {role key value {order 0}} { proc tb-set-elabinelab-attribute {role key value {order 0}} {
var_import ::TBCOMPAT::EINEROLE;
var_import ::TBCOMPAT::EINEKEY;
var_import ::TBCOMPAT::EINEVALUE;
var_import ::TBCOMPAT::EINEORDER;
var_import ::TBCOMPAT::elabinelab_attributes;
if {[regexp $EINEROLE $role] == 0} { if {[regexp $EINEROLE $role] == 0} {
perror "\[tb-set-elabinelab-attribute] - $role is not a valid elabinelab role" perror "\[tb-set-elabinelab-attribute] - \"$role\" is not a valid elabinelab role"
return return
} }
if {[regexp $EINEKEY $key] == 0} { if {[regexp $EINEKEY $key] == 0} {
...@@ -1773,13 +1779,29 @@ proc tb-set-elabinelab-attribute {role key value {order 0}} { ...@@ -1773,13 +1779,29 @@ proc tb-set-elabinelab-attribute {role key value {order 0}} {
return return
} }
if {[regexp $EINEORDER $order] == 0} { if {[regexp $EINEORDER $order] == 0} {
perror "\[tb-set-elabinelab-attribute] - $order is not a valid elabinelab order" perror "\[tb-set-elabinelab-attribute] - \"$order\" is not a valid elabinelab order"
return return
} }
lappend elabinelab_attributes "$role,$key,$value,$order"
} }
proc tb-unset-elabinelab-attribute {role key} { proc tb-unset-elabinelab-attribute {role key} {
var_import ::TBCOMPAT::EINEROLE;
var_import ::TBCOMPAT::EINEKEY;
var_import ::TBCOMPAT::elabinelab_attributes;
if {[regexp $EINEROLE $role] == 0} {
perror "\[tb-unset-elabinelab-attribute] - \"$role\" is not a valid elabinelab role"
return
}
if {[regexp $EINEKEY $key] == 0} {
perror "\[tb-unset-elabinelab-attribute] - \"$key\" is not a valid elabinelab key"
return
}
while {[lsearch -glob $elabinelab_attributes "$role,$key,*"] > 0} {
set i [lsearch -glob $elabinelab_attributes "$role,$key,*"]
set elabinelab_attributes [lreplace $elabinelab_attributes $i $i]
}
} }
# #
......
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