awful 0.0.65 → 0.0.66

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/awful/ecs.rb +92 -11
  3. data/lib/awful/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 833a0d6caac75f922bd8fd7085cb047142564e31
4
- data.tar.gz: d5bb1cbca3c714b12043f69c36056f0d41a34f19
3
+ metadata.gz: 57dacf6336b652aa2c0d7cc5919e9a80a701ed2c
4
+ data.tar.gz: c967f4c6f5ee11643ba4faf175b05928127b78a3
5
5
  SHA512:
6
- metadata.gz: efb0d8ad07fcf29ffc1d6e6f2047607c62eb0be32563215cef03568b2f3d64e13a696a620531ecd63ee6c384cc1aa294f0557a0420b62e760d2d83386ab73390
7
- data.tar.gz: de93c913120a50d137cdd1ea5f612e53e3ee17b4fda03a7145ede5298d72c7014c6017167bd2740db42d15ab7acad61fe1576f3d0bf5dacf27669881e47bbd72
6
+ metadata.gz: 67012d564e08dfadf310ef222f7dcaf1a4fc9c44ec1db4b54bad0e2a465353671ae6c4743aebdf7d339295b74d9e5a8e4f6b55afc18d65c59f274ba4e592ec00
7
+ data.tar.gz: 991406fa1cad2c52941e44c3a65e001bd5a55f6f1c6649e22c378430c8616258a7f4029e5d5aedcf024b59d64a1337ace6b07e6d21ff1e4e6b37b49b24443b68
@@ -76,25 +76,106 @@ module Awful
76
76
  end
77
77
  end
78
78
 
79
+ desc 'definitions [FAMILY_PREFIX]', 'task definitions [for FAMILY]'
80
+ method_option :arns, aliases: '-a', default: false, desc: 'show full ARNs for tasks definitions'
81
+ method_option :inactive, aliases: '-i', default: false, desc: 'show INACTIVE instead of ACTIVE task definitions'
82
+ def definitions(family = nil)
83
+ params = {family_prefix: family, status: options[:inactive] ? 'INACTIVE' : 'ACTIVE'}.reject{|_,v| v.nil?}
84
+ arns = ecs.list_task_definitions(params).task_definition_arns
85
+ if options[:arns]
86
+ arns
87
+ else
88
+ arns.map{|a| a.split('/').last}
89
+ end.tap(&method(:puts))
90
+ end
91
+
92
+ desc 'deregister TASK_DEFINITION', 'mark a task definition as INACTIVE'
93
+ def deregister(task)
94
+ ecs.deregister_task_definition(task_definition: task)
95
+ end
96
+
97
+ desc 'dump TASK', 'describe details for TASK definition'
98
+ method_option :json, aliases: '-j', default: false, desc: 'dump as json instead of yaml'
99
+ def dump(task)
100
+ ecs.describe_task_definition(task_definition: task).task_definition.to_h.tap do |hash|
101
+ if options[:json]
102
+ puts JSON.pretty_generate(hash)
103
+ else
104
+ puts YAML.dump(stringify_keys(hash))
105
+ end
106
+ end
107
+ end
108
+
79
109
  desc 'tasks CLUSTER', 'list tasks for CLUSTER'
80
- method_option :long, aliases: '-l', default: false, desc: 'Long listing'
110
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
111
+ method_option :status, aliases: '-s', default: 'running', desc: 'choose status to show: running/pending/stopped'
81
112
  def tasks(cluster)
82
- arns = ecs.list_tasks(cluster: cluster).task_arns
113
+ status = %w[running pending stopped].find{ |s| s.match(/^#{options[:status]}/i) }
114
+ arns = ecs.list_tasks(cluster: cluster, desired_status: status.upcase).task_arns
115
+ if arns.empty?
116
+ []
117
+ elsif options[:long]
118
+ ecs.describe_tasks(cluster: cluster, tasks: arns).tasks.tap do |tasks|
119
+ print_table tasks.map { |task|
120
+ [
121
+ task.task_arn.split('/').last,
122
+ task.task_definition_arn.split('/').last,
123
+ task.container_instance_arn.split('/').last,
124
+ "#{color(task.last_status)} (#{task.desired_status})",
125
+ task.started_by,
126
+ ]
127
+ }
128
+ end
129
+ else
130
+ arns.tap(&method(:puts))
131
+ end
132
+ end
133
+
134
+ desc 'services CLUSTER', 'list services for a cluster'
135
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
136
+ def services(cluster)
137
+ arns = ecs.list_services(cluster: cluster).service_arns
83
138
  if options[:long]
84
- tasks = ecs.describe_tasks(cluster: cluster, tasks: arns).tasks
85
- print_table tasks.map { |task|
139
+ print_table ecs.describe_services(cluster: cluster, services: arns).services.map { |svc|
86
140
  [
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,
141
+ svc.service_name,
142
+ color(svc.status),
143
+ svc.task_definition.split('/').last,
144
+ "#{svc.running_count}/#{svc.desired_count}",
92
145
  ]
93
146
  }
94
147
  else
95
- puts arns
148
+ arns.tap(&method(:puts))
149
+ end
150
+ end
151
+
152
+ desc 'run_task CLUSTER TASK_DEFINITION', 'run a task on given cluster'
153
+ method_option :command, aliases: '-c', default: nil, desc: 'override container command as name:cmd,arg1,arg2'
154
+ def run_task(cluster, task)
155
+ container_overrides = {}
156
+ if options[:command]
157
+ name, command = options[:command].split(':', 2)
158
+ container_overrides.merge!(name: name, command: command.split(','))
159
+ end
160
+
161
+ params = {
162
+ cluster: cluster,
163
+ task_definition: task,
164
+ overrides: container_overrides.empty? ? {} : {container_overrides: [container_overrides]}
165
+ }
166
+
167
+ ecs.run_task(params).tap do |response|
168
+ puts YAML.dump(stringify_keys(response.to_h))
169
+ end
170
+ end
171
+
172
+ desc 'stop_task CLUSTER TASK_ID', 'stop a running task'
173
+ def stop_task(cluster, id)
174
+ ecs.stop_task(cluster: cluster, task: id).task.tap do |response|
175
+ puts YAML.dump(stringify_keys(response.to_h))
96
176
  end
97
177
  end
98
178
 
99
179
  end
100
- end
180
+
181
+ end
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.65"
2
+ VERSION = "0.0.66"
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.65
4
+ version: 0.0.66
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-19 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler