amazon-ec2 0.5.1 → 0.5.2
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 +2 -0
- data/.yardopts +1 -0
- data/ChangeLog +3 -0
- data/LICENSE +1 -1
- data/README.rdoc +13 -1
- data/Rakefile +6 -16
- data/VERSION +1 -1
- data/amazon-ec2.gemspec +4 -4
- data/lib/AWS.rb +59 -11
- data/lib/AWS/EC2.rb +6 -40
- data/lib/AWS/EC2/availability_zones.rb +4 -26
- data/lib/AWS/EC2/console.rb +5 -28
- data/lib/AWS/EC2/elastic_ips.rb +7 -80
- data/lib/AWS/EC2/image_attributes.rb +10 -45
- data/lib/AWS/EC2/images.rb +5 -40
- data/lib/AWS/EC2/instances.rb +15 -56
- data/lib/AWS/EC2/keypairs.rb +3 -38
- data/lib/AWS/EC2/products.rb +3 -27
- data/lib/AWS/EC2/security_groups.rb +19 -70
- data/lib/AWS/EC2/snapshots.rb +4 -41
- data/lib/AWS/EC2/volumes.rb +15 -72
- data/lib/AWS/ELB.rb +5 -40
- data/lib/AWS/ELB/load_balancers.rb +27 -47
- data/lib/AWS/exceptions.rb +78 -122
- data/lib/AWS/responses.rb +6 -46
- data/test/test_helper.rb +4 -0
- metadata +6 -3
data/lib/AWS/exceptions.rb
CHANGED
@@ -1,166 +1,122 @@
|
|
1
1
|
#--
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
2
|
+
# AWS EC2 CLIENT ERROR CODES
|
3
|
+
# AWS EC2 can throw error exceptions that contain a '.' in them.
|
4
|
+
# since we can't name an exception class with that '.' I compressed
|
5
|
+
# each class name into the non-dot version. This allows us to retain
|
6
|
+
# the granularity of the exception.
|
9
7
|
#++
|
10
8
|
|
11
9
|
module AWS
|
12
|
-
# OUR CUSTOM ERROR CODES
|
13
10
|
|
14
|
-
# All
|
15
|
-
class Error < RuntimeError
|
16
|
-
end
|
11
|
+
# All AWS errors are superclassed by Error < RuntimeError
|
12
|
+
class Error < RuntimeError; end
|
17
13
|
|
18
|
-
# A client side
|
19
|
-
class ArgumentError < Error
|
20
|
-
end
|
14
|
+
# CLIENT : A client side argument error
|
15
|
+
class ArgumentError < Error; end
|
21
16
|
|
17
|
+
# EC2 : User not authorized.
|
18
|
+
class AuthFailure < Error; end
|
22
19
|
|
23
|
-
#
|
20
|
+
# EC2 : Invalid AWS Account
|
21
|
+
class InvalidClientTokenId < Error; end
|
24
22
|
|
25
|
-
#
|
26
|
-
|
27
|
-
# each class name into the non-dot version. This allows us to retain
|
28
|
-
# the granularity of the exception.
|
23
|
+
# EC2 : Invalid Parameters for Value
|
24
|
+
class InvalidParameterValue < Error; end
|
29
25
|
|
30
|
-
#
|
31
|
-
class
|
32
|
-
end
|
26
|
+
# EC2 : Specified AMI has an unparsable manifest.
|
27
|
+
class InvalidManifest < Error; end
|
33
28
|
|
34
|
-
#
|
35
|
-
class
|
36
|
-
end
|
29
|
+
# EC2 : Specified AMI ID is not valid.
|
30
|
+
class InvalidAMIIDMalformed < Error; end
|
37
31
|
|
38
|
-
#
|
39
|
-
class
|
40
|
-
end
|
32
|
+
# EC2 : Specified AMI ID does not exist.
|
33
|
+
class InvalidAMIIDNotFound < Error; end
|
41
34
|
|
42
|
-
# Specified AMI has
|
43
|
-
class
|
44
|
-
end
|
35
|
+
# EC2 : Specified AMI ID has been deregistered and is no longer available.
|
36
|
+
class InvalidAMIIDUnavailable < Error; end
|
45
37
|
|
46
|
-
# Specified
|
47
|
-
class
|
48
|
-
end
|
38
|
+
# EC2 : Specified instance ID is not valid.
|
39
|
+
class InvalidInstanceIDMalformed < Error; end
|
49
40
|
|
50
|
-
# Specified
|
51
|
-
class
|
52
|
-
end
|
41
|
+
# EC2 : Specified instance ID does not exist.
|
42
|
+
class InvalidInstanceIDNotFound < Error; end
|
53
43
|
|
54
|
-
#
|
55
|
-
class
|
56
|
-
end
|
44
|
+
# EC2 : Specified keypair name does not exist.
|
45
|
+
class InvalidKeyPairNotFound < Error; end
|
57
46
|
|
58
|
-
#
|
59
|
-
class
|
60
|
-
end
|
47
|
+
# EC2 : Attempt to create a duplicate keypair.
|
48
|
+
class InvalidKeyPairDuplicate < Error; end
|
61
49
|
|
62
|
-
# Specified
|
63
|
-
class
|
64
|
-
end
|
50
|
+
# EC2 : Specified group name does not exist.
|
51
|
+
class InvalidGroupNotFound < Error; end
|
65
52
|
|
66
|
-
#
|
67
|
-
class
|
68
|
-
end
|
53
|
+
# EC2 : Attempt to create a duplicate group.
|
54
|
+
class InvalidGroupDuplicate < Error; end
|
69
55
|
|
70
|
-
#
|
71
|
-
class
|
72
|
-
end
|
56
|
+
# EC2 : Specified group can not be deleted because it is in use.
|
57
|
+
class InvalidGroupInUse < Error; end
|
73
58
|
|
74
|
-
# Specified group name
|
75
|
-
class
|
76
|
-
end
|
59
|
+
# EC2 : Specified group name is a reserved name.
|
60
|
+
class InvalidGroupReserved < Error; end
|
77
61
|
|
78
|
-
# Attempt to
|
79
|
-
class
|
80
|
-
end
|
62
|
+
# EC2 : Attempt to authorize a permission that has already been authorized.
|
63
|
+
class InvalidPermissionDuplicate < Error; end
|
81
64
|
|
82
|
-
#
|
83
|
-
class
|
84
|
-
end
|
65
|
+
# EC2 : Specified permission is invalid.
|
66
|
+
class InvalidPermissionMalformed < Error; end
|
85
67
|
|
86
|
-
# Specified
|
87
|
-
class
|
88
|
-
end
|
68
|
+
# EC2 : Specified reservation ID is invalid.
|
69
|
+
class InvalidReservationIDMalformed < Error; end
|
89
70
|
|
90
|
-
#
|
91
|
-
class
|
92
|
-
end
|
71
|
+
# EC2 : Specified reservation ID does not exist.
|
72
|
+
class InvalidReservationIDNotFound < Error; end
|
93
73
|
|
94
|
-
#
|
95
|
-
class
|
96
|
-
end
|
74
|
+
# EC2 : User has reached max allowed concurrent running instances.
|
75
|
+
class InstanceLimitExceeded < Error; end
|
97
76
|
|
98
|
-
#
|
99
|
-
class
|
100
|
-
end
|
77
|
+
# EC2 : An invalid set of parameters were passed as arguments
|
78
|
+
class InvalidParameterCombination < Error; end
|
101
79
|
|
102
|
-
#
|
103
|
-
class
|
104
|
-
end
|
80
|
+
# EC2 : An unknown parameter was passed as an argument
|
81
|
+
class UnknownParameter < Error; end
|
105
82
|
|
106
|
-
#
|
107
|
-
class InstanceLimitExceeded < Error #:nodoc:
|
108
|
-
end
|
109
|
-
|
110
|
-
# An invalid set of parameters were passed as arguments
|
111
|
-
# e.g. RunInstances was called with minCount and maxCount set to 0 or minCount > maxCount.
|
112
|
-
class InvalidParameterCombination < Error #:nodoc:
|
113
|
-
end
|
114
|
-
|
115
|
-
# An unknown parameter was passed as an argument
|
116
|
-
class UnknownParameter < Error #:nodoc:
|
117
|
-
end
|
118
|
-
|
119
|
-
# The user ID is neither in the form of an AWS account ID or one
|
83
|
+
# EC2 : The user ID is neither in the form of an AWS account ID or one
|
120
84
|
# of the special values accepted by the owner or executableBy flags
|
121
85
|
# in the DescribeImages call.
|
122
|
-
class InvalidUserIDMalformed < Error
|
123
|
-
end
|
86
|
+
class InvalidUserIDMalformed < Error; end
|
124
87
|
|
125
|
-
# The value of an item added to, or removed from, an image attribute is invalid.
|
126
|
-
class InvalidAMIAttributeItemValue < Error
|
127
|
-
end
|
88
|
+
# EC2 : The value of an item added to, or removed from, an image attribute is invalid.
|
89
|
+
class InvalidAMIAttributeItemValue < Error; end
|
128
90
|
|
129
|
-
# ELB
|
91
|
+
# ELB : The Load balancer specified was not found.
|
92
|
+
class LoadBalancerNotFound < Error; end
|
130
93
|
|
131
|
-
|
132
|
-
end
|
94
|
+
# ELB :
|
95
|
+
class ValidationError < Error; end
|
133
96
|
|
134
|
-
|
135
|
-
end
|
97
|
+
# ELB :
|
98
|
+
class DuplicateLoadBalancerName < Error; end
|
136
99
|
|
137
|
-
|
138
|
-
end
|
100
|
+
# ELB :
|
101
|
+
class TooManyLoadBalancers < Error; end
|
139
102
|
|
140
|
-
|
141
|
-
end
|
103
|
+
# ELB :
|
104
|
+
class InvalidInstance < Error; end
|
142
105
|
|
143
|
-
|
144
|
-
end
|
106
|
+
# ELB :
|
107
|
+
class InvalidConfigurationRequest < Error; end
|
145
108
|
|
146
|
-
|
147
|
-
end
|
109
|
+
# Server : Internal AWS EC2 Error.
|
110
|
+
class InternalError < Error; end
|
148
111
|
|
149
|
-
#
|
112
|
+
# Server : There are not enough available instances to satisfy your minimum request.
|
113
|
+
class InsufficientInstanceCapacity < Error; end
|
150
114
|
|
151
|
-
#
|
152
|
-
class
|
153
|
-
end
|
115
|
+
# Server : The server is overloaded and cannot handle the request.
|
116
|
+
class Unavailable < Error; end
|
154
117
|
|
155
|
-
#
|
156
|
-
class
|
157
|
-
end
|
158
|
-
|
159
|
-
# The server is overloaded and cannot handle request.
|
160
|
-
class Unavailable < Error #:nodoc:
|
161
|
-
end
|
162
|
-
|
163
|
-
class SignatureDoesNotMatch < Error #:nodoc:
|
164
|
-
end
|
118
|
+
# Server : The provided signature does not match.
|
119
|
+
class SignatureDoesNotMatch < Error; end
|
165
120
|
|
166
121
|
end
|
122
|
+
|
data/lib/AWS/responses.rb
CHANGED
@@ -1,61 +1,21 @@
|
|
1
|
-
#--
|
2
|
-
# Amazon Web Services EC2 Query API Ruby library
|
3
|
-
#
|
4
|
-
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
-
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
-
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
-
#++
|
10
|
-
|
11
|
-
# This allows us to access hash values as if they were methods
|
12
|
-
# e.g. foo[:bar] can be accessed as foo.bar
|
13
|
-
|
14
|
-
class Hash
|
15
|
-
def method_missing(meth, *args, &block)
|
16
|
-
if args.size == 0
|
17
|
-
self[meth.to_s] || self[meth.to_sym]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
1
|
module AWS
|
23
2
|
|
24
|
-
# The make_request() and aws_error? methods, which are shared by all, will raise any
|
25
|
-
# exceptions encountered along the way as it converses with EC2.
|
26
|
-
#
|
27
|
-
# Exception Handling: If for some reason an error occurrs when executing a method
|
28
|
-
# (e.g. its arguments were incorrect, or it simply failed) then an exception will
|
29
|
-
# be thrown. The exceptions are defined in exceptions.rb as individual classes and should
|
30
|
-
# match the exceptions that Amazon has defined for EC2. If the exception raised cannot be
|
31
|
-
# identified then a more generic exception class will be thrown.
|
32
|
-
#
|
33
|
-
# The implication of this is that you need to be prepared to handle any exceptions that
|
34
|
-
# may be raised by this library in YOUR code with a 'rescue' clauses. It is up to you
|
35
|
-
# how gracefully you want to handle these exceptions that are raised.
|
36
|
-
|
37
|
-
begin
|
38
|
-
require 'xmlsimple' unless defined? XmlSimple
|
39
|
-
rescue Exception => e
|
40
|
-
require 'xml-simple' unless defined? XmlSimple
|
41
|
-
end
|
42
|
-
|
43
3
|
class Response
|
44
4
|
|
5
|
+
# Parse the XML response from AWS
|
6
|
+
#
|
7
|
+
# @option options [String] :xml The XML response from AWS that we want to parse
|
8
|
+
# @option options [Hash] :parse_options Override the options for XmlSimple.
|
9
|
+
# @return [Hash] the input :xml converted to a custom Ruby Hash by XmlSimple.
|
45
10
|
def self.parse(options = {})
|
46
11
|
options = {
|
47
12
|
:xml => "",
|
48
13
|
:parse_options => { 'forcearray' => ['item', 'member'], 'suppressempty' => nil, 'keeproot' => false }
|
49
14
|
}.merge(options)
|
50
|
-
|
51
|
-
# NOTE: Parsing the response as a nested set of Response objects was extremely
|
52
|
-
# memory intensive and appeared to leak (the memory was not freed on subsequent requests).
|
53
|
-
# It was changed to return the raw XmlSimple response.
|
54
15
|
response = XmlSimple.xml_in(options[:xml], options[:parse_options])
|
55
|
-
|
56
|
-
return response
|
57
16
|
end
|
58
17
|
|
59
18
|
end # class Response
|
60
19
|
|
61
20
|
end # module AWS
|
21
|
+
|
data/test/test_helper.rb
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
|
+
require 'rubygems'
|
12
|
+
gem 'test-unit'
|
13
|
+
|
11
14
|
%w[ test/unit test/spec mocha ].each { |f|
|
12
15
|
begin
|
13
16
|
require f
|
@@ -17,3 +20,4 @@
|
|
17
20
|
}
|
18
21
|
|
19
22
|
require File.dirname(__FILE__) + '/../lib/AWS'
|
23
|
+
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glenn Rempe
|
@@ -78,6 +78,7 @@ extra_rdoc_files:
|
|
78
78
|
- README_dev.rdoc
|
79
79
|
files:
|
80
80
|
- .gitignore
|
81
|
+
- .yardopts
|
81
82
|
- ChangeLog
|
82
83
|
- LICENSE
|
83
84
|
- README.rdoc
|
@@ -133,6 +134,8 @@ files:
|
|
133
134
|
- wsdl/2008-12-01.ec2.wsdl
|
134
135
|
has_rdoc: true
|
135
136
|
homepage: http://github.com/grempe/amazon-ec2
|
137
|
+
licenses: []
|
138
|
+
|
136
139
|
post_install_message:
|
137
140
|
rdoc_options:
|
138
141
|
- --title
|
@@ -157,9 +160,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
160
|
requirements: []
|
158
161
|
|
159
162
|
rubyforge_project: amazon-ec2
|
160
|
-
rubygems_version: 1.3.
|
163
|
+
rubygems_version: 1.3.5
|
161
164
|
signing_key:
|
162
|
-
specification_version:
|
165
|
+
specification_version: 3
|
163
166
|
summary: Amazon EC2 Ruby Gem
|
164
167
|
test_files:
|
165
168
|
- test/test_EC2.rb
|