Browse files

MB-5307: made run_in_ns.rb slightly less broken

Change-Id: Ifb6a5ebc01a941ea074e50882a83af0118e45657
Tested-by: Aliaksey Kandratsenka <>
Reviewed-by: Aliaksey Artamonau <>
  • Loading branch information...
1 parent d66e262 commit 3ee126dde1ef1f4430d4122ac7c981cd485494a3 Aliaksey Kandratsenka committed with alk Aug 19, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 scripts/run_in_ns.rb
19 scripts/run_in_ns.rb
@@ -33,6 +33,14 @@ def poll_for_condition(timeout=10.0, delay=0.1, &block)
+if ARGV == ["--help"]
+ puts <<HERE
+# NS_NODE_NAME='n_11@lh' ./cluster_run -n1 --start-index=11 --dont-rename -i --prepend-extras ./scripts/run_in_ns.rb
+ exit
# apparently vde is eating HUP. Or maybe not. Anyway ruby is normally
# messing up with SIGHUP, so lets make it at least do some work for
# us. That sending out of SIGTERM is really crucial here
@@ -61,14 +69,18 @@ def poll_for_condition(timeout=10.0, delay=0.1, &block)
dummy_name, node_name = ARGV.each_cons(2).detect {|(maybe_name, val)| maybe_name == "-name"}
-raise unless node_name =~ /\Ans?_([0-9]+)@/
+node_name ||= ENV['NS_NODE_NAME']
+raise "dont't have node -name" unless node_name =~ /\Ans?_([0-9]+)@/
node_number = $1.to_i
node_host = $'
-vde_sock = "/tmp/vdesock/c_node_#{node_number}"
+puts "node_number: #{node_number}\nnode_host: #{node_host}"
+vde_sock = "/tmp/vdesock/cs_node_#{node_number}"
tap_if = "tapCNode#{node_number}"
-netns = "c_node_#{node_number}"
+netns = "cs_node_#{node_number}"
ifaddr = "172.25.0.#{2+node_number}"
puts "Creating vde switch"
@@ -85,6 +97,7 @@ def poll_for_condition(timeout=10.0, delay=0.1, &block)
# ourselves (in fact it'll be open in erlang and all it's child :). So
# when we're 'done' wirefilter has less chance 'escaping'
puts "Creating netns"
+sh "ip netns exec #{netns} ifconfig lo down || true"
sh "ip netns del #{netns}; ip netns add #{netns}"
sh "ip netns exec #{netns} ifconfig lo up"
puts "Passing tap interface into netns"

0 comments on commit 3ee126d

Please sign in to comment.