Sha256: ee259a113b4acc0e16f770388cf65bed84f3988866d8b5749c80a6278b01d05b

Contents?: true

Size: 1.5 KB

Versions: 16

Compression:

Stored size: 1.5 KB

Contents

module Nucleon
module Action
module Node
class Destroy < Nucleon.plugin_class(:nucleon, :cloud_action)

  #-----------------------------------------------------------------------------
  # Info

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

  #-----------------------------------------------------------------------------
  # Settings

  def configure
    super do
      register_bool :force, false

      register_nodes :destroy_nodes
    end
  end

  #---

  def ignore
    [ :nodes ]
  end

  def arguments
    [ :destroy_nodes ]
  end

  #-----------------------------------------------------------------------------
  # Operations

  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
end
end
end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
corl-0.5.18 lib/nucleon/action/node/destroy.rb
corl-0.5.17 lib/nucleon/action/node/destroy.rb
corl-0.5.16 lib/nucleon/action/node/destroy.rb
corl-0.5.15 lib/nucleon/action/node/destroy.rb
corl-0.5.14 lib/nucleon/action/node/destroy.rb
corl-0.5.13 lib/nucleon/action/node/destroy.rb
corl-0.5.12 lib/nucleon/action/node/destroy.rb
corl-0.5.11 lib/nucleon/action/node/destroy.rb
corl-0.5.10 lib/nucleon/action/node/destroy.rb
corl-0.5.9 lib/nucleon/action/node/destroy.rb
corl-0.5.8 lib/nucleon/action/node/destroy.rb
corl-0.5.7 lib/nucleon/action/node/destroy.rb
corl-0.5.6 lib/nucleon/action/node/destroy.rb
corl-0.5.5 lib/nucleon/action/node/destroy.rb
corl-0.5.4 lib/nucleon/action/node/destroy.rb
corl-0.5.3 lib/nucleon/action/node/destroy.rb