feature #595: changed initializers to use options hash

This commit is contained in:
Javi Fontan committed 2011-06-01 18:15:24 +02:00
1 parent 48c20f57a2
commit 2891715205
4 files changed
+57 -16

No files matched your search

+6 -2
View File
@@ -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
+24 -6
View File
@@ -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"
+16 -5
View File
@@ -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)
+11 -3
View File
@@ -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