awful 0.0.64 → 0.0.65

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: 197984134d5cd711e7621da746ab62517ecfdb45
4
- data.tar.gz: 588c9979e01069e6817fa3335b2fe76d4b3c32fe
3
+ metadata.gz: 833a0d6caac75f922bd8fd7085cb047142564e31
4
+ data.tar.gz: d5bb1cbca3c714b12043f69c36056f0d41a34f19
5
5
  SHA512:
6
- metadata.gz: ebda32f8f5061fe2aabadf78075cd304da15ff59b34b2f60f56550ac9e5e165a366b0eb5a23aaf20db8fc0d2618b185017775ef1ed215a36f7addc4629d3d6bb
7
- data.tar.gz: b56a1ed0e90e116882d65fc59abc271cce22186ac3b3bf7c276463d8a99c5c47baacc655dfc940fcaaa9175dedbe3c9d20c0116add40958b71d0e52d1c5182d5
6
+ metadata.gz: efb0d8ad07fcf29ffc1d6e6f2047607c62eb0be32563215cef03568b2f3d64e13a696a620531ecd63ee6c384cc1aa294f0557a0420b62e760d2d83386ab73390
7
+ data.tar.gz: de93c913120a50d137cdd1ea5f612e53e3ee17b4fda03a7145ede5298d72c7014c6017167bd2740db42d15ab7acad61fe1576f3d0bf5dacf27669881e47bbd72
data/bin/ecs CHANGED
@@ -4,4 +4,4 @@
4
4
  require 'awful'
5
5
  require 'awful/ecs'
6
6
 
7
- Awful::Ecs.start(ARGV)
7
+ Awful::Ecs.start(ARGV)
@@ -140,22 +140,26 @@ module Awful
140
140
  end
141
141
 
142
142
  ## lame progress indicator, pass true for put, false for skip
143
- dots = options[:dots] ? ->(x){print x ? '.' : 'x'} : ->{}
143
+ dots = options[:dots] ? ->(x){print x ? '.' : 'x'} : ->(_){}
144
144
 
145
145
  ## recursive closure to scan some items from src and put to dest;
146
146
  ## would be more studly as an anonymous y-combinator, but we should write readable code instead
147
147
  scan_and_put = ->(myself, key) {
148
148
  r = src_client.scan(table_name: src_table, exclusive_start_key: key, return_consumed_capacity: 'INDEXES')
149
- print "[#{Time.now}] Scanned #{r.count} items; last evaluated key: #{r.last_evaluated_key}"
149
+ print "[#{Time.now}] [#{src_table}] [scanned:#{r.count}] last key: #{r.last_evaluated_key || 'nil'}"
150
+ put = skipped = 0
150
151
  r.items.each do |item|
151
152
  begin
152
153
  dst_client.put_item(params.merge(item: item))
154
+ put += 1
153
155
  dots.call(true)
154
156
  rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException #item key exists
157
+ skipped += 1
155
158
  dots.call(false)
156
159
  end
157
160
  end
158
161
  print "\n"
162
+ puts "[#{Time.now}] [#{dst_table}] [put:#{put} skipped:#{skipped}]"
159
163
 
160
164
  ## recurse if there are more keys to scan
161
165
  if r.last_evaluated_key
data/lib/awful/ecs.rb CHANGED
@@ -5,6 +5,10 @@ module Awful
5
5
  COLORS = {
6
6
  ACTIVE: :green,
7
7
  INACTIVE: :red,
8
+ true: :green,
9
+ false: :red,
10
+ RUNNING: :green,
11
+ STOPPED: :red,
8
12
  }
9
13
 
10
14
  no_commands do
@@ -49,19 +53,48 @@ module Awful
49
53
  arns = ecs.list_container_instances(cluster: cluster).container_instance_arns
50
54
  if options[:long]
51
55
  container_instances = ecs.describe_container_instances(cluster: cluster, container_instances: arns).container_instances
52
- ec2_instances = ec2.describe_instances(instance_ids: container_instances.map(&:ec2_instance_id)).map(&:reservations).flatten.map(&:instances).flatten
56
+
57
+ ## get hash of tags for each instance id
58
+ tags = ec2.describe_instances(instance_ids: container_instances.map(&:ec2_instance_id)).
59
+ map(&:reservations).flatten.
60
+ map(&:instances).flatten.
61
+ each_with_object({}) do |i,h|
62
+ h[i.instance_id] = tag_name(i, '--')
63
+ end
64
+
53
65
  print_table container_instances.each_with_index.map { |ins, i|
54
66
  [
55
- tag_name(ec2_instances[i]),
67
+ tags[ins.ec2_instance_id],
56
68
  ins.container_instance_arn.split('/').last,
57
69
  ins.ec2_instance_id,
58
- "agent:#{ins.agent_connected}",
70
+ "agent:#{color(ins.agent_connected.to_s)}",
59
71
  color(ins.status),
60
72
  ]
73
+ }.sort
74
+ else
75
+ puts arns
76
+ end
77
+ end
78
+
79
+ desc 'tasks CLUSTER', 'list tasks for CLUSTER'
80
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
81
+ def tasks(cluster)
82
+ arns = ecs.list_tasks(cluster: cluster).task_arns
83
+ if options[:long]
84
+ tasks = ecs.describe_tasks(cluster: cluster, tasks: arns).tasks
85
+ print_table tasks.map { |task|
86
+ [
87
+ task.task_arn.split('/').last,
88
+ task.task_definition_arn.split('/').last,
89
+ task.container_instance_arn.split('/').last,
90
+ "#{color(task.last_status)} (#{task.desired_status})",
91
+ task.started_by,
92
+ ]
61
93
  }
62
94
  else
63
95
  puts arns
64
96
  end
65
97
  end
98
+
66
99
  end
67
100
  end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.64"
2
+ VERSION = "0.0.65"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.64
4
+ version: 0.0.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler