Class: Nucleon::Action::Node::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleon/action/node/upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.describeObject


Info



10
11
12
# File 'lib/nucleon/action/node/upload.rb', line 10

def self.describe
  super(:node, :upload, 500)
end

Instance Method Details

#argumentsObject



53
54
55
# File 'lib/nucleon/action/node/upload.rb', line 53

def arguments
  [ :local_path, :remote_path, :upload_nodes ]
end

#configureObject


Settings



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
# File 'lib/nucleon/action/node/upload.rb', line 17

def configure
  super do
    register_str :local_path, nil
    register_str :remote_path, nil
    register_str :file_mode, '0755'

    register_bool :progress, true

    register_array :upload_nodes, nil do |values|
      if values.nil?
        warn('upload_nodes_empty')
        next false
      end

      node_plugins = CORL.loaded_plugins(:CORL, :node)
      success      = true

      values.each do |value|
        if info = CORL.plugin_class(:CORL, :node).translate_reference(value)
          if ! node_plugins.keys.include?(info[:provider].to_sym) || info[:name].empty?
            warn('upload_nodes', { :value => value, :node_provider => info[:provider],  :name => info[:name] })
            success = false
          end
        end
      end
      success
    end
  end
end

#executeObject


Operations



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/nucleon/action/node/upload.rb', line 60

def execute
  super do |local_node|
    ensure_network do
      batch_success = network.batch(settings[:upload_nodes], settings[:node_provider], settings[:parallel]) do |node|
        render_options = { :id => node.id, :hostname => node.hostname, :local_path => settings[:local_path], :remote_path => settings[:remote_path] }

        info('start', render_options)
        success = node.send_files(settings[:local_path], settings[:remote_path], nil, settings[:file_mode], { :progress => settings[:progress] })

        if success
          success('complete', render_options)
        else
          error('failure', render_options)
        end
        success
      end
      myself.status = code.batch_error unless batch_success
    end
  end
end

#ignoreObject




49
50
51
# File 'lib/nucleon/action/node/upload.rb', line 49

def ignore
  [ :nodes ]
end