amazon-ec2 0.2.13 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/EC2/availability_zones.rb +42 -0
- data/lib/EC2/instances.rb +3 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_instances.rb +7 -1
- metadata +9 -3
data/CHANGELOG
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:grempe@rubyforge.org)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
module EC2
|
12
|
+
|
13
|
+
class Base
|
14
|
+
|
15
|
+
#Amazon Developer Guide Docs:
|
16
|
+
#
|
17
|
+
# The DescribeAvailabilityZones operation describes availability zones that are currently
|
18
|
+
# available to the account and their states.
|
19
|
+
#
|
20
|
+
# An optional list of zone names can be passed.
|
21
|
+
#
|
22
|
+
#Required Arguments:
|
23
|
+
#
|
24
|
+
# none
|
25
|
+
#
|
26
|
+
#Optional Arguments:
|
27
|
+
#
|
28
|
+
# :zone_name => Array (default : [])
|
29
|
+
#
|
30
|
+
|
31
|
+
def describe_availability_zones( options = {} )
|
32
|
+
|
33
|
+
options = { :zone_name => [] }.merge(options)
|
34
|
+
|
35
|
+
params = pathlist("ZoneName", options[:zone_name] )
|
36
|
+
|
37
|
+
return response_generator(:action => "DescribeAvailabilityZones", :params => params)
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
data/lib/EC2/instances.rb
CHANGED
@@ -64,6 +64,7 @@ module EC2
|
|
64
64
|
# :user_data => String (default : nil)
|
65
65
|
# :addressing_type => String (default : "public")
|
66
66
|
# :instance_type => String (default : "m1.small")
|
67
|
+
# :availability_zone => String (default : nil)
|
67
68
|
# :base64_encoded => Boolean (default : false)
|
68
69
|
#
|
69
70
|
def run_instances( options = {} )
|
@@ -76,6 +77,7 @@ module EC2
|
|
76
77
|
:user_data => nil,
|
77
78
|
:addressing_type => "public",
|
78
79
|
:instance_type => "m1.small",
|
80
|
+
:availability_zone => nil,
|
79
81
|
:base64_encoded => false }.merge(options)
|
80
82
|
|
81
83
|
# Do some validation on the arguments provided
|
@@ -109,6 +111,7 @@ module EC2
|
|
109
111
|
params["UserData"] = user_data unless user_data.nil?
|
110
112
|
params["AddressingType"] = options[:addressing_type]
|
111
113
|
params["InstanceType"] = options[:instance_type]
|
114
|
+
params["Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil?
|
112
115
|
|
113
116
|
return response_generator(:action => "RunInstances", :params => params)
|
114
117
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:grempe@rubyforge.org)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 availability zones" do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_availability_zones_response_body = <<-RESPONSE
|
19
|
+
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01/">
|
20
|
+
<availabilityZoneInfo>
|
21
|
+
<item>
|
22
|
+
<zoneName>us-east-1a</zoneName>
|
23
|
+
<zoneState>available</zoneState>
|
24
|
+
</item>
|
25
|
+
<item>
|
26
|
+
<zoneName>us-east-1b</zoneName>
|
27
|
+
<zoneState>available</zoneState>
|
28
|
+
</item>
|
29
|
+
</availabilityZoneInfo>
|
30
|
+
</DescribeAvailabilityZonesResponse>
|
31
|
+
RESPONSE
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "should be able to be described with describe_availability_zones" do
|
36
|
+
@ec2.stubs(:make_request).with('DescribeAvailabilityZones', { "ZoneName.1" => "us-east-1a", "ZoneName.2" => "us-east-1b" }).
|
37
|
+
returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
|
38
|
+
@ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] ).should.be.an.instance_of EC2::Response
|
39
|
+
|
40
|
+
response = @ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] )
|
41
|
+
|
42
|
+
response.availabilityZoneInfo.item[0].zoneName.should.equal "us-east-1a"
|
43
|
+
response.availabilityZoneInfo.item[0].zoneState.should.equal "available"
|
44
|
+
|
45
|
+
response.availabilityZoneInfo.item[1].zoneName.should.equal "us-east-1b"
|
46
|
+
response.availabilityZoneInfo.item[1].zoneState.should.equal "available"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/test/test_EC2_instances.rb
CHANGED
@@ -220,6 +220,12 @@ context "EC2 instances " do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
|
223
|
+
specify "should be able specify an availability_zone" do
|
224
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Placement.AvailabilityZone" => "zone123", "UserData" => "foo", "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
225
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
226
|
+
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :availability_zone => "zone123", :group_id => [], :user_data => "foo", :base64_encoded => true ).should.be.an.instance_of EC2::Response
|
227
|
+
end
|
228
|
+
|
223
229
|
specify "should be able to call run_instances with :user_data and :base64_encoded => true (default is false)" do
|
224
230
|
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "UserData" => "foo", "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
225
231
|
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
@@ -322,4 +328,4 @@ context "EC2 instances " do
|
|
322
328
|
@response.instancesSet.item[1].previousState.name.should.equal "pending"
|
323
329
|
end
|
324
330
|
|
325
|
-
end
|
331
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glenn Rempe
|
@@ -9,11 +9,12 @@ autorequire: EC2
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-07-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: xml-simple
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -23,6 +24,7 @@ dependencies:
|
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: mocha
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
@@ -32,6 +34,7 @@ dependencies:
|
|
32
34
|
version:
|
33
35
|
- !ruby/object:Gem::Dependency
|
34
36
|
name: test-spec
|
37
|
+
type: :runtime
|
35
38
|
version_requirement:
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
@@ -41,6 +44,7 @@ dependencies:
|
|
41
44
|
version:
|
42
45
|
- !ruby/object:Gem::Dependency
|
43
46
|
name: rcov
|
47
|
+
type: :runtime
|
44
48
|
version_requirement:
|
45
49
|
version_requirements: !ruby/object:Gem::Requirement
|
46
50
|
requirements:
|
@@ -66,6 +70,7 @@ files:
|
|
66
70
|
- CHANGELOG
|
67
71
|
- Rakefile
|
68
72
|
- lib/EC2
|
73
|
+
- lib/EC2/availability_zones.rb
|
69
74
|
- lib/EC2/console.rb
|
70
75
|
- lib/EC2/elastic_ips.rb
|
71
76
|
- lib/EC2/exceptions.rb
|
@@ -78,6 +83,7 @@ files:
|
|
78
83
|
- lib/EC2/security_groups.rb
|
79
84
|
- lib/EC2.rb
|
80
85
|
- test/test_EC2.rb
|
86
|
+
- test/test_EC2_availability_zones.rb
|
81
87
|
- test/test_EC2_console.rb
|
82
88
|
- test/test_EC2_elastic_ips.rb
|
83
89
|
- test/test_EC2_image_attributes.rb
|
@@ -118,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
124
|
requirements: []
|
119
125
|
|
120
126
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.
|
127
|
+
rubygems_version: 1.2.0
|
122
128
|
signing_key:
|
123
129
|
specification_version: 2
|
124
130
|
summary: An interface library that allows Ruby applications to easily connect to the HTTP 'Query API' for the Amazon Web Services Elastic Compute Cloud (EC2) and manipulate cloud servers.
|