ey_cloud_awareness 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,9 @@ begin
11
11
  gem.homepage = "http://github.com/seamusabshere/ey_cloud_awareness"
12
12
  gem.authors = ["Seamus Abshere"]
13
13
  # gem.rubyforge_project = "ey_cloud_awareness"
14
- %w{ activesupport right_aws }.each { |name| gem.add_dependency name }
14
+ gem.add_dependency 'json', '>=1.2.3'
15
+ gem.add_dependency 'activesupport', '>=2.3.4'
16
+ gem.add_dependency 'right_aws', '1.10.0' # static because of my hack
15
17
  gem.add_development_dependency "rspec", ">= 1.2.9"
16
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
19
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.12
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ey_cloud_awareness}
8
- s.version = "0.1.11"
8
+ s.version = "0.1.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-04-07}
13
13
  s.description = %q{Make your EngineYard cloud instances aware of each other.}
14
14
  s.email = %q{seamus@abshere.net}
15
15
  s.extra_rdoc_files = [
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.homepage = %q{http://github.com/seamusabshere/ey_cloud_awareness}
36
36
  s.rdoc_options = ["--charset=UTF-8"]
37
37
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.5}
38
+ s.rubygems_version = %q{1.3.6}
39
39
  s.summary = %q{Make your EngineYard cloud instances aware of each other.}
40
40
  s.test_files = [
41
41
  "spec/ey_cloud_awareness_spec.rb",
@@ -47,17 +47,20 @@ Gem::Specification.new do |s|
47
47
  s.specification_version = 3
48
48
 
49
49
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
51
- s.add_runtime_dependency(%q<right_aws>, [">= 0"])
50
+ s.add_runtime_dependency(%q<json>, [">= 1.2.3"])
51
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
52
+ s.add_runtime_dependency(%q<right_aws>, ["= 1.10.0"])
52
53
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
53
54
  else
54
- s.add_dependency(%q<activesupport>, [">= 0"])
55
- s.add_dependency(%q<right_aws>, [">= 0"])
55
+ s.add_dependency(%q<json>, [">= 1.2.3"])
56
+ s.add_dependency(%q<activesupport>, [">= 2.3.4"])
57
+ s.add_dependency(%q<right_aws>, ["= 1.10.0"])
56
58
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
57
59
  end
58
60
  else
59
- s.add_dependency(%q<activesupport>, [">= 0"])
60
- s.add_dependency(%q<right_aws>, [">= 0"])
61
+ s.add_dependency(%q<json>, [">= 1.2.3"])
62
+ s.add_dependency(%q<activesupport>, [">= 2.3.4"])
63
+ s.add_dependency(%q<right_aws>, ["= 1.10.0"])
61
64
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
62
65
  end
63
66
  end
@@ -1,7 +1,7 @@
1
1
  class EngineYardCloudInstance
2
- CURRENT_INSTANCE_ID_CACHE_PATH = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/engine_yard_cloud_instance_id" : '/etc/engine_yard_cloud_instance_id'
3
- CURRENT_SECURITY_GROUPS_CACHE_PATH = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/engine_yard_cloud_security_groups" : '/etc/engine_yard_cloud_security_groups'
4
- INSTANCE_DESCRIPTIONS_CACHE_PATH = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/engine_yard_cloud_instance_descriptions.yml" : '/etc/engine_yard_cloud_instance_descriptions.yml'
2
+ CURRENT_INSTANCE_ID_CACHE_PATH = File.expand_path '~/.ey_cloud_awareness/engine_yard_cloud_instance_id'
3
+ CURRENT_SECURITY_GROUPS_CACHE_PATH = File.expand_path '~/.ey_cloud_awareness/engine_yard_cloud_security_groups'
4
+ INSTANCE_DESCRIPTIONS_CACHE_PATH = File.expand_path '~/.ey_cloud_awareness/engine_yard_cloud_instance_descriptions.yml'
5
5
  DNA_PATH = '/etc/chef/dna.json'
6
6
 
7
7
  attr_reader :instance_id
@@ -152,23 +152,33 @@ class EngineYardCloudInstance
152
152
 
153
153
  private
154
154
 
155
- # def cached_current_instance_id
156
- # def cached_current_security_groups
157
- %w{ current_instance_id current_security_groups }.each do |name|
158
- eval %{
159
- def cached_#{name}(refresh = false)
160
- raise "[EY CLOUD AWARENESS GEM] Can't call #{name} if we used from_hash" if self.proxy
161
- if refresh or !File.readable?(#{name.upcase}_CACHE_PATH)
162
- @_cached_#{name} = open("http://169.254.169.254/latest/meta-data/#{name.gsub('current_', '').dasherize}").gets
163
- begin
164
- File.open(#{name.upcase}_CACHE_PATH, 'w') { |f| f.write @_cached_#{name} }
165
- rescue Errno::EACCES
166
- $stderr.puts "[EY CLOUD AWARENESS GEM] Not caching #{name.humanize.downcase} because \#{#{name.upcase}_CACHE_PATH} can't be written to"
167
- end
168
- end
169
- @_cached_#{name} ||= IO.read(#{name.upcase}_CACHE_PATH)
155
+ def cached_current_instance_id(refresh = false)
156
+ raise "[EY CLOUD AWARENESS GEM] Can't call current_instance_id if we used from_hash" if self.proxy
157
+ if refresh or !File.readable?(CURRENT_INSTANCE_ID_CACHE_PATH)
158
+ @_cached_current_instance_id = open("http://169.254.169.254/latest/meta-data/instance-id").gets
159
+ begin
160
+ FileUtils.mkdir_p File.dirname(CURRENT_INSTANCE_ID_CACHE_PATH)
161
+ File.open(CURRENT_INSTANCE_ID_CACHE_PATH, 'w') { |f| f.write @_cached_current_instance_id }
162
+ rescue Errno::EACCES
163
+ $stderr.puts "[EY CLOUD AWARENESS GEM] Not caching current instance because #{CURRENT_INSTANCE_ID_CACHE_PATH} can't be written to"
170
164
  end
171
- }
165
+ end
166
+ @_cached_current_instance_id ||= IO.read(CURRENT_INSTANCE_ID_CACHE_PATH)
167
+ end
168
+
169
+
170
+ def cached_current_security_groups(refresh = false)
171
+ raise "[EY CLOUD AWARENESS GEM] Can't call current_security_groups if we used from_hash" if self.proxy
172
+ if refresh or !File.readable?(CURRENT_SECURITY_GROUPS_CACHE_PATH)
173
+ @_cached_current_security_groups = open("http://169.254.169.254/latest/meta-data/security-groups").gets
174
+ begin
175
+ FileUtils.mkdir_p File.dirname(CURRENT_SECURITY_GROUPS_CACHE_PATH)
176
+ File.open(CURRENT_SECURITY_GROUPS_CACHE_PATH, 'w') { |f| f.write @_cached_current_security_groups }
177
+ rescue Errno::EACCES
178
+ $stderr.puts "[EY CLOUD AWARENESS GEM] Not caching current security groups because #{CURRENT_SECURITY_GROUPS_CACHE_PATH} can't be written to"
179
+ end
180
+ end
181
+ @_cached_current_security_groups ||= IO.read(CURRENT_SECURITY_GROUPS_CACHE_PATH)
172
182
  end
173
183
 
174
184
  def cached_instance_descriptions(refresh = false)
@@ -177,6 +187,7 @@ class EngineYardCloudInstance
177
187
  ec2 = RightAws::Ec2.new dna[:aws_secret_id], dna[:aws_secret_key]
178
188
  @_cached_instance_descriptions = ec2.describe_instances.map(&:recursive_symbolize_keys!)
179
189
  begin
190
+ FileUtils.mkdir_p File.dirname(INSTANCE_DESCRIPTIONS_CACHE_PATH)
180
191
  File.open(INSTANCE_DESCRIPTIONS_CACHE_PATH, 'w') { |f| f.write @_cached_instance_descriptions.to_yaml }
181
192
  rescue Errno::EACCES
182
193
  $stderr.puts "[EY CLOUD AWARENESS GEM] Not caching instance data because #{INSTANCE_DESCRIPTIONS_CACHE_PATH} can't be written to"
@@ -1,8 +1,16 @@
1
1
  require 'open-uri'
2
2
  require 'set'
3
- require 'active_support'
3
+ require 'fileutils'
4
+ require 'json'
5
+ require 'yaml'
4
6
  require 'right_aws' # See aws-s3 compatibility hack below
5
- require File.expand_path(File.join(File.dirname(__FILE__), 'engine_yard_cloud_instance'))
7
+ require 'active_support'
8
+ begin; require 'active_support/core_ext/class/inheritable_attributes'; rescue MissingSourceFile; end
9
+ begin; require 'active_support/inflector/inflections'; rescue MissingSourceFile; end
10
+ begin; require 'active_support/core_ext/string/inflections'; rescue MissingSourceFile; end
11
+ begin; require 'active_support/core_ext/hash/keys'; rescue MissingSourceFile; end
12
+ begin; require 'active_support/core_ext/array/wrap'; rescue MissingSourceFile; end
13
+ require 'engine_yard_cloud_instance'
6
14
 
7
15
  class Hash
8
16
  # http://pragmatig.wordpress.com/2009/04/14/recursive-symbolize_keys/
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_cloud_awareness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 12
9
+ version: 0.1.12
5
10
  platform: ruby
6
11
  authors:
7
12
  - Seamus Abshere
@@ -9,39 +14,65 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-11 00:00:00 -05:00
17
+ date: 2010-04-07 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: activesupport
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 3
31
+ version: 1.2.3
17
32
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: activesupport
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
20
38
  requirements:
21
39
  - - ">="
22
40
  - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 4
45
+ version: 2.3.4
46
+ type: :runtime
47
+ version_requirements: *id002
25
48
  - !ruby/object:Gem::Dependency
26
49
  name: right_aws
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
30
52
  requirements:
31
- - - ">="
53
+ - - "="
32
54
  - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
55
+ segments:
56
+ - 1
57
+ - 10
58
+ - 0
59
+ version: 1.10.0
60
+ type: :runtime
61
+ version_requirements: *id003
35
62
  - !ruby/object:Gem::Dependency
36
63
  name: rspec
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
40
66
  requirements:
41
67
  - - ">="
42
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 2
72
+ - 9
43
73
  version: 1.2.9
44
- version:
74
+ type: :development
75
+ version_requirements: *id004
45
76
  description: Make your EngineYard cloud instances aware of each other.
46
77
  email: seamus@abshere.net
47
78
  executables: []
@@ -79,18 +110,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
110
  requirements:
80
111
  - - ">="
81
112
  - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
82
115
  version: "0"
83
- version:
84
116
  required_rubygems_version: !ruby/object:Gem::Requirement
85
117
  requirements:
86
118
  - - ">="
87
119
  - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
88
122
  version: "0"
89
- version:
90
123
  requirements: []
91
124
 
92
125
  rubyforge_project:
93
- rubygems_version: 1.3.5
126
+ rubygems_version: 1.3.6
94
127
  signing_key:
95
128
  specification_version: 3
96
129
  summary: Make your EngineYard cloud instances aware of each other.