Module: Vagabond::Actions::Destroy

Defined in:
lib/vagabond/actions/destroy.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vagabond/actions/destroy.rb', line 7

def included(klass)
  klass.class_eval do
    class << self
      def _destroy_options
        [
          [
            :cluster, :type => :boolean,
            :desc => 'Destroy cluster of nodes with provided name', :default => false
          ]
        ]
      end
    end
  end
end

Instance Method Details

#_destroyObject



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
54
55
56
57
58
59
60
61
# File 'lib/vagabond/actions/destroy.rb', line 27

def _destroy
  name_required!
  @destroyed ||= []
  if(options[:cluster])
    @cluster_name = name
    @to_destroy = vagabondfile[:clusters][name] if vagabondfile[:clusters]
    if(@to_destroy)
      ui.info "#{ui.color('Vagabond:', :bold)} Destroying cluster - #{ui.color(name, :red)}"
    else
      ui.error "Cluster name provided does not exist: #{name}"
      @to_destroy = []
    end
  else
    @to_destroy = [name, @leftover_args].flatten.compact
  end
  remain = @to_destroy - @destroyed
  @name = remain.shift
  configure(:allow_missing)
  if(lxc.exists?)
    ui.info "#{ui.color('Vagabond:', :bold)} Destroying node: #{ui.color(name, :red)}"
    do_destroy
    ui.info ui.color('  -> DESTROYED', :red)
  else
    ui.error "Node not created: #{name}"
  end
  @destroyed << @name
  if(@destroyed.size == @to_destroy.size)
    if(@cluster_name)
      @name = @cluster_name
      configure
    end
  else
    add_link(:destroy)
  end
end

#destroy_validate?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/vagabond/actions/destroy.rb', line 23

def destroy_validate?
  !options[:cluster]
end