From c4dbdf53ef6a02dbc7f688dabbf4ea8c8f8da9b7 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 19 Nov 2010 14:43:40 +0100 Subject: [PATCH] bug #412: Fix remotes location for RemoteCommand. Checks info string to be returned to the core. Includes std output for local_actions --- src/mad/ruby/CommandManager.rb | 23 ++++++++++----------- src/mad/ruby/VirtualMachineDriver.rb | 30 +++++++++++++++++----------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/mad/ruby/CommandManager.rb b/src/mad/ruby/CommandManager.rb index 8879df8c83..f7a17b1492 100644 --- a/src/mad/ruby/CommandManager.rb +++ b/src/mad/ruby/CommandManager.rb @@ -140,37 +140,36 @@ end class RemotesCommand < SSHCommand ONE_LOCATION=ENV["ONE_LOCATION"] - + if !ONE_LOCATION - REMOTES_LOCATION="/usr/lib/one/remotes" + REMOTES_LOCATION="/var/lib/one/remotes" else - REMOTES_LOCATION=ONE_LOCATION+"/lib/remotes/" + 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) cmd_file = command.split(' ')[0] - + cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\ exit #{MAGIC_RC}; fi'" - - cmd = self.new(cmd_string, host, logger, stdin) - cmd.run - + + cmd = super(cmd_string, host, logger, stdin) + if cmd.code == MAGIC_RC cmd.update_remotes(host, remote_dir, logger) cmd = super(command, host, logger, stdin) end - + cmd end def update_remotes(host, remote_dir, logger=nil) log("Remote worker node files not found") log("Updating remotes") - + # Use SCP to sync: sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{remote_dir}" diff --git a/src/mad/ruby/VirtualMachineDriver.rb b/src/mad/ruby/VirtualMachineDriver.rb index f75fb5eb90..f696875926 100644 --- a/src/mad/ruby/VirtualMachineDriver.rb +++ b/src/mad/ruby/VirtualMachineDriver.rb @@ -59,7 +59,7 @@ class VirtualMachineDriver < OpenNebulaDriver :deleted => 'd', :unknown => '-' } - + HOST_ARG = 1 # ------------------------------------------------------------------------- @@ -67,7 +67,7 @@ class VirtualMachineDriver < OpenNebulaDriver # ------------------------------------------------------------------------- def initialize(concurrency=10, threaded=true) super(concurrency,threaded) - + @hosts = Array.new register_action(ACTION[:deploy].to_sym, method("deploy")) @@ -119,9 +119,11 @@ class VirtualMachineDriver < OpenNebulaDriver info = command_exe.stderr end + info = "-" if info == nil || info.empty? + send_message(ACTION[action],RESULT[result],id,info) end - + # ------------------------------------------------------------------------- # Execute a command associated to an action and id on localhost # ------------------------------------------------------------------------- @@ -130,10 +132,14 @@ class VirtualMachineDriver < OpenNebulaDriver if command_exe.code == 0 result = :success + info = command_exe.stdout else result = :failure + info = command_exe.stderr end + info = "-" if info == nil || info.empty? + send_message(ACTION[action],RESULT[result],id) end @@ -174,7 +180,7 @@ class VirtualMachineDriver < OpenNebulaDriver error = "Action not implemented by driver #{self.class}" send_message(ACTION[:poll],RESULT[:failure],id,error) end - + private def delete_running_action(action_id) @@ -184,7 +190,7 @@ private @action_running.delete(action_id) end end - + def get_first_runable action_index=nil @action_queue.each_with_index do |action, index| @@ -198,32 +204,32 @@ private break end end - + return action_index end - + def get_runable_action action_index=get_first_runable - + if action_index action=@action_queue[action_index] else action=nil end - + if action @hosts << action[:args][HOST_ARG] if action[:args][HOST_ARG] @action_queue.delete_at(action_index) end - + STDERR.puts "action: #{action.inspect}" STDERR.puts "queue: #{@action_queue.inspect}" STDERR.puts "hosts: #{@hosts.inspect}" STDERR.flush - + return action end - + def empty_queue get_first_runable==nil end