Module: Delete
Overview
Index deleting operations
Constant Summary
Constants included from Logging
Instance Method Summary collapse
- #delete ⇒ Object
- #delete_populate_indices(indices, date_from, date_to, daysago) ⇒ Object
- #do_delete(indices) ⇒ Object
Methods included from Logging
configure_logger_for, #log, log_level, logger_for
Instance Method Details
#delete ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/elastic_manager/delete.rb', line 48 def delete indices, date_from, date_to, daysago = prepare_vars prechecks(date_from, date_to) indices = delete_populate_indices(indices, date_from, date_to, daysago) log.debug indices.inspect do_delete(indices) end |
#delete_populate_indices(indices, date_from, date_to, daysago) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elastic_manager/delete.rb', line 9 def delete_populate_indices(indices, date_from, date_to, daysago) result = [] if indices.length == 1 && indices.first == '_all' result = @elastic.all_indices(date_from, date_to, daysago, nil, nil, @config) else if date_from.nil? result = @elastic.all_indices(date_from, date_to, daysago, nil, nil, @config).select { |r| r.start_with?(*indices) } else date_from.upto(date_to) do |date| indices.each do |index| date_formatted = date.to_s.tr('-', '.') result << "#{index}-#{date_formatted}" end end end end return result unless result.empty? log.fatal 'no indices for work' exit 1 end |
#do_delete(indices) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/elastic_manager/delete.rb', line 33 def do_delete(indices) indices.each do |index| next if skip_index?(index, 'delete') response = @elastic.request(:get, "/_cat/indices/#{index}") if index_exist?(response) elastic_action_with_log('delete_index', index, delete_without_snapshot?(index)) else log.warn "#{index} index not found" end end end |