awsborn 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.2
1
+ 0.8.3
data/awsborn.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{awsborn}
8
- s.version = "0.8.2"
8
+ s.version = "0.8.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Vrensk", "Jean-Louis Giordano"]
12
- s.date = %q{2011-08-23}
12
+ s.date = %q{2011-08-25}
13
13
  s.description = %q{Awsborn lets you define and launch a server cluster on Amazon EC2.}
14
14
  s.email = %q{david@icehouse.se}
15
15
  s.extra_rdoc_files = [
@@ -28,24 +28,39 @@ module Awsborn
28
28
  @elb ||= Elb.new(@region)
29
29
  end
30
30
 
31
- def aws_dns_name
32
- elb.dns_name(@name)
31
+ def route53
32
+ @route53 ||= Route53.new
33
33
  end
34
34
 
35
- def instances
36
- elb.instances(@name)
35
+ def ec2
36
+ @ec2 ||= Ec2.new(@region)
37
+ end
38
+
39
+ def aws_dns_name
40
+ elb.dns_name(@name)
37
41
  end
38
42
 
39
43
  def canonical_hosted_zone_name_id
40
44
  elb.canonical_hosted_zone_name_id(@name)
41
45
  end
42
46
 
47
+ def instances
48
+ elb.instances(@name)
49
+ end
50
+
43
51
  def instances= (new_instances)
44
52
  previous_instances = self.instances
45
53
  register_instances(new_instances - previous_instances)
46
54
  deregister_instances(previous_instances - new_instances)
47
55
  end
48
56
 
57
+ def instances_dns_names
58
+ instances.map do |instance_id|
59
+ ec2.instance_id = instance_id
60
+ (ec2.describe_instance || {})[:dns_name]
61
+ end.compact
62
+ end
63
+
49
64
  def zones
50
65
  elb.zones(@name)
51
66
  end
@@ -120,10 +135,6 @@ module Awsborn
120
135
  end
121
136
  end
122
137
 
123
- def route53
124
- @route53 ||= Route53.new
125
- end
126
-
127
138
  def dns_info
128
139
  if dns_alias
129
140
  route53.zone_for(dns_alias)
@@ -16,6 +16,9 @@ describe Awsborn::LoadBalancer do
16
16
  :configure_health_check => true)
17
17
  Awsborn::Elb.stub!(:new).and_return(@mocked_elb)
18
18
 
19
+ @mocked_ec2 = mock(:ec2)
20
+ Awsborn::Ec2.stub!(:new).and_return(@mocked_ec2)
21
+
19
22
  @mocked_route53 = mock(:route53,
20
23
  :zone_exists? => true,
21
24
  :add_alias_record => true,
@@ -141,6 +144,57 @@ describe Awsborn::LoadBalancer do
141
144
  end
142
145
  end
143
146
 
147
+ describe "instances_dns_names" do
148
+ before do
149
+ @balancer = Awsborn::LoadBalancer.new(
150
+ 'some-name',
151
+ :region => :eu_west_1
152
+ )
153
+ @desc_fixture = {
154
+ :private_ip_address => "10.240.7.99",
155
+ :aws_image_id => "ami-c2a3f5d4",
156
+ :ip_address => "174.129.134.109",
157
+ :dns_name => "ec2-174-129-134-109.compute-1.amazonaws.com",
158
+ :aws_instance_type => "m1.small",
159
+ :aws_owner => "826693181925",
160
+ :root_device_name => "/dev/sda1",
161
+ :instance_class => "elastic",
162
+ :aws_state => "running",
163
+ :private_dns_name => "domU-12-31-39-04-00-95.compute-1.internal",
164
+ :aws_reason => "",
165
+ :aws_launch_time => "2009-11-18T14:03:25.000Z",
166
+ :aws_reservation_id => "r-54d38542",
167
+ :aws_state_code => 16,
168
+ :ami_launch_index => "0",
169
+ :aws_availability_zone => "us-east-1a",
170
+ :aws_groups => ["default"],
171
+ :monitoring_state => "disabled",
172
+ :aws_product_codes => [],
173
+ :ssh_key_name => "",
174
+ :block_device_mappings => [],
175
+ :aws_instance_id => "i-8ce84ae4"
176
+ }
177
+ end
178
+ it "returns a list of the dns names of the instances of the load balancer" do
179
+ desc1 = @desc_fixture.merge(:aws_instance_id => 'i-00000001', :dns_name => 'server1.example.com')
180
+ desc2 = @desc_fixture.merge(:aws_instance_id => 'i-00000002', :dns_name => 'server2.example.com')
181
+ @mocked_elb.should_receive(:instances).with('some-name').and_return(['i-00000001', 'i-00000002'])
182
+ @mocked_ec2.should_receive(:instance_id=).with('i-00000001')
183
+ @mocked_ec2.should_receive(:describe_instance).and_return(desc1)
184
+ @mocked_ec2.should_receive(:instance_id=).with('i-00000002')
185
+ @mocked_ec2.should_receive(:describe_instance).and_return(desc2)
186
+ @balancer.instances_dns_names.should == ['server1.example.com', 'server2.example.com']
187
+ end
188
+ it "returns empty list if no description is available" do
189
+ @mocked_elb.should_receive(:instances).with('some-name').and_return(['i-00000001', 'i-00000002'])
190
+ @mocked_ec2.should_receive(:instance_id=).with('i-00000001')
191
+ @mocked_ec2.should_receive(:describe_instance).and_return(nil)
192
+ @mocked_ec2.should_receive(:instance_id=).with('i-00000002')
193
+ @mocked_ec2.should_receive(:describe_instance).and_return(nil)
194
+ @balancer.instances_dns_names.should be_empty
195
+ end
196
+ end
197
+
144
198
  describe "zones" do
145
199
  it "delegates to elb" do
146
200
  @mocked_elb.should_receive(:zones).with('some-name').and_return('zones')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsborn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Vrensk
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-23 00:00:00 +02:00
19
+ date: 2011-08-25 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency