Class: CORL::Action::Image

Inherits:
Plugin::CloudAction show all
Defined in:
lib/CORL/action/image.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



39
40
41
# File 'lib/CORL/action/image.rb', line 39

def arguments
  [ :image_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
# File 'lib/CORL/action/image.rb', line 9

def configure
  super do
    register :image_nodes, :array, nil do |values|
      if values.nil?
        warn('corl.actions.image.errors.image_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.image.errors.image_nodes', { :value => value, :node_provider => info[:provider],  :name => info[:name] })
            success = false
          end
        end
      end
      success
    end  
  end
end

#executeObject


Operations



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/CORL/action/image.rb', line 46

def execute
  super do |local_node, network|
    ensure_network(network) do
      batch_success = network.batch(settings[:image_nodes], settings[:node_provider], settings[:parallel]) do |node|
        info('corl.actions.image.start', { :provider => node.plugin_provider, :name => node.plugin_name })
        node.create_image
      end
      myself.status = code.batch_error unless batch_success  
    end    
  end
end

#ignoreObject




35
36
37
# File 'lib/CORL/action/image.rb', line 35

def ignore
  [ :nodes ]
end