mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #595: changed initializers to use options hash
This commit is contained in:
parent
48c20f57a2
commit
2891715205
@ -38,8 +38,12 @@ require 'getoptlong'
|
||||
class InformationManagerDriverSSH < OpenNebulaDriver
|
||||
|
||||
# Init the driver
|
||||
def initialize(hypervisor, threads, retries, local_actions)
|
||||
super(threads, true, retries, 'im', local_actions)
|
||||
def initialize(hypervisor, options)
|
||||
@options={
|
||||
:threaded => true
|
||||
}.merge!(options)
|
||||
|
||||
super('im', @options)
|
||||
|
||||
@hypervisor = hypervisor
|
||||
|
||||
|
@ -67,18 +67,36 @@ class OpenNebulaDriver < ActionManager
|
||||
:failure => "FAILURE"
|
||||
}
|
||||
|
||||
def initialize(concurrency=10, threaded=true, retries=0,
|
||||
directory='subsystem', local_actions={})
|
||||
super(concurrency, threaded)
|
||||
# Initialize OpenNebulaDriver object
|
||||
#
|
||||
# @param [String] directory path inside the remotes directory where the
|
||||
# scripts are located
|
||||
# @param [Hash] options named options to change the object's behaviour
|
||||
# @option options [Number] :concurrency (10) max number of threads
|
||||
# @option options [Boolean] :threaded (true) enables or disables threads
|
||||
# @option options [Number] :retries (0) number of retries to copy scripts
|
||||
# to the remote host
|
||||
# @option options [Hash] :local_actions ({}) hash with the actions
|
||||
# executed locally and the name of the script if it differs from the
|
||||
# default one. This hash can be constructed using {parse_actions_list}
|
||||
def initialize(directory, options={})
|
||||
@options={
|
||||
:concurrency => 10,
|
||||
:threaded => true,
|
||||
:retries => 0,
|
||||
:local_actions => {}
|
||||
}.merge!(options)
|
||||
|
||||
super(@options[:concurrency], @options[:threaded])
|
||||
|
||||
@retries = retries
|
||||
@retries = @options[:retries]
|
||||
@send_mutex=Mutex.new
|
||||
@local_actions=local_actions
|
||||
@local_actions=@options[:local_actions]
|
||||
|
||||
# set default values
|
||||
@config = read_configuration
|
||||
@remote_scripts_base_path=@config['SCRIPTS_REMOTE_DIR']
|
||||
if ONE_LOCATION == nil
|
||||
if ENV['ONE_LOCATION'] == nil
|
||||
@local_scripts_base_path = "/var/lib/one/remotes"
|
||||
else
|
||||
@local_scripts_base_path = "#{ENV['ONE_LOCATION']}/var/remotes"
|
||||
|
@ -61,10 +61,19 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
|
||||
HOST_ARG = 1
|
||||
|
||||
# Register default actions for the protocol
|
||||
def initialize(concurrency=10, threaded=true, retries=0,
|
||||
directory='vmm', local_actions={})
|
||||
super(concurrency, threaded, retries, directory, local_actions)
|
||||
# Register default actions for the protocol.
|
||||
#
|
||||
# @param [String] directory path inside remotes path where the scripts
|
||||
# reside
|
||||
# @param [Hash] options options for OpenNebula driver (check the available
|
||||
# options in {OpenNebulaDriver#initialize})
|
||||
# @option options [Boolean] :threaded (true) enables or disables threads
|
||||
def initialize(directory, options={})
|
||||
@options={
|
||||
:threaded => true
|
||||
}.merge!(options)
|
||||
|
||||
super(directory, @options)
|
||||
|
||||
@hosts = Array.new
|
||||
|
||||
@ -201,7 +210,9 @@ if __FILE__ == $0
|
||||
|
||||
class TemplateDriver < VirtualMachineDriver
|
||||
def initialize
|
||||
super(15,true)
|
||||
super('vmm/dummy',
|
||||
:concurrency => 15,
|
||||
:threaded => true)
|
||||
end
|
||||
|
||||
def deploy(id, host, remote_dfile, not_used)
|
||||
|
@ -38,8 +38,12 @@ require 'getoptlong'
|
||||
class SshDriver < VirtualMachineDriver
|
||||
|
||||
# SshDriver constructor
|
||||
def initialize(hypervisor, threads, retries, local_actions)
|
||||
super(threads, true, retries, "vmm/#{hypervisor}", local_actions)
|
||||
def initialize(hypervisor, options={})
|
||||
@options={
|
||||
:threaded => true
|
||||
}.merge!(options)
|
||||
|
||||
super("vmm/#{hypervisor}", @options)
|
||||
|
||||
@hypervisor = hypervisor
|
||||
end
|
||||
@ -128,5 +132,9 @@ else
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
ssh_driver = SshDriver.new(hypervisor, threads, retries, local_actions)
|
||||
ssh_driver = SshDriver.new(hypervisor,
|
||||
:concurrency => threads,
|
||||
:retries => retries,
|
||||
:local_actions => local_actions)
|
||||
|
||||
ssh_driver.start_driver
|
||||
|
Loading…
x
Reference in New Issue
Block a user