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 +4 -4
- data/lib/ec2ctl/cli.rb +49 -63
- data/lib/ec2ctl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5dab3ddeac4018a3031e936b10a76e691dd0d05
|
4
|
+
data.tar.gz: 25ddb0b8b1b57f6141a60f0087a447adbd36a266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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(
|
177
|
+
def invoke(cmd, opt, &block)
|
194
178
|
begin
|
195
|
-
|
196
|
-
|
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(
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
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(
|
228
|
+
ssm_options(cmd)
|
244
229
|
end
|
245
230
|
|
246
|
-
def ssm_options(
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
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(
|
265
|
-
|
266
|
-
|
267
|
-
|
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(
|
271
|
-
|
272
|
-
|
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
|
-
|
275
|
-
|
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.
|
291
|
+
return JSON.parse(File.read(pathname), symbolize_names: true) if File.exists? pathname
|
306
292
|
end
|
307
293
|
|
308
294
|
{}
|
data/lib/ec2ctl/version.rb
CHANGED