From 7006a984928752ad5061ac2bb7aa60e707a7492b Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 7 Sep 2016 14:30:33 +0200 Subject: [PATCH] feature #4716: add --timeout parameter to drivers --- src/authm_mad/one_auth_mad.rb | 24 ++++++++++++++++++------ src/datastore_mad/one_datastore.rb | 10 ++++++++-- src/im_mad/im_exec/one_im_exec.rb | 15 ++++++++++----- src/ipamm_mad/one_ipam.rb | 8 +++++++- src/market_mad/one_market.rb | 8 +++++++- src/tm_mad/one_tm.rb | 10 ++++++++-- src/vmm_mad/exec/one_vmm_exec.rb | 9 +++++++-- 7 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 788d635a29..d582cf8b48 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -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 diff --git a/src/datastore_mad/one_datastore.rb b/src/datastore_mad/one_datastore.rb index 14c3aa1400..8e8aab8425 100755 --- a/src/datastore_mad/one_datastore.rb +++ b/src/datastore_mad/one_datastore.rb @@ -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 diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index 59aabc4d61..6f36ed3adf 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -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 diff --git a/src/ipamm_mad/one_ipam.rb b/src/ipamm_mad/one_ipam.rb index c1e99ae9b3..e9106acb1f 100755 --- a/src/ipamm_mad/one_ipam.rb +++ b/src/ipamm_mad/one_ipam.rb @@ -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 diff --git a/src/market_mad/one_market.rb b/src/market_mad/one_market.rb index a97b3eb6dc..aaf71635ee 100755 --- a/src/market_mad/one_market.rb +++ b/src/market_mad/one_market.rb @@ -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 diff --git a/src/tm_mad/one_tm.rb b/src/tm_mad/one_tm.rb index 73157d08f8..bb757213b7 100755 --- a/src/tm_mad/one_tm.rb +++ b/src/tm_mad/one_tm.rb @@ -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 diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index e7c1e71edc..72057c4428 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -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