Commit 5a5376c9 authored by Kirk Webb's avatar Kirk Webb

Fix up bookkeeping.

parent a93c7f94
...@@ -158,12 +158,12 @@ sub mkVlanIfaceName($$$); ...@@ -158,12 +158,12 @@ sub mkVlanIfaceName($$$);
sub getIfConfig($); sub getIfConfig($);
sub interfaceExists($); sub interfaceExists($);
sub createVlanInterface($$); sub createVlanInterface($$);
sub runBlockstoreCmds($$); sub runBlockstoreCmds($$$);
sub removeVlanInterface($$); sub removeVlanInterface($$);
sub allocSlice($$$); sub allocSlice($$$$);
sub exportSlice($$$); sub exportSlice($$$$);
sub deallocSlice($$$); sub deallocSlice($$$$);
sub unexportSlice($$$); sub unexportSlice($$$$);
# Dispatch table for storage configuration commands. # Dispatch table for storage configuration commands.
my %setup_cmds = ( my %setup_cmds = (
...@@ -317,7 +317,7 @@ sub vnodeCreate($$$$) ...@@ -317,7 +317,7 @@ sub vnodeCreate($$$$)
} }
# Create blockstore slice # Create blockstore slice
if (runBlockstoreCmds($vnode_id, $vnconfig) != 0) { if (runBlockstoreCmds($vnode_id, $vnconfig, $private) != 0) {
TBScriptUnlock(); TBScriptUnlock();
fatal("blockstore_vnodeCreate: ". fatal("blockstore_vnodeCreate: ".
"Blockstore slice creation failed!"); "Blockstore slice creation failed!");
...@@ -430,7 +430,8 @@ sub vnodeDestroy($$$$){ ...@@ -430,7 +430,8 @@ sub vnodeDestroy($$$$){
foreach my $sconf (@revconfigs) { foreach my $sconf (@revconfigs) {
my $cmd = $sconf->{'CMD'}; my $cmd = $sconf->{'CMD'};
if (exists($teardown_cmds{$cmd})) { if (exists($teardown_cmds{$cmd})) {
if ($teardown_cmds{$cmd}->($vnode_id, $sconf, $vnconfig) != 0) { if ($teardown_cmds{$cmd}->($vnode_id, $sconf,
$vnconfig, $private) != 0) {
TBScriptUnlock(); TBScriptUnlock();
fatal("blockstore_vnodeDestroy: ". fatal("blockstore_vnodeDestroy: ".
"Failed to execute teardown command: $cmd"); "Failed to execute teardown command: $cmd");
...@@ -566,14 +567,15 @@ sub parseFreeNASListing($) { ...@@ -566,14 +567,15 @@ sub parseFreeNASListing($) {
# Run through list of storage commands and execute them, checking # Run through list of storage commands and execute them, checking
# for errors. (Should have a lock before doing this.) # for errors. (Should have a lock before doing this.)
# #
sub runBlockstoreCmds($$) { sub runBlockstoreCmds($$$) {
my ($vnode_id, $vnconfig) = @_; my ($vnode_id, $vnconfig, $private) = @_;
my $sconfigs = $vnconfig->{'storageconfig'}; my $sconfigs = $vnconfig->{'storageconfig'};
foreach my $sconf (@$sconfigs) { foreach my $sconf (@$sconfigs) {
my $cmd = $sconf->{'CMD'}; my $cmd = $sconf->{'CMD'};
if (exists($setup_cmds{$cmd})) { if (exists($setup_cmds{$cmd})) {
if ($setup_cmds{$cmd}->($vnode_id, $sconf, $vnconfig) != 0) { if ($setup_cmds{$cmd}->($vnode_id, $sconf,
$vnconfig, $private) != 0) {
warn("*** ERROR: blockstore_runBlockstoreCmds: ". warn("*** ERROR: blockstore_runBlockstoreCmds: ".
"Failed to execute setup command: $cmd"); "Failed to execute setup command: $cmd");
return -1; return -1;
...@@ -732,10 +734,8 @@ sub getPoolList() { ...@@ -732,10 +734,8 @@ sub getPoolList() {
# Allocate a slice based on information from Emulab Central # Allocate a slice based on information from Emulab Central
# XXX: Do 'sliceconfig' parameter checking. # XXX: Do 'sliceconfig' parameter checking.
sub allocSlice($$$) { sub allocSlice($$$$) {
my ($vnode_id, $sconf, $vnconfig) = @_; my ($vnode_id, $sconf, $vnconfig, $priv) = @_;
my $priv = $vnconfig->{'private'};
my $slices = getSliceList(); my $slices = getSliceList();
my $pools = getPoolList(); my $pools = getPoolList();
...@@ -752,7 +752,7 @@ sub allocSlice($$$) { ...@@ -752,7 +752,7 @@ sub allocSlice($$$) {
my $destpool; my $destpool;
if (exists($pools->{$bsid})) { if (exists($pools->{$bsid})) {
$destpool = $pools->{$bsid}; $destpool = $pools->{$bsid};
$priv->{"bsid"} = $bsid; # save for future calls. $priv->{'bsid'} = $bsid; # save for future calls.
} else { } else {
warn("*** ERROR: blockstore_allocSlice: ". warn("*** ERROR: blockstore_allocSlice: ".
"Requested blockstore not found: $bsid!"); "Requested blockstore not found: $bsid!");
...@@ -782,8 +782,8 @@ sub allocSlice($$$) { ...@@ -782,8 +782,8 @@ sub allocSlice($$$) {
} }
# Setup device export. # Setup device export.
sub exportSlice($$$) { sub exportSlice($$$$) {
my ($vnode_id, $sconf, $vnconfig) = @_; my ($vnode_id, $sconf, $vnconfig, $priv) = @_;
# Should only be one ifconfig entry - checked earlier. # Should only be one ifconfig entry - checked earlier.
my $ifcfg = (@{$vnconfig->{'ifconfig'}})[0]; my $ifcfg = (@{$vnconfig->{'ifconfig'}})[0];
...@@ -797,10 +797,10 @@ sub exportSlice($$$) { ...@@ -797,10 +797,10 @@ sub exportSlice($$$) {
} }
# Extract bsid # Extract bsid
my $bsid = untaintHostname($sconf->{'BSID'}); my $bsid = $priv->{'bsid'};
if (!defined($bsid)) { if (!defined($bsid)) {
warn("*** ERROR: blockstore_exportSlice: ". warn("*** ERROR: blockstore_exportSlice: ".
"blockstore ID not found or invalid!"); "blockstore ID not found!");
return -1; return -1;
} }
...@@ -1124,8 +1124,8 @@ sub removeVlanInterface($$) { ...@@ -1124,8 +1124,8 @@ sub removeVlanInterface($$) {
return 0; return 0;
} }
sub unexportSlice($$$) { sub unexportSlice($$$$) {
my ($vnode_id, $sconf, $vnconfig) = @_; my ($vnode_id, $sconf, $vnconfig, $priv) = @_;
# Check that the slice exists. Emit warning and return if not. # Check that the slice exists. Emit warning and return if not.
my $slices = getSliceList(); my $slices = getSliceList();
...@@ -1191,9 +1191,8 @@ sub unexportSlice($$$) { ...@@ -1191,9 +1191,8 @@ sub unexportSlice($$$) {
return 0; return 0;
} }
sub deallocSlice($$$) { sub deallocSlice($$$$) {
my ($vnode_id, $sconf, $vnconfig) = @_; my ($vnode_id, $sconf, $vnconfig, $priv) = @_;
my $priv = $vnconfig->{'private'};
# Check that the associated storage pool exists. # Check that the associated storage pool exists.
my $pools = getPoolList(); my $pools = getPoolList();
......
...@@ -72,7 +72,8 @@ my %sconf = ( ...@@ -72,7 +72,8 @@ my %sconf = (
'VOLNAME' => "d-1", 'VOLNAME' => "d-1",
'VOLSIZE' => "51200", 'VOLSIZE' => "51200",
); );
libvnode_blockstore::allocSlice($vnodeid, \%sconf, $vnconfig); libvnode_blockstore::allocSlice($vnodeid, \%sconf, $vnconfig,
$vnconfig->{'private'});
# Try to export it! # Try to export it!
my %sconf2 = ( my %sconf2 = (
...@@ -86,7 +87,8 @@ my %sconf2 = ( ...@@ -86,7 +87,8 @@ my %sconf2 = (
'UUID' => "iqn.2000-10.net.emulab:tbres:sandev:d-1", 'UUID' => "iqn.2000-10.net.emulab:tbres:sandev:d-1",
'UUID_TYPE' => "iqn", 'UUID_TYPE' => "iqn",
); );
libvnode_blockstore::exportSlice($vnodeid, \%sconf2, $vnconfig); libvnode_blockstore::exportSlice($vnodeid, \%sconf2, $vnconfig,
$vnconfig->{'private'});
sub mkvnconfig($) { sub mkvnconfig($) {
my $vnodeid = shift; my $vnodeid = shift;
......
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