Commit 09177fb2 authored by Mike Hibler's avatar Mike Hibler

The parser-side of persistent blockstore support.

In parse-ns, we generate a list of accessible blockstores and put that in
the .input file. The accessiblity check right now is just that the blockstore
(actually lease) pid must match that of the experiment. This needs to be
generalized.

The blockstore set-lease command verifies that the asked-for lease matches
one of those accessible blockstores. If it does, it make sure the correct
size and other info wind up in the virt_blockstores table. Less obviously,
but of critical importance, it emits a "lease" virt_blockstore_attribute
with the correct lease index. This attributes gets converted into the
desire that is added by vtopgen to the .vtop file.
parent a721e561
# -*- tcl -*-
#
# Copyright (c) 2012-2013 University of Utah and the Flux Group.
......@@ -49,8 +48,8 @@ Blockstore instproc init {s} {
$self set node {}
$self set type {}
$self set size 0
$self set type {}
$self set role "unknown"
$self set leasename {}
# for compat with LanLink
$self set simulated 0
......@@ -106,6 +105,33 @@ Blockstore instproc set-type {newtype} {
return
}
Blockstore instproc set-lease {lname} {
var_import ::TBCOMPAT::dataset_node
var_import ::TBCOMPAT::dataset_index
var_import ::GLOBALS::pid
var_import ::GLOBALS::anonymous
var_import ::GLOBALS::passmode
$self instvar leasename
$self instvar attributes
set fullname $lname
set index 0
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode}} {
if {[string first / $lname] == -1} {
set fullname "$pid/"
append fullname $lname
}
if {![info exists dataset_node($fullname)]} {
perror "\[set-lease] Invalid lease name $lname ($fullname)"
return
}
set index $dataset_index($fullname)
}
set leasename $fullname
set attributes(lease) $index
return
}
Blockstore instproc set-placement {newplace} {
var_import ::TBCOMPAT::soplacementdesires
$self instvar attributes
......@@ -221,10 +247,16 @@ Blockstore instproc finalize {} {
var_import ::TBCOMPAT::sofullplacements
var_import ::TBCOMPAT::soplacementdesires
var_import ::TBCOMPAT::sonodemounts
var_import ::TBCOMPAT::dataset_node
var_import ::TBCOMPAT::dataset_size
var_import ::TBCOMPAT::dataset_type
var_import ::TBCOMPAT::dataset_bsid
$self instvar sim
$self instvar node
$self instvar size
$self instvar type
$self instvar attributes
$self instvar leasename
# Die if the user didn't attach the blockstore to anything.
if { $node == {} } {
......@@ -232,6 +264,32 @@ Blockstore instproc finalize {} {
return -1
}
# If the blockstore is associated with a lease, disallow/override certain
# explicitly-specified values
if {$leasename != {}} {
var_import ::GLOBALS::anonymous
var_import ::GLOBALS::passmode
var_import ::GLOBALS::pid
if {$size != 0 || $type != {} ||
[info exists attributes(class)] ||
[info exists attributes(protocol)]} {
perror "Cannot explicitly set size/type/class/protocol of lease-associated blockstore $self";
return -1;
}
if {! ${GLOBALS::anonymous} && ! ${GLOBALS::passmode}} {
set size $dataset_size($leasename)
set type $dataset_type($leasename)
} else {
set size 1
set type "stdataset"
}
# XXX
set attributes(class) "SAN"
set attributes(protocol) "iSCSI"
}
# Make sure the blockstore has class...
if {![info exists attributes(class)]} {
perror "Blockstore's class must be specified: $self"
......
......@@ -110,6 +110,8 @@ use Template;
use Experiment;
use User;
use BlockstoreType;
use Blockstore;
use Lease;
use constant false => 0;
use constant true => 1;
......@@ -879,6 +881,37 @@ sub GenDefsFile($)
}
print TCL "\n";
#
# XXX for now, all available datasets (leases) are those in the
# same project as the experiment.
#
if (defined($experiment)) {
my $pid = $experiment->pid();
my @leases = Lease->AllProjectLeases($pid);
print TCL "# Available datasets\n";
foreach my $lease (@leases) {
# lease must be valid
next if ($lease->state() ne "valid");
# must have associated blockstore
my $idx = $lease->lease_idx();
my $bstore = Blockstore->LookupByLease($idx);
next if (!$bstore);
my $name = "$pid/" . $lease->lease_id();
my $type = $lease->type();
my $node = $bstore->node_id();
my $bsid = $bstore->bs_id();
my $size = $bstore->total_size();
print TCL "set dataset_node($name) $node\n";
print TCL "set dataset_bsid($name) $bsid\n";
print TCL "set dataset_type($name) $type\n";
print TCL "set dataset_size($name) $size\n";
print TCL "set dataset_index($name) $idx\n";
}
print TCL "\n";
}
print TCL "# Storage Objects\n";
my @sotypes = BlockstoreType->AllTypes();
foreach my $sot (@sotypes) {
......
......@@ -103,6 +103,7 @@ namespace eval TBCOMPAT {
array set sodesires {
"class" 1
"protocol" 1
"lease" 1
}
variable soplacementdesires
......
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