engineyard-metadata 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -1,4 +1,4 @@
1
- README.rdoc
1
+ README.markdown
2
2
  lib/**/*.rb
3
3
  bin/*
4
4
  features/**/*.feature
data/.gitignore CHANGED
@@ -15,8 +15,10 @@ tmtags
15
15
 
16
16
  ## PROJECT::GENERAL
17
17
  coverage
18
- rdoc
18
+ doc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  Gemfile.lock
23
+ .yardoc/
24
+ *.gem
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in engineyard-metadata.gemspec
4
4
  gemspec
5
+
6
+ gem 'yard'
7
+ gem "webmock"
8
+ gem "fakefs"
9
+ gem "rspec", "~>2"
@@ -1,46 +1,44 @@
1
- = engineyard-metadata
1
+ # engineyard-metadata
2
2
 
3
3
  Presents a simple interface to get metadata about your EngineYard AppCloud instances running on Amazon EC2.
4
4
 
5
- == Purpose
5
+ ## Purpose
6
6
 
7
7
  To define a simple interface to useful metadata (passwords, IP addresses, etc.) that is otherwise buried deep inside EngineYard's chef config files and various API calls.
8
8
 
9
- == Examples
10
-
11
- * Get the current database password so that you can write a script that connects to it. (<tt>EY.metadata.database_password</tt>)
9
+ ## Examples
12
10
 
13
11
  Here's the current method list:
14
12
 
15
- EY.metadata.app_master
16
- EY.metadata.app_name
17
- EY.metadata.app_servers
18
- EY.metadata.app_slaves
19
- EY.metadata.current_path
20
- EY.metadata.database_host
21
- EY.metadata.database_name
22
- EY.metadata.database_password (only works from cloud instances)
23
- EY.metadata.database_username
24
- EY.metadata.db_master
25
- EY.metadata.db_servers
26
- EY.metadata.db_slaves
27
- EY.metadata.environment_name
28
- EY.metadata.mysql_command (only works from cloud instances)
29
- EY.metadata.mysqldump_command (only works from cloud instances)
30
- EY.metadata.present_instance_id (only works from cloud instances)
31
- EY.metadata.present_instance_role (only works from cloud instances)
32
- EY.metadata.present_public_hostname (only works from cloud instances)
33
- EY.metadata.present_security_group (only works from cloud instances)
34
- EY.metadata.repository_uri
35
- EY.metadata.shared_path
36
- EY.metadata.solo
37
- EY.metadata.ssh_aliases
38
- EY.metadata.ssh_password (only works from cloud instances)
39
- EY.metadata.ssh_username
40
- EY.metadata.stack_name
41
- EY.metadata.utilities
42
-
43
- == public_hostname, amazon_id, etc.
13
+ EY.metadata.app_master
14
+ EY.metadata.app_name
15
+ EY.metadata.app_servers
16
+ EY.metadata.app_slaves
17
+ EY.metadata.current_path
18
+ EY.metadata.database_host
19
+ EY.metadata.database_name
20
+ EY.metadata.database_password (only works from cloud instances)
21
+ EY.metadata.database_username
22
+ EY.metadata.db_master
23
+ EY.metadata.db_servers
24
+ EY.metadata.db_slaves
25
+ EY.metadata.environment_name
26
+ EY.metadata.mysql_command (only works from cloud instances)
27
+ EY.metadata.mysqldump_command (only works from cloud instances)
28
+ EY.metadata.present_instance_id (only works from cloud instances)
29
+ EY.metadata.present_instance_role (only works from cloud instances)
30
+ EY.metadata.present_public_hostname (only works from cloud instances)
31
+ EY.metadata.present_security_group (only works from cloud instances)
32
+ EY.metadata.repository_uri
33
+ EY.metadata.shared_path
34
+ EY.metadata.solo
35
+ EY.metadata.ssh_aliases
36
+ EY.metadata.ssh_password (only works from cloud instances)
37
+ EY.metadata.ssh_username
38
+ EY.metadata.stack_name
39
+ EY.metadata.utilities
40
+
41
+ ## public\_hostname, amazon\_id, etc.
44
42
 
45
43
  Thanks to Nick Marden, you can do things like:
46
44
 
@@ -49,11 +47,11 @@ Thanks to Nick Marden, you can do things like:
49
47
 
50
48
  By default, you get the public hostname.
51
49
 
52
- == Use
50
+ ## Use
53
51
 
54
- See the rdoc at {the engineyard-metadata rdoc}[http://rubydoc.info/gems/engineyard-metadata].
52
+ See the documentation at (the engineyard-metadata documentation}[http://rubydoc.info/gems/engineyard-metadata].
55
53
 
56
- === When you're executing this gem from INSIDE the cloud
54
+ ### When you're executing this gem from INSIDE the cloud
57
55
 
58
56
  When you're executing the gem from your instances, you don't have to configure anything. Just require the gem.
59
57
 
@@ -67,56 +65,67 @@ then I suggest adding something like this to `deploy/before_bundle.rb`
67
65
 
68
66
  or find some other way to make the file readable.
69
67
 
70
- === When you're executing this gem from OUTSIDE the cloud
68
+ The Engine Yard recipes will often reset the permissions on the file, so you can periodically fix that using
69
+ a custom chef recipe like this:
70
+
71
+ # Only run on app server instances.
72
+ if ['app','app_master'].include?(node[:instance_role]) then
73
+ cron "Make /etc/chef/dna.json readable" do
74
+ minute "*/5"
75
+ command "chmod a+r /etc/chef/dna.json"
76
+ end
77
+ end
78
+
79
+ ### When you're executing this gem from OUTSIDE the cloud
71
80
 
72
81
  You must...
73
82
 
74
- * have <tt>~/.eyrc</tt> or set <tt>EY.metadata.ey_cloud_token=</tt> or set <tt>ENV['EY_CLOUD_TOKEN']</tt>.
75
- * execute the gem from the local copy of your application's repo or set <tt>EY.metadata.environment_name=</tt> or set <tt>ENV['EY_ENVIRONMENT_NAME']</tt>.
83
+ * have `~/.eyrc` or set `EY.metadata.ey_cloud_token=` or set `ENV['EY_CLOUD_TOKEN']`.
84
+ * execute the gem from the local copy of your application's repo or set `EY.metadata.environment_name=` or set `ENV['EY_ENVIRONMENT_NAME']`.
76
85
 
77
- === Where the methods are defined
86
+ ### Where the methods are defined
78
87
 
79
- Metadata getters are defined directly on <tt>EY.metadata</tt> (which in turn delegates out to various adapters). Even if EngineYard changes the structure of the config files or Amazon EC2's API changes, these methods will stay the same.
88
+ Metadata getters are defined directly on `EY.metadata` (which in turn delegates out to various adapters). Even if EngineYard changes the structure of the config files or Amazon EC2's API changes, these methods will stay the same.
80
89
 
81
- [...]
82
- >> require 'rubygems'
83
- [...]
84
- >> require 'engineyard-metadata'
85
- [...]
86
- >> EY.metadata.database_host
87
- => "external_db_master.compute-1.amazonaws.com"
88
- >> EY.metadata.app_servers
89
- => [ 'app_1.compute-1.amazonaws.com' , 'app_master.compute-1.amazonaws.com' ]
90
- >> EY.metadata.db_servers
91
- => [ 'db_master.compute-1.amazonaws.com', 'db_slave_1.compute-1.amazonaws.com' ]
92
- [...and many more...]
90
+ [...]
91
+ >> require 'rubygems'
92
+ [...]
93
+ >> require 'engineyard-metadata'
94
+ [...]
95
+ >> EY.metadata.database_host
96
+ => "external_db_master.compute-1.amazonaws.com"
97
+ >> EY.metadata.app_servers
98
+ => [ 'app_1.compute-1.amazonaws.com' , 'app_master.compute-1.amazonaws.com' ]
99
+ >> EY.metadata.db_servers
100
+ => [ 'db_master.compute-1.amazonaws.com', 'db_slave_1.compute-1.amazonaws.com' ]
101
+ [...and many more...]
93
102
 
94
- == SSH alias helper
103
+ ## SSH alias helper
95
104
 
96
- You can put the output of <tt>ey_ssh_aliases</tt> into <tt>~/.ssh/config</tt>:
105
+ You can put the output of `ey_ssh_aliases` into `~/.ssh/config`:
97
106
 
98
- $ EY_ENVIRONMENT_NAME=my_env ey_ssh_aliases
99
- Host my_env-app_master
100
- Hostname ec2-11-11-111-11.compute-1.amazonaws.com
101
- User deploy
102
- StrictHostKeyChecking no
107
+ $ EY_ENVIRONMENT_NAME=my_env ey_ssh_aliases
108
+ Host my_env-app_master
109
+ Hostname ec2-11-11-111-11.compute-1.amazonaws.com
110
+ User deploy
111
+ StrictHostKeyChecking no
103
112
 
104
- Host my_env-db_master
105
- Hostname ec2-111-11-11-11.compute-1.amazonaws.com
106
- User deploy
107
- StrictHostKeyChecking no
113
+ Host my_env-db_master
114
+ Hostname ec2-111-11-11-11.compute-1.amazonaws.com
115
+ User deploy
116
+ StrictHostKeyChecking no
108
117
 
109
- == Known issues
118
+ ## Known issues
110
119
 
111
120
  * Doesn't work with multiple apps per environment. [FIXED!]
112
- * It's not always clear what environment you're running in. For example, you say <tt>EY.metadata.something</tt> and you're just supposed to know what environment you're in. You can use <tt>.environment_name=</tt>, but you might not remember.
113
- * There are no factory methods. If we fully fleshed this out, it might be like <tt>my_env = EY::Environment.find('my_env')</tt> and <tt>my_app_master = my_env.app_master</tt>. Not sure that complexity would add a lot of value.
121
+ * It's not always clear what environment you're running in. For example, you say `EY.metadata.something` and you're just supposed to know what environment you're in. You can use `.environment_name=`, but you might not remember.
122
+ * There are no factory methods. If we fully fleshed this out, it might be like `my_env = EY::Environment.find('my_env')` and `my_app_master = my_env.app_master`. Not sure that complexity would add a lot of value.
114
123
 
115
- == History
124
+ ## History
116
125
 
117
126
  This is the second generation of http://rubygems.org/gems/ey_cloud_awareness.
118
127
 
119
- == Sample test output
128
+ ## Sample test output
120
129
 
121
130
  engineyard-metadata (master) $ rake
122
131
 
@@ -250,6 +259,6 @@ This is the second generation of http://rubygems.org/gems/ey_cloud_awareness.
250
259
  Finished in 0.95816 seconds
251
260
  112 examples, 0 failures
252
261
 
253
- == Copyright
262
+ ## Copyright
254
263
 
255
- Copyright (c) 2010 Seamus Abshere. See LICENSE for details.
264
+ Copyright (c) 2012 Seamus Abshere. See LICENSE for details.
data/Rakefile CHANGED
@@ -3,15 +3,8 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rake'
5
5
 
6
- require 'rake/rdoctask'
7
- Rake::RDocTask.new do |rdoc|
8
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
9
-
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = "engineyard-metadata #{version}"
12
- rdoc.rdoc_files.include('README*')
13
- rdoc.rdoc_files.include('lib/**/*.rb')
14
- end
6
+ require 'yard'
7
+ YARD::Rake::YardocTask.new
15
8
 
16
9
  require 'rspec/core/rake_task'
17
10
 
@@ -22,7 +22,4 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'activesupport', '>=2.3.4'
23
23
  s.add_dependency 'nap', '>=0.4'
24
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"
28
25
  end
@@ -1,4 +1,4 @@
1
- require 'open-uri'
1
+ require 'eat'
2
2
 
3
3
  module EY
4
4
  class Metadata
@@ -6,12 +6,12 @@ module EY
6
6
  class AmazonEc2Api
7
7
  # The present instance's Amazon Ec2 instance id.
8
8
  def present_instance_id
9
- @present_instance_id ||= open('http://169.254.169.254/latest/meta-data/instance-id').read
9
+ @present_instance_id ||= eat('http://169.254.169.254/latest/meta-data/instance-id')
10
10
  end
11
11
 
12
12
  # The present instance's Amazon Ec2 security group.
13
13
  def present_security_group
14
- @present_security_group ||= open('http://169.254.169.254/latest/meta-data/security-groups').read
14
+ @present_security_group ||= eat('http://169.254.169.254/latest/meta-data/security-groups')
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  class Metadata
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require 'bundler'
3
3
  Bundler.setup
4
4
  require 'rspec'
5
5
  require 'active_support/json/encoding'
6
- require 'fakeweb'
6
+ require 'webmock/rspec'
7
7
  require 'fakefs/safe'
8
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -14,11 +14,11 @@ FAKE_INSTANCE_ID = 'i-ff17d493'
14
14
  FAKE_CLOUD_TOKEN = 'justareallygreatsecret'
15
15
 
16
16
  def pretend_we_are_on_a_developer_machine
17
- FakeWeb.allow_net_connect = false
18
- FakeWeb.register_uri :get,
19
- "https://cloud.engineyard.com/api/v2/environments",
20
- :status => ["200", "OK"],
21
- :body => File.read(File.join(File.dirname(__FILE__), 'support', 'engine_yard_cloud_api_response.json'))
17
+ WebMock.enable!
18
+ WebMock.stub_request(:get, "https://cloud.engineyard.com/api/v2/environments").to_return(
19
+ :status => 200,
20
+ :body => File.read(File.join(File.dirname(__FILE__), 'support', 'engine_yard_cloud_api_response.json')))
21
+
22
22
  dot_git_config = File.read File.join(File.dirname(__FILE__), 'support', 'dot.git.config')
23
23
  FakeFS.activate!
24
24
  git_config_path = File.join Dir.pwd, '.git', 'config'
@@ -29,18 +29,18 @@ def pretend_we_are_on_a_developer_machine
29
29
  end
30
30
 
31
31
  def pretend_we_are_on_an_engineyard_appcloud_ec2_instance
32
- FakeWeb.allow_net_connect = false
32
+ WebMock.enable!
33
33
  # fake call to amazon ec2 api to get present security group
34
- FakeWeb.register_uri :get,
35
- "http://169.254.169.254/latest/meta-data/security-groups",
36
- :status => ["200", "OK"],
37
- :body => FAKE_SECURITY_GROUP
34
+ WebMock.stub_request(:get, "http://169.254.169.254/latest/meta-data/security-groups").to_return(
35
+ :status => 200,
36
+ :body => FAKE_SECURITY_GROUP
37
+ )
38
38
 
39
39
  # fake call to amazon ec2 api to get present instance id
40
- FakeWeb.register_uri :get,
41
- "http://169.254.169.254/latest/meta-data/instance-id",
42
- :status => ["200", "OK"],
43
- :body => FAKE_INSTANCE_ID
40
+ WebMock.stub_request(:get, "http://169.254.169.254/latest/meta-data/instance-id").to_return(
41
+ :status => 200,
42
+ :body => FAKE_INSTANCE_ID
43
+ )
44
44
 
45
45
  # first read a file from the real file system...
46
46
  dna_json = File.read File.join(File.dirname(__FILE__), 'support', 'dna.json')
@@ -57,5 +57,5 @@ def stop_pretending
57
57
  # http://lukeredpath.co.uk/blog/using-fakefs-with-cucumber-features.html
58
58
  FakeFS::FileSystem.clear
59
59
  FakeFS.deactivate!
60
- FakeWeb.clean_registry
60
+ WebMock.reset!
61
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-03 00:00:00.000000000Z
12
+ date: 2012-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2153302620 !ruby/object:Gem::Requirement
16
+ requirement: &2156735380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153302620
24
+ version_requirements: *2156735380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nap
27
- requirement: &2153289780 !ruby/object:Gem::Requirement
27
+ requirement: &2156734440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.4'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153289780
35
+ version_requirements: *2156734440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: eat
38
- requirement: &2153287620 !ruby/object:Gem::Requirement
38
+ requirement: &2156733900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,40 +43,7 @@ dependencies:
43
43
  version: 0.0.5
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153287620
47
- - !ruby/object:Gem::Dependency
48
- name: fakeweb
49
- requirement: &2153286600 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *2153286600
58
- - !ruby/object:Gem::Dependency
59
- name: fakefs
60
- requirement: &2153285120 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *2153285120
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: &2153283100 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: '2'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *2153283100
46
+ version_requirements: *2156733900
80
47
  description: Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud
81
48
  (Amazon EC2) instances know about each other.
82
49
  email:
@@ -90,7 +57,7 @@ files:
90
57
  - .gitignore
91
58
  - Gemfile
92
59
  - LICENSE
93
- - README.rdoc
60
+ - README.markdown
94
61
  - Rakefile
95
62
  - bin/ey_ssh_aliases
96
63
  - engineyard-metadata.gemspec
@@ -128,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
95
  version: '0'
129
96
  requirements: []
130
97
  rubyforge_project: engineyard-metadata
131
- rubygems_version: 1.8.10
98
+ rubygems_version: 1.8.15
132
99
  signing_key:
133
100
  specification_version: 3
134
101
  summary: Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.