Class: Nucleon::Action::Node::Destroy

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.describeObject


Info



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

def self.describe
  super(:node, :destroy, 580)
end

Instance Method Details

#argumentsObject



31
32
33
# File 'lib/nucleon/action/node/destroy.rb', line 31

def arguments
  [ :destroy_nodes ]
end

#configureObject


Settings



17
18
19
20
21
22
23
# File 'lib/nucleon/action/node/destroy.rb', line 17

def configure
  super do
    register_bool :force, false

    register_nodes :destroy_nodes
  end
end

#executeObject


Operations



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/nucleon/action/node/destroy.rb', line 38

def execute
  super do |local_node|
    ensure_network do
      if settings[:force]
        answer = 'YES'
      else
        message = render_message('prompt', { :operation => :ask }) + "\n\n"

        array(settings[:destroy_nodes]).each do |hostname|
          message << "  #{hostname}\n"
        end

        message << "\n" + render_message('yes_query', { :operation => :ask, :yes => 'YES' }) + ' '
        answer = ask(message)
      end

      if answer.upcase == 'YES'
        batch_success = network.batch(settings[:destroy_nodes], settings[:node_provider], settings[:parallel], false) do |node|
          info('start', { :provider => node.plugin_provider, :name => node.plugin_name })
          node.destroy
        end
        myself.status = code.batch_error unless batch_success
      end
    end
  end
end

#ignoreObject




27
28
29
# File 'lib/nucleon/action/node/destroy.rb', line 27

def ignore
  [ :nodes ]
end