ec2-host 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/ec2-host.gemspec +1 -1
- data/lib/ec2/host/cli.rb +22 -11
- data/lib/ec2/host/client_util.rb +1 -2
- data/lib/ec2/host/host_data.rb +4 -4
- 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: 71fdb977a6c700081fd8af2f3274b70778854458
|
4
|
+
data.tar.gz: 380fbcf200f1fb57fca95d1b8a8a1f5f8a431873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9deed0d8a1921c188193536c519f3be9f918767c174e4cf2116517a5ae1bc8403d33d5f82d434e0b2d7d62236f8f4a2686be45fab71ba40823289d15e2b991c
|
7
|
+
data.tar.gz: 901615c730d1a69786586c864a55a53f1e00d6da90c0f8e924cd02f4fedabc3deaf8a4e0e6410f9a9e920b0e5ba5b8f4254772701ec1ce6fd763329e325fecc9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 0.1.1 (2015/08/11)
|
2
|
+
|
3
|
+
Changes:
|
4
|
+
|
5
|
+
* Rename `--json` to `--line-delimited-json`. Alias is kept as `-j`.
|
6
|
+
* Add `--json` which returns an arrayed json
|
7
|
+
* Add `--pretty-json` which returns json in pretty print
|
8
|
+
|
9
|
+
Fixes:
|
10
|
+
|
11
|
+
* Stop using Aws.config.update, it changes the default config
|
12
|
+
|
1
13
|
# 0.1.0 (2015/08/11)
|
2
14
|
|
3
15
|
Enhancements:
|
data/ec2-host.gemspec
CHANGED
data/lib/ec2/host/cli.rb
CHANGED
@@ -49,33 +49,44 @@ class EC2
|
|
49
49
|
option :info,
|
50
50
|
:aliases => %w[-i],
|
51
51
|
:type => :boolean,
|
52
|
-
:desc => "show host info
|
53
|
-
option :
|
52
|
+
:desc => "show host info"
|
53
|
+
option :line_delimited_json,
|
54
54
|
:aliases => %w[-j],
|
55
55
|
:type => :boolean,
|
56
|
-
:desc => "show
|
56
|
+
:desc => "show host info in line delimited json"
|
57
|
+
option :json,
|
58
|
+
:type => :boolean,
|
59
|
+
:desc => "show host info in json"
|
60
|
+
option :pretty_json,
|
61
|
+
:type => :boolean,
|
62
|
+
:desc => "show host info in pretty json"
|
57
63
|
option :debug,
|
58
64
|
:type => :boolean,
|
59
65
|
:desc => "debug mode"
|
60
66
|
def get_hosts
|
67
|
+
hosts = EC2::Host.new(condition)
|
61
68
|
if options[:info]
|
62
|
-
|
69
|
+
hosts.each do |host|
|
63
70
|
$stdout.puts host.info
|
64
71
|
end
|
65
|
-
elsif options[:
|
66
|
-
|
67
|
-
$stdout.puts host.
|
72
|
+
elsif options[:line_delimited_json]
|
73
|
+
hosts.each do |host|
|
74
|
+
$stdout.puts host.to_hash.to_json
|
68
75
|
end
|
76
|
+
elsif options[:json]
|
77
|
+
$stdout.puts hosts.map(&:to_hash).to_json
|
78
|
+
elsif options[:pretty_json]
|
79
|
+
$stdout.puts JSON.pretty_generate(hosts.map(&:to_hash))
|
69
80
|
elsif options[:private_ip]
|
70
|
-
|
81
|
+
hosts.each do |host|
|
71
82
|
$stdout.puts host.private_ip_address
|
72
83
|
end
|
73
84
|
elsif options[:public_ip]
|
74
|
-
|
85
|
+
hosts.each do |host|
|
75
86
|
$stdout.puts host.public_ip_address
|
76
87
|
end
|
77
88
|
else
|
78
|
-
|
89
|
+
hosts.each do |host|
|
79
90
|
$stdout.puts host.hostname
|
80
91
|
end
|
81
92
|
end
|
@@ -85,7 +96,7 @@ class EC2
|
|
85
96
|
|
86
97
|
def condition
|
87
98
|
return @condition if @condition
|
88
|
-
_condition = HashUtil.except(options, :info, :json, :debug, :private_ip, :public_ip)
|
99
|
+
_condition = HashUtil.except(options, :info, :line_delimited_json, :json, :pretty_json, :debug, :private_ip, :public_ip)
|
89
100
|
@condition = {}
|
90
101
|
_condition.each do |key, val|
|
91
102
|
if tag = Config.optional_options[key.to_s]
|
data/lib/ec2/host/client_util.rb
CHANGED
@@ -6,8 +6,7 @@ class EC2
|
|
6
6
|
class ClientUtil
|
7
7
|
def self.ec2(reload = false)
|
8
8
|
if @ec2.nil? || reload
|
9
|
-
Aws.
|
10
|
-
@ec2 = Aws::EC2::Client.new
|
9
|
+
@ec2 = Aws::EC2::Client.new(region: Config.aws_region, credentials: Config.aws_credentials)
|
11
10
|
end
|
12
11
|
@ec2
|
13
12
|
end
|
data/lib/ec2/host/host_data.rb
CHANGED
@@ -71,19 +71,19 @@ class EC2
|
|
71
71
|
info << "{#{service}}" unless service.empty?
|
72
72
|
info
|
73
73
|
else
|
74
|
-
|
74
|
+
to_hash.to_s
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
79
|
-
HashUtil.except(self, :instance).merge(
|
78
|
+
def to_hash
|
79
|
+
HashUtil.except(self, :instance).to_h.merge(
|
80
80
|
instance_id: instance_id,
|
81
81
|
private_ip_address: private_ip_address,
|
82
82
|
public_ip_address: public_ip_address,
|
83
83
|
launch_time: launch_time,
|
84
84
|
state: state,
|
85
85
|
monitoring: monitoring,
|
86
|
-
)
|
86
|
+
)
|
87
87
|
end
|
88
88
|
|
89
89
|
# private
|
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.1.
|
4
|
+
version: 0.1.1
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|