ec2ctl 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ec2ctl/cli.rb +55 -6
- data/lib/ec2ctl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e08c5db7580a3b3be676e4974d7186c98eacbe
|
4
|
+
data.tar.gz: 15c9f9525fc194337ec5ece48ae94fe05cc7282b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f22cba95a82b4069cc33fef991cd92d01a52f49857f7f2971b78895b7eac3fcbe56b1fc013b23d77900014f18371e20d25e42c6b87ed6169774cb11391026f
|
7
|
+
data.tar.gz: 8ffc388529bd49ed70573cd2f107e2446cd0a4999c919a048eeb4ee0ac48de5f64c0a05a9153580a2102eca572f97ee7af85c8424994bf8db63a54803c823c23
|
data/lib/ec2ctl/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "commander"
|
2
2
|
require "ec2ctl/logger"
|
3
|
+
require "pathname"
|
3
4
|
|
4
5
|
module EC2Ctl
|
5
6
|
class CLI
|
@@ -7,16 +8,24 @@ module EC2Ctl
|
|
7
8
|
|
8
9
|
OptionError = Class.new RuntimeError
|
9
10
|
|
11
|
+
USER_OPTION_FILE_PATH = Pathname.new(ENV["HOME"]) / ".ec2ctlrc"
|
12
|
+
|
13
|
+
DEFAULT_OPTIONS = {
|
14
|
+
"ec2 list" => {
|
15
|
+
attributes: %w(instance_id tag:Name instance_type public_dns_name state.name ssm:ping_status),
|
16
|
+
},
|
17
|
+
}
|
18
|
+
|
10
19
|
def run
|
11
20
|
program :name, self.class.to_s
|
12
21
|
program :version, VERSION
|
13
22
|
program :description, "A small command line tool for managing EC2/ELB."
|
14
23
|
|
15
|
-
global_option
|
16
|
-
global_option
|
17
|
-
global_option
|
18
|
-
global_option
|
19
|
-
global_option
|
24
|
+
global_option "-V", "--verbose", "Debug output."
|
25
|
+
global_option "-P", "--pretty", "Pretty JSON output."
|
26
|
+
global_option "-o", "--output #{EC2Ctl::Logger::VALID_FORMATS}", "Log output format."
|
27
|
+
global_option "-p", "--profile PROFILE_NAME", "AWS profile name."
|
28
|
+
global_option "-r", "--region REGION_NAME", "AWS region name."
|
20
29
|
|
21
30
|
default_command :"ec2 list"
|
22
31
|
|
@@ -31,7 +40,7 @@ module EC2Ctl
|
|
31
40
|
c.option "--platform-type Linux|Windows", String, "(Optional) Platform type: `Linux` or `Windows`. Default is `Linux`."
|
32
41
|
|
33
42
|
c.action do |args, options|
|
34
|
-
|
43
|
+
handle_options c, options
|
35
44
|
|
36
45
|
invoke options do
|
37
46
|
@client.ec2_list
|
@@ -47,6 +56,8 @@ module EC2Ctl
|
|
47
56
|
ssm_options c
|
48
57
|
|
49
58
|
c.action do |args, options|
|
59
|
+
handle_options c, options
|
60
|
+
|
50
61
|
invoke options do
|
51
62
|
mandatory options, :commands
|
52
63
|
@client.ec2_execute
|
@@ -59,6 +70,8 @@ module EC2Ctl
|
|
59
70
|
c.description = "List load balancers."
|
60
71
|
|
61
72
|
c.action do |args, options|
|
73
|
+
handle_options c, options
|
74
|
+
|
62
75
|
invoke options do
|
63
76
|
@client.elb_list
|
64
77
|
end
|
@@ -72,6 +85,8 @@ module EC2Ctl
|
|
72
85
|
c.option "-b", "--load-balancer-name VALUE", String, "The name of the load balancer."
|
73
86
|
|
74
87
|
c.action do |args, options|
|
88
|
+
handle_options c, options
|
89
|
+
|
75
90
|
invoke options do
|
76
91
|
mandatory options, :load_balancer_name
|
77
92
|
@client.elb_status
|
@@ -87,6 +102,8 @@ module EC2Ctl
|
|
87
102
|
c.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances to attach."
|
88
103
|
|
89
104
|
c.action do |args, options|
|
105
|
+
handle_options c, options
|
106
|
+
|
90
107
|
invoke options do
|
91
108
|
mandatory options, :load_balancer_name, :instance_ids
|
92
109
|
@client.elb_attach
|
@@ -102,6 +119,8 @@ module EC2Ctl
|
|
102
119
|
c.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances to detach."
|
103
120
|
|
104
121
|
c.action do |args, options|
|
122
|
+
handle_options c, options
|
123
|
+
|
105
124
|
invoke options do
|
106
125
|
mandatory options, :load_balancer_name, :instance_ids
|
107
126
|
@client.elb_detach
|
@@ -116,6 +135,8 @@ module EC2Ctl
|
|
116
135
|
elb_execute_options c
|
117
136
|
|
118
137
|
c.action do |args, options|
|
138
|
+
handle_options c, options
|
139
|
+
|
119
140
|
invoke options do
|
120
141
|
mandatory options, :load_balancer_name, :commands
|
121
142
|
@client.elb_execute
|
@@ -130,6 +151,8 @@ module EC2Ctl
|
|
130
151
|
elb_execute_options c
|
131
152
|
|
132
153
|
c.action do |args, options|
|
154
|
+
handle_options c, options
|
155
|
+
|
133
156
|
invoke options do
|
134
157
|
mandatory options, :load_balancer_name, :commands
|
135
158
|
@client.elb_graceful
|
@@ -241,5 +264,31 @@ module EC2Ctl
|
|
241
264
|
_command.option "-s", "--search KEY1=VALUE1,KEY2=VALUE2...", Array, "(Optional) The key-value pairs to search instances by Regexp."
|
242
265
|
_command.option "-i", "--instance-ids STRING1,STRING2", Array, "(Optional) The IDs of the instances."
|
243
266
|
end
|
267
|
+
|
268
|
+
def handle_options(_command, opt)
|
269
|
+
default_opt = DEFAULT_OPTIONS[_command.name]
|
270
|
+
|
271
|
+
user_options = if File.exists? USER_OPTION_FILE_PATH
|
272
|
+
require "json"
|
273
|
+
JSON.load(File.read(USER_OPTION_FILE_PATH))
|
274
|
+
end
|
275
|
+
|
276
|
+
if user_options && user_options[_command.name]
|
277
|
+
user_options[_command.name].each do |k, v|
|
278
|
+
default_opt.update k.intern => v
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
opt.default default_opt if default_opt
|
283
|
+
handle_global_options opt
|
284
|
+
end
|
285
|
+
|
286
|
+
def handle_global_options(opt)
|
287
|
+
@verbose = true if opt.verbose
|
288
|
+
@pretty = true if opt.pretty
|
289
|
+
@output_format = opt.output if opt.output
|
290
|
+
ENV["AWS_PROFILE"] = opt.profile if opt.profile
|
291
|
+
ENV["AWS_REGION"] = opt.region if opt.region
|
292
|
+
end
|
244
293
|
end
|
245
294
|
end
|
data/lib/ec2ctl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2ctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoriki Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|