Commit b0d1eab7 authored by Gary Wong's avatar Gary Wong

Save profile parameters in database. Closes #33.

parent 2a96fc09
......@@ -182,7 +182,8 @@ $EXPT_RESOURCESHOSED = 0;
"virt_client_service_opts",
"virt_blockstores",
"virt_blockstore_attributes",
"virt_address_allocation");
"virt_address_allocation",
"virt_profile_parameters");
%physicalTables = ("delays" => ["node_id", "vname", "vnode0", "vnode1"],
"v2pmap" => ["node_id", "vname"],
......@@ -6419,5 +6420,40 @@ sub LookupAddressPools($$)
return $result;
}
#
# Add a profile parameter.
#
sub AddProfileParameter($$$)
{
my ($self, $name, $value) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $pid = $self->pid();
my $eid = $self->eid();
my $exptidx = $self->idx();
if (defined($name)) {
$name = DBQuoteSpecial($name);
} else {
return -1;
}
if (defined($value)) {
$value = DBQuoteSpecial($value);
} else {
$value = "''";
}
DBQueryWarn( "REPLACE INTO virt_profile_parameters SET pid='$pid', " .
"eid='$eid', exptidx='$exptidx', name=$name, " .
"value=$value" )
or return -1;
return 0;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -3012,6 +3012,12 @@ sub GetTicketAuxAux($$$$$$$$$$$)
goto bad;
}
# Save a local copy of any profile parameters.
foreach my $param ( @{ GeniXML::GetProfileParameters( $rspec ) } ) {
$slice_experiment->AddProfileParameter( $param->{ 'name' },
$param->{ 'value' } );
}
#
# Now contact external CMs to coordinate vlans.
#
......
......@@ -43,7 +43,8 @@ GetVirtualizationType SetVirtualizationSubtype GetVirtualizationSubtype
GetExclusive SetExclusive GetLinkManager SetText GetText Serialize
CreateDocument AddElement RemoveChild PolicyExists GetMask
GetDiskImage IsUntaggedLan IsTaggedLan GetAddressPools GetHopLinkID GetCapabilitySection
GetSuggestedVlanFromHop GetAvailableVlanFromHop SetVlanTagInHop);
GetSuggestedVlanFromHop GetAvailableVlanFromHop SetVlanTagInHop
GetProfileParamaters);
use English;
use Data::Dumper;
......@@ -60,7 +61,8 @@ use vars qw($RSPEC_0_1 $RSPEC_0_2 $RSPEC_2 $RSPEC_3
$RSPEC_0_1_NS $RSPEC_0_2_NS $RSPEC_2_NS
$EMULAB_NS $JACKS_NS $XSI_NS $STITCH_NS $SHAREDVLAN_NS $SITEINFO_NS
$REQUEST_2_URL $MANIFEST_2_URL
$REQUEST_3_URL $MANIFEST_3_URL);
$REQUEST_3_URL $MANIFEST_3_URL
$PROFILE_PARAMETERS_NS);
$RSPEC_0_1 = "0.1";
$RSPEC_0_2 = "0.2";
$RSPEC_2 = "2";
......@@ -77,6 +79,7 @@ our $XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
our $STITCH_NS = "http://hpn.east.isi.edu/rspec/ext/stitch/0.1/";
our $SHAREDVLAN_NS = "http://www.geni.net/resources/rspec/ext/shared-vlan/1";
our $SHAREDVLAN_PG_NS = "http://www.protogeni.net/resources/rspec/ext/shared-vlan/1";
our $PROFILE_PARAMETERS_NS = "http://www.protogeni.net/resources/rspec/ext/profile-parameters/1";
$REQUEST_2_URL = "http://www.protogeni.net/resources/rspec/2/request.xsd";
$MANIFEST_2_URL = "http://www.protogeni.net/resources/rspec/2/manifest.xsd";
......@@ -1417,5 +1420,22 @@ sub GetADBTarget($)
return GetText( "adb_target", $node );
}
sub GetProfileParameters($)
{
my ($rspec) = @_;
my $result = [];
my @parameters = FindNodesNS("n:parameter", $rspec,
$PROFILE_PARAMETERS_NS)->get_nodelist();
foreach my $parameter (@parameters) {
my $name = GetText( "name", $parameter );
my $value = GetText( "value", $parameter );
push( @{ $result }, {
"name" => $name,
"value" => $value
} );
}
return $result;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -5426,6 +5426,20 @@ CREATE TABLE `virt_paths` (
KEY `pideid` (`pid`,`eid`,`pathname`,`segmentname`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `virt_profile_parameters`
--
DROP TABLE IF EXISTS `virt_profile_parameters`;
CREATE TABLE `virt_profile_parameters` (
`pid` varchar(48) NOT NULL DEFAULT '',
`eid` varchar(32) NOT NULL DEFAULT '',
`exptidx` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL,
`value` text NOT NULL,
PRIMARY KEY (`exptidx`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `virt_programs`
--
......
use strict;
use libdb;
use Image;
use EmulabFeatures;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBTableExists("virt_profile_parameters")) {
DBQueryFatal("CREATE TABLE `virt_profile_parameters` ( ".
" `pid` varchar(48) NOT NULL default '', ".
" `eid` varchar(32) NOT NULL default '', ".
" `exptidx` int(11) NOT NULL default '0', ".
" `name` varchar(255) NOT NULL, ".
" `value` text NOT NULL, ".
" PRIMARY KEY (`exptidx`, `name`) ".
") ENGINE=MyISAM DEFAULT CHARSET=latin1");
}
return 0;
}
# Local Variables:
# mode:perl
# End:
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