specinfra 2.1.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b9e548051872936a7762ecd20f6aad70c36800c
4
- data.tar.gz: 4c8ec1b47db6cff41db9a07d5fc557fb789fecc3
3
+ metadata.gz: 19e727870d09377357c6b87f15c2082d0db7c324
4
+ data.tar.gz: a34a5f974cf293b8dc2c0fe58e73eb2e71036ec9
5
5
  SHA512:
6
- metadata.gz: e8d634ab5db261fe89a92e4da83bb0801a62451a36b33c51609363e20a49b19a5ef12dc8d20b3f9912c3aeba9999cb87edd0121d25ff6ca964cd74703ced4405
7
- data.tar.gz: eeb6fd92201dcf0c346c9f32c4b625dc6248843f9855da99b162a8743d693d23cd616804311f20dfca2877adac6f9d57099660333bb2788e3b5223bcc77bf0ff
6
+ metadata.gz: 8ac6ece39ed7ab790c51953e09127dae664089c40a0248f0f562df8118f7bdd00bf3e5493ceb0bf553a0e177e6793e02f896e951ddd93086843e3ea6972ea08d
7
+ data.tar.gz: dfb9eb7f64282dce2f6cacebf30f47f3c3ef2cd6ada2cf2804e56e6ceed3261a928320c8c4c1f63aa12e46ec581bd1c87a71498aecd5a7398ead4cef83ea550a
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Specinfra
3
+ class Ec2Metadata
4
+ def initialize
5
+ @base_uri = 'http://169.254.169.254/latest/meta-data/'
6
+ end
7
+
8
+ def get(path='')
9
+ metadata = {}
10
+
11
+ keys = Specinfra::Runner.run_command("curl #{@base_uri}#{path}").stdout.split("\n")
12
+
13
+ keys.each do |key|
14
+ if key =~ %r{/$}
15
+ metadata[key[0..-2]] = get(path + key)
16
+ else
17
+ if key =~ %r{=}
18
+ key = key.split('=')[0] + '/'
19
+ metadata[key[0..-2]] = get(path + key)
20
+ else
21
+ ret = get_endpoint(path)
22
+ metadata[key] = get_endpoint(path + key) if ret
23
+ end
24
+ end
25
+ end
26
+
27
+ metadata
28
+ end
29
+
30
+ def get_endpoint(path)
31
+ ret = Specinfra::Runner.run_command("curl #{@base_uri}#{path}")
32
+ if ret.success?
33
+ ret.stdout
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,3 +1,5 @@
1
+ require 'specinfra/ec2_metadata'
2
+
1
3
  module Specinfra
2
4
  class Processor
3
5
  def self.check_service_is_running(service)
@@ -181,5 +183,9 @@ module Specinfra
181
183
  end
182
184
  memory
183
185
  end
186
+
187
+ def self.get_inventory_ec2
188
+ Specinfra::Ec2Metadata.new.get
189
+ end
184
190
  end
185
191
  end
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.1.1"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-06 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -304,6 +304,7 @@ files:
304
304
  - lib/specinfra/command_factory.rb
305
305
  - lib/specinfra/command_result.rb
306
306
  - lib/specinfra/configuration.rb
307
+ - lib/specinfra/ec2_metadata.rb
307
308
  - lib/specinfra/helper.rb
308
309
  - lib/specinfra/helper/configuration.rb
309
310
  - lib/specinfra/helper/detect_os.rb