ey_aws 0.9 → 0.9.1

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.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg/*
2
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,10 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem 'aws-sdk'
4
- gem 'rest-client'
5
- gem 'rake'
6
-
7
- group :test do
8
- gem 'rspec'
9
- gem 'webmock'
10
- end
3
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 James Martelletti
1
+ Copyright (c) 2012 Hooroo
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -128,3 +128,18 @@ Or from your application
128
128
  ## Testing
129
129
 
130
130
  bundle exec rake spec
131
+
132
+ ## Alternatives
133
+
134
+ An alternative to this gem is the [engineyard-metadata](https://github.com/seamusabshere/engineyard-metadata)
135
+ gem which also provides similar functionality, engineyard-metadata also supports
136
+ returning local data from the chef dna.json file when executed from an EC2 instance.
137
+
138
+ ## Known Issues
139
+
140
+ Y U SO SLOW? It couldn't hurt to help speed this library up, it will generally take about 60 seconds
141
+ for a reasonably sized environment. This may be able to be helped by memoising the additional AWS calls.
142
+
143
+ ## Copyright
144
+
145
+ Copyright (c) 2012 Hooroo. See LICENSE for details.
data/ey_aws.gemspec CHANGED
@@ -6,13 +6,17 @@ Gem::Specification.new do |gem|
6
6
  gem.authors = [ "James Martelletti" ]
7
7
  gem.email = [ "james@hooroo.com" ]
8
8
 
9
- gem.summary = "EngineYard & AWS environment/host information"
10
- gem.description = "Retrieve your EngineYard & AWS environment/host info via APIs"
9
+ gem.summary = "Engine Yard and AWS environment/host information"
10
+ gem.description = "Retrieve environment and host information from your Engine Yard account, providing detailed information for each EC2 instance."
11
11
  gem.homepage = "http://github.com/hooroo/ey_aws"
12
12
 
13
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
14
14
  gem.files = `git ls-files`.split("\n")
15
15
  gem.test_files = `git ls-files -- spec/*`.split("\n")
16
16
 
17
- gem.add_development_dependency "rspec", "~>2.7"
17
+ gem.add_dependency 'aws-sdk', '~>1.6'
18
+ gem.add_dependency 'rest-client', '~>1.6'
19
+ gem.add_development_dependency 'rake', '~>0.9'
20
+ gem.add_development_dependency 'rspec', '~>2.11'
21
+ gem.add_development_dependency 'webmock', '~>1.8'
18
22
  end
@@ -1,3 +1,3 @@
1
- module EYAWS
2
- VERSION = '0.9'
1
+ class EYAWS < Hash
2
+ VERSION = '0.9.1'
3
3
  end
data/lib/ey_aws.rb CHANGED
@@ -1,4 +1,3 @@
1
- #require 'rest'
2
1
  require 'rest_client'
3
2
  require 'json'
4
3
  require 'aws-sdk'
@@ -6,8 +5,8 @@ require 'aws-sdk'
6
5
  class EYAWS < Hash
7
6
  attr_reader :environments
8
7
 
9
- URL = 'https://cloud.engineyard.com/api/v2/environments'
10
- AWS_ATTRIBUTES = [
8
+ EY_URL = 'https://cloud.engineyard.com/api/v2/environments'
9
+ AWS_ATTRIBUTES = [
11
10
  :ami_launch_index,:architecture, :client_token, :dns_name, :hypervisor,
12
11
  :id, :image_id, :instance_type, :ip_address, :kernel_id,
13
12
  :key_name, :launch_time, :monitoring, :owner_id, :platform,
@@ -30,7 +29,7 @@ class EYAWS < Hash
30
29
  raise "No EY_CLOUD_TOKEN supplied" if ey_cloud_token.nil?
31
30
 
32
31
  # Get EY environment info
33
- @data = JSON.parse(RestClient.get(URL, 'X-EY-Cloud-Token' => ey_cloud_token).body, :symbolize_names => true)
32
+ @data = JSON.parse(RestClient.get(EY_URL, 'X-EY-Cloud-Token' => ey_cloud_token).body, :symbolize_names => true)
34
33
 
35
34
  # Figure out the region each EY host lives in
36
35
  @data[:environments].each do |e|
@@ -57,12 +56,17 @@ class EYAWS < Hash
57
56
  end
58
57
 
59
58
  private
59
+ def map_attributes(attributes, data)
60
+ mapped_attributes = {}
61
+ attributes.each do |attr|
62
+ mapped_attributes[attr] = data.send(attr.to_s) if data.respond_to?(attr.to_s)
63
+ end
64
+ mapped_attributes
65
+ end
66
+
60
67
  def add_aws_info(inst)
61
68
  # Grab all our aws attributes
62
- aws_attributes = {}
63
- AWS_ATTRIBUTES.each do |attr|
64
- aws_attributes[attr] = inst.send(attr.to_s)
65
- end
69
+ aws_attributes = map_attributes(AWS_ATTRIBUTES, inst)
66
70
 
67
71
  # Find the instance to attach this stuff to
68
72
  instance = @data[:environments].map { |e|
@@ -72,17 +76,10 @@ class EYAWS < Hash
72
76
  # Now grab all the block attributes
73
77
  block_devices = []
74
78
  inst.block_device_mappings.each do |mnt, device|
75
- block_device = {}
76
- AWS_DEVICE_ATTRIBUTES.map do |dattr|
77
- block_device[dattr] = device.send(dattr.to_s)
78
- end
79
+ block_device = map_attributes(AWS_DEVICE_ATTRIBUTES, device)
79
80
 
80
81
  # And the volume...
81
- volume = {}
82
- AWS_VOLUME_ATTRIBUTES.map do |vattr|
83
- volume[vattr] = device.volume.send(vattr.to_s)
84
- end
85
- block_device[:volume] = volume
82
+ block_device[:volume] = map_attributes(AWS_VOLUME_ATTRIBUTES, device.volume)
86
83
 
87
84
  block_devices << block_device
88
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,20 +9,65 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: aws-sdk
16
+ requirement: &70348638160080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70348638160080
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70348638159080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70348638159080
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70348638142040 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70348638142040
14
47
  - !ruby/object:Gem::Dependency
15
48
  name: rspec
16
- requirement: &70268252775260 !ruby/object:Gem::Requirement
49
+ requirement: &70348638140840 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.11'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70348638140840
58
+ - !ruby/object:Gem::Dependency
59
+ name: webmock
60
+ requirement: &70348638139320 !ruby/object:Gem::Requirement
17
61
  none: false
18
62
  requirements:
19
63
  - - ~>
20
64
  - !ruby/object:Gem::Version
21
- version: '2.7'
65
+ version: '1.8'
22
66
  type: :development
23
67
  prerelease: false
24
- version_requirements: *70268252775260
25
- description: Retrieve your EngineYard & AWS environment/host info via APIs
68
+ version_requirements: *70348638139320
69
+ description: Retrieve environment and host information from your Engine Yard account,
70
+ providing detailed information for each EC2 instance.
26
71
  email:
27
72
  - james@hooroo.com
28
73
  executables:
@@ -30,8 +75,8 @@ executables:
30
75
  extensions: []
31
76
  extra_rdoc_files: []
32
77
  files:
78
+ - .gitignore
33
79
  - Gemfile
34
- - Gemfile.lock
35
80
  - LICENSE
36
81
  - README.md
37
82
  - Rakefile
@@ -55,19 +100,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
100
  version: '0'
56
101
  segments:
57
102
  - 0
58
- hash: -1802294364488782302
103
+ hash: -3250632359038003336
59
104
  required_rubygems_version: !ruby/object:Gem::Requirement
60
105
  none: false
61
106
  requirements:
62
107
  - - ! '>='
63
108
  - !ruby/object:Gem::Version
64
109
  version: '0'
110
+ segments:
111
+ - 0
112
+ hash: -3250632359038003336
65
113
  requirements: []
66
114
  rubyforge_project:
67
115
  rubygems_version: 1.8.17
68
116
  signing_key:
69
117
  specification_version: 3
70
- summary: EngineYard & AWS environment/host information
118
+ summary: Engine Yard and AWS environment/host information
71
119
  test_files:
72
120
  - spec/ey_aws_spec.rb
73
121
  - spec/support/cloud_engineyard_com.json
data/Gemfile.lock DELETED
@@ -1,44 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- addressable (2.3.2)
5
- aws-sdk (1.3.4)
6
- httparty (~> 0.7)
7
- json (~> 1.4)
8
- nokogiri (>= 1.4.4)
9
- uuidtools (~> 2.1)
10
- crack (0.3.1)
11
- diff-lcs (1.1.3)
12
- httparty (0.8.1)
13
- multi_json
14
- multi_xml
15
- json (1.6.5)
16
- mime-types (1.19)
17
- multi_json (1.1.0)
18
- multi_xml (0.4.1)
19
- nokogiri (1.5.0)
20
- rake (0.9.2.2)
21
- rest-client (1.6.7)
22
- mime-types (>= 1.16)
23
- rspec (2.11.0)
24
- rspec-core (~> 2.11.0)
25
- rspec-expectations (~> 2.11.0)
26
- rspec-mocks (~> 2.11.0)
27
- rspec-core (2.11.1)
28
- rspec-expectations (2.11.3)
29
- diff-lcs (~> 1.1.3)
30
- rspec-mocks (2.11.3)
31
- uuidtools (2.1.2)
32
- webmock (1.8.11)
33
- addressable (>= 2.2.7)
34
- crack (>= 0.1.7)
35
-
36
- PLATFORMS
37
- ruby
38
-
39
- DEPENDENCIES
40
- aws-sdk
41
- rake
42
- rest-client
43
- rspec
44
- webmock