ec2ctl 0.9.9 → 0.9.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3295ca73bd89c2cc15d3b8d66afddc03999fd3a1
4
- data.tar.gz: 8d0a77f8b71f742b03f907dff0cdbdcec38fb4ca
3
+ metadata.gz: d5dab3ddeac4018a3031e936b10a76e691dd0d05
4
+ data.tar.gz: 25ddb0b8b1b57f6141a60f0087a447adbd36a266
5
5
  SHA512:
6
- metadata.gz: 7a6afe01532aabdd4a690cb7af08a2c697413b79e643a19771fdfd8258b2676e87d74738c0b8fb432821d7db1ba19c1e36243cd669fbf71c5b739f505402b31c
7
- data.tar.gz: 1873d16a54c70737982852abed955d91c28ceb98af26644d5f16dc1c2b69cb6ecd03c0f522e68a9f849323b5a9432cfdf52d411bd870b5bc26b30077786e3926
6
+ metadata.gz: 26698b541f6ef89a600af5ff0a153cb8121a670749bd14bb6f05fdd125fd7406c674fe83159ed6bb2246ab0527c96e4e086609480a17e4d4c45c8fee56e58a24
7
+ data.tar.gz: 9930e4a4e93b9d780c5571a3c1a550f23292b2c6c027281bf76010ed74c8fd91e40ebf4fc2f2f92eacc0724db13adb65c7cb1c6e9e664759b2a9e5635b81343e
data/lib/ec2ctl/cli.rb CHANGED
@@ -12,7 +12,7 @@ module EC2Ctl
12
12
  OPTION_FILE_NAME = ".ec2ctlrc".freeze
13
13
 
14
14
  DEFAULT_OPTIONS = {
15
- "ec2 list" => {
15
+ :"ec2 list" => {
16
16
  attributes: %w(instance_id tag:Name instance_type public_dns_name state.name ssm:ping_status),
17
17
  },
18
18
  }
@@ -42,9 +42,7 @@ module EC2Ctl
42
42
  c.option "-S", "--sort KEY", String, "(Optional) Sort instances by this attribute."
43
43
 
44
44
  c.action do |args, options|
45
- handle_options c, options
46
-
47
- invoke options do
45
+ invoke c, options do
48
46
  @client.ec2_list
49
47
  end
50
48
  end
@@ -58,9 +56,7 @@ module EC2Ctl
58
56
  ssm_options c
59
57
 
60
58
  c.action do |args, options|
61
- handle_options c, options
62
-
63
- invoke options do
59
+ invoke c, options do
64
60
  mandatory options, :commands
65
61
  @client.ec2_execute
66
62
  end
@@ -72,9 +68,7 @@ module EC2Ctl
72
68
  c.description = "List load balancers."
73
69
 
74
70
  c.action do |args, options|
75
- handle_options c, options
76
-
77
- invoke options do
71
+ invoke c, options do
78
72
  @client.elb_list
79
73
  end
80
74
  end
@@ -87,9 +81,7 @@ module EC2Ctl
87
81
  c.option "-b", "--load-balancer-name VALUE", String, "The name of the load balancer."
88
82
 
89
83
  c.action do |args, options|
90
- handle_options c, options
91
-
92
- invoke options do
84
+ invoke c, options do
93
85
  mandatory options, :load_balancer_name
94
86
  @client.elb_status
95
87
  end
@@ -104,9 +96,7 @@ module EC2Ctl
104
96
  c.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances to attach."
105
97
 
106
98
  c.action do |args, options|
107
- handle_options c, options
108
-
109
- invoke options do
99
+ invoke c, options do
110
100
  mandatory options, :load_balancer_name, :instance_ids
111
101
  @client.elb_attach
112
102
  end
@@ -121,9 +111,7 @@ module EC2Ctl
121
111
  c.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances to detach."
122
112
 
123
113
  c.action do |args, options|
124
- handle_options c, options
125
-
126
- invoke options do
114
+ invoke c, options do
127
115
  mandatory options, :load_balancer_name, :instance_ids
128
116
  @client.elb_detach
129
117
  end
@@ -137,9 +125,7 @@ module EC2Ctl
137
125
  elb_execute_options c
138
126
 
139
127
  c.action do |args, options|
140
- handle_options c, options
141
-
142
- invoke options do
128
+ invoke c, options do
143
129
  mandatory options, :load_balancer_name, :commands
144
130
  @client.elb_execute
145
131
  end
@@ -153,9 +139,7 @@ module EC2Ctl
153
139
  elb_execute_options c
154
140
 
155
141
  c.action do |args, options|
156
- handle_options c, options
157
-
158
- invoke options do
142
+ invoke c, options do
159
143
  mandatory options, :load_balancer_name, :commands
160
144
  @client.elb_graceful
161
145
  end
@@ -190,10 +174,11 @@ module EC2Ctl
190
174
  )
191
175
  end
192
176
 
193
- def invoke(options, &block)
177
+ def invoke(cmd, opt, &block)
194
178
  begin
195
- debug_init options
196
- init_client options
179
+ handle_options cmd, opt
180
+ debug_init opt
181
+ init_client opt
197
182
  block.call
198
183
  rescue => ex
199
184
  logger.error(
@@ -232,49 +217,50 @@ module EC2Ctl
232
217
  logger.debug aws_env: aws_env
233
218
  end
234
219
 
235
- def elb_execute_options(_command)
236
- _command.option "-b", "--load-balancer-name STRING", String, "The name of the load balancer."
237
- _command.option "--rolling-group-size INTEGER", Integer, "(Optional) The count of instances to register/deregister/execute simultaneously."
238
- _command.option "--skip-draining-waits", "(Optional) Skip waiting connection draining after deregistering instances from load balancer."
239
- _command.option "--skip-inservice-waits", "(Optional) Skip waiting `InService` state after registering instances to load balancer."
240
- _command.option "--inservice-wait-timeout INTEGER", Integer, "(Optional) The time in seconds for instances to be `InService` state after registering to load balancer."
241
- _command.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances. If specified, the commands will be executed only on these instances."
220
+ def elb_execute_options(cmd)
221
+ cmd.option "-b", "--load-balancer-name STRING", String, "The name of the load balancer."
222
+ cmd.option "--rolling-group-size INTEGER", Integer, "(Optional) The count of instances to register/deregister/execute simultaneously."
223
+ cmd.option "--skip-draining-waits", "(Optional) Skip waiting connection draining after deregistering instances from load balancer."
224
+ cmd.option "--skip-inservice-waits", "(Optional) Skip waiting `InService` state after registering instances to load balancer."
225
+ cmd.option "--inservice-wait-timeout INTEGER", Integer, "(Optional) The time in seconds for instances to be `InService` state after registering to load balancer."
226
+ cmd.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances. If specified, the commands will be executed only on these instances."
242
227
 
243
- ssm_options(_command)
228
+ ssm_options(cmd)
244
229
  end
245
230
 
246
- def ssm_options(_command)
247
- _command.option "-c", "--commands 'STRING1','STRING2',...", Array, "The commands to execute."
248
- _command.option "--platform-type Linux|Windows", String, "(Optional) Platform type: `Linux` or `Windows`. Default is `Linux`."
249
- _command.option "--skip-ping-check", "(Optional) Skip SSM ping check."
250
- _command.option "--skip-command-waits", "(Optional) Skip waiting command success."
251
- _command.option "--wait-interval INTEGER", Integer, "(Optional) Waiting interval."
252
- _command.option "--working-directory STRING", String, "(Optional) The path to the working directory on your instance."
253
- _command.option "--execution-timeout INTEGER", Integer, "(Optional) The time in seconds for a command to be completed before it is considered to have failed. Default is 3600 (1 hour). Maximum is 28800 (8 hours)."
254
- _command.option "--timeout-seconds INTEGER", Integer, "(Optional) If this time is reached and the command has not already started executing, it will not execute."
255
- _command.option "--comment STRING", String, "(Optional) User-specified information about the command, such as a brief description of what the command should do."
256
- _command.option "--output-s3-bucket-name STRING", String, "(Optional) The name of the S3 bucket where command execution responses should be stored."
257
- _command.option "--output-s3-key-prefix STRING", String, "(Optional) The directory structure within the S3 bucket where the responses should be stored."
258
- _command.option "--service-role-arn STRING", String, "(Optional) The IAM role that SSM uses to send notifications."
259
- _command.option "--notification-arn STRING", String, "(Optional) An Amazon Resource Name (ARN) for a Simple Notification Service (SNS) topic."
260
- _command.option "--notification-events STRING1,STRING2,...", Array, "(Optional) The different events for which you can receive notifications."
261
- _command.option "--notification-type STRING", String, "(Optional) Command: Receive notification when the status of a command changes."
231
+ def ssm_options(cmd)
232
+ cmd.option "-c", "--commands 'STRING1','STRING2',...", Array, "The commands to execute."
233
+ cmd.option "--platform-type Linux|Windows", String, "(Optional) Platform type: `Linux` or `Windows`. Default is `Linux`."
234
+ cmd.option "--skip-ping-check", "(Optional) Skip SSM ping check."
235
+ cmd.option "--skip-command-waits", "(Optional) Skip waiting command success."
236
+ cmd.option "--wait-interval INTEGER", Integer, "(Optional) Waiting interval."
237
+ cmd.option "--working-directory STRING", String, "(Optional) The path to the working directory on your instance."
238
+ cmd.option "--execution-timeout INTEGER", Integer, "(Optional) The time in seconds for a command to be completed before it is considered to have failed. Default is 3600 (1 hour). Maximum is 28800 (8 hours)."
239
+ cmd.option "--timeout-seconds INTEGER", Integer, "(Optional) If this time is reached and the command has not already started executing, it will not execute."
240
+ cmd.option "--comment STRING", String, "(Optional) User-specified information about the command, such as a brief description of what the command should do."
241
+ cmd.option "--output-s3-bucket-name STRING", String, "(Optional) The name of the S3 bucket where command execution responses should be stored."
242
+ cmd.option "--output-s3-key-prefix STRING", String, "(Optional) The directory structure within the S3 bucket where the responses should be stored."
243
+ cmd.option "--service-role-arn STRING", String, "(Optional) The IAM role that SSM uses to send notifications."
244
+ cmd.option "--notification-arn STRING", String, "(Optional) An Amazon Resource Name (ARN) for a Simple Notification Service (SNS) topic."
245
+ cmd.option "--notification-events STRING1,STRING2,...", Array, "(Optional) The different events for which you can receive notifications."
246
+ cmd.option "--notification-type STRING", String, "(Optional) Command: Receive notification when the status of a command changes."
262
247
  end
263
248
 
264
- def ec2_options(_command)
265
- _command.option "-f", "--filters KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to filter instances."
266
- _command.option "-s", "--search KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to search instances by Regexp."
267
- _command.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances."
249
+ def ec2_options(cmd)
250
+ cmd.option "-f", "--filters KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to filter instances."
251
+ cmd.option "-s", "--search KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to search instances by Regexp."
252
+ cmd.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances."
268
253
  end
269
254
 
270
- def handle_options(_command, opt)
271
- default_opt = DEFAULT_OPTIONS[_command.name]
272
- file_opt = options_from_file[_command.name]
255
+ def handle_options(cmd, opt)
256
+ o = {}
257
+ default_opt = DEFAULT_OPTIONS[cmd.name.intern]
258
+ file_opt = options_from_file[cmd.name.intern]
273
259
 
274
- [default_opt, file_opt].each do |o|
275
- o.each {|k, v| opt.default k.intern => v} if o
276
- end
260
+ o.update default_opt if default_opt
261
+ o.update file_opt if file_opt
277
262
 
263
+ opt.default o
278
264
  handle_global_options opt
279
265
  end
280
266
 
@@ -302,7 +288,7 @@ module EC2Ctl
302
288
  end
303
289
 
304
290
  pathnames.each do |pathname|
305
- return JSON.load File.read(pathname) if File.exists? pathname
291
+ return JSON.parse(File.read(pathname), symbolize_names: true) if File.exists? pathname
306
292
  end
307
293
 
308
294
  {}
@@ -1,3 +1,3 @@
1
1
  module EC2Ctl
2
- VERSION = "0.9.9"
2
+ VERSION = "0.9.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoriki Yamaguchi