engineyard-metadata 0.2.2 → 0.2.3

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 CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in engineyard-metadata.gemspec
4
+ gemspec
data/README.rdoc CHANGED
@@ -98,6 +98,140 @@ You can put the output of <tt>ey_ssh_aliases</tt> into <tt>~/.ssh/config</tt>:
98
98
 
99
99
  This is the second generation of http://rubygems.org/gems/ey_cloud_awareness.
100
100
 
101
+ == Sample test output
102
+
103
+ engineyard-metadata (master) $ rake
104
+
105
+ EY.metadata
106
+ being executed on an EngineYard AppCloud (i.e. Amazon EC2) instance
107
+ it should behave like it does in all execution environments
108
+ by getting the database username
109
+ by getting the database name
110
+ by getting the database host
111
+ by getting the ssh username
112
+ by getting the app server hostnames
113
+ by getting the db server hostnames
114
+ by getting the utilities hostnames
115
+ by getting the app master hostname
116
+ by getting the db master hostname
117
+ by getting the db slave hostnames
118
+ by getting the app slave hostnames
119
+ by getting the solo hostname
120
+ by getting the environment name
121
+ by getting the stack name
122
+ by getting the repository URI
123
+ by getting the app name
124
+ by getting the current path
125
+ by getting the shared path
126
+ by getting helpful ssh aliases
127
+ it should behave like it's executing inside the cloud
128
+ by refusing to get the list of all environment names
129
+ by getting the present instance ID
130
+ by getting the present instance role (as a string)
131
+ by getting the present public hostname
132
+ by getting the present security group
133
+ by getting the database password
134
+ by getting the ssh password
135
+ by getting the mysql command
136
+ by getting the mysqldump command
137
+ being executed from a developer/administrator's local machine
138
+ controlled with environment variables
139
+ it should behave like it does in all execution environments
140
+ by getting the database username
141
+ by getting the database name
142
+ by getting the database host
143
+ by getting the ssh username
144
+ by getting the app server hostnames
145
+ by getting the db server hostnames
146
+ by getting the utilities hostnames
147
+ by getting the app master hostname
148
+ by getting the db master hostname
149
+ by getting the db slave hostnames
150
+ by getting the app slave hostnames
151
+ by getting the solo hostname
152
+ by getting the environment name
153
+ by getting the stack name
154
+ by getting the repository URI
155
+ by getting the app name
156
+ by getting the current path
157
+ by getting the shared path
158
+ by getting helpful ssh aliases
159
+ it should behave like it's executing outside the cloud
160
+ by getting the list of all environment names
161
+ by refusing to get the present instance ID
162
+ by refusing to get the present instance role (as a string)
163
+ by refusing to get the present public hostname
164
+ by refusing to get the present security group
165
+ by refusing to get the database password
166
+ by refusing to get the ssh password
167
+ by refusing to get the mysql command
168
+ by refusing to get the mysqldump command
169
+ controlled with attr writers
170
+ it should behave like it does in all execution environments
171
+ by getting the database username
172
+ by getting the database name
173
+ by getting the database host
174
+ by getting the ssh username
175
+ by getting the app server hostnames
176
+ by getting the db server hostnames
177
+ by getting the utilities hostnames
178
+ by getting the app master hostname
179
+ by getting the db master hostname
180
+ by getting the db slave hostnames
181
+ by getting the app slave hostnames
182
+ by getting the solo hostname
183
+ by getting the environment name
184
+ by getting the stack name
185
+ by getting the repository URI
186
+ by getting the app name
187
+ by getting the current path
188
+ by getting the shared path
189
+ by getting helpful ssh aliases
190
+ it should behave like it's executing outside the cloud
191
+ by getting the list of all environment names
192
+ by refusing to get the present instance ID
193
+ by refusing to get the present instance role (as a string)
194
+ by refusing to get the present public hostname
195
+ by refusing to get the present security group
196
+ by refusing to get the database password
197
+ by refusing to get the ssh password
198
+ by refusing to get the mysql command
199
+ by refusing to get the mysqldump command
200
+ depending on .eyrc
201
+ it should behave like it does in all execution environments
202
+ by getting the database username
203
+ by getting the database name
204
+ by getting the database host
205
+ by getting the ssh username
206
+ by getting the app server hostnames
207
+ by getting the db server hostnames
208
+ by getting the utilities hostnames
209
+ by getting the app master hostname
210
+ by getting the db master hostname
211
+ by getting the db slave hostnames
212
+ by getting the app slave hostnames
213
+ by getting the solo hostname
214
+ by getting the environment name
215
+ by getting the stack name
216
+ by getting the repository URI
217
+ by getting the app name
218
+ by getting the current path
219
+ by getting the shared path
220
+ by getting helpful ssh aliases
221
+ it should behave like it's executing outside the cloud
222
+ by getting the list of all environment names
223
+ by refusing to get the present instance ID
224
+ by refusing to get the present instance role (as a string)
225
+ by refusing to get the present public hostname
226
+ by refusing to get the present security group
227
+ by refusing to get the database password
228
+ by refusing to get the ssh password
229
+ by refusing to get the mysql command
230
+ by refusing to get the mysqldump command
231
+
232
+ Finished in 0.95816 seconds
233
+ 112 examples, 0 failures
234
+
101
235
  == Copyright
102
236
 
103
237
  Copyright (c) 2010 Seamus Abshere. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,52 +1,7 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "engineyard-metadata"
8
- gem.summary = %Q{Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.}
9
- gem.description = %Q{Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.}
10
- gem.email = "seamus@abshere.net"
11
- gem.homepage = "http://github.com/seamusabshere/engineyard-metadata"
12
- gem.authors = ["Seamus Abshere"]
13
- gem.add_dependency 'activesupport', '>=2.3.4'
14
- gem.add_dependency 'nap', '>=0.4'
15
- gem.add_dependency 'eat', '>=0.0.5'
16
- gem.add_development_dependency "fakeweb"
17
- gem.add_development_dependency "fakefs"
18
- gem.add_development_dependency "rspec", "~>2"
19
- gem.executables = ['ey_ssh_aliases']
20
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
21
- end
22
- Jeweler::GemcutterTasks.new
23
- rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
- end
26
-
27
- require 'rake/testtask'
28
- Rake::TestTask.new(:test) do |test|
29
- test.libs << 'lib' << 'test'
30
- test.pattern = 'test/**/test_*.rb'
31
- test.verbose = true
32
- end
33
-
34
- begin
35
- require 'rcov/rcovtask'
36
- Rcov::RcovTask.new do |test|
37
- test.libs << 'test'
38
- test.pattern = 'test/**/test_*.rb'
39
- test.verbose = true
40
- end
41
- rescue LoadError
42
- task :rcov do
43
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
- end
45
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
46
3
 
47
- task :test => :check_dependencies
48
-
49
- task :default => :test
4
+ require 'rake'
50
5
 
51
6
  require 'rake/rdoctask'
52
7
  Rake::RDocTask.new do |rdoc|
@@ -57,3 +12,13 @@ Rake::RDocTask.new do |rdoc|
57
12
  rdoc.rdoc_files.include('README*')
58
13
  rdoc.rdoc_files.include('lib/**/*.rb')
59
14
  end
15
+
16
+ require 'rspec/core/rake_task'
17
+
18
+ # thanks bundler
19
+ RSpec::Core::RakeTask.new do |t|
20
+ t.rspec_opts = %w(-fs --color)
21
+ # t.ruby_opts = %w(-w)
22
+ end
23
+
24
+ task :default => :spec
@@ -1,82 +1,28 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "engineyard-metadata/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{engineyard-metadata}
8
- s.version = "0.2.2"
6
+ s.name = "engineyard-metadata"
7
+ s.version = EY::Metadata::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Seamus Abshere"]
10
+ s.email = ["seamus@abshere.net"]
11
+ s.homepage = "https://github.com/seamusabshere/engineyard-metadata"
12
+ s.summary = %Q{Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.}
13
+ s.description = %Q{Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Seamus Abshere"]
12
- s.date = %q{2011-02-01}
13
- s.default_executable = %q{ey_ssh_aliases}
14
- s.description = %q{Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.}
15
- s.email = %q{seamus@abshere.net}
16
- s.executables = ["ey_ssh_aliases"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".gitignore",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "bin/ey_ssh_aliases",
29
- "engineyard-metadata.gemspec",
30
- "lib/engineyard-metadata.rb",
31
- "lib/engineyard-metadata/amazon_ec2_api.rb",
32
- "lib/engineyard-metadata/chef_dna.rb",
33
- "lib/engineyard-metadata/engine_yard_cloud_api.rb",
34
- "lib/engineyard-metadata/insider.rb",
35
- "lib/engineyard-metadata/metadata.rb",
36
- "lib/engineyard-metadata/outsider.rb",
37
- "lib/engineyard-metadata/ssh_alias_helper.rb",
38
- "spec/metadata_spec.rb",
39
- "spec/spec_helper.rb",
40
- "spec/support/dna.json",
41
- "spec/support/dot.git.config",
42
- "spec/support/engine_yard_cloud_api_response.json"
43
- ]
44
- s.homepage = %q{http://github.com/seamusabshere/engineyard-metadata}
45
- s.rdoc_options = ["--charset=UTF-8"]
46
- s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.7}
48
- s.summary = %q{Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.}
49
- s.test_files = [
50
- "spec/metadata_spec.rb",
51
- "spec/spec_helper.rb"
52
- ]
53
-
54
- if s.respond_to? :specification_version then
55
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
- s.specification_version = 3
15
+ s.rubyforge_project = "engineyard-metadata"
57
16
 
58
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.4"])
60
- s.add_runtime_dependency(%q<nap>, [">= 0.4"])
61
- s.add_runtime_dependency(%q<eat>, [">= 0.0.5"])
62
- s.add_development_dependency(%q<fakeweb>, [">= 0"])
63
- s.add_development_dependency(%q<fakefs>, [">= 0"])
64
- s.add_development_dependency(%q<rspec>, ["~> 2"])
65
- else
66
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
67
- s.add_dependency(%q<nap>, [">= 0.4"])
68
- s.add_dependency(%q<eat>, [">= 0.0.5"])
69
- s.add_dependency(%q<fakeweb>, [">= 0"])
70
- s.add_dependency(%q<fakefs>, [">= 0"])
71
- s.add_dependency(%q<rspec>, ["~> 2"])
72
- end
73
- else
74
- s.add_dependency(%q<activesupport>, [">= 2.3.4"])
75
- s.add_dependency(%q<nap>, [">= 0.4"])
76
- s.add_dependency(%q<eat>, [">= 0.0.5"])
77
- s.add_dependency(%q<fakeweb>, [">= 0"])
78
- s.add_dependency(%q<fakefs>, [">= 0"])
79
- s.add_dependency(%q<rspec>, ["~> 2"])
80
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,fengineyard-metadataures}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'activesupport', '>=2.3.4'
23
+ s.add_dependency 'nap', '>=0.4'
24
+ s.add_dependency 'eat', '>=0.0.5'
25
+ s.add_development_dependency "fakeweb"
26
+ s.add_development_dependency "fakefs"
27
+ s.add_development_dependency "rspec", "~>2"
81
28
  end
82
-
@@ -1,6 +1,16 @@
1
+ require 'engineyard-metadata/version'
2
+ require 'engineyard-metadata/metadata'
3
+
1
4
  module EY
2
- autoload :Metadata, 'engineyard-metadata/metadata'
3
5
  def self.metadata
4
- Metadata.instance
6
+ @metadata ||= if ::File.directory?('/var/log/engineyard')
7
+ Metadata::Insider.new
8
+ else
9
+ Metadata::Outsider.new
10
+ end
11
+ end
12
+
13
+ def self.reload_metadata
14
+ @metadata = nil
5
15
  end
6
16
  end
@@ -1,26 +1,7 @@
1
1
  module EY
2
2
  class Metadata
3
3
  # This gets pulled in when you're running directly on a cloud instance.
4
- module Insider
5
- DELEGATED_TO_AMAZON_EC2_API = %w{
6
- present_instance_id
7
- present_security_group
8
- }
9
-
10
- DELEGATED_TO_CHEF_DNA = METHODS - DELEGATED_TO_AMAZON_EC2_API
11
-
12
- DELEGATED_TO_AMAZON_EC2_API.each do |name|
13
- define_method name do
14
- amazon_ec2_api.send name
15
- end
16
- end
17
-
18
- DELEGATED_TO_CHEF_DNA.each do |name|
19
- define_method name do
20
- chef_dna.send name
21
- end
22
- end
23
-
4
+ class Insider < Metadata
24
5
  # You can't get the list of environment names while you're on the instances themselves.
25
6
  def environment_names
26
7
  raise CannotGetFromHere
@@ -46,6 +27,25 @@ module EY
46
27
  raise RuntimeError, "[engineyard-metadata gem] Please set EY.metadata.app_name= or set ENV['EY_APP_NAME']" unless @app_name.to_s.strip.length > 0
47
28
  @app_name
48
29
  end
30
+
31
+ DELEGATED_TO_AMAZON_EC2_API = %w{
32
+ present_instance_id
33
+ present_security_group
34
+ }
35
+
36
+ DELEGATED_TO_CHEF_DNA = METHODS - instance_methods.map { |m| m.to_s } - DELEGATED_TO_AMAZON_EC2_API
37
+
38
+ DELEGATED_TO_AMAZON_EC2_API.each do |name|
39
+ define_method name do
40
+ amazon_ec2_api.send name
41
+ end
42
+ end
43
+
44
+ DELEGATED_TO_CHEF_DNA.each do |name|
45
+ define_method name do
46
+ chef_dna.send name
47
+ end
48
+ end
49
49
  end
50
50
  end
51
51
  end
@@ -1,5 +1,3 @@
1
- require 'singleton'
2
-
3
1
  module EY
4
2
  # All methods are defined on this module. For example, you're supposed to say
5
3
  #
@@ -7,8 +5,17 @@ module EY
7
5
  #
8
6
  # instead of trying to call it from a particular adapter.
9
7
  class Metadata
10
- include Singleton
11
-
8
+ autoload :Insider, 'engineyard-metadata/insider'
9
+ autoload :Outsider, 'engineyard-metadata/outsider'
10
+ autoload :SshAliasHelper, 'engineyard-metadata/ssh_alias_helper'
11
+ autoload :ChefDna, 'engineyard-metadata/chef_dna'
12
+ autoload :AmazonEc2Api, 'engineyard-metadata/amazon_ec2_api'
13
+ autoload :EngineYardCloudApi, 'engineyard-metadata/engine_yard_cloud_api'
14
+
15
+ # This gets raised when you can't get a particular piece of metadata from the execution environment you're in.
16
+ class CannotGetFromHere < RuntimeError
17
+ end
18
+
12
19
  attr_writer :app_name
13
20
 
14
21
  METHODS = %w{
@@ -51,27 +58,5 @@ module EY
51
58
  def shared_path
52
59
  "/data/#{app_name}/shared"
53
60
  end
54
-
55
- # This gets raised when you can't get a particular piece of metadata from the execution environment you're in.
56
- class CannotGetFromHere < RuntimeError
57
- end
58
-
59
- autoload :SshAliasHelper, 'engineyard-metadata/ssh_alias_helper'
60
-
61
- autoload :Insider, 'engineyard-metadata/insider'
62
- autoload :Outsider, 'engineyard-metadata/outsider'
63
- autoload :ChefDna, 'engineyard-metadata/chef_dna'
64
- autoload :AmazonEc2Api, 'engineyard-metadata/amazon_ec2_api'
65
- autoload :EngineYardCloudApi, 'engineyard-metadata/engine_yard_cloud_api'
66
-
67
- def reload
68
- if File.directory? '/var/log/engineyard'
69
- Metadata.send :include, Insider
70
- else
71
- Metadata.send :include, Outsider
72
- end
73
- end
74
61
  end
75
62
  end
76
-
77
- EY.metadata.reload
@@ -4,23 +4,7 @@ require 'yaml'
4
4
  module EY
5
5
  class Metadata
6
6
  # This gets pulled in when you're running from your developer machine (i.e., not on a cloud instance).
7
- module Outsider
8
- UNGETTABLE = METHODS.grep(/present/) + METHODS.grep(/password/) + METHODS.grep(/mysql/)
9
-
10
- GETTABLE = METHODS - UNGETTABLE - %w{ environment_name }
11
-
12
- UNGETTABLE.each do |name|
13
- define_method name do
14
- raise CannotGetFromHere
15
- end
16
- end
17
-
18
- GETTABLE.each do |name|
19
- define_method name do
20
- engine_yard_cloud_api.send name
21
- end
22
- end
23
-
7
+ class Outsider < Metadata
24
8
  def eyrc_path
25
9
  File.join File.expand_path("~#{Etc.getpwuid.name}"), '.eyrc'
26
10
  end
@@ -84,6 +68,22 @@ module EY
84
68
  def engine_yard_cloud_api
85
69
  @engine_yard_cloud_api ||= EngineYardCloudApi.new ey_cloud_token
86
70
  end
71
+
72
+ UNGETTABLE = METHODS.grep(/present/) + METHODS.grep(/password/) + METHODS.grep(/mysql/)
73
+
74
+ GETTABLE = METHODS - instance_methods.map { |m| m.to_s } - UNGETTABLE
75
+
76
+ UNGETTABLE.each do |name|
77
+ define_method name do
78
+ raise CannotGetFromHere
79
+ end
80
+ end
81
+
82
+ GETTABLE.each do |name|
83
+ define_method name do
84
+ engine_yard_cloud_api.send name
85
+ end
86
+ end
87
87
  end
88
88
  end
89
89
  end
@@ -11,7 +11,7 @@ module EY
11
11
  def ssh_aliases
12
12
  counter = Hash.new 0
13
13
  %w{ app_master db_master db_slaves app_slaves utilities }.map do |role_group|
14
- send(role_group).map do |public_hostname|
14
+ [send(role_group)].flatten.map do |public_hostname|
15
15
  ssh_alias counter, role_group, public_hostname
16
16
  end
17
17
  end.flatten.join("\n")
@@ -0,0 +1,5 @@
1
+ module EY
2
+ class Metadata
3
+ VERSION = '0.2.3'
4
+ end
5
+ end
@@ -1,131 +1,131 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  shared_examples_for "it does in all execution environments" do
4
- it 'get the database username' do
4
+ it 'by getting the database username' do
5
5
  EY.metadata.database_username.should == 'deploy'
6
6
  end
7
7
 
8
- it 'get the database name' do
8
+ it 'by getting the database name' do
9
9
  EY.metadata.database_name.should == 'cm1_certified_blue'
10
10
  end
11
11
 
12
- it 'get the database host' do
12
+ it 'by getting the database host' do
13
13
  EY.metadata.database_host.should == 'ec2-67-202-19-255.compute-1.amazonaws.com'
14
14
  end
15
15
 
16
- it 'get the ssh username' do
16
+ it 'by getting the ssh username' do
17
17
  EY.metadata.ssh_username.should == 'deploy'
18
18
  end
19
19
 
20
- it 'get the app server hostnames' do
20
+ it 'by getting the app server hostnames' do
21
21
  EY.metadata.app_servers.should == ["ec2-174-129-212-130.compute-1.amazonaws.com"]
22
22
  end
23
23
 
24
- it 'get the db server hostnames' do
24
+ it 'by getting the db server hostnames' do
25
25
  EY.metadata.db_servers.should == ["ec2-67-202-19-255.compute-1.amazonaws.com"]
26
26
  end
27
27
 
28
- it 'get the utilities hostnames' do
28
+ it 'by getting the utilities hostnames' do
29
29
  EY.metadata.utilities.should == []
30
30
  end
31
31
 
32
- it 'get the app master hostname' do
32
+ it 'by getting the app master hostname' do
33
33
  EY.metadata.app_master.should == 'ec2-174-129-212-130.compute-1.amazonaws.com'
34
34
  end
35
35
 
36
- it 'get the db master hostname' do
36
+ it 'by getting the db master hostname' do
37
37
  EY.metadata.db_master.should == 'ec2-67-202-19-255.compute-1.amazonaws.com'
38
38
  end
39
39
 
40
- it 'get the db slave hostnames' do
40
+ it 'by getting the db slave hostnames' do
41
41
  EY.metadata.db_slaves.should == []
42
42
  end
43
43
 
44
- it 'get the app slave hostnames' do
44
+ it 'by getting the app slave hostnames' do
45
45
  EY.metadata.app_slaves.should == []
46
46
  end
47
47
 
48
- it 'get the solo hostname' do
48
+ it 'by getting the solo hostname' do
49
49
  EY.metadata.solo.should == nil
50
50
  end
51
51
 
52
- it 'get the environment name' do
52
+ it 'by getting the environment name' do
53
53
  EY.metadata.environment_name.should == 'cm1_production_blue'
54
54
  end
55
55
 
56
- it 'get the stack name' do
56
+ it 'by getting the stack name' do
57
57
  EY.metadata.stack_name.should == 'nginx_unicorn'
58
58
  end
59
59
 
60
- it 'get the repository URI' do
60
+ it 'by getting the repository URI' do
61
61
  EY.metadata.repository_uri.should == 'git@github.com:brighterplanet/cm1.git'
62
62
  end
63
63
 
64
- it 'gets the app name' do
64
+ it 'by getting the app name' do
65
65
  EY.metadata.app_name.should == 'cm1_certified_blue'
66
66
  end
67
67
 
68
- it 'gets the current path' do
68
+ it 'by getting the current path' do
69
69
  EY.metadata.current_path.should == '/data/cm1_certified_blue/current'
70
70
  end
71
71
 
72
- it 'gets the shared path' do
72
+ it 'by getting the shared path' do
73
73
  EY.metadata.shared_path.should == '/data/cm1_certified_blue/shared'
74
74
  end
75
75
 
76
- it 'gets helpful ssh aliases' do
76
+ it 'by getting helpful ssh aliases' do
77
77
  EY.metadata.ssh_aliases.should =~ /Host cm1_production_blue-app_master\n Hostname ec2-174-129-212-130.compute-1.amazonaws.com/
78
78
  end
79
79
  end
80
80
 
81
81
  shared_examples_for "it's executing outside the cloud" do
82
- it 'gets the list of all environment names' do
82
+ it 'by getting the list of all environment names' do
83
83
  EY.metadata.environment_names.should == ["app1_production", "wlpf1_production", "data1_production", "cm1_production_red", "cm1_production_blue"]
84
84
  end
85
85
 
86
- it 'not get the present instance ID' do
86
+ it 'by refusing to get the present instance ID' do
87
87
  lambda {
88
88
  EY.metadata.present_instance_id
89
89
  }.should raise_error(EY::Metadata::CannotGetFromHere)
90
90
  end
91
91
 
92
- it 'not get the present instance role (as a string)' do
92
+ it 'by refusing to get the present instance role (as a string)' do
93
93
  lambda {
94
94
  EY.metadata.present_instance_role
95
95
  }.should raise_error(EY::Metadata::CannotGetFromHere)
96
96
  end
97
97
 
98
- it 'not get the present public hostname' do
98
+ it 'by refusing to get the present public hostname' do
99
99
  lambda {
100
100
  EY.metadata.present_public_hostname
101
101
  }.should raise_error(EY::Metadata::CannotGetFromHere)
102
102
  end
103
103
 
104
- it 'not get the present security group' do
104
+ it 'by refusing to get the present security group' do
105
105
  lambda {
106
106
  EY.metadata.present_security_group
107
107
  }.should raise_error(EY::Metadata::CannotGetFromHere)
108
108
  end
109
109
 
110
- it 'not get the database password' do
110
+ it 'by refusing to get the database password' do
111
111
  lambda {
112
112
  EY.metadata.database_password
113
113
  }.should raise_error(EY::Metadata::CannotGetFromHere)
114
114
  end
115
115
 
116
- it 'not get the ssh password' do
116
+ it 'by refusing to get the ssh password' do
117
117
  lambda {
118
118
  EY.metadata.ssh_password
119
119
  }.should raise_error(EY::Metadata::CannotGetFromHere)
120
120
  end
121
121
 
122
- it 'not get the mysql command' do
122
+ it 'by refusing to get the mysql command' do
123
123
  lambda {
124
124
  EY.metadata.mysql_command
125
125
  }.should raise_error(EY::Metadata::CannotGetFromHere)
126
126
  end
127
127
 
128
- it 'not get the mysqldump command' do
128
+ it 'by refusing to get the mysqldump command' do
129
129
  lambda {
130
130
  EY.metadata.mysqldump_command
131
131
  }.should raise_error(EY::Metadata::CannotGetFromHere)
@@ -133,41 +133,41 @@ shared_examples_for "it's executing outside the cloud" do
133
133
  end
134
134
 
135
135
  shared_examples_for "it's executing inside the cloud" do
136
- it 'not get the list of all environment names' do
136
+ it 'by refusing to get the list of all environment names' do
137
137
  lambda {
138
138
  EY.metadata.environment_names
139
139
  }.should raise_error(EY::Metadata::CannotGetFromHere)
140
140
  end
141
141
 
142
- it 'get the present instance ID' do
142
+ it 'by getting the present instance ID' do
143
143
  EY.metadata.present_instance_id.should == FAKE_INSTANCE_ID
144
144
  end
145
145
 
146
- it 'get the present instance role (as a string)' do
146
+ it 'by getting the present instance role (as a string)' do
147
147
  EY.metadata.present_instance_role.should == 'app_master'
148
148
  end
149
149
 
150
- it 'get the present public hostname' do
150
+ it 'by getting the present public hostname' do
151
151
  EY.metadata.present_public_hostname.should == 'ec2-174-129-212-130.compute-1.amazonaws.com'
152
152
  end
153
153
 
154
- it 'get the present security group' do
154
+ it 'by getting the present security group' do
155
155
  EY.metadata.present_security_group.should == FAKE_SECURITY_GROUP
156
156
  end
157
157
 
158
- it 'get the database password' do
158
+ it 'by getting the database password' do
159
159
  EY.metadata.database_password.should == 'USERS-0-PASSWORD'
160
160
  end
161
161
 
162
- it 'get the ssh password' do
162
+ it 'by getting the ssh password' do
163
163
  EY.metadata.ssh_password.should == 'USERS-0-PASSWORD'
164
164
  end
165
165
 
166
- it 'get the mysql command' do
166
+ it 'by getting the mysql command' do
167
167
  EY.metadata.mysql_command.should =~ %r{mysql -h ec2-67-202-19-255.compute-1.amazonaws.com -u deploy -pUSERS-0-PASSWORD cm1_certified_blue}
168
168
  end
169
169
 
170
- it 'get the mysqldump command' do
170
+ it 'by getting the mysqldump command' do
171
171
  EY.metadata.mysqldump_command.should =~ %r{mysqldump -h ec2-67-202-19-255.compute-1.amazonaws.com -u deploy -pUSERS-0-PASSWORD cm1_certified_blue}
172
172
  end
173
173
  end
@@ -180,7 +180,7 @@ describe 'EY.metadata' do
180
180
  describe "being executed on an EngineYard AppCloud (i.e. Amazon EC2) instance" do
181
181
  before do
182
182
  pretend_we_are_on_an_engineyard_appcloud_ec2_instance
183
- EY.metadata.reload
183
+ EY.reload_metadata
184
184
  EY.metadata.app_name = 'cm1_certified_blue'
185
185
  end
186
186
  it_should_behave_like "it does in all execution environments"
@@ -190,10 +190,7 @@ describe 'EY.metadata' do
190
190
  describe "being executed from a developer/administrator's local machine" do
191
191
  before do
192
192
  pretend_we_are_on_a_developer_machine
193
- EY.metadata.reload
194
- EY.metadata.instance_variables.each do |ivar_name|
195
- EY.metadata.instance_variable_set ivar_name, nil
196
- end
193
+ EY.reload_metadata
197
194
  ENV.delete 'EY_CLOUD_TOKEN'
198
195
  ENV.delete 'EY_ENVIRONMENT_NAME'
199
196
  ENV.delete 'EY_APP_NAME'
@@ -201,9 +198,6 @@ describe 'EY.metadata' do
201
198
  end
202
199
  describe "controlled with environment variables" do
203
200
  before do
204
- EY.metadata.instance_variables.each do |ivar_name|
205
- EY.metadata.instance_variable_set ivar_name, nil
206
- end
207
201
  ENV['EY_CLOUD_TOKEN'] = FAKE_CLOUD_TOKEN + 'aaa'
208
202
  ENV['EY_APP_NAME'] = 'cm1_certified_blue'
209
203
  EY.metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'aaa' # sanity check
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
1
  require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
2
4
  require 'rspec'
3
5
  require 'active_support/json/encoding'
4
6
  require 'fakeweb'
5
7
  require 'fakefs/safe'
6
8
  require 'eat' # otherwise it's loaded when fakefs is already active
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ require 'engineyard-metadata'
7
12
 
8
13
  FAKE_SECURITY_GROUP = 'ey-cm1_production_blue-1294775925-1371-55979'
9
14
  FAKE_INSTANCE_ID = 'i-ff17d493'
@@ -55,5 +60,3 @@ def stop_pretending
55
60
  FakeFS.deactivate!
56
61
  FakeWeb.clean_registry
57
62
  end
58
-
59
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'engineyard-metadata'))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-metadata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -15,8 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-01 00:00:00 -06:00
19
- default_executable: ey_ssh_aliases
18
+ date: 2011-03-31 00:00:00 -05:00
19
+ default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activesupport
@@ -108,21 +108,21 @@ dependencies:
108
108
  type: :development
109
109
  version_requirements: *id006
110
110
  description: Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.
111
- email: seamus@abshere.net
111
+ email:
112
+ - seamus@abshere.net
112
113
  executables:
113
114
  - ey_ssh_aliases
114
115
  extensions: []
115
116
 
116
- extra_rdoc_files:
117
- - LICENSE
118
- - README.rdoc
117
+ extra_rdoc_files: []
118
+
119
119
  files:
120
120
  - .document
121
121
  - .gitignore
122
+ - Gemfile
122
123
  - LICENSE
123
124
  - README.rdoc
124
125
  - Rakefile
125
- - VERSION
126
126
  - bin/ey_ssh_aliases
127
127
  - engineyard-metadata.gemspec
128
128
  - lib/engineyard-metadata.rb
@@ -133,18 +133,19 @@ files:
133
133
  - lib/engineyard-metadata/metadata.rb
134
134
  - lib/engineyard-metadata/outsider.rb
135
135
  - lib/engineyard-metadata/ssh_alias_helper.rb
136
+ - lib/engineyard-metadata/version.rb
136
137
  - spec/metadata_spec.rb
137
138
  - spec/spec_helper.rb
138
139
  - spec/support/dna.json
139
140
  - spec/support/dot.git.config
140
141
  - spec/support/engine_yard_cloud_api_response.json
141
142
  has_rdoc: true
142
- homepage: http://github.com/seamusabshere/engineyard-metadata
143
+ homepage: https://github.com/seamusabshere/engineyard-metadata
143
144
  licenses: []
144
145
 
145
146
  post_install_message:
146
- rdoc_options:
147
- - --charset=UTF-8
147
+ rdoc_options: []
148
+
148
149
  require_paths:
149
150
  - lib
150
151
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -167,11 +168,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  version: "0"
168
169
  requirements: []
169
170
 
170
- rubyforge_project:
171
- rubygems_version: 1.3.7
171
+ rubyforge_project: engineyard-metadata
172
+ rubygems_version: 1.6.2
172
173
  signing_key:
173
174
  specification_version: 3
174
175
  summary: Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.
175
176
  test_files:
176
177
  - spec/metadata_spec.rb
177
178
  - spec/spec_helper.rb
179
+ - spec/support/dna.json
180
+ - spec/support/dot.git.config
181
+ - spec/support/engine_yard_cloud_api_response.json
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.2