ec2-host 0.1.1 → 0.2.0
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/CHANGELOG.md +8 -0
- data/README.md +88 -22
- data/bin/ec2-host +1 -1
- data/ec2-host.gemspec +1 -2
- data/lib/ec2/host/cli.rb +87 -60
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 111eba0b58ae0c88e7c0c8dc2fa342f8f397d594
|
4
|
+
data.tar.gz: cfddfadf8447f1cc751ef005c7173a3b64480cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e09e433370bfd266977ce286de1969dff6137b152745e510937903f0a481b58ef7af01a5d70d97221d0f3912e04d17181cff94e9e18c3ea78a5659f45c806d
|
7
|
+
data.tar.gz: 54d9dca3656d00d3f32d35210bc98e7c9ec40ef1e91985edcb20a4d6ded4280515ad2f32f858cb2ab05464da1cc004e7c8e69f8349fec0f03b28db7724661317
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.2.0 (2015/08/19)
|
2
|
+
|
3
|
+
Changes:
|
4
|
+
|
5
|
+
* Use optparse instead of thor
|
6
|
+
* Format to specify array option arguments are changed from --option a b c to --option a,b,c
|
7
|
+
* --long_option (underscore) is no longer available, only --long-option (dash) is available
|
8
|
+
|
1
9
|
# 0.1.1 (2015/08/11)
|
2
10
|
|
3
11
|
Changes:
|
data/README.md
CHANGED
@@ -44,38 +44,104 @@ See [sampel.conf](./sample.conf)
|
|
44
44
|
|
45
45
|
## CLI Usage
|
46
46
|
|
47
|
+
### CLI Example
|
48
|
+
|
49
|
+
```
|
50
|
+
$ ec2-host -j
|
51
|
+
{"hostname":"test","roles":["admin:ami","test"],"region":"ap-northeast-1","instance_id":"i-85900780","private_ip_address":"172.31.23.50","public_ip_address":null,"launch_time":"2013-09-16 06:14:20 UTC","state":"stopped","monitoring":"disabled"}
|
52
|
+
{"hostname":"ip-172-31-6-194","roles":["isucon4:qual"],"region":"ap-northeast-1","instance_id":"i-f88cc8e1","private_ip_address":"172.31.6.194","public_ip_address":null,"launch_time":"2014-10-20 15:57:23 UTC","state":"stopped","monitoring":"disabled"}
|
53
|
+
```
|
54
|
+
|
55
|
+
```
|
56
|
+
$ ec2-host
|
57
|
+
test
|
58
|
+
ip-172-31-6-194 # if Name tag is not available
|
59
|
+
```
|
60
|
+
|
47
61
|
```
|
48
62
|
$ ec2-host --role1 admin
|
49
|
-
|
50
|
-
|
63
|
+
test
|
64
|
+
```
|
65
|
+
|
66
|
+
```
|
67
|
+
$ ec2-host --role admin:ami
|
68
|
+
test
|
51
69
|
```
|
52
70
|
|
53
|
-
|
71
|
+
```
|
72
|
+
$ ec2-host --pretty-json
|
73
|
+
[
|
74
|
+
{
|
75
|
+
"hostname": "test",
|
76
|
+
"roles": [
|
77
|
+
"admin:ami",
|
78
|
+
"test"
|
79
|
+
],
|
80
|
+
"region": "ap-northeast-1",
|
81
|
+
"instance_id": "i-85900780",
|
82
|
+
"private_ip_address": "172.31.23.50",
|
83
|
+
"public_ip_address": null,
|
84
|
+
"launch_time": "2013-09-16 06:14:20 UTC",
|
85
|
+
"state": "stopped",
|
86
|
+
"monitoring": "disabled"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"hostname": "ip-172-31-6-194",
|
90
|
+
"roles": [
|
91
|
+
"isucon4:qual"
|
92
|
+
],
|
93
|
+
"region": "ap-northeast-1",
|
94
|
+
"instance_id": "i-f88cc8e1",
|
95
|
+
"private_ip_address": "172.31.6.194",
|
96
|
+
"public_ip_address": null,
|
97
|
+
"launch_time": "2014-10-20 15:57:23 UTC",
|
98
|
+
"state": "stopped",
|
99
|
+
"monitoring": "disabled"
|
100
|
+
}
|
101
|
+
]
|
102
|
+
```
|
103
|
+
|
104
|
+
### CLI Help
|
54
105
|
|
55
106
|
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
107
|
+
$ bin/ec2-host --help
|
108
|
+
Usage: ec2-host [options]
|
109
|
+
--hostname one,two,three name or private_dns_name
|
110
|
+
-r, --role one,two,three role
|
111
|
+
--r1, --role1 one,two,three role1, the 1st part of role delimited by :
|
112
|
+
--r2, --role2 one,two,three role2, the 2st part of role delimited by :
|
113
|
+
--r3, --role3 one,two,three role3, the 3st part of role delimited by :
|
114
|
+
--instance-id one,two,three instance_id
|
115
|
+
--state one,two,three state
|
116
|
+
--monitoring one,two,three monitoring
|
117
|
+
--tag one,two,three tag
|
118
|
+
--service one,two,three service
|
119
|
+
--status one,two,three status
|
120
|
+
--private-ip, --ip show private ip address instead of hostname
|
121
|
+
--public-ip show public ip address instead of hostname
|
122
|
+
-i, --info show host info
|
123
|
+
-j, --line-delimited-json show host info in line delimited json
|
124
|
+
--json show host info in json
|
125
|
+
--pretty-json show host info in pretty json
|
126
|
+
--debug debug mode
|
127
|
+
-h, --help show help
|
75
128
|
```
|
76
129
|
|
77
130
|
## Library Usage
|
78
131
|
|
132
|
+
### Library Example
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
require 'ec2-host'
|
136
|
+
|
137
|
+
hosts = EC2::Host.new(role: 'admin:ami')
|
138
|
+
hosts.each do |host|
|
139
|
+
puts host
|
140
|
+
end
|
141
|
+
```
|
142
|
+
|
143
|
+
### Library Reference
|
144
|
+
|
79
145
|
See http://sonots.github.io/ec2-host/doc/frames.html.
|
80
146
|
|
81
147
|
## ChangeLog
|
data/bin/ec2-host
CHANGED
data/ec2-host.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "ec2-host"
|
3
|
-
gem.version = '0.
|
3
|
+
gem.version = '0.2.0'
|
4
4
|
gem.author = ['Naotoshi Seo']
|
5
5
|
gem.email = ['sonots@gmail.com']
|
6
6
|
gem.homepage = 'https://github.com/sonots/ec2-host'
|
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
|
|
15
15
|
|
16
16
|
gem.add_runtime_dependency 'aws-sdk'
|
17
17
|
gem.add_runtime_dependency 'hashie'
|
18
|
-
gem.add_runtime_dependency 'thor'
|
19
18
|
gem.add_runtime_dependency 'dotenv'
|
20
19
|
|
21
20
|
gem.add_development_dependency 'yard'
|
data/lib/ec2/host/cli.rb
CHANGED
@@ -1,69 +1,96 @@
|
|
1
|
-
require 'thor'
|
2
1
|
require 'ec2-host'
|
2
|
+
require 'optparse'
|
3
3
|
|
4
4
|
class EC2
|
5
5
|
class Host
|
6
|
-
class CLI
|
7
|
-
|
6
|
+
class CLI
|
7
|
+
attr_reader :options
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
:aliases => '-h',
|
12
|
-
:type => :array,
|
13
|
-
:desc => "name or private_dns_name"
|
14
|
-
option :role,
|
15
|
-
:aliases => %w[-r --usage -u],
|
16
|
-
:type => :array,
|
17
|
-
:desc => "role"
|
18
|
-
option :role1,
|
19
|
-
:aliases => %w[--r1 --usage1 --u1], # hmm, -r1 is not suppored by thor
|
20
|
-
:type => :array,
|
21
|
-
:desc => "role1, the 1st part of role delimited by #{Config.role_tag_delimiter}"
|
22
|
-
option :role2,
|
23
|
-
:aliases => %w[--r2 --usage2 --u2],
|
24
|
-
:type => :array,
|
25
|
-
:desc => "role2, the 2nd part of role delimited by #{Config.role_tag_delimiter}"
|
26
|
-
option :role3,
|
27
|
-
:aliases => %w[--r3 --usage3 --u3],
|
28
|
-
:type => :array,
|
29
|
-
:desc => "role3, the 3rd part of role delimited by #{Config.role_tag_delimiter}"
|
30
|
-
option :instance_id,
|
31
|
-
:type => :array,
|
32
|
-
:desc => "instance_id"
|
33
|
-
option :state,
|
34
|
-
:type => :array,
|
35
|
-
:desc => "state"
|
36
|
-
option :monitoring,
|
37
|
-
:type => :array,
|
38
|
-
:desc => "monitoring"
|
39
|
-
Config.optional_options.each do |opt, tag|
|
40
|
-
option opt, :type => :array, :desc => opt
|
9
|
+
def initialize(argv = ARGV)
|
10
|
+
@options = parse_options(argv)
|
41
11
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
12
|
+
|
13
|
+
def parse_options(argv = ARGV)
|
14
|
+
op = OptionParser.new
|
15
|
+
|
16
|
+
self.class.module_eval do
|
17
|
+
define_method(:usage) do |msg = nil|
|
18
|
+
puts op.to_s
|
19
|
+
puts "error: #{msg}" if msg
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
opts = {}
|
25
|
+
|
26
|
+
op.on('--hostname one,two,three', Array, "name or private_dns_name") {|v|
|
27
|
+
opts[:hostname] = v
|
28
|
+
}
|
29
|
+
op.on('-r', '--role one,two,three', Array, "role") {|v|
|
30
|
+
opts[:role] = v
|
31
|
+
}
|
32
|
+
op.on('--r1', '--role1 one,two,three', Array, "role1, the 1st part of role delimited by #{Config.role_tag_delimiter}") {|v|
|
33
|
+
opts[:role1] = v
|
34
|
+
}
|
35
|
+
op.on('--r2', '--role2 one,two,three', Array, "role2, the 2st part of role delimited by #{Config.role_tag_delimiter}") {|v|
|
36
|
+
opts[:role2] = v
|
37
|
+
}
|
38
|
+
op.on('--r3', '--role3 one,two,three', Array, "role3, the 3st part of role delimited by #{Config.role_tag_delimiter}") {|v|
|
39
|
+
opts[:role3] = v
|
40
|
+
}
|
41
|
+
op.on('--instance-id one,two,three', Array, "instance_id") {|v|
|
42
|
+
opts[:instance_id] = v
|
43
|
+
}
|
44
|
+
op.on('--state one,two,three', Array, "state") {|v|
|
45
|
+
opts[:state] = v
|
46
|
+
}
|
47
|
+
op.on('--monitoring one,two,three', Array, "monitoring") {|v|
|
48
|
+
opts[:monitoring] = v
|
49
|
+
}
|
50
|
+
Config.optional_options.each do |opt, tag|
|
51
|
+
op.on("--#{opt.to_s.gsub('_', '-')} one,two,three", Array, opt) {|v|
|
52
|
+
opts[opt.to_sym] = v
|
53
|
+
}
|
54
|
+
end
|
55
|
+
op.on('--private-ip', '--ip', "show private ip address instead of hostname") {|v|
|
56
|
+
opts[:private_ip] = v
|
57
|
+
}
|
58
|
+
op.on('--public-ip', "show public ip address instead of hostname") {|v|
|
59
|
+
opts[:public_ip] = v
|
60
|
+
}
|
61
|
+
op.on('-i', '--info', "show host info") {|v|
|
62
|
+
opts[:info] = v
|
63
|
+
}
|
64
|
+
op.on('-j', '--line-delimited-json', "show host info in line delimited json") {|v|
|
65
|
+
opts[:line_delimited_json] = v
|
66
|
+
}
|
67
|
+
op.on('--json', "show host info in json") {|v|
|
68
|
+
opts[:json] = v
|
69
|
+
}
|
70
|
+
op.on('--pretty-json', "show host info in pretty json") {|v|
|
71
|
+
opts[:pretty_json] = v
|
72
|
+
}
|
73
|
+
op.on('--debug', "debug mode") {|v|
|
74
|
+
opts[:debug] = v
|
75
|
+
}
|
76
|
+
op.on('-h', '--help', "show help") {|v|
|
77
|
+
opts[:help] = v
|
78
|
+
}
|
79
|
+
|
80
|
+
begin
|
81
|
+
args = op.parse(argv)
|
82
|
+
rescue OptionParser::InvalidOption => e
|
83
|
+
usage e.message
|
84
|
+
end
|
85
|
+
|
86
|
+
if opts[:help]
|
87
|
+
usage
|
88
|
+
end
|
89
|
+
|
90
|
+
opts
|
91
|
+
end
|
92
|
+
|
93
|
+
def run
|
67
94
|
hosts = EC2::Host.new(condition)
|
68
95
|
if options[:info]
|
69
96
|
hosts.each do |host|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2-host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: thor
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: dotenv
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|