1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

feature #4716: add --timeout parameter to drivers

This commit is contained in:
Javi Fontan 2016-09-07 14:30:33 +02:00
parent 581269b0de
commit 7006a98492
7 changed files with 65 additions and 19 deletions

View File

@ -50,12 +50,19 @@ class AuthDriver < OpenNebulaDriver
# built-in ACL engine
# @param [Array] authentication modules enabled, nil will use any
# any method existing in remotes directory
def initialize(authZ, authN, nthreads)
# @param [Numeric] number of threads
# @param [Hash] extra options
def initialize(authZ, authN, nthreads, options = {})
super(
"auth",
:concurrency => nthreads,
:threaded => nthreads > 0,
:local_actions => {ACTION[:authN] => nil, ACTION[:authZ] => nil}
options.merge({
:concurrency => nthreads,
:threaded => nthreads > 0,
:local_actions => {
ACTION[:authN] => nil,
ACTION[:authZ] => nil
}
})
)
register_action(ACTION[:authN].to_sym, method("authN"))
@ -170,12 +177,14 @@ end
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::REQUIRED_ARGUMENT ],
[ '--authz', '-z', GetoptLong::REQUIRED_ARGUMENT ],
[ '--authn', '-n', GetoptLong::REQUIRED_ARGUMENT ]
[ '--authn', '-n', GetoptLong::REQUIRED_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
threads = 15
authz = nil
authn = nil
timeout = nil
begin
opts.each do |opt, arg|
@ -186,12 +195,15 @@ begin
authz = arg
when '--authn'
authn = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg
end
end
rescue Exception => e
exit(-1)
end
auth_driver = AuthDriver.new(authz, authn, threads)
auth_driver = AuthDriver.new(authz, authn, threads,
:timeout => timeout)
auth_driver.start_driver

View File

@ -237,12 +237,14 @@ end
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--ds-types', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--system-ds-types', '-s', GetoptLong::OPTIONAL_ARGUMENT ]
[ '--system-ds-types', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
ds_type = nil
sys_ds_type = nil
threads = 15
timeout = nil
begin
opts.each do |opt, arg|
@ -253,11 +255,15 @@ begin
ds_type = arg.split(',').map {|a| a.strip }
when '--system-ds-types'
sys_ds_type = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg
end
end
rescue Exception => e
exit(-1)
end
ds_driver = DatastoreDriver.new(ds_type, sys_ds_type, :concurrency => threads)
ds_driver = DatastoreDriver.new(ds_type, sys_ds_type,
:concurrency => threads,
:timeout => timeout)
ds_driver.start_driver

View File

@ -109,7 +109,8 @@ opts = GetoptLong.new(
[ '--retries', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--local', '-l', GetoptLong::NO_ARGUMENT ],
[ '--force-copy', '-c', GetoptLong::NO_ARGUMENT ]
[ '--force-copy', '-c', GetoptLong::NO_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
hypervisor = ''
@ -117,6 +118,7 @@ retries = 0
threads = 15
local_actions = {}
force_copy = false
timeout = nil
begin
opts.each do |opt, arg|
@ -129,6 +131,8 @@ begin
local_actions={ 'MONITOR' => nil }
when '--force-copy'
force_copy=true
when '--timeout'
timeout = arg
end
end
rescue Exception => e
@ -140,9 +144,10 @@ if ARGV.length >= 1
end
im = InformationManagerDriver.new(hypervisor,
:concurrency => threads,
:retries => retries,
:local_actions => local_actions,
:force_copy => force_copy)
:concurrency => threads,
:retries => retries,
:local_actions => local_actions,
:force_copy => force_copy,
:timeout => timeout)
im.start_driver

View File

@ -146,10 +146,12 @@ end
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--ipam-types', '-i', GetoptLong::REQUIRED_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
i_types = nil
threads = 1
timeout = 1
begin
opts.each do |opt, arg|
@ -158,12 +160,16 @@ begin
i_types = arg.split(',').map {|a| a.strip }
when '--threads'
threads = arg.to_i
when '--timeout'
timeout = arg
end
end
rescue Exception => e
exit(-1)
end
ipam_driver = IPAMDriver.new(i_types, :concurrency => threads)
ipam_driver = IPAMDriver.new(i_types,
:concurrency => threads,
:timeout => timeout)
ipam_driver.start_driver

View File

@ -282,11 +282,13 @@ end
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--market-types', '-m', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--proxy' , GetoptLong::OPTIONAL_ARGUMENT ]
)
mp_type = nil
threads = 15
timeout = nil
begin
opts.each do |opt, arg|
@ -295,12 +297,16 @@ begin
threads = arg.to_i
when '--market-types'
mp_type = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg
end
end
rescue Exception => e
exit(-1)
end
mp_driver = MarketPlaceDriver.new(mp_type, :concurrency => threads)
mp_driver = MarketPlaceDriver.new(mp_type,
:concurrency => threads,
:timeout => timeout)
mp_driver.start_driver

View File

@ -148,11 +148,13 @@ end
if __FILE__ == $0
opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--tm-types', '-d', GetoptLong::OPTIONAL_ARGUMENT ]
[ '--tm-types', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
tm_type = nil
threads = 15
timeout = 15
begin
opts.each do |opt, arg|
@ -161,12 +163,16 @@ if __FILE__ == $0
threads = arg.to_i
when '--tm-types'
tm_type = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg
end
end
rescue Exception => e
exit(-1)
end
tm_driver = TransferManagerDriver.new(tm_type, :concurrency => threads)
tm_driver = TransferManagerDriver.new(tm_type,
:concurrency => threads,
:timeout => timeout)
tm_driver.start_driver
end

View File

@ -1063,7 +1063,8 @@ opts = GetoptLong.new(
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--local', '-l', GetoptLong::REQUIRED_ARGUMENT ],
[ '--shell', '-s', GetoptLong::REQUIRED_ARGUMENT ],
[ '--parallel', '-p', GetoptLong::NO_ARGUMENT ]
[ '--parallel', '-p', GetoptLong::NO_ARGUMENT ],
[ '--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT ]
)
hypervisor = ''
@ -1072,6 +1073,7 @@ threads = 15
shell = 'bash'
local_actions = {}
single_host = true
timeout = nil
begin
opts.each do |opt, arg|
@ -1086,6 +1088,8 @@ begin
shell = arg
when '--parallel'
single_host = false
when '--timeout'
timeout = arg
end
end
rescue Exception => e
@ -1103,6 +1107,7 @@ exec_driver = ExecDriver.new(hypervisor,
:retries => retries,
:local_actions => local_actions,
:shell => shell,
:single_host => single_host)
:single_host => single_host,
:timeout => timeout)
exec_driver.start_driver