1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-28 07:21:29 +03:00

feature #457: retries is now an option for IMs. Also the number of retries defaults to 0 for all drivers

This commit is contained in:
Ruben S. Montero 2011-01-20 18:36:37 +01:00
parent b8975669e4
commit 6fdc67f6bd
4 changed files with 50 additions and 13 deletions

View File

@ -116,15 +116,19 @@ DEFAULT_DEVICE_PREFIX = "hd"
#-------------------------------------------------------------------------------
# KVM Information Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
#-------------------------------------------------------------------------------
IM_MAD = [
name = "im_kvm",
executable = "one_im_ssh",
arguments = "kvm" ]
arguments = "-r 0 -t 15 kvm" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# XEN Information Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
#-------------------------------------------------------------------------------
#IM_MAD = [
# name = "im_xen",

View File

@ -32,6 +32,7 @@ $: << RUBY_LIB_LOCATION
require 'OpenNebulaDriver'
require 'CommandManager'
require 'getoptlong'
#-------------------------------------------------------------------------------
# The SSH Information Manager Driver
@ -41,13 +42,14 @@ class InformationManager < OpenNebulaDriver
#---------------------------------------------------------------------------
# Init the driver
#---------------------------------------------------------------------------
def initialize(hypervisor, num)
super(num, true)
def initialize(hypervisor, threads, retries)
super(threads, true)
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
@retries = retries
# register actions
register_action(:MONITOR, method("action_monitor"))
@ -72,8 +74,11 @@ class InformationManager < OpenNebulaDriver
cmd_string = "#{@remote_dir}/im/run_probes #{@hypervisor} #{host}"
cmd = RemotesCommand.run(cmd_string, host, @remote_dir, log_lambda, 2)
cmd = RemotesCommand.run(cmd_string,
host,
@remote_dir,
log_lambda,
@retries)
if cmd.code == 0
send_message("MONITOR", RESULT[:success], number, cmd.stdout)
else
@ -90,6 +95,33 @@ end
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
hypervisor = ARGV[0]||''
im = InformationManager.new(hypervisor, 15)
opts = GetoptLong.new(
[ '--retries', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ]
)
hypervisor = ''
retries = 0
threads = 15
begin
opts.each do |opt, arg|
case opt
when '--retries'
retries = arg.to_i
when '--threads'
threads = arg.to_i
end
end
rescue Exception => e
exit(-1)
end
if ARGV.length >= 1
hypervisor = ARGV.shift
end
puts retries, threads, hypervisor
im = InformationManager.new(hypervisor, threads, retries)
im.start_driver

View File

@ -150,7 +150,7 @@ class RemotesCommand < SSHCommand
MAGIC_RC = 42
# Creates a command and runs it
def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=1)
def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0)
cmd_file = command.split(' ')[0]
cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\

View File

@ -65,10 +65,11 @@ class VirtualMachineDriver < OpenNebulaDriver
# -------------------------------------------------------------------------
# Register default actions for the protocol
# -------------------------------------------------------------------------
def initialize(concurrency=10, threaded=true)
def initialize(concurrency=10, threaded=true, retries=0)
super(concurrency,threaded)
@hosts = Array.new
@hosts = Array.new
@retries = retries
register_action(ACTION[:deploy].to_sym, method("deploy"))
register_action(ACTION[:shutdown].to_sym, method("shutdown"))
@ -107,14 +108,14 @@ class VirtualMachineDriver < OpenNebulaDriver
# -------------------------------------------------------------------------
# Execute a command associated to an action and id in a remote host.
# -------------------------------------------------------------------------
def remotes_action(command, id, host, action, remote_dir, std_in=nil, retries=1)
def remotes_action(command, id, host, action, remote_dir, std_in=nil)
command_exe = RemotesCommand.run(command,
host,
remote_dir,
log_method(id),
std_in,
retries)
@retries)
if command_exe.code == 0
result = :success
info = command_exe.stdout