Commit 1e12f604 authored by Mike Hibler's avatar Mike Hibler

Final tweaks to get elabinelab attributes through to the DB.

parent bb243a68
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2009, 2010 University of Utah and the Flux Group.
# Copyright (c) 2009-2010 University of Utah and the Flux Group.
# All rights reserved.
#
package VirtExperiment;
......@@ -69,7 +69,7 @@ my $debug = 0;
"event_groups" => [ "group_name", "agent_name" ],
"virt_firewalls" => [ "fwname", "type", "style" ],
"firewall_rules" => [ "fwname", "ruleno", "rule" ],
"elabinelab_attributes" => [ "role", "attrkey", "order" ],
"elabinelab_attributes" => [ "role", "attrkey", "ordering" ],
"virt_tiptunnels" => [ "host", "vnode" ],
"virt_parameters" => [ "name", "value" ],
);
......@@ -628,7 +628,7 @@ sub NewRow($$)
$argref->{$key} = $self->{'COUNTER'}++;
}
else {
carp("Missing table key for new table in $tablename");
carp("Missing table key $key for new table in $tablename");
return undef;
}
}
......@@ -1179,5 +1179,10 @@ use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::elabinelab_attributes;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -432,8 +432,8 @@ CREATE TABLE `elabinelab_attributes` (
`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`)
`ordering` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`exptidx`,`role`,`attrkey`,`ordering`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
......
......@@ -963,6 +963,11 @@ REPLACE INTO table_regex VALUES ('user_pubkeys','verify','text','redirect','defa
REPLACE INTO table_regex VALUES ('user_pubkeys','user','text','redirect','users:uid',0,0,NULL);
REPLACE INTO table_regex VALUES ('user_pubkeys','keyfile','text','regex','^[-_\\w\\.\\/:+]*$',1,256,NULL);
REPLACE INTO table_regex VALUES ('elabinelab_attributes','role','text','regex','^(boss|router|ops|fs|node)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('elabinelab_attributes','attrkey','text','regex','^[-\\w\\.]+$',1,32,NULL);
REPLACE INTO table_regex VALUES ('elabinelab_attributes','attrvalue','text','regex','^[-\\w\\.\\+,\\s\\/]+$',0,255,NULL);
REPLACE INTO table_regex VALUES ('elabinelab_attributes','ordering','int','redirect','default:tinyint',0,0,NULL);
REPLACE INTO table_regex VALUES ('default','tinytext_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,256,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','text_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','fulltext_utf8','text','regex','^(?:[\\x09\\x0A\\x0D\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
......
......@@ -16,11 +16,25 @@ sub DoUpdate($$$)
" `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`) ".
" `ordering` smallint(5) unsigned NOT NULL default '0', ".
" PRIMARY KEY (`exptidx`,`role`,`attrkey`,`ordering`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
# Fill in check fields
DBQueryFatal("REPLACE INTO table_regex VALUES".
" ('elabinelab_attributes','role','text','regex',".
" '^(boss|router|ops|fs|node)\$',0,0,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES".
" ('elabinelab_attributes','attrkey','text','regex',".
" '^[-\\\\w\\\\.]+\$',1,32,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES".
" ('elabinelab_attributes','attrvalue','text','regex',".
" '^[-\\\\w\\\\.\\\\+,\\\\s\\\\/]+\$',0,255,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES".
" ('elabinelab_attributes','ordering','int','redirect',".
" 'default:tinyint',0,0,NULL)");
# Initialize new table.
return 0;
}
......
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004, 2006, 2009 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -80,6 +80,8 @@ proc tb-elab-in-elab-topology {topo} {}
proc tb-set-inner-elab-eid {eid} {}
proc tb-set-elabinelab-cvstag {cvstag} {}
proc tb-elabinelab-singlenet {} {}
proc tb-set-elabinelab-attribute {role key val {order 0}} {}
proc tb-unset-elabinelab-attribute {role key} {}
proc tb-set-node-inner-elab-role {node role} {}
proc tb-set-node-id {vnode myid} {}
proc tb-set-link-est-bandwidth {srclink args} {}
......
......@@ -703,13 +703,8 @@ Simulator instproc run {} {
if {$elab_in_elab} {
foreach attr $elabinelab_attributes {
set fields [list "role" "attrkey" "attrvalue" "order"]
set fields [list "role" "attrkey" "attrvalue" "ordering"]
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
}
}
......
......@@ -133,9 +133,9 @@ namespace eval TBCOMPAT {
# Elabinelab attribute stuff.
variable elabinelab_attributes
set elabinelab_attributes {}
variable EINEROLE {^(boss|ops|fs|router)$}
variable EINEKEY {^(\w[-\w\.]+)$}
variable EINEVALUE {^([-\w\s\.\,\/]+)$}
variable EINEROLE {^(boss|ops|fs|router|node)$}
variable EINEKEY {^([-\w\.]+)$}
variable EINEVALUE {^([-\w\.\+\,\s\/]+)$}
variable EINEORDER {^\d+$}
# Mapping of "resource classes" and "reservation types" to bootstrap
......@@ -1798,7 +1798,7 @@ proc tb-unset-elabinelab-attribute {role key} {
perror "\[tb-unset-elabinelab-attribute] - \"$key\" is not a valid elabinelab key"
return
}
while {[lsearch -glob $elabinelab_attributes "$role,$key,*"] > 0} {
while {[lsearch -glob $elabinelab_attributes "$role,$key,*"] > -1} {
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