engineyard-metadata 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{engineyard-metadata}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
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-10-08}
12
+ s.date = %q{2010-10-11}
13
13
  s.description = %q{Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.}
14
14
  s.email = %q{seamus@abshere.net}
15
15
  s.extra_rdoc_files = [
@@ -65,6 +65,11 @@ module EY
65
65
  def app_servers
66
66
  data['engineyard']['environment']['instances'].select { |i| %w{ app_master app solo }.include? i['role'] }.map { |i| i['public_hostname'] }.sort
67
67
  end
68
+
69
+ # The public hostnames of all the app slaves.
70
+ def app_slaves
71
+ data['engineyard']['environment']['instances'].select { |i| %w{ app }.include? i['role'] }.map { |i| i['public_hostname'] }.sort
72
+ end
68
73
 
69
74
  # The public hostnames of all the db servers.
70
75
  #
@@ -73,6 +78,11 @@ module EY
73
78
  data['engineyard']['environment']['instances'].select { |i| %w{ db_master db_slave solo }.include? i['role'] }.map { |i| i['public_hostname'] }.sort
74
79
  end
75
80
 
81
+ # The public hostnames of all the db slaves.
82
+ def db_slaves
83
+ data['engineyard']['environment']['instances'].select { |i| %w{ db_slave }.include? i['role'] }.map { |i| i['public_hostname'] }.sort
84
+ end
85
+
76
86
  # The public hostnames of all the utility servers.
77
87
  #
78
88
  # If you're on a solo app, it counts the solo as a utility.
@@ -82,16 +92,27 @@ module EY
82
92
 
83
93
  # The public hostname of the app_master.
84
94
  def app_master
85
- i = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'app_master' } ||
86
- data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'solo' }
87
- i['public_hostname']
95
+ if x = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'app_master' }
96
+ x['public_hostname']
97
+ else
98
+ solo
99
+ end
88
100
  end
89
101
 
90
102
  # The public hostname of the db_master,
91
103
  def db_master
92
- i = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'db_master' } ||
93
- data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'solo' }
94
- i['public_hostname']
104
+ if x = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'db_master' }
105
+ x['public_hostname']
106
+ else
107
+ solo
108
+ end
109
+ end
110
+
111
+ # The public hostname of the solo.
112
+ def solo
113
+ if x = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'solo' }
114
+ x['public_hostname']
115
+ end
95
116
  end
96
117
 
97
118
  # The shell command for mysql, including username, password, hostname and database
@@ -103,6 +124,11 @@ module EY
103
124
  def mysqldump_command
104
125
  "#{MYSQLDUMP_BIN} -h #{database_host} -u #{database_username} -p#{database_password} #{database_name}"
105
126
  end
127
+
128
+ # The name of the EngineYard AppCloud environment.
129
+ def environment_name
130
+ data['environment']['name']
131
+ end
106
132
  end
107
133
  end
108
134
  end
@@ -21,6 +21,10 @@ module EY
21
21
  db_master
22
22
  mysql_command
23
23
  mysqldump_command
24
+ app_slaves
25
+ db_slaves
26
+ solo
27
+ environment_name
24
28
  }
25
29
 
26
30
  DELEGATED_TO_AMAZON_EC2_API.each do |name|
@@ -55,7 +55,7 @@ describe EY::Metadata do
55
55
  EY::Metadata.db_servers.should == [ 'db_master.compute-1.amazonaws.com', 'db_slave_1.compute-1.amazonaws.com' ]
56
56
  end
57
57
 
58
- it 'gets the utilitie hostnames' do
58
+ it 'gets the utilities hostnames' do
59
59
  EY::Metadata.utilities.should == [ 'util_1.compute-1.amazonaws.com' ]
60
60
  end
61
61
 
@@ -74,4 +74,20 @@ describe EY::Metadata do
74
74
  it 'gets the mysqldump command' do
75
75
  EY::Metadata.mysqldump_command.should == '/usr/bin/mysqldump -h external_db_master.compute-1.amazonaws.com -u USERS-0-USERNAME -pUSERS-0-PASSWORD APPS-0-DATABASE_NAME'
76
76
  end
77
+
78
+ it 'gets the db slave hostnames' do
79
+ EY::Metadata.db_slaves.should == [ 'db_slave_1.compute-1.amazonaws.com' ]
80
+ end
81
+
82
+ it 'gets the app slave hostnames' do
83
+ EY::Metadata.app_slaves.should == [ 'app_1.compute-1.amazonaws.com' ]
84
+ end
85
+
86
+ it 'gets the solo hostname' do
87
+ EY::Metadata.solo.should == nil
88
+ end
89
+
90
+ it 'gets the environment name' do
91
+ EY::Metadata.environment_name.should == 'APP-NAME_production'
92
+ end
77
93
  end
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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-08 00:00:00 -05:00
18
+ date: 2010-10-11 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency