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:
parent
b8975669e4
commit
6fdc67f6bd
@ -116,15 +116,19 @@ DEFAULT_DEVICE_PREFIX = "hd"
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# KVM Information Driver Manager Configuration
|
# 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 = [
|
IM_MAD = [
|
||||||
name = "im_kvm",
|
name = "im_kvm",
|
||||||
executable = "one_im_ssh",
|
executable = "one_im_ssh",
|
||||||
arguments = "kvm" ]
|
arguments = "-r 0 -t 15 kvm" ]
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# XEN Information Driver Manager Configuration
|
# 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 = [
|
#IM_MAD = [
|
||||||
# name = "im_xen",
|
# name = "im_xen",
|
||||||
|
@ -32,6 +32,7 @@ $: << RUBY_LIB_LOCATION
|
|||||||
|
|
||||||
require 'OpenNebulaDriver'
|
require 'OpenNebulaDriver'
|
||||||
require 'CommandManager'
|
require 'CommandManager'
|
||||||
|
require 'getoptlong'
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# The SSH Information Manager Driver
|
# The SSH Information Manager Driver
|
||||||
@ -41,13 +42,14 @@ class InformationManager < OpenNebulaDriver
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Init the driver
|
# Init the driver
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
def initialize(hypervisor, num)
|
def initialize(hypervisor, threads, retries)
|
||||||
super(num, true)
|
super(threads, true)
|
||||||
|
|
||||||
@config = read_configuration
|
@config = read_configuration
|
||||||
|
|
||||||
@hypervisor = hypervisor
|
@hypervisor = hypervisor
|
||||||
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
|
@remote_dir = @config['SCRIPTS_REMOTE_DIR']
|
||||||
|
@retries = retries
|
||||||
|
|
||||||
# register actions
|
# register actions
|
||||||
register_action(:MONITOR, method("action_monitor"))
|
register_action(:MONITOR, method("action_monitor"))
|
||||||
@ -72,8 +74,11 @@ class InformationManager < OpenNebulaDriver
|
|||||||
|
|
||||||
cmd_string = "#{@remote_dir}/im/run_probes #{@hypervisor} #{host}"
|
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
|
if cmd.code == 0
|
||||||
send_message("MONITOR", RESULT[:success], number, cmd.stdout)
|
send_message("MONITOR", RESULT[:success], number, cmd.stdout)
|
||||||
else
|
else
|
||||||
@ -90,6 +95,33 @@ end
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
hypervisor = ARGV[0]||''
|
opts = GetoptLong.new(
|
||||||
im = InformationManager.new(hypervisor, 15)
|
[ '--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
|
im.start_driver
|
||||||
|
@ -150,7 +150,7 @@ class RemotesCommand < SSHCommand
|
|||||||
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, retries=1)
|
def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0)
|
||||||
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\
|
||||||
|
@ -65,10 +65,11 @@ class VirtualMachineDriver < OpenNebulaDriver
|
|||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# Register default actions for the protocol
|
# Register default actions for the protocol
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
def initialize(concurrency=10, threaded=true)
|
def initialize(concurrency=10, threaded=true, retries=0)
|
||||||
super(concurrency,threaded)
|
super(concurrency,threaded)
|
||||||
|
|
||||||
@hosts = Array.new
|
@hosts = Array.new
|
||||||
|
@retries = retries
|
||||||
|
|
||||||
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
register_action(ACTION[:deploy].to_sym, method("deploy"))
|
||||||
register_action(ACTION[:shutdown].to_sym, method("shutdown"))
|
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.
|
# 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,
|
command_exe = RemotesCommand.run(command,
|
||||||
host,
|
host,
|
||||||
remote_dir,
|
remote_dir,
|
||||||
log_method(id),
|
log_method(id),
|
||||||
std_in,
|
std_in,
|
||||||
retries)
|
@retries)
|
||||||
|
|
||||||
if command_exe.code == 0
|
if command_exe.code == 0
|
||||||
result = :success
|
result = :success
|
||||||
info = command_exe.stdout
|
info = command_exe.stdout
|
||||||
|
Loading…
Reference in New Issue
Block a user