shards 2.2.1.pre.test → 2.2.2.pre.test

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11aaa88e5e9af9729d5b5554f54842bde6a885c0
4
- data.tar.gz: 7373e2a508097075659ef1a1a644ed0947dc711a
3
+ metadata.gz: bae1a3defedebbb797e8d968f676f0e9637d21fa
4
+ data.tar.gz: 837aeb01e735d6a24d7a5ab96d217d4efbcdeac8
5
5
  SHA512:
6
- metadata.gz: 035ae7f6ae76900c45e8c88d3e52b777d2a4021425cf88504c989af152c4496edd34a3a3fc5a0b8bc26d5470aee1fae5f26e74a0510f6ab205d54162509bcdd3
7
- data.tar.gz: ed2206cf2f5fa7e56e00f7d23c55df784295b50280175685915c95805cdf6dde72596066f1c5b79401b0a0ec1a6833020ed135b609e6f64c27d92bfa80764841
6
+ metadata.gz: e4e7a335292840e88b71c8e8bbe8cce042400e16f4500737c0a9b62eee7f4bb6efb25397ac9cfa642d39343d772d08ae399a58c4f90dd88341aafe0493439be2
7
+ data.tar.gz: 12f39de20ac2ffccf73395d6e4f6094fbb9939469ce66c4c733649996dc6510374ac41624afc319f7fd0978f89b024f3646327ea38150a039af66fc5384af335
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shards (2.2.1.pre.test)
4
+ shards (2.2.2.pre.test)
5
5
  aws-sdk-ec2 (~> 1.48)
6
6
  aws-sdk-elasticloadbalancing (~> 1.5)
7
7
  aws-sdk-elasticloadbalancingv2 (~> 1.14)
@@ -24,13 +24,13 @@ GEM
24
24
  rspec-expectations (>= 2.99)
25
25
  thor (~> 0.19)
26
26
  aws-eventstream (1.0.1)
27
- aws-partitions (1.104.0)
28
- aws-sdk-core (3.27.0)
27
+ aws-partitions (1.105.0)
28
+ aws-sdk-core (3.28.0)
29
29
  aws-eventstream (~> 1.0)
30
30
  aws-partitions (~> 1.0)
31
31
  aws-sigv4 (~> 1.0)
32
32
  jmespath (~> 1.0)
33
- aws-sdk-ec2 (1.48.0)
33
+ aws-sdk-ec2 (1.49.0)
34
34
  aws-sdk-core (~> 3, >= 3.26.0)
35
35
  aws-sigv4 (~> 1.0)
36
36
  aws-sdk-elasticloadbalancing (1.5.0)
@@ -0,0 +1,53 @@
1
+ ---
2
+ # see shared_steps in base.yaml to find the steps not defined in a workflow
3
+
4
+ delete_by_api:
5
+
6
+ validate_stage:
7
+ correct: validate_subdomain
8
+ wrong_message: Stage %s does not exist.
9
+ wrong: finish
10
+
11
+ validate_subdomain:
12
+ correct: delete_record
13
+ wrong_message: DNS record for host %s, %s.
14
+ wrong: delete_record
15
+
16
+ delete_record:
17
+ message: Record %s deleted in target %s
18
+ correct: delete_site_and_shard
19
+ wrong: finish
20
+ wrong_message: Could not delete the record %s.
21
+
22
+ delete_site_and_shard:
23
+ correct: commit_changes
24
+ wrong: clean_repo_and_exit
25
+ wrong_message: Could not delete site or shard.\n %s.
26
+
27
+ commit_changes:
28
+ message: The changes has been committed and pushed to the remote repository.
29
+ wrong_message: We had an issue to commit and push the changes.
30
+ correct: delete_database
31
+ wrong: finish
32
+
33
+ #TODO restart sidekiq before the database deletion.
34
+
35
+ delete_database:
36
+ wrong_message: The database %s could not be deleted.
37
+ message: Database %s has been deleted.
38
+ correct: finish_successfully
39
+ wrong: finish
40
+
41
+ start: validate_location
42
+
43
+ correct_steps_summary:
44
+ - validate_location
45
+ - validate_stage
46
+ - validate_subdomain
47
+ - delete_record
48
+ - delete_site_and_shard
49
+ - write_yaml_files
50
+ - commit_changes
51
+ - delete_database
52
+
53
+ start: validate_location
@@ -1,3 +1,3 @@
1
1
  module Shards
2
- VERSION = "2.2.1-test"
2
+ VERSION = "2.2.2-test"
3
3
  end
@@ -0,0 +1,97 @@
1
+
2
+ module Shards
3
+
4
+ module Workflow
5
+
6
+ class DeleteByApi < Shards::Workflow::ByApi
7
+
8
+ attr_accessor :dns, :db, :database_to_drop
9
+
10
+ def validate_subdomain
11
+ @dns=Shards::Dns.new stage: stage
12
+ dns.subdomain_param=params[:subdomain]
13
+
14
+ raise_wrong_text [dns.host_param, " doesn't exist"] unless dns.exist?
15
+
16
+ unless dns.include_target?
17
+ raise_wrong_text [dns.host_param, target_message_error ]
18
+ end
19
+ end
20
+
21
+ def delete_record
22
+ if dns.exist?
23
+ dns.delete
24
+ message_params= [dns.host_param, dns.resource_records.to_s]
25
+ raise_wrong_text message_params if dns.exist?
26
+ ouptput_message step['message'] % message_params
27
+ end
28
+ end
29
+
30
+ def delete_site_and_shard
31
+ site=Shards::Site.new stage
32
+ site.subdomain_param=params[:subdomain]
33
+ site.delete
34
+
35
+ shard=Shards::Shard.new stage
36
+ @shard_name= site.shard
37
+ shard.name_param = @shard_name
38
+ shard.delete
39
+
40
+ @database_to_drop=shard.database['database']
41
+
42
+ end
43
+
44
+ def commit_changes
45
+ ouptput_message config.repo.diff
46
+ config.repo.message = "Deleted site: #{params[:subdomain]} and shard: #{@shard_name} in #{location.name}"
47
+ config.repo.autocommit
48
+ ouptput_message step['message']
49
+ ouptput_message config.repo.message
50
+ end
51
+
52
+ def delete_database
53
+
54
+ @db=Shards::Db.new stage: stage
55
+
56
+ db.database_to_drop=database_to_drop
57
+
58
+ raise "Database %s does is not in present db servers" % database_to_drop unless db.exist?(database_to_drop)
59
+
60
+ db.servers_to_drop.each do |host|
61
+
62
+ ouptput_message "Database:\t #{database_to_drop}"
63
+ ouptput_message "Host: \t #{host}"
64
+ ouptput_message "Do you want to delete the above database? (y) to confirm, another string to not."
65
+
66
+ answer=$stdin.gets
67
+
68
+ if answer.chomp.downcase=='y'
69
+ ouptput_message "DELETING database #{database_to_drop} in #{host}"
70
+ db.server=host
71
+ db.drop
72
+ else
73
+ ouptput_message "KEEP database #{database_to_drop} in #{host}"
74
+ end
75
+ ouptput_message "-" * 50
76
+ end
77
+
78
+ raise_wrong_text database_to_drop if db.exist? database_to_drop
79
+ ouptput_message step['message'] % database_to_drop
80
+ end
81
+
82
+ private
83
+
84
+ def target_message_error
85
+ message = []
86
+ message<< "Defined target: #{dns.target},"
87
+ message<< "not found in resource record values:"
88
+ message<< dns.record_data.to_s
89
+ message.join("\n\t")
90
+ end
91
+
92
+
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -5,6 +5,7 @@ require "shards/workflow/fingerprints_terminal"
5
5
  require "shards/workflow/delete_by_terminal"
6
6
  require "shards/workflow/by_api"
7
7
  require "shards/workflow/create_by_api"
8
+ require "shards/workflow/delete_by_api"
8
9
  require "shards/workflow/fingerprints_by_api"
9
10
 
10
11
  module Shards
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.pre.test
4
+ version: 2.2.2.pre.test
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego PL
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-27 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -245,6 +245,7 @@ files:
245
245
  - lib/settings/format_methods.yaml
246
246
  - lib/settings/workflows/base.yaml
247
247
  - lib/settings/workflows/create_by_api.yaml
248
+ - lib/settings/workflows/delete_by_api.yaml
248
249
  - lib/settings/workflows/delete_by_terminal.yaml
249
250
  - lib/settings/workflows/fast_terminal.yaml
250
251
  - lib/settings/workflows/fast_terminal_all.yaml
@@ -270,6 +271,7 @@ files:
270
271
  - lib/shards/workflow/base.rb
271
272
  - lib/shards/workflow/by_api.rb
272
273
  - lib/shards/workflow/create_by_api.rb
274
+ - lib/shards/workflow/delete_by_api.rb
273
275
  - lib/shards/workflow/delete_by_terminal.rb
274
276
  - lib/shards/workflow/fast_terminal.rb
275
277
  - lib/shards/workflow/fast_terminal_all.rb