Class: Elasticsearch::Drain::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/elasticsearch/drain/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#active_nodesObject

Returns the value of attribute active_nodes.



9
10
11
# File 'lib/elasticsearch/drain/cli.rb', line 9

def active_nodes
  @active_nodes
end

#drainerObject (readonly)

Returns the value of attribute drainer.



8
9
10
# File 'lib/elasticsearch/drain/cli.rb', line 8

def drainer
  @drainer
end

Instance Method Details

#asgObject

rubocop:disable Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/elasticsearch/drain/cli.rb', line 15

def asg # rubocop:disable Metrics/MethodLength
  @drainer = Elasticsearch::Drain.new(options[:host],
                                      options[:asg],
                                      options[:region])
  ensure_cluster_healthy
  @active_nodes = drainer.active_nodes_in_asg
  do_exit { say_status 'Complete', 'Nothing to do', :green } if active_nodes.empty?
  say_status 'Found Nodes', "AutoScalingGroup: #{instances}", :magenta
  ensure_cluster_healthy
  drain_nodes
  remove_nodes
  say_status 'Complete', 'Draining nodes complete!', :green
end