ec2-host 0.2.0 → 0.2.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 +6 -0
- data/ec2-host.gemspec +1 -1
- data/lib/ec2/host/host_data.rb +14 -14
- data/spec/host_spec.rb +6 -0
- 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: a11603984da7e55345504bce0b96e21a903d26f9
|
4
|
+
data.tar.gz: d01d8ea00adca128ad0e2eb0036725fd4cd2cffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a047cb53fc0a9f1c7234ccd8df891e23223574d8d389d7b968cab5da6890ecf171d71157f916d0122a2b24a2942422be3b61a686244f1784b8c92728914cb131
|
7
|
+
data.tar.gz: 26074ba59e96bf6b71c52862667b882db1d7254b5d053f3e537bdd51f8f1996cb7849fe2c19de186380e69ba7b84863b59e2f1efb25ea3a7576b303def3123d9
|
data/CHANGELOG.md
CHANGED
data/ec2-host.gemspec
CHANGED
data/lib/ec2/host/host_data.rb
CHANGED
@@ -19,12 +19,12 @@ class EC2
|
|
19
19
|
:private_ip_address,
|
20
20
|
:public_ip_address,
|
21
21
|
:launch_time
|
22
|
-
def state; instance.state.name; end
|
23
|
-
def monitoring; instance.monitoring.state; end
|
22
|
+
def state; self[:instance].state.name; end
|
23
|
+
def monitoring; self[:instance].monitoring.state; end
|
24
24
|
|
25
25
|
alias_method :ip, :private_ip_address
|
26
26
|
alias_method :start_date, :launch_time
|
27
|
-
def usages; roles; end
|
27
|
+
def usages; self[:roles]; end
|
28
28
|
|
29
29
|
def self.initialize(instance)
|
30
30
|
d = self.new
|
@@ -63,12 +63,12 @@ class EC2
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def info
|
66
|
-
if hostname and status and roles and tags and service
|
66
|
+
if self[:hostname] and self[:status] and self[:roles] and self[:tags] and self[:service]
|
67
67
|
# special treatment for DeNA ;)
|
68
|
-
info = "#{hostname}:#{status}"
|
69
|
-
info << "(#{roles.join(' ')})" unless roles.empty?
|
70
|
-
info << "[#{tags.join(' ')}]" unless tags.empty?
|
71
|
-
info << "{#{service}}" unless service.empty?
|
68
|
+
info = "#{self[:hostname]}:#{self[:status]}"
|
69
|
+
info << "(#{self[:roles].join(' ')})" unless self[:roles].empty?
|
70
|
+
info << "[#{self[:tags].join(' ')}]" unless self[:tags].empty?
|
71
|
+
info << "{#{self[:service]}}" unless self[:service].empty?
|
72
72
|
info
|
73
73
|
else
|
74
74
|
to_hash.to_s
|
@@ -91,7 +91,7 @@ class EC2
|
|
91
91
|
# "instance.instance_id" => self.send("instance").send("instance_id")
|
92
92
|
def get_value(key)
|
93
93
|
v = self
|
94
|
-
key.to_s.split('.').each {|k| v = v.send(k) }
|
94
|
+
key.to_s.split('.').each {|k| v = v[k] || v.send(k) }
|
95
95
|
v
|
96
96
|
end
|
97
97
|
|
@@ -109,23 +109,23 @@ class EC2
|
|
109
109
|
role3 = (condition[:role3] || condition[:usage3] || []).first
|
110
110
|
end
|
111
111
|
if role1
|
112
|
-
return false unless self
|
112
|
+
return false unless self[:roles].find {|role| role.match?(role1, role2, role3) }
|
113
113
|
end
|
114
114
|
true
|
115
115
|
end
|
116
116
|
|
117
117
|
def set_hostname
|
118
|
-
self
|
119
|
-
self
|
118
|
+
self[:hostname] = find_string_tag(Config.hostname_tag)
|
119
|
+
self[:hostname] = self[:instance].private_dns_name.split('.').first if self[:hostname].empty?
|
120
120
|
end
|
121
121
|
|
122
122
|
def set_roles
|
123
123
|
roles = find_array_tag(Config.roles_tag)
|
124
|
-
self
|
124
|
+
self[:roles] = roles.map {|role| EC2::Host::RoleData.initialize(role) }
|
125
125
|
end
|
126
126
|
|
127
127
|
def set_region
|
128
|
-
self
|
128
|
+
self[:region] = Config.aws_region
|
129
129
|
end
|
130
130
|
|
131
131
|
def set_string_tags
|
data/spec/host_spec.rb
CHANGED
@@ -39,6 +39,12 @@ describe EC2::Host do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
describe '#get_value' do
|
43
|
+
let(:hosts) { EC2::Host.new(instance_id: 'i-85900780').to_a }
|
44
|
+
let(:subject) { hosts.first }
|
45
|
+
it { expect(subject.get_value('instance.instance_id')).to eql('i-85900780') }
|
46
|
+
end
|
47
|
+
|
42
48
|
context 'by instance_id' do
|
43
49
|
let(:hosts) { EC2::Host.new(instance_id: 'i-85900780').to_a }
|
44
50
|
let(:subject) { hosts.first }
|
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.2.
|
4
|
+
version: 0.2.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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|