Class: Shards::Workflow::DeleteByTerminal
- Inherits:
-
Base
- Object
- Base
- Shards::Workflow::DeleteByTerminal
show all
- Defined in:
- lib/shards/workflow/delete_by_terminal.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#answer, #blank_db, #client, #config, #current_loop, #domain, #flow, #location, #params, #pointer, #pointer_history, #site, #stage, #step, #wf
Instance Method Summary
collapse
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_shard_presence_in_shards, #choose_one, #clean_repo_and_exit, #create_database, #decamelize, #default_path, #dns_upsert, #file, #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_in_index, #validate_location, #validate_min_size, #validate_regex, #validate_stage, #validation, #yaml
Instance Attribute Details
#database_to_drop ⇒ Object
Returns the value of attribute database_to_drop.
9
10
11
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 9
def database_to_drop
@database_to_drop
end
|
#db ⇒ Object
Returns the value of attribute db.
9
10
11
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 9
def db
@db
end
|
#dns ⇒ Object
Returns the value of attribute dns.
9
10
11
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 9
def dns
@dns
end
|
Instance Method Details
#ask_to_continue ⇒ Object
22
23
24
25
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 22
def ask_to_continue
ask_question
raise step['wrong_message'] if answer.strip.downcase!='y'
end
|
#commit_changes ⇒ Object
56
57
58
59
60
61
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 56
def commit_changes
config.repo.message = "Deleted site: #{params[:subdomain]} and shard: #{@shard_name} in #{location.name}"
config.repo.autocommit
puts step['message']
puts config.repo.message
end
|
#delete_database ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 63
def delete_database
@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|
puts
puts "Database:\t #{database_to_drop}"
puts "Host: \t #{host}"
puts
puts "Do you want to delete the above database? (y) to confirm, another string to not."
answer=$stdin.gets
puts
if answer.chomp.downcase=='y'
puts "DELETING database #{database_to_drop} in #{host}"
db.server=host
db.drop
else
puts "KEEP database #{database_to_drop} in #{host}"
end
puts
puts "-" * 50
puts
end
raise_wrong_text database_to_drop if db.exist? database_to_drop
puts step['message'] % database_to_drop
end
|
#delete_record ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 27
def delete_record
if dns.exist?
dns.delete
message_params= [dns.host_param, dns.resource_records.to_s]
raise_wrong_text message_params if dns.exist?
puts step['message'] % message_params
end
end
|
#delete_site_and_shard ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 36
def delete_site_and_shard
site=Shards::Site.new stage
site.subdomain_param=params[:subdomain]
site.delete
shard=Shards::Shard.new stage
@shard_name= site.shard
shard.name_param = @shard_name
shard.delete
@database_to_drop=shard.database['database']
end
|
#validate_subdomain ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 11
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, target_message_error ]
end
end
|
#write_yaml_files ⇒ Object
50
51
52
53
54
|
# File 'lib/shards/workflow/delete_by_terminal.rb', line 50
def write_yaml_files
puts config.repo.diff
ask_question
raise step['wrong_message'] if answer.strip.downcase!='y'
end
|