Class: Shards::Workflow::DeleteByApi
- Defined in:
- lib/shards/workflow/delete_by_api.rb
Instance Attribute Summary collapse
-
#database_to_drop ⇒ Object
Returns the value of attribute database_to_drop.
-
#db ⇒ Object
Returns the value of attribute db.
-
#dns ⇒ Object
Returns the value of attribute dns.
Attributes inherited from ByApi
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
- #commit_changes ⇒ Object
- #delete_database ⇒ Object
- #delete_record ⇒ Object
- #delete_site_and_shard ⇒ Object
- #validate_subdomain ⇒ Object
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, #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 Attribute Details
#database_to_drop ⇒ Object
Returns the value of attribute database_to_drop.
8 9 10 |
# File 'lib/shards/workflow/delete_by_api.rb', line 8 def database_to_drop @database_to_drop end |
#db ⇒ Object
Returns the value of attribute db.
8 9 10 |
# File 'lib/shards/workflow/delete_by_api.rb', line 8 def db @db end |
#dns ⇒ Object
Returns the value of attribute dns.
8 9 10 |
# File 'lib/shards/workflow/delete_by_api.rb', line 8 def dns @dns end |
Instance Method Details
#commit_changes ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/shards/workflow/delete_by_api.rb', line 48 def commit_changes config.repo.diff config.repo. = "Deleted site: #{params[:subdomain]} and shard: #{@shard_name} in #{location.name}" config.repo.autocommit step['message'] config.repo. end |
#delete_database ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/shards/workflow/delete_by_api.rb', line 56 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| "Database:\t #{database_to_drop}" "Host: \t #{host}" "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 step['message'] % database_to_drop else "The shard is in use by other site, will not be deleted" end end |
#delete_record ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/shards/workflow/delete_by_api.rb', line 21 def delete_record if dns.exist? dns.delete = [dns.host_param, dns.resource_records.to_s] raise_wrong_text if dns.exist? step['message'] % end end |
#delete_site_and_shard ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/shards/workflow/delete_by_api.rb', line 30 def delete_site_and_shard site=Shards::Site.new stage site.subdomain_param=params[:subdomain] site.delete if site.select_by_shard.count<1 shard=Shards::Shard.new stage @shard_name= site.shard shard.name_param = @shard_name shard.delete @database_to_drop=shard.database['database'] end end |
#validate_subdomain ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/shards/workflow/delete_by_api.rb', line 10 def validate_subdomain @dns=Shards::Dns.new stage: stage dns.subdomain_param=params[:subdomain] raise_wrong_text [dns.host_param, " doesn't exist"] unless dns.exist? unless dns.include_target? raise_wrong_text [dns.host_param, ] end end |