From d3622fe892c291d069c90f70864fd01b3dfd683a Mon Sep 17 00:00:00 2001
From: Kirk Webb <kwebb@flux.utah.edu>
Date: Thu, 16 May 2013 12:17:30 -0600
Subject: [PATCH] Schema update for new blockstore OS features.

---
 sql/database-create.sql      |  2 +-
 sql/updates/4/356            | 21 +++++++++++++++++++++
 tbsetup/libvtop_test.pm.in   |  2 +-
 tbsetup/ns2ir/blockstore.tcl | 15 ++++++++-------
 tbsetup/ns2ir/sim.tcl.in     | 16 ++++++++--------
 5 files changed, 39 insertions(+), 17 deletions(-)
 create mode 100644 sql/updates/4/356

diff --git a/sql/database-create.sql b/sql/database-create.sql
index 364d59d5b2..99a7720a3e 100644
--- a/sql/database-create.sql
+++ b/sql/database-create.sql
@@ -3050,7 +3050,7 @@ CREATE TABLE `os_info` (
   `path` tinytext,
   `magic` tinytext,
   `machinetype` varchar(30) NOT NULL default '',
-  `osfeatures` set('ping','ssh','ipod','isup','veths','veth-ne','veth-en','mlinks','linktest','linkdelays','vlans','suboses','ontrustedboot','no-usb-boot','egre') default NULL,
+  `osfeatures` set('ping','ssh','ipod','isup','veths','veth-ne','veth-en','mlinks','linktest','linkdelays','vlans','suboses','ontrustedboot','no-usb-boot','egre','loc-bstore','rem-bstore') default NULL,
   `ezid` tinyint(4) NOT NULL default '0',
   `shared` tinyint(4) NOT NULL default '0',
   `mustclean` tinyint(4) NOT NULL default '1',
diff --git a/sql/updates/4/356 b/sql/updates/4/356
new file mode 100644
index 0000000000..e374d65c46
--- /dev/null
+++ b/sql/updates/4/356
@@ -0,0 +1,21 @@
+#
+# Add remote and local blockstore os features.
+#
+use strict;
+use libdb;
+
+sub DoUpdate($$$)
+{
+    my ($dbhandle, $dbname, $version) = @_;
+
+    DBQueryFatal("alter table os_info modify ".
+                 "  `osfeatures` set('ping','ssh','ipod','isup','veths','veth-ne','veth-en','mlinks','linktest','linkdelays','vlans','suboses','ontrustedboot','no-usb-boot','egre','loc-bstore','rem-bstore') default NULL");
+
+    return 0;
+}
+
+1;
+
+# Local Variables:
+# mode:perl
+# End:
diff --git a/tbsetup/libvtop_test.pm.in b/tbsetup/libvtop_test.pm.in
index 6f29e95099..9e6c977864 100755
--- a/tbsetup/libvtop_test.pm.in
+++ b/tbsetup/libvtop_test.pm.in
@@ -2715,7 +2715,7 @@ sub GenVirtLans($)
 
 	# The OS on all nodes in a lan containing remote blockstores
 	# (sanlan) must support the "rem-bstore" OS feature.
-	if ($sanlan && $nodesdo{'rem-bstore'} != $realnodes) {
+	if ($sanlan && $nodesdo{"rem-bstore"} != $realnodes) {
 	    tberror("The OS on all nodes in sanlan $vname must support ".
 		    "remote blockstores.\n");
 	    return -1;
diff --git a/tbsetup/ns2ir/blockstore.tcl b/tbsetup/ns2ir/blockstore.tcl
index c3433a035c..5924e93978 100644
--- a/tbsetup/ns2ir/blockstore.tcl
+++ b/tbsetup/ns2ir/blockstore.tcl
@@ -183,13 +183,7 @@ Blockstore instproc set_fixed {pnode} {
 	perror "Can only fix blockstores to a node object!"
     }
 
-    # Deal with some syntactic sugar for 1-to-1 bindings to nodes.
-    if {[$pnode set type] != "blockstore" && $attributes(class) == "SAN"} {
-	set node [$self alloc_pseudonode]
-	uplevel "#0" "set ${self}-link [$sim duplex-link $pnode $node ~ 0ms DropTail]"
-    } else {
-	set node $pnode
-    }
+    set node $pnode
 
     return
 }
@@ -257,6 +251,13 @@ Blockstore instproc finalize {} {
 	    perror "Placement setting only makes sense with local blockstores: $self"
 	    return -1
 	}
+	# Deal with some syntactic sugar for 1-to-1 bindings to nodes.
+	if {[$node set type] != "blockstore"} {
+	    set pnode $node
+	    set node [$self alloc_pseudonode]
+	    uplevel "#0" "set ${self}-link [$sim duplex-link $pnode $node ~ 0ms DropTail]"
+	}
+	${self}-link set sanlan 1
 	# Die if the user has attempted to connect the blockstore via multiple
 	# links.  We only support one.
 	if {[llength [$node set portlist]] != 1} {
diff --git a/tbsetup/ns2ir/sim.tcl.in b/tbsetup/ns2ir/sim.tcl.in
index b2026fcac6..ffcc6999e4 100644
--- a/tbsetup/ns2ir/sim.tcl.in
+++ b/tbsetup/ns2ir/sim.tcl.in
@@ -559,6 +559,14 @@ Simulator instproc run {} {
 	uplevel 1 real_source "@prefix@/lib/ns2ir/fw.ns"
     }
 
+    # Finalize the blockstore objects - last minute initialization and checks
+    # before they are spit out to the db.
+    foreach bstore [array names blockstore_list] {
+	if {[$bstore finalize] != 0} {
+	    break
+	}
+    }
+
     # Fill out IPs
     if {! $use_ipassign } {
 	foreach obj [concat [array names lanlink_list]] {
@@ -605,14 +613,6 @@ Simulator instproc run {} {
 	}
     }
 
-    # Finalize the blockstore objects - last minute initialization and checks
-    # before they are spit out to the db.
-    foreach bstore [array names blockstore_list] {
-	if {[$bstore finalize] != 0} {
-	    break
-	}
-    }
-
     # If any errors occur stop here.
     if {$errors == 1} {return}
 
-- 
GitLab