Class: Shards::Workflow::ReloadByApi

Inherits:
FingerprintsByApi show all
Defined in:
lib/shards/workflow/reload_by_api.rb

Instance Attribute Summary

Attributes inherited from ByApi

#log

Attributes inherited from Base

#answer, #blank_db, #client, #config, #current_loop, #domain, #flow, #location, #params, #pointer, #pointer_history, #site, #stage, #step, #success, #wf

Instance Method Summary collapse

Methods inherited from FingerprintsByApi

#dns_upsert, #shared_steps_with_workflow, #shared_wf_file, #shared_workflow, #start

Methods inherited from ByApi

#output_message, #write_yaml_files

Methods inherited from Base

#add_ask_blank_db_step, #application_reload_shards_task, #ask_blank_db, #ask_for_exit, #ask_for_exit_and_restart, #ask_for_repeat, #ask_question, #check_database_presence_in_server, #check_domain_dns_presence, #check_domain_presence_in_sites, #check_fingerprints, #check_fingerprints2, #check_shard_presence_in_shards, #choose_one, #clean_repo_and_exit, #commit_changes, #create_database, #decamelize, #default_path, #dns_upsert, #file, #finish_successfully, #format_options, #get_file, #host, #initialize, #loop_step, #output_message, #path, #previous_pointer, #puppet_agent_update, #raise_wrong_text, #run_step, #shared_file, #shared_steps, #start, #start_at, #validate_blank_db_shard, #validate_client, #validate_domain, #validate_in_index, #validate_location, #validate_min_size, #validate_regex, #validate_stage, #validation, #write_yaml_files, #yaml

Constructor Details

This class inherits a constructor from Shards::Workflow::Base

Instance Method Details

#delete_databaseObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shards/workflow/reload_by_api.rb', line 4

def delete_database

  if database_to_drop

    @db=Shards::Db.new stage: stage

    db.database_to_drop=database_to_drop

    raise "Database %s does is not in present db servers" % database_to_drop  unless db.exist?(database_to_drop)

    db.servers_to_drop.each do |host|

      output_message "Database:\t #{database_to_drop}"
      output_message "Host:    \t #{host}"
      output_message "DELETING database #{database_to_drop} in #{host}"
      db.server=host
      db.drop

    end

    raise_wrong_text database_to_drop if db.exist? database_to_drop
    output_message step['message'] % database_to_drop

  else
    output_message "The shard is in use by other site, will not be deleted"
  end
end