From 2ea127180bd6aa7495d5bb0309371e2823e41c4c Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Wed, 8 Dec 2004 19:28:01 +0000
Subject: [PATCH] Allow specification of inner elab experiment eid in the NS
 file.  I'm so unhappy with my current approach that I decided to drop that
 idea for now and just specify the eid of the experiment to run.  Obviously,
 it has to be an existing experiment in the same project, whose nsfile is
 grabbed from the DB and shipped over to the inner boss.

---
 db/xmlconvert.in               |  1 +
 sql/database-fill.sql          |  1 +
 tbsetup/ns2ir/elabinelab.ns    | 10 +++-------
 tbsetup/ns2ir/parse.tcl.in     |  1 +
 tbsetup/ns2ir/sim.tcl.in       |  6 ++++++
 tbsetup/ns2ir/tb_compat.tcl.in |  5 +++++
 6 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/db/xmlconvert.in b/db/xmlconvert.in
index 4342eb000f..b00a640d30 100644
--- a/db/xmlconvert.in
+++ b/db/xmlconvert.in
@@ -151,6 +151,7 @@ my %experiment_fields = ("multiplex_factor"		=> 1,
 		         "modelnet_cores"		=> 1,
 		         "modelnet_edges"		=> 1,
 		         "elab_in_elab"			=> 1,
+		         "elabinelab_eid"		=> 1,
 		         "security_level"		=> 1);
 
 # New parsing code state machine control.
diff --git a/sql/database-fill.sql b/sql/database-fill.sql
index 59e3984f25..70c761cdd1 100644
--- a/sql/database-fill.sql
+++ b/sql/database-fill.sql
@@ -669,6 +669,7 @@ REPLACE INTO table_regex VALUES ('firewall_rules','ruleno','int','redirect','def
 REPLACE INTO table_regex VALUES ('firewall_rules','rule','text','regex','^\\w[-\\w \\t,/\\{\\}\\(\\)!:\\.]*$',0,1024,NULL);
 REPLACE INTO table_regex VALUES ('virt_nodes','inner_elab_role','text','regex','^(boss|ops|node)$',0,0,NULL);
 REPLACE INTO table_regex VALUES ('experiments','elab_in_elab','int','redirect','default:boolean',0,0,NULL);
+REPLACE INTO table_regex VALUES ('experiments','elabinelab_eid','text','redirect','experiments:eid',0,0,NULL);
 REPLACE INTO table_regex VALUES ('images','imageid','text','regex','^[a-zA-Z0-9][-\\w\\.+]+$',0,45,NULL);
 REPLACE INTO table_regex VALUES ('images','imagename','text','regex','^[a-zA-Z0-9][-\\w\\.+]+$',2,30,NULL);
 
diff --git a/tbsetup/ns2ir/elabinelab.ns b/tbsetup/ns2ir/elabinelab.ns
index 81b61ed742..d6ba29af29 100644
--- a/tbsetup/ns2ir/elabinelab.ns
+++ b/tbsetup/ns2ir/elabinelab.ns
@@ -9,7 +9,7 @@ set myboss [$ns node]
 set myops  [$ns node]
 
 tb-set-hardware $myboss pc2000
-tb-set-hardware $myops  pc2000
+tb-set-hardware $myops  pc850
 
 tb-elab-in-elab 1
 tb-set-node-inner-elab-role $myboss boss
@@ -22,7 +22,7 @@ for {set i 1} {$i <= $maxpcs} {incr i} {
 	append lanstr "[set $name] "
 	tb-set-node-os [set $name] FBSD-STD
 	tb-set-node-inner-elab-role [set $name] node
-	tb-set-hardware [set $name] pc600
+#	tb-set-hardware [set $name] pc600
 }
 set publiclan [$ns make-lan $lanstr 100Mb 0ms]
 
@@ -41,11 +41,7 @@ if {$security_level >= 2} {
 	# Set up a firewall
 	set fw [new Firewall $ns]
 	$fw set-type ipfw2-vlan
-	$fw set-style closed
-
-	# allow tracroute as well
-	$fw add-rule "allow udp from 155.98.36.0/22 to any 33434-33524"
-	$fw add-rule "allow udp from any 33434-33524 to 155.98.36.0/22"
+	$fw set-style open
 }
 
 # No routing! 
diff --git a/tbsetup/ns2ir/parse.tcl.in b/tbsetup/ns2ir/parse.tcl.in
index 3b7c0638e9..1e36729996 100644
--- a/tbsetup/ns2ir/parse.tcl.in
+++ b/tbsetup/ns2ir/parse.tcl.in
@@ -256,6 +256,7 @@ namespace eval GLOBALS {
 
     # Is an inner elab experiment.
     variable elab_in_elab 0
+    variable elabinelab_eid {}
 
     # Security level. Defaults to green
     variable security_level 0
diff --git a/tbsetup/ns2ir/sim.tcl.in b/tbsetup/ns2ir/sim.tcl.in
index 0474725389..d6f6c0190d 100644
--- a/tbsetup/ns2ir/sim.tcl.in
+++ b/tbsetup/ns2ir/sim.tcl.in
@@ -270,6 +270,7 @@ Simulator instproc run {} {
     var_import ::GLOBALS::modelnet_cores
     var_import ::GLOBALS::modelnet_edges
     var_import ::GLOBALS::elab_in_elab
+    var_import ::GLOBALS::elabinelab_eid
     var_import ::GLOBALS::security_level
     
     if {$ran == 1} {
@@ -452,6 +453,11 @@ Simulator instproc run {} {
     if {$elab_in_elab} {
 	lappend fields "elab_in_elab"
 	lappend values 1
+
+	if { $elabinelab_eid != {} } {
+	    lappend fields "elabinelab_eid"
+	    lappend values $elabinelab_eid
+	}
     }
     
     if {$security_level} {
diff --git a/tbsetup/ns2ir/tb_compat.tcl.in b/tbsetup/ns2ir/tb_compat.tcl.in
index 858f174bf6..61c498ea74 100644
--- a/tbsetup/ns2ir/tb_compat.tcl.in
+++ b/tbsetup/ns2ir/tb_compat.tcl.in
@@ -1438,6 +1438,11 @@ proc tb-elab-in-elab {onoff} {
 	set elab_in_elab 0
     }
 }
+proc tb-set-inner-elab-eid {eid} {
+    var_import ::GLOBALS::elabinelab_eid
+
+    set elabinelab_eid $eid
+}
 
 #
 # Set the inner elab role for a node.
-- 
GitLab