Class: CORL::Action::Bootstrap

Inherits:
Plugin::CloudAction show all
Defined in:
lib/CORL/action/bootstrap.rb

Instance Method Summary collapse

Methods inherited from Plugin::CloudAction

#ensure_network, #ensure_node, #execute_remote, #init_network, #namespace, #node_config, #node_exec, #node_ignore, #validate

Instance Method Details

#argumentsObject



61
62
63
# File 'lib/CORL/action/bootstrap.rb', line 61

def arguments
  [ :bootstrap_nodes ]
end

#configureObject


Settings



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/CORL/action/bootstrap.rb', line 9

def configure
  super do
    register :auth_files, :array, [] do |values|
      success = true
      values.each do |value|
        unless File.exists?(value)
          warn('corl.actions.bootstrap.errors.auth_files', { :value => value })
          success = false
        end
      end
      success
    end
    register :home_env_var, :str, 'HOME'
    register :home, :str, nil    
    register :bootstrap_path, :str, File.join(CORL.lib_path, '..', 'bootstrap') do |value|
      unless File.directory?(value)
        warn('corl.actions.bootstrap.errors.bootstrap_path', { :value => value })
        next false
      end
      true
    end
    register :bootstrap_glob, :str, '**/*.sh'
    register :bootstrap_init, :str, 'bootstrap.sh'
    
    register :bootstrap_nodes, :array, nil do |values|
      if values.nil?
        warn('corl.actions.bootstrap.errors.bootstrap_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.bootstrap.errors.bootstrap_nodes', { :value => value, :node_provider => info[:provider],  :name => info[:name] })
            success = false
          end
        end
      end
      success
    end
  end
end

#executeObject


Operations



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/CORL/action/bootstrap.rb', line 68

def execute
  super do |local_node, network|
    ensure_network(network) do
      batch_success = network.batch(settings[:bootstrap_nodes], settings[:node_provider], settings[:parallel]) do |node|
        render_options = { :id => node.id, :hostname => node.hostname }
        
        info('corl.actions.bootstrap.start', render_options)
        success = node.bootstrap(network.home, extended_config(:bootstrap, settings))
        if success
          info('corl.actions.bootstrap.success', render_options)
        else
          render_options[:status] = node.status
          error('corl.actions.bootstrap.failure', render_options)
        end
        success
      end
      myself.status = code.batch_error unless batch_success
    end
  end
end

#ignoreObject




57
58
59
# File 'lib/CORL/action/bootstrap.rb', line 57

def ignore
  [ :nodes ]
end