From b796817b97466ddf99654d3554e434fbae8c4099 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Sat, 18 Jun 2011 01:26:45 +0200 Subject: [PATCH 1/5] bug: remote dir is not recreated if removed --- src/mad/ruby/CommandManager.rb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index d08c6988dc..b7f5864cfe 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -160,15 +160,6 @@ private end class RemotesCommand < SSHCommand - ONE_LOCATION=ENV["ONE_LOCATION"] - - if !ONE_LOCATION - REMOTES_LOCATION="/var/lib/one/remotes" - else - REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/" - end - - MAGIC_RC = 42 # Creates a command and runs it def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0) @@ -182,9 +173,7 @@ class RemotesCommand < SSHCommand while cmd.code != 0 and retries != 0 if cmd.code == MAGIC_RC - cmd.update_remotes(host, remote_dir, logger) - - @command = command + update_remotes(host, remote_dir, logger) cmd.run end @@ -196,10 +185,25 @@ class RemotesCommand < SSHCommand cmd end - def update_remotes(host, remote_dir, logger=nil) +private + + ONE_LOCATION=ENV["ONE_LOCATION"] + + if !ONE_LOCATION + REMOTES_LOCATION="/var/lib/one/remotes" + else + REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/" + end + + MAGIC_RC = 42 + + def self.update_remotes(host, remote_dir, logger=nil) log("Remote worker node files not found") log("Updating remotes") + #recreate remote dir structure + SSHCommand.run("mkdir -p #{remote_dir}",host,logger) + # Use SCP to sync: sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{remote_dir}" From 778e17eb6500a84b93f01c3c1430449d4738f082 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Sat, 18 Jun 2011 02:11:56 +0200 Subject: [PATCH 2/5] bug: fixes update functionality --- src/mad/ruby/CommandManager.rb | 6 ++++-- src/mad/ruby/OpenNebulaDriver.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index b7f5864cfe..0f8561d2ea 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -198,8 +198,10 @@ private MAGIC_RC = 42 def self.update_remotes(host, remote_dir, logger=nil) - log("Remote worker node files not found") - log("Updating remotes") + if logger != nil + logger.call("Remote worker node files not found") + logger.call("Updating remotes") + end #recreate remote dir structure SSHCommand.run("mkdir -p #{remote_dir}",host,logger) diff --git a/src/mad/ruby/OpenNebulaDriver.rb b/src/mad/ruby/OpenNebulaDriver.rb index ad44359d3c..7b32ad705a 100644 --- a/src/mad/ruby/OpenNebulaDriver.rb +++ b/src/mad/ruby/OpenNebulaDriver.rb @@ -149,7 +149,7 @@ class OpenNebulaDriver < ActionManager if action_is_local? aname local_action(command, id, aname) else - remotes_action(command, id, host, aname, @remote_scripts_path, + remotes_action(command, id, host, aname, @remote_scripts_base_path, options[:stdin]) end end From 41bbe8ccb9f834ab66b31c53cf1f966241d5c035 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" <rubensm@dacya.ucm.es> Date: Sat, 18 Jun 2011 02:27:23 +0200 Subject: [PATCH 3/5] bug: removed unneeded command execution when remotes dir is missing --- src/mad/ruby/CommandManager.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index 0f8561d2ea..e8e62ab818 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -174,7 +174,6 @@ class RemotesCommand < SSHCommand while cmd.code != 0 and retries != 0 if cmd.code == MAGIC_RC update_remotes(host, remote_dir, logger) - cmd.run end sleep 1 From 2dd628cc360dac9c987c859fcb1b9328f127f6cd Mon Sep 17 00:00:00 2001 From: Javi Fontan <jfontan@fdi.ucm.es> Date: Sat, 18 Jun 2011 18:22:56 +0200 Subject: [PATCH 4/5] Changed authm_mad test to be runable from test dir --- src/authm_mad/test/one_usage_spec.rb | 4 +++- src/authm_mad/test/quota_spec.rb | 4 +++- src/authm_mad/test/simple_permissions_spec.rb | 4 +++- src/authm_mad/test/spec_common.rb | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/authm_mad/test/one_usage_spec.rb b/src/authm_mad/test/one_usage_spec.rb index 3b56a344ff..1a68229128 100644 --- a/src/authm_mad/test/one_usage_spec.rb +++ b/src/authm_mad/test/one_usage_spec.rb @@ -14,6 +14,8 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +$: << '../' + require 'spec_common' require 'client_mock' @@ -21,7 +23,7 @@ require 'one_usage' describe "OneUsage" do before(:all) do - mock_data=YAML::load(File.read('spec/oca_vms.yaml')) + mock_data=YAML::load(File.read('oca_vms.yaml')) client=ClientMock.new(mock_data) @one_usage=OneUsage.new(client) end diff --git a/src/authm_mad/test/quota_spec.rb b/src/authm_mad/test/quota_spec.rb index 6bb1b7fc3d..7743e45622 100644 --- a/src/authm_mad/test/quota_spec.rb +++ b/src/authm_mad/test/quota_spec.rb @@ -14,6 +14,8 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +$: << '../' + require 'spec_common' require 'client_mock' @@ -30,7 +32,7 @@ end describe 'Quota' do before(:all) do @db=Sequel.sqlite - mock_data=YAML::load(File.read('spec/oca_vms.yaml')) + mock_data=YAML::load(File.read('oca_vms.yaml')) client=ClientMock.new(mock_data) @quota=Quota.new(@db, client) end diff --git a/src/authm_mad/test/simple_permissions_spec.rb b/src/authm_mad/test/simple_permissions_spec.rb index b2164713b5..75a63bf2b6 100644 --- a/src/authm_mad/test/simple_permissions_spec.rb +++ b/src/authm_mad/test/simple_permissions_spec.rb @@ -14,6 +14,8 @@ # limitations under the License. # #--------------------------------------------------------------------------- # +$: << '../' + require 'spec_common' require 'client_mock' @@ -64,7 +66,7 @@ end describe SimplePermissions do before(:all) do @db=Sequel.sqlite - mock_data=YAML::load(File.read('spec/oca_vms.yaml')) + mock_data=YAML::load(File.read('oca_vms.yaml')) client=ClientMock.new(mock_data) @perm=SimplePermissions.new(@db, client, YAML::load(CONF)) end diff --git a/src/authm_mad/test/spec_common.rb b/src/authm_mad/test/spec_common.rb index 016ff885d1..80850db4fd 100644 --- a/src/authm_mad/test/spec_common.rb +++ b/src/authm_mad/test/spec_common.rb @@ -16,10 +16,11 @@ require 'pp' +$: << '../../oca/ruby' +$: << '..' + require 'db_helpers' -$: << '../oca/ruby' -$: << './spec' From 6693c8e04ab1ae0228cc1bf6693fff3a95ef9bcf Mon Sep 17 00:00:00 2001 From: Javi Fontan <jfontan@fdi.ucm.es> Date: Sat, 18 Jun 2011 18:59:35 +0200 Subject: [PATCH 5/5] Changed ruby mad test to be runable from test dir --- src/mad/ruby/test/OpenNebulaDriver_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mad/ruby/test/OpenNebulaDriver_spec.rb b/src/mad/ruby/test/OpenNebulaDriver_spec.rb index 408b907337..6b1efffce6 100644 --- a/src/mad/ruby/test/OpenNebulaDriver_spec.rb +++ b/src/mad/ruby/test/OpenNebulaDriver_spec.rb @@ -1,4 +1,5 @@ +$: << '..' require 'OpenNebulaDriver' require 'test/MonkeyPatcher' @@ -26,7 +27,7 @@ class OpenNebulaDriver def read_configuration old_one_location=ENV['ONE_LOCATION'] - ENV['ONE_LOCATION']=File.join(ENV['PWD'], 'test', 'fixtures') + ENV['ONE_LOCATION']=File.join(ENV['PWD'], 'fixtures') result=read_configuration_old ENV['ONE_LOCATION']=old_one_location result