mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-21 13:57:56 +03:00
bug #412: Fix remotes location for RemoteCommand. Checks info string to be returned to the core. Includes std output for local_actions
This commit is contained in:
parent
8ded51f3a6
commit
c4dbdf53ef
@ -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}"
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user