Sha256: 4bdf13625e9d2fa44655af692fc8a2dab727df2e3607ed0a1d8e07c8d3a3c693

Contents?: true

Size: 1.92 KB

Versions: 13

Compression:

Stored size: 1.92 KB

Contents

module CORL
module Action
class Spawn < Plugin::CloudAction
  
  include Mixin::Action::Keypair
 
  #----------------------------------------------------------------------------
  # Settings
  
  def configure
    super do
      codes :network_failure,
            :key_failure,
            :node_create_failure
      
      register :groups, :array, []      
      register :region, :str, nil
      register :machine_type, :str, nil
      register :image, :str, nil
      register :user, :str, :root     
      register :hostnames, :array, nil
        
      keypair_config
      
      config.defaults(CORL.action_config(:bootstrap))
      config.defaults(CORL.action_config(:seed))
      
      config[:project_reference].default = "github:::coraltech/cluster-test[master]"
    end
  end
  
  #---
  
  def ignore
    node_ignore - [ :parallel, :node_provider ] + [ :bootstrap_nodes ]
  end
  
  def arguments
    [ :node_provider, :image, :hostnames ]
  end
  
  #-----------------------------------------------------------------------------
  # Operations
 
  def execute
    super do |node, network|
      info('corl.actions.spawn.start')      
      
      if network
        if keypair && keypair_clean
          results       = []
          node_provider = settings.delete(:node_provider)
          
          settings.delete(:hostnames).each do |hostname|
            if settings[:parallel]
              results << network.future.add_node(node_provider, hostname, settings)
            else
              results << network.add_node(node_provider, hostname, settings)    
            end
          end
          results     = results.map { |future| future.value } if settings[:parallel]                  
          myself.status = code.batch_error if results.include?(false)
        else
          myself.status = code.key_failure  
        end        
      else
        myself.status = code.network_failure    
      end
    end
  end
end
end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
corl-0.4.14 lib/CORL/action/spawn.rb
corl-0.4.13 lib/CORL/action/spawn.rb
corl-0.4.12 lib/CORL/action/spawn.rb
corl-0.4.11 lib/CORL/action/spawn.rb
corl-0.4.10 lib/CORL/action/spawn.rb
corl-0.4.9 lib/CORL/action/spawn.rb
corl-0.4.8 lib/CORL/action/spawn.rb
corl-0.4.7 lib/CORL/action/spawn.rb
corl-0.4.6 lib/CORL/action/spawn.rb
corl-0.4.5 lib/CORL/action/spawn.rb
corl-0.4.4 lib/CORL/action/spawn.rb
corl-0.4.3 lib/CORL/action/spawn.rb
corl-0.4.2 lib/CORL/action/spawn.rb