awful 0.0.139 → 0.0.140

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: 44cbc14484454157636d714889043a28eb9ec88f
4
- data.tar.gz: f269e807d07a1869f3d115adaedd0b3263588bc4
3
+ metadata.gz: 66c22e626406819242c9acc7c78fb4c77e94b8f2
4
+ data.tar.gz: 27b295d708c26242d403df60b7a76fe3d61e3aef
5
5
  SHA512:
6
- metadata.gz: 830faefc88c4eae0b13ae3adcafe8ebc76af3f34e6c030dd7e50af12f28f0b317ec58d44d497e442e1b593349a1530a268b9d028a0d5a84d1eae7de3336c6346
7
- data.tar.gz: d4b9ec6d61354b9f4c8c8fe324f08c29a540085ccd3019f21172a04a39465a76071003c131e9ea498a6199e3235120ac0399dd2038304094d6bbb761444913d5
6
+ metadata.gz: fdecb010ceaa9ad0bfdafbc53eac13796420889c604a41b6fd215ed7a84c1037a87e9aaa054096b25607b9ba7e47f717fc1d12e63c947cf048499e6311a2b2b0
7
+ data.tar.gz: 38019975c26582feaa932a8efb8020000f47c4911b1c10aa3b64fe5fe8f73715e67b08d8022f254dfc445586a6e09ae954430f5d3a491b6df7da93353ab4f7f1
data/bin/alb ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby
2
+ #-*- mode: ruby; -*-
3
+
4
+ require 'awful'
5
+ require 'awful/alb'
6
+
7
+ Awful::Alb.start(ARGV)
data/lib/awful/alb.rb ADDED
@@ -0,0 +1,87 @@
1
+ module Awful
2
+ module Short
3
+ def alb(*args)
4
+ Awful::Alb.new.invoke(*args)
5
+ end
6
+ end
7
+
8
+ class Alb < Cli
9
+ COLORS = {
10
+ active: :green,
11
+ provisioning: :yellow,
12
+ failed: :red,
13
+ InService: :green,
14
+ OutOfService: :red,
15
+ }
16
+
17
+ no_commands do
18
+ def color(string)
19
+ set_color(string, COLORS.fetch(string.to_sym, :yellow))
20
+ end
21
+
22
+ def alb
23
+ @alb ||= Aws::ElasticLoadBalancingV2::Client.new
24
+ end
25
+
26
+ def describe_load_balancers(*names)
27
+ next_marker = nil
28
+ albs = []
29
+ loop do
30
+ response = alb.describe_load_balancers(names: names, marker: next_marker)
31
+ albs += response.load_balancers
32
+ next_marker = response.next_marker
33
+ break unless next_marker
34
+ end
35
+ albs
36
+ end
37
+
38
+ ## return ARN for named ALB
39
+ def get_arn(name_or_arn)
40
+ if name_or_arn.start_with?('arn:')
41
+ name_or_arn # it is already an arn
42
+ else
43
+ describe_load_balancers(name_or_arn).first.load_balancer_arn
44
+ end
45
+ end
46
+ end
47
+
48
+ desc 'ls [NAMES]', 'list application load-balancers'
49
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
50
+ method_option :matching, aliases: '-m', type: :string, default: nil, desc: 'return matching ALB names'
51
+ def ls(*names)
52
+ describe_load_balancers(*names).tap do |albs|
53
+ albs.select! { |a| a.load_balancer_name.match(options[:matching]) } if options[:matching]
54
+ end.output do |list|
55
+ if options[:long]
56
+ print_table list.map { |a| [a.load_balancer_name, a.dns_name, color(a.state.code), a.vpc_id, a.created_time] }
57
+ else
58
+ puts list.map(&:load_balancer_name)
59
+ end
60
+ end
61
+ end
62
+
63
+ desc 'dump NAMES', 'dump ALB details'
64
+ def dump(*names)
65
+ describe_load_balancers(*names).output do |albs|
66
+ albs.each do |alb|
67
+ puts YAML.dump(stringify_keys(alb.to_hash))
68
+ end
69
+ end
70
+ end
71
+
72
+ desc 'listeners NAME', 'list listeners for ALB with NAME'
73
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
74
+ def listeners(name)
75
+ alb.describe_listeners(load_balancer_arn: get_arn(name)).listeners.output do |listeners|
76
+ if options[:long]
77
+ print_table listeners.map { |l|
78
+ [l.protocol, l.port, l.ssl_policy, l.certificates.join(','), l.listener_arn]
79
+ }.sort
80
+ else
81
+ puts listeners.map(&:listener_arn)
82
+ end
83
+ end
84
+ end
85
+
86
+ end
87
+ end
data/lib/awful/ecs.rb CHANGED
@@ -171,6 +171,29 @@ module Awful
171
171
  end
172
172
  end
173
173
 
174
+ desc 'update', 'update a service'
175
+ method_option :desired_count, aliases: '-d', type: :numeric, default: nil, desc: 'desired number of tasks'
176
+ method_option :task_definition, aliases: '-t', type: :string, default: nil, desc: 'task def as family:revision'
177
+ def update(cluster, service)
178
+ params = {
179
+ cluster: cluster,
180
+ service: service,
181
+ desired_count: options[:desired_count],
182
+ task_definition: options[:task_definition],
183
+ }.reject { |k,v| v.nil? }
184
+
185
+ ecs.update_service(params).service.output do |response|
186
+ puts YAML.dump(stringify_keys(response.to_h))
187
+ end
188
+ end
189
+
190
+ desc 'events', 'list events for given CLUSTER and SERVICE'
191
+ def events(cluster, service)
192
+ ecs.describe_services(cluster: cluster, services: [service]).services.first.events.output do |events|
193
+ print_table events.map { |e| [e.created_at, e.id, e.message] }
194
+ end
195
+ end
196
+
174
197
  desc 'run_task CLUSTER TASK_DEFINITION', 'run a task on given cluster'
175
198
  method_option :command, aliases: '-c', default: nil, desc: 'override container command as name:cmd,arg1,arg2'
176
199
  def run_task(cluster, task)
data/lib/awful/ssm.rb CHANGED
@@ -26,7 +26,7 @@ module Awful
26
26
  desc 'ls', 'list commands'
27
27
  method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
28
28
  def ls
29
- ssm.list_commands.commands.tap do |cmds|
29
+ ssm.list_commands.commands.output do |cmds|
30
30
  if options[:long]
31
31
  print_table cmds.map { |c|
32
32
  [
@@ -46,7 +46,7 @@ module Awful
46
46
 
47
47
  desc 'dump ID', 'get details of command invocation for command ID'
48
48
  def dump(id)
49
- ssm.list_command_invocations(command_id: id, details: true).command_invocations.tap do |cmds|
49
+ ssm.list_command_invocations(command_id: id, details: true).command_invocations.output do |cmds|
50
50
  cmds.each do |cmd|
51
51
  puts YAML.dump(stringify_keys(cmd.to_hash))
52
52
  end
@@ -60,7 +60,7 @@ module Awful
60
60
  filter = [{key: 'PlatformTypes', value: options[:platform_types].capitalize}]
61
61
  ssm.list_documents(document_filter_list: filter).document_identifiers.select do |doc|
62
62
  doc.name.match(/#{name}/i)
63
- end.tap do |docs|
63
+ end.output do |docs|
64
64
  if options[:long]
65
65
  print_table docs.map { |d| [d.name, d.platform_types.join(',')] }
66
66
  else
@@ -86,7 +86,7 @@ module Awful
86
86
  parameters: {
87
87
  commands: options[:commands]
88
88
  }
89
- ).tap do |response|
89
+ ).output do |response|
90
90
  puts response.command.command_id
91
91
  end
92
92
  end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.139'
2
+ VERSION = '0.0.140'
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.139
4
+ version: 0.0.140
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,6 +84,7 @@ description: AWS cmdline and yaml loader.
84
84
  email:
85
85
  - rlister+gh@gmail.com
86
86
  executables:
87
+ - alb
87
88
  - ami
88
89
  - apigw
89
90
  - asg
@@ -122,6 +123,7 @@ files:
122
123
  - README.md
123
124
  - Rakefile
124
125
  - awful.gemspec
126
+ - bin/alb
125
127
  - bin/ami
126
128
  - bin/apigw
127
129
  - bin/asg
@@ -152,6 +154,7 @@ files:
152
154
  - bin/ta
153
155
  - bin/vpc
154
156
  - lib/awful.rb
157
+ - lib/awful/alb.rb
155
158
  - lib/awful/ami.rb
156
159
  - lib/awful/api_gateway.rb
157
160
  - lib/awful/api_gateway_deployments.rb