shards 2.1.6 → 2.2.1.pre.test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/settings/workflows/base.yaml +5 -1
- data/lib/settings/workflows/create_by_api.yaml +13 -15
- data/lib/settings/workflows/delete_by_terminal.yaml +1 -1
- data/lib/settings/workflows/fast_terminal.yaml +22 -17
- data/lib/settings/workflows/fingerprints_by_api.yaml +48 -0
- data/lib/settings/workflows/fingerprints_terminal.yaml +42 -0
- data/lib/shards/client.rb +3 -3
- data/lib/shards/version.rb +1 -1
- data/lib/shards/workflow/base.rb +38 -11
- data/lib/shards/workflow/by_api.rb +25 -0
- data/lib/shards/workflow/create_by_api.rb +1 -10
- data/lib/shards/workflow/delete_by_terminal.rb +0 -1
- data/lib/shards/workflow/fast_terminal.rb +0 -22
- data/lib/shards/workflow/fast_terminal_all.rb +0 -1
- data/lib/shards/workflow/fingerprints_by_api.rb +31 -0
- data/lib/shards/workflow/{fingerprint_terminal.rb → fingerprints_terminal.rb} +1 -2
- data/lib/shards/workflow/terminal.rb +0 -1
- data/lib/shards/workflow/workflow.rb +3 -1
- metadata +9 -6
- data/lib/settings/workflows/fingerprint_terminal.yaml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11aaa88e5e9af9729d5b5554f54842bde6a885c0
|
4
|
+
data.tar.gz: 7373e2a508097075659ef1a1a644ed0947dc711a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035ae7f6ae76900c45e8c88d3e52b777d2a4021425cf88504c989af152c4496edd34a3a3fc5a0b8bc26d5470aee1fae5f26e74a0510f6ab205d54162509bcdd3
|
7
|
+
data.tar.gz: ed2206cf2f5fa7e56e00f7d23c55df784295b50280175685915c95805cdf6dde72596066f1c5b79401b0a0ec1a6833020ed135b609e6f64c27d92bfa80764841
|
data/Gemfile.lock
CHANGED
@@ -74,7 +74,7 @@ shared_steps:
|
|
74
74
|
dns_upsert:
|
75
75
|
message: The dns record with the host %s has been succesfully created.
|
76
76
|
wrong_message: Error. Could not register the host %s as a dns record.
|
77
|
-
correct:
|
77
|
+
correct: finish_successfully
|
78
78
|
wrong: finish
|
79
79
|
|
80
80
|
clean_repo_and_exit:
|
@@ -84,6 +84,10 @@ shared_steps:
|
|
84
84
|
finish:
|
85
85
|
correct: final_step
|
86
86
|
|
87
|
+
finish_successfully:
|
88
|
+
message: The workflow finish successfully.
|
89
|
+
correct: finish
|
90
|
+
|
87
91
|
ask_blank_db:
|
88
92
|
# this step could be called or not after the write_yaml_files
|
89
93
|
# to change the workflow dinamically call the methods
|
@@ -6,23 +6,21 @@ create_by_api:
|
|
6
6
|
commit_changes:
|
7
7
|
message: The changes has been committed and pushed to the remote repository.
|
8
8
|
wrong_message: We had an issue to commit and push the changes.
|
9
|
-
correct:
|
9
|
+
correct: finish_successfully
|
10
10
|
wrong: finish
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
- commit_changes
|
25
|
-
- finish
|
12
|
+
correct_steps_summary:
|
13
|
+
- validate_client
|
14
|
+
- validate_domain
|
15
|
+
- validate_location
|
16
|
+
- validate_stage
|
17
|
+
- check_shard_presence_in_shards
|
18
|
+
- check_database_presence_in_server
|
19
|
+
- check_domain_dns_presence
|
20
|
+
- check_domain_presence_in_sites
|
21
|
+
- write_yaml_files
|
22
|
+
- create_database
|
23
|
+
- commit_changes
|
26
24
|
|
27
25
|
|
28
26
|
start: validate_client
|
@@ -2,23 +2,28 @@
|
|
2
2
|
# see shared_steps in base.yaml to find the steps not defined in a workflow
|
3
3
|
|
4
4
|
fast_terminal:
|
5
|
+
all_steps_in_base:
|
6
|
+
- all steps are in base yaml
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
correct_steps_summary:
|
9
|
+
- validate_client
|
10
|
+
- validate_domain
|
11
|
+
- validate_location
|
12
|
+
- validate_stage
|
13
|
+
- check_shard_presence_in_shards
|
14
|
+
- check_database_presence_in_server
|
15
|
+
- check_domain_dns_presence
|
16
|
+
- check_domain_presence_in_sites
|
17
|
+
- write_yaml_files
|
18
|
+
- create_database
|
19
|
+
- commit_changes
|
20
|
+
- check_fingerprints
|
21
|
+
# Run a 3 times loop when the above check fails.
|
22
|
+
- loop_step
|
23
|
+
- puppet_agent_udate
|
24
|
+
- check_fingerprints
|
25
|
+
# finish loop
|
26
|
+
- application_reload_shards_task
|
27
|
+
- dns_upsert
|
23
28
|
|
24
29
|
start: validate_client
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
# see shared_steps in base.yaml to find the steps not defined in a workflow
|
3
|
+
|
4
|
+
fingerprints_by_api:
|
5
|
+
|
6
|
+
# import validate client domain location and stage from fingerprints terminal
|
7
|
+
|
8
|
+
check_fingerprints:
|
9
|
+
message: The yaml files have been updated correctly in server(s).
|
10
|
+
wrong_message: Fingerprints are not matching %s
|
11
|
+
correct: application_reload_shards_task
|
12
|
+
wrong: loop_step
|
13
|
+
|
14
|
+
application_reload_shards_task:
|
15
|
+
message: Reload task have been executed successfully.
|
16
|
+
wrong_message: Errors found in the reload task %s.
|
17
|
+
correct: dns_upsert
|
18
|
+
wrong: finish
|
19
|
+
|
20
|
+
puppet_agent_update:
|
21
|
+
message: Puppet has been executed successfully.
|
22
|
+
correct: check_fingerprints
|
23
|
+
wrong_message: Errors executing the puppet update % s
|
24
|
+
wrong: check_fingerprints
|
25
|
+
|
26
|
+
loop_step:
|
27
|
+
correct: puppet_agent_update
|
28
|
+
message: The step %s will be executed after wait %d seconds.
|
29
|
+
wrong: finish
|
30
|
+
wrong_message: This is the %dth loop. The maximun is (%d).
|
31
|
+
total_loops: 1
|
32
|
+
seconds_between_loop: 1
|
33
|
+
|
34
|
+
correct_steps_summary:
|
35
|
+
- validate_client
|
36
|
+
- validate_domain
|
37
|
+
- validate_location
|
38
|
+
- validate_stage
|
39
|
+
- check_fingerprints
|
40
|
+
# Run a 1 time loop when the above check fails.
|
41
|
+
- loop_step
|
42
|
+
- puppet_agent_udate
|
43
|
+
- check_fingerprints
|
44
|
+
# finish loop
|
45
|
+
- application_reload_shards_task
|
46
|
+
- dns_upsert
|
47
|
+
|
48
|
+
start: validate_client
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
# see shared_steps in base.yaml to find the steps not defined in a workflow
|
3
|
+
|
4
|
+
fingerprints_terminal:
|
5
|
+
|
6
|
+
validate_client:
|
7
|
+
correct: validate_domain
|
8
|
+
wrong: finish
|
9
|
+
wrong_message: The client name %s.
|
10
|
+
min_size: 2
|
11
|
+
|
12
|
+
validate_domain:
|
13
|
+
correct: validate_location
|
14
|
+
wrong: finish
|
15
|
+
wrong_message: The domain %s.
|
16
|
+
min_size: 3
|
17
|
+
regex: ^[a-z0-9_]*$
|
18
|
+
|
19
|
+
validate_stage:
|
20
|
+
correct: check_fingerprints
|
21
|
+
wrong_message: Stage %s does not exist.
|
22
|
+
wrong: finish
|
23
|
+
|
24
|
+
validate_location:
|
25
|
+
correct: validate_stage
|
26
|
+
wrong_message: Location %s does not exist.
|
27
|
+
wrong: finish
|
28
|
+
|
29
|
+
correct_steps_summary:
|
30
|
+
- validate_client
|
31
|
+
- validate_domain
|
32
|
+
- validate_location
|
33
|
+
- validate_stage
|
34
|
+
- check_fingerprints
|
35
|
+
# Run a 3 times loop when the above check fails.
|
36
|
+
- loop_step # start the loop here
|
37
|
+
- puppet_agent_udate
|
38
|
+
- check_fingerprints # finish loop
|
39
|
+
- application_reload_shards_task
|
40
|
+
- dns_upsert
|
41
|
+
|
42
|
+
start: validate_client
|
data/lib/shards/client.rb
CHANGED
@@ -20,9 +20,9 @@ module Shards
|
|
20
20
|
|
21
21
|
def loop_fingerprint_check location, stage, client, domain
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
terminal=Shards::Workflow::FingerprintsTerminal.new config
|
24
|
+
terminal.params= { client: client, domain: domain, location: location.downcase, stage: stage }
|
25
|
+
terminal.start
|
26
26
|
|
27
27
|
end
|
28
28
|
|
data/lib/shards/version.rb
CHANGED
data/lib/shards/workflow/base.rb
CHANGED
@@ -9,12 +9,13 @@ module Shards
|
|
9
9
|
attr_accessor :config, :flow, :pointer, :step, :answer, :pointer_history, :client, :location, :stage, :domain, :site, :params, :blank_db
|
10
10
|
|
11
11
|
attr_writer :wf
|
12
|
-
attr_reader :current_loop
|
12
|
+
attr_reader :current_loop, :success
|
13
13
|
|
14
14
|
def initialize config
|
15
15
|
@config=config
|
16
16
|
config.repo.clean
|
17
17
|
@pointer_history = []
|
18
|
+
@success=false
|
18
19
|
end
|
19
20
|
|
20
21
|
def yaml
|
@@ -101,6 +102,27 @@ module Shards
|
|
101
102
|
puts message
|
102
103
|
end
|
103
104
|
|
105
|
+
def validate_client
|
106
|
+
|
107
|
+
cli=params[:client]
|
108
|
+
|
109
|
+
validate_min_size cli, step['min_size']
|
110
|
+
|
111
|
+
@client=cli
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
def validate_domain
|
116
|
+
|
117
|
+
domain_name=params[:domain]
|
118
|
+
|
119
|
+
validate_min_size domain_name, step['min_size']
|
120
|
+
|
121
|
+
validate_regex domain_name, step['regex']
|
122
|
+
|
123
|
+
@domain=domain_name
|
124
|
+
|
125
|
+
end
|
104
126
|
|
105
127
|
def ask_question
|
106
128
|
puts step['question']
|
@@ -188,7 +210,7 @@ module Shards
|
|
188
210
|
def write_yaml_files
|
189
211
|
stage.add_domain domain
|
190
212
|
site.add_site
|
191
|
-
|
213
|
+
output_message config.repo.diff
|
192
214
|
ask_question
|
193
215
|
raise step['wrong_message'] if answer.strip.downcase!='y'
|
194
216
|
end
|
@@ -196,8 +218,8 @@ module Shards
|
|
196
218
|
def commit_changes
|
197
219
|
config.repo.message = "Added shard in #{location.name} for #{client}"
|
198
220
|
config.repo.autocommit
|
199
|
-
|
200
|
-
|
221
|
+
output_message step['message']
|
222
|
+
output_message config.repo.message
|
201
223
|
end
|
202
224
|
|
203
225
|
def create_database
|
@@ -205,17 +227,17 @@ module Shards
|
|
205
227
|
stage.shard.db.create dryrun: false
|
206
228
|
message_params= [stage.shard.db.name, stage.shard.db.server]
|
207
229
|
raise_wrong_text message_params unless stage.shard.db.exist?
|
208
|
-
|
230
|
+
output_message step['message'] % message_params
|
209
231
|
end
|
210
232
|
|
211
233
|
def clean_repo_and_exit
|
212
|
-
|
234
|
+
output_message config.repo.clean
|
213
235
|
end
|
214
236
|
|
215
237
|
def dns_upsert
|
216
238
|
stage.shard.dns.set dryrun: false
|
217
239
|
raise_wrong_text host unless stage.shard.dns.exist?
|
218
|
-
|
240
|
+
output_message step['message'] % host
|
219
241
|
end
|
220
242
|
|
221
243
|
def host
|
@@ -253,7 +275,7 @@ module Shards
|
|
253
275
|
resp=stage.check_remote_process remote_check: :fingerprints
|
254
276
|
errors=filter_errors resp
|
255
277
|
raise_wrong_text errors if errors.count>0
|
256
|
-
|
278
|
+
output_message step['message']
|
257
279
|
end
|
258
280
|
|
259
281
|
def loop_step
|
@@ -261,7 +283,7 @@ module Shards
|
|
261
283
|
@total_loops||=step['total_loops']
|
262
284
|
@current_loop+=1
|
263
285
|
raise_wrong_text [current_loop,@total_loops] if current_loop>@total_loops
|
264
|
-
|
286
|
+
output_message step['message'] % [step['correct'], step['seconds_between_loop']]
|
265
287
|
sleep step['seconds_between_loop']
|
266
288
|
end
|
267
289
|
|
@@ -270,14 +292,19 @@ module Shards
|
|
270
292
|
resp=stage.check_remote_process remote_check: :reload_shards!
|
271
293
|
errors=filter_status_errors resp
|
272
294
|
raise_wrong_text errors if errors.count>0
|
273
|
-
|
295
|
+
output_message step['message']
|
274
296
|
end
|
275
297
|
|
276
298
|
def puppet_agent_update
|
277
299
|
resp=stage.check_remote_process remote_check: :puppet_agent!
|
278
300
|
errors=filter_status_errors resp
|
279
301
|
raise_wrong_text errors if errors.count>0
|
280
|
-
|
302
|
+
output_message step['message']
|
303
|
+
end
|
304
|
+
|
305
|
+
def finish_successfully
|
306
|
+
output_message step['message']
|
307
|
+
@success=true
|
281
308
|
end
|
282
309
|
|
283
310
|
private
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
module Shards
|
3
|
+
|
4
|
+
module Workflow
|
5
|
+
|
6
|
+
class ByApi < Shards::Workflow::Base
|
7
|
+
|
8
|
+
attr_accessor :log
|
9
|
+
|
10
|
+
def write_yaml_files
|
11
|
+
stage.add_domain domain
|
12
|
+
site.add_site
|
13
|
+
output_message config.repo.diff
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_message message
|
17
|
+
@log||="Create By API\n"
|
18
|
+
@log << "#{pointer} -> #{message} #{Time.now.to_s}\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -1,19 +1,10 @@
|
|
1
|
-
require_relative './base.rb'
|
2
1
|
|
3
2
|
module Shards
|
4
3
|
|
5
4
|
module Workflow
|
6
5
|
|
7
|
-
class CreateByApi < Shards::Workflow::
|
6
|
+
class CreateByApi < Shards::Workflow::ByApi
|
8
7
|
|
9
|
-
def write_yaml_files
|
10
|
-
stage.add_domain domain
|
11
|
-
site.add_site
|
12
|
-
end
|
13
|
-
|
14
|
-
def output_message message
|
15
|
-
message
|
16
|
-
end
|
17
8
|
|
18
9
|
end
|
19
10
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require_relative './base.rb'
|
2
1
|
|
3
2
|
module Shards
|
4
3
|
|
@@ -6,27 +5,6 @@ module Shards
|
|
6
5
|
|
7
6
|
class FastTerminal < Shards::Workflow::Base
|
8
7
|
|
9
|
-
def validate_client
|
10
|
-
|
11
|
-
cli=params[:client]
|
12
|
-
|
13
|
-
validate_min_size cli, step['min_size']
|
14
|
-
|
15
|
-
@client=cli
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def validate_domain
|
20
|
-
|
21
|
-
domain_name=params[:domain]
|
22
|
-
|
23
|
-
validate_min_size domain_name, step['min_size']
|
24
|
-
|
25
|
-
validate_regex domain_name, step['regex']
|
26
|
-
|
27
|
-
@domain=domain_name
|
28
|
-
|
29
|
-
end
|
30
8
|
|
31
9
|
end
|
32
10
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Shards
|
3
|
+
|
4
|
+
module Workflow
|
5
|
+
|
6
|
+
class FingerprintsByApi < Shards::Workflow::ByApi
|
7
|
+
|
8
|
+
def shared_workflow
|
9
|
+
'fingerprints_terminal'
|
10
|
+
end
|
11
|
+
|
12
|
+
def shared_wf_file
|
13
|
+
get_file "#{shared_workflow}.yaml"
|
14
|
+
end
|
15
|
+
|
16
|
+
def shared_steps_with_workflow
|
17
|
+
YAML.load_file(shared_wf_file)[shared_workflow]
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
@flow=shared_steps.merge yaml[wf]
|
22
|
+
@flow.merge! shared_steps_with_workflow
|
23
|
+
@pointer=yaml['start']
|
24
|
+
run_step
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require "shards/workflow/base"
|
2
2
|
require "shards/workflow/terminal"
|
3
3
|
require "shards/workflow/fast_terminal"
|
4
|
-
require "shards/workflow/
|
4
|
+
require "shards/workflow/fingerprints_terminal"
|
5
5
|
require "shards/workflow/delete_by_terminal"
|
6
|
+
require "shards/workflow/by_api"
|
6
7
|
require "shards/workflow/create_by_api"
|
8
|
+
require "shards/workflow/fingerprints_by_api"
|
7
9
|
|
8
10
|
module Shards
|
9
11
|
|
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.1.
|
4
|
+
version: 2.2.1.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-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -248,7 +248,8 @@ files:
|
|
248
248
|
- lib/settings/workflows/delete_by_terminal.yaml
|
249
249
|
- lib/settings/workflows/fast_terminal.yaml
|
250
250
|
- lib/settings/workflows/fast_terminal_all.yaml
|
251
|
-
- lib/settings/workflows/
|
251
|
+
- lib/settings/workflows/fingerprints_by_api.yaml
|
252
|
+
- lib/settings/workflows/fingerprints_terminal.yaml
|
252
253
|
- lib/settings/workflows/terminal.yaml
|
253
254
|
- lib/shards.rb
|
254
255
|
- lib/shards/base.rb
|
@@ -267,11 +268,13 @@ files:
|
|
267
268
|
- lib/shards/stage.rb
|
268
269
|
- lib/shards/version.rb
|
269
270
|
- lib/shards/workflow/base.rb
|
271
|
+
- lib/shards/workflow/by_api.rb
|
270
272
|
- lib/shards/workflow/create_by_api.rb
|
271
273
|
- lib/shards/workflow/delete_by_terminal.rb
|
272
274
|
- lib/shards/workflow/fast_terminal.rb
|
273
275
|
- lib/shards/workflow/fast_terminal_all.rb
|
274
|
-
- lib/shards/workflow/
|
276
|
+
- lib/shards/workflow/fingerprints_by_api.rb
|
277
|
+
- lib/shards/workflow/fingerprints_terminal.rb
|
275
278
|
- lib/shards/workflow/terminal.rb
|
276
279
|
- lib/shards/workflow/workflow.rb
|
277
280
|
- shards.gemspec
|
@@ -292,9 +295,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
295
|
version: '0'
|
293
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
294
297
|
requirements:
|
295
|
-
- - "
|
298
|
+
- - ">"
|
296
299
|
- !ruby/object:Gem::Version
|
297
|
-
version:
|
300
|
+
version: 1.3.1
|
298
301
|
requirements: []
|
299
302
|
rubyforge_project:
|
300
303
|
rubygems_version: 2.6.14
|
@@ -1,23 +0,0 @@
|
|
1
|
-
---
|
2
|
-
# see shared_steps in base.yaml to find the steps not defined in a workflow
|
3
|
-
|
4
|
-
fingerprint_terminal:
|
5
|
-
|
6
|
-
validate_stage:
|
7
|
-
correct: check_fingerprints
|
8
|
-
wrong_message: Stage %s does not exist.
|
9
|
-
wrong: clean_repo_and_exit
|
10
|
-
|
11
|
-
correct_steps_summary:
|
12
|
-
- validate_client
|
13
|
-
- validate_domain
|
14
|
-
- validate_location
|
15
|
-
- validate_stage
|
16
|
-
- check_fingerprints
|
17
|
-
- loop_step
|
18
|
-
# It runs a puppet agent -t 3 times when the above check fails.
|
19
|
-
- application_reload_shards_task
|
20
|
-
- dns_upsert
|
21
|
-
- finish
|
22
|
-
|
23
|
-
start: validate_client
|