Sha256: da3481de99f553e0700cf84e5357482ab458404e2a454b1c10d74f6737e5513c

Contents?: true

Size: 1.51 KB

Versions: 13

Compression:

Stored size: 1.51 KB

Contents

module CORL
module Action
class Reboot < Plugin::CloudAction
 
  #-----------------------------------------------------------------------------
  # Settings
 
  def configure
    super do
      register :reboot_nodes, :array, nil do |values|
        if values.nil?
          warn('corl.actions.reboot.errors.reboot_nodes_empty')
          next false 
        end
        
        node_plugins = CORL.loaded_plugins(:node)
        success      = true
        
        values.each do |value|
          if info = CORL.plugin_class(:node).translate_reference(value)
            if ! node_plugins.keys.include?(info[:provider].to_sym) || info[:name].empty?
              warn('corl.actions.reboot.errors.reboot_nodes', { :value => value, :node_provider => info[:provider],  :name => info[:name] })
              success = false
            end
          end
        end
        success
      end
    end
  end

  #---
  
  def ignore
    [ :nodes ]
  end
  
  def arguments
    [ :reboot_nodes ]
  end
  
  #-----------------------------------------------------------------------------
  # Operations
   
  def execute
    super do |local_node, network|
      ensure_network(network) do
        batch_success = network.batch(settings[:reboot_nodes], settings[:node_provider], settings[:parallel]) do |node|
          info('corl.actions.reboot.start', { :provider => node.plugin_provider, :name => node.plugin_name })
          node.reload  
        end
        myself.status = code.batch_error unless batch_success
      end
    end
  end
end
end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
corl-0.4.29 lib/CORL/action/reboot.rb
corl-0.4.28 lib/CORL/action/reboot.rb
corl-0.4.27 lib/CORL/action/reboot.rb
corl-0.4.26 lib/CORL/action/reboot.rb
corl-0.4.25 lib/CORL/action/reboot.rb
corl-0.4.24 lib/CORL/action/reboot.rb
corl-0.4.23 lib/CORL/action/reboot.rb
corl-0.4.22 lib/CORL/action/reboot.rb
corl-0.4.21 lib/CORL/action/reboot.rb
corl-0.4.20 lib/CORL/action/reboot.rb
corl-0.4.19 lib/CORL/action/reboot.rb
corl-0.4.18 lib/CORL/action/reboot.rb
corl-0.4.17 lib/CORL/action/reboot.rb