gaptool-client 0.8.0.pre.alpha → 0.8.0.pre.alpha1
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/VERSION +1 -1
- data/lib/gaptool_client.rb +38 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92e391320b96f17ba1b9358205ae193dde78207
|
4
|
+
data.tar.gz: e7a32dd8afaff543c265919d24ccf3dd97d74ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5294bade02406d836c50f88c01ee217eacad18e647d63a827135e31223b612e62fe53f135ec94619fab7c61a5c1160f0987e815c2b7ed0cd03a7b9429f73ae
|
7
|
+
data.tar.gz: db78cd64429cae2485801b922d005f241dcc10a6384c4052abd34f972f3292b4fb97296456441354d33b6dc250690870edcf8ab2e6e03bcea7230b1a71241f0f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.0-
|
1
|
+
0.8.0-alpha1
|
data/lib/gaptool_client.rb
CHANGED
@@ -146,6 +146,26 @@ EOF
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
def self.query_nodes(opts)
|
150
|
+
instance = opts[:instance]
|
151
|
+
role = opts[:role]
|
152
|
+
environment = opts[:environment]
|
153
|
+
params = opts[:params]
|
154
|
+
|
155
|
+
if instance
|
156
|
+
puts Rainbow('Ignoring role and environment as instance is set').red if role || environment
|
157
|
+
[Gaptool.api.getonenode(instance)]
|
158
|
+
elsif role && environment
|
159
|
+
Gaptool.api.getenvroles(role, environment, params)
|
160
|
+
elsif role
|
161
|
+
Gaptool.api.getrolenodes(role, params)
|
162
|
+
elsif environment
|
163
|
+
Gaptool.api.getenvnodes(environment, params)
|
164
|
+
else
|
165
|
+
Gaptool.api.getallnodes(params)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
149
169
|
def self.remote_exec(nodes, commands, opts = {})
|
150
170
|
serial = opts[:serial]
|
151
171
|
group_size = opts[:group_size] || 10
|
@@ -260,15 +280,13 @@ EOF
|
|
260
280
|
option ['-e', '--environment'], 'ENVIRONMENT', 'Instance environment'
|
261
281
|
option ['-i', '--instance'], 'INSTANCE', 'Instance id (i-xxxxxxxx)'
|
262
282
|
option ['-s', '--serial'], :flag, 'Run command serially. Order of execution is unknown.'
|
283
|
+
option ['-x', '--exclude-hidden'], :flag, 'Exclude hidden hosts'
|
263
284
|
parameter 'COMMAND ...', 'Command to run', attribute_name: :commands
|
264
285
|
|
265
286
|
def execute
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
Gaptool.error 'Missing role' if !role && !instance
|
270
|
-
Gaptool.error 'Missing environment' if !environment && !instance
|
271
|
-
nodes = instance ? [Gaptool.api.getonenode(instance)] : Gaptool.api.getenvroles(role, environment)
|
287
|
+
params = exclude_hidden? ? {} : { hidden: true }
|
288
|
+
nodes = Gaptool.query_nodes(params.merge(instance: instance,
|
289
|
+
role: role, environment: environment))
|
272
290
|
Gaptool.remote_exec(nodes, [commands.join(' ')], serial: serial?)
|
273
291
|
end
|
274
292
|
end
|
@@ -311,12 +329,10 @@ EOF
|
|
311
329
|
|
312
330
|
def execute
|
313
331
|
puts Rainbow('tmux support has been removed').yellow if tmux?
|
314
|
-
Gaptool.
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
Gaptool.error 'Missing environment' if !environment && !instance
|
319
|
-
nodes = instance ? [Gaptool.api.getonenode(instance)] : Gaptool.api.getenvroles(role, environment)
|
332
|
+
nodes = Gaptool.query_nodes(hidden: true,
|
333
|
+
instance: instance,
|
334
|
+
environment: environment,
|
335
|
+
role: role)
|
320
336
|
|
321
337
|
if first? || (nodes.length == 1 && !instance)
|
322
338
|
puts Rainbow('No instance specified, but only one instance in cluster or first forced').green
|
@@ -348,15 +364,9 @@ EOF
|
|
348
364
|
def execute
|
349
365
|
nodes = []
|
350
366
|
params = hidden? ? { hidden: true } : {}
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
nodes = Gaptool.api.getenvroles(role, environment, params)
|
355
|
-
elsif role && !environment
|
356
|
-
nodes = Gaptool.api.getrolenodes(role, params)
|
357
|
-
else
|
358
|
-
nodes = Gaptool.api.getallnodes(params)
|
359
|
-
end
|
367
|
+
nodes = Gaptool.query_nodes(params.merge(instance: instance,
|
368
|
+
role: role,
|
369
|
+
environment: environment))
|
360
370
|
Gaptool.infohelper(nodes, parseable?, grepable?, short?)
|
361
371
|
end
|
362
372
|
end
|
@@ -392,6 +402,7 @@ EOF
|
|
392
402
|
option ['-r', '--role'], 'ROLE', 'Role name to ssh to', required: true
|
393
403
|
option ['-e', '--environment'], 'ENVIRONMENT', 'Which environment, e.g. production', required: true
|
394
404
|
option ['-i', '--instance'], 'INSTANCE', 'Instance ID, e.g. i-12345678'
|
405
|
+
option ['-H', '--hidden'], :flag, 'Include hidden hosts'
|
395
406
|
option(['-A', '--attribute'], 'ATTRIBUTE',
|
396
407
|
'Pass one or more parameters to the deploy recipe in recipe.attr=value format',
|
397
408
|
multivalued: true)
|
@@ -403,11 +414,10 @@ EOF
|
|
403
414
|
|
404
415
|
def execute
|
405
416
|
attrs = Gaptool.split_attrs(attribute_list)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
end
|
417
|
+
nodes = Gaptool.query_nodes(hidden: hidden? ? true : nil,
|
418
|
+
role: role,
|
419
|
+
instance: instance,
|
420
|
+
environment: environment)
|
411
421
|
|
412
422
|
nodes = nodes.map do |x|
|
413
423
|
x['whyrun'] = whyrun?
|
@@ -482,10 +492,10 @@ EOS
|
|
482
492
|
if instance
|
483
493
|
n = Gaptool.api.getonenode(instance)
|
484
494
|
if n['environment'] != environment
|
485
|
-
|
495
|
+
Gaptool.error "Instance #{instance} is not in environment #{environment}"
|
486
496
|
else
|
487
497
|
app_list.each do |app|
|
488
|
-
|
498
|
+
Gaptool.error "Instance #{instance} does not host #{app} in env #{environment}" \
|
489
499
|
unless n['apps'].include?(app)
|
490
500
|
end
|
491
501
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaptool-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0.pre.
|
4
|
+
version: 0.8.0.pre.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Laurita
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-12-
|
13
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|