mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-22 17:57:46 +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
|
class RemotesCommand < SSHCommand
|
||||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||||
|
|
||||||
if !ONE_LOCATION
|
if !ONE_LOCATION
|
||||||
REMOTES_LOCATION="/usr/lib/one/remotes"
|
REMOTES_LOCATION="/var/lib/one/remotes"
|
||||||
else
|
else
|
||||||
REMOTES_LOCATION=ONE_LOCATION+"/lib/remotes/"
|
REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/"
|
||||||
end
|
end
|
||||||
|
|
||||||
MAGIC_RC = 42
|
MAGIC_RC = 42
|
||||||
|
|
||||||
# Creates a command and runs it
|
# Creates a command and runs it
|
||||||
def self.run(command, host, remote_dir, logger=nil, stdin=nil)
|
def self.run(command, host, remote_dir, logger=nil, stdin=nil)
|
||||||
cmd_file = command.split(' ')[0]
|
cmd_file = command.split(' ')[0]
|
||||||
|
|
||||||
cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\
|
cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\
|
||||||
exit #{MAGIC_RC}; fi'"
|
exit #{MAGIC_RC}; fi'"
|
||||||
|
|
||||||
cmd = self.new(cmd_string, host, logger, stdin)
|
cmd = super(cmd_string, host, logger, stdin)
|
||||||
cmd.run
|
|
||||||
|
|
||||||
if cmd.code == MAGIC_RC
|
if cmd.code == MAGIC_RC
|
||||||
cmd.update_remotes(host, remote_dir, logger)
|
cmd.update_remotes(host, remote_dir, logger)
|
||||||
cmd = super(command, host, logger, stdin)
|
cmd = super(command, host, logger, stdin)
|
||||||
end
|
end
|
||||||
|
|
||||||
cmd
|
cmd
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_remotes(host, remote_dir, logger=nil)
|
def update_remotes(host, remote_dir, logger=nil)
|
||||||
log("Remote worker node files not found")
|
log("Remote worker node files not found")
|
||||||
log("Updating remotes")
|
log("Updating remotes")
|
||||||
|
|
||||||
# Use SCP to sync:
|
# Use SCP to sync:
|
||||||
sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{remote_dir}"
|
sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{remote_dir}"
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
:deleted => 'd',
|
:deleted => 'd',
|
||||||
:unknown => '-'
|
:unknown => '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
HOST_ARG = 1
|
HOST_ARG = 1
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
@ -67,7 +67,7 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
def initialize(concurrency=10, threaded=true)
|
def initialize(concurrency=10, threaded=true)
|
||||||
super(concurrency,threaded)
|
super(concurrency,threaded)
|
||||||
|
|
||||||
@hosts = Array.new
|
@hosts = Array.new
|
||||||
|
|
||||||
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
||||||
@ -119,9 +119,11 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
info = command_exe.stderr
|
info = command_exe.stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
info = "-" if info == nil || info.empty?
|
||||||
|
|
||||||
send_message(ACTION[action],RESULT[result],id,info)
|
send_message(ACTION[action],RESULT[result],id,info)
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# Execute a command associated to an action and id on localhost
|
# Execute a command associated to an action and id on localhost
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
@ -130,10 +132,14 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
|
|
||||||
if command_exe.code == 0
|
if command_exe.code == 0
|
||||||
result = :success
|
result = :success
|
||||||
|
info = command_exe.stdout
|
||||||
else
|
else
|
||||||
result = :failure
|
result = :failure
|
||||||
|
info = command_exe.stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
info = "-" if info == nil || info.empty?
|
||||||
|
|
||||||
send_message(ACTION[action],RESULT[result],id)
|
send_message(ACTION[action],RESULT[result],id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,7 +180,7 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
error = "Action not implemented by driver #{self.class}"
|
error = "Action not implemented by driver #{self.class}"
|
||||||
send_message(ACTION[:poll],RESULT[:failure],id,error)
|
send_message(ACTION[:poll],RESULT[:failure],id,error)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def delete_running_action(action_id)
|
def delete_running_action(action_id)
|
||||||
@ -184,7 +190,7 @@ private
|
|||||||
@action_running.delete(action_id)
|
@action_running.delete(action_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_first_runable
|
def get_first_runable
|
||||||
action_index=nil
|
action_index=nil
|
||||||
@action_queue.each_with_index do |action, index|
|
@action_queue.each_with_index do |action, index|
|
||||||
@ -198,32 +204,32 @@ private
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return action_index
|
return action_index
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_runable_action
|
def get_runable_action
|
||||||
action_index=get_first_runable
|
action_index=get_first_runable
|
||||||
|
|
||||||
if action_index
|
if action_index
|
||||||
action=@action_queue[action_index]
|
action=@action_queue[action_index]
|
||||||
else
|
else
|
||||||
action=nil
|
action=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if action
|
if action
|
||||||
@hosts << action[:args][HOST_ARG] if action[:args][HOST_ARG]
|
@hosts << action[:args][HOST_ARG] if action[:args][HOST_ARG]
|
||||||
@action_queue.delete_at(action_index)
|
@action_queue.delete_at(action_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
STDERR.puts "action: #{action.inspect}"
|
STDERR.puts "action: #{action.inspect}"
|
||||||
STDERR.puts "queue: #{@action_queue.inspect}"
|
STDERR.puts "queue: #{@action_queue.inspect}"
|
||||||
STDERR.puts "hosts: #{@hosts.inspect}"
|
STDERR.puts "hosts: #{@hosts.inspect}"
|
||||||
STDERR.flush
|
STDERR.flush
|
||||||
|
|
||||||
return action
|
return action
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty_queue
|
def empty_queue
|
||||||
get_first_runable==nil
|
get_first_runable==nil
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user