diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index dcaa1b0108..84e34b2788 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -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 diff --git a/src/mad/ruby/OpenNebulaDriver.rb b/src/mad/ruby/OpenNebulaDriver.rb index 72dec8864f..be559befdd 100644 --- a/src/mad/ruby/OpenNebulaDriver.rb +++ b/src/mad/ruby/OpenNebulaDriver.rb @@ -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" diff --git a/src/mad/ruby/VirtualMachineDriver.rb b/src/mad/ruby/VirtualMachineDriver.rb index 6992746c31..a2aefd40dc 100644 --- a/src/mad/ruby/VirtualMachineDriver.rb +++ b/src/mad/ruby/VirtualMachineDriver.rb @@ -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) diff --git a/src/vmm_mad/ssh/one_vmm_ssh.rb b/src/vmm_mad/ssh/one_vmm_ssh.rb index 84ca9bd437..57a13ddb83 100755 --- a/src/vmm_mad/ssh/one_vmm_ssh.rb +++ b/src/vmm_mad/ssh/one_vmm_ssh.rb @@ -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