fog 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/fog.gemspec +2 -2
- data/lib/fog.rb +7 -3
- data/lib/fog/aws/ec2.rb +30 -18
- data/lib/fog/aws/models/ec2/flavors.rb +3 -2
- data/lib/fog/aws/models/ec2/server.rb +1 -1
- data/lib/fog/aws/requests/ec2/associate_address.rb +5 -4
- data/lib/fog/aws/requests/ec2/attach_volume.rb +10 -11
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +33 -19
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -3
- data/lib/fog/aws/requests/ec2/create_security_group.rb +4 -5
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +2 -3
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +2 -3
- data/lib/fog/aws/requests/ec2/delete_volume.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +10 -6
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_regions.rb +10 -6
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -3
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -3
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -3
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +2 -3
- data/lib/fog/aws/requests/ec2/get_console_output.rb +3 -4
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +2 -3
- data/lib/fog/aws/requests/ec2/release_address.rb +2 -3
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +24 -15
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +3 -3
- data/lib/fog/aws/requests/s3/put_object.rb +3 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +2 -2
- data/spec/aws/requests/ec2/get_console_output_spec.rb +2 -2
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +2 -2
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +2 -2
- data/tests/aws/requests/ec2/address_tests.rb +13 -25
- data/tests/aws/requests/ec2/availability_zone_tests.rb +1 -1
- data/tests/aws/requests/ec2/key_pair_tests.rb +2 -2
- data/tests/aws/requests/ec2/region_tests.rb +1 -1
- data/tests/aws/requests/ec2/security_group_tests.rb +7 -7
- data/tests/aws/requests/ec2/snapshot_tests.rb +2 -2
- data/tests/aws/requests/ec2/volume_tests.rb +5 -5
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -62,13 +62,13 @@ specs:
|
|
62
62
|
- net-ssh:
|
63
63
|
version: 2.0.22
|
64
64
|
- nokogiri:
|
65
|
-
version: 1.4.
|
65
|
+
version: 1.4.2
|
66
66
|
- rspec:
|
67
67
|
version: 1.3.0
|
68
68
|
- ruby-hmac:
|
69
69
|
version: 0.4.0
|
70
70
|
- shindo:
|
71
|
-
version: 0.1.
|
71
|
+
version: 0.1.3
|
72
72
|
hash: 4e55927c1be02ee00fc3353e71caecdebd9d4817
|
73
73
|
sources:
|
74
74
|
- Rubygems:
|
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.1.
|
11
|
-
s.date = '2010-05-
|
10
|
+
s.version = '0.1.3'
|
11
|
+
s.date = '2010-05-26'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
data/lib/fog.rb
CHANGED
@@ -25,6 +25,10 @@ require 'fog/model'
|
|
25
25
|
require 'fog/parser'
|
26
26
|
require 'fog/ssh'
|
27
27
|
|
28
|
+
module Fog
|
29
|
+
class Error < StandardError; end
|
30
|
+
end
|
31
|
+
|
28
32
|
require 'fog/aws'
|
29
33
|
require 'fog/local'
|
30
34
|
require 'fog/rackspace'
|
@@ -34,8 +38,10 @@ require 'fog/vcloud'
|
|
34
38
|
|
35
39
|
module Fog
|
36
40
|
|
41
|
+
class MockNotImplemented < Fog::Error; end
|
42
|
+
|
37
43
|
unless const_defined?(:VERSION)
|
38
|
-
VERSION = '0.1.
|
44
|
+
VERSION = '0.1.3'
|
39
45
|
end
|
40
46
|
|
41
47
|
module Mock
|
@@ -50,8 +56,6 @@ module Fog
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
53
|
-
class MockNotImplemented < StandardError; end
|
54
|
-
|
55
59
|
def self.mock!
|
56
60
|
@mocking = true
|
57
61
|
end
|
data/lib/fog/aws/ec2.rb
CHANGED
@@ -2,6 +2,8 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
module EC2
|
4
4
|
|
5
|
+
class Error < Fog::Error; end
|
6
|
+
|
5
7
|
def self.new(options={})
|
6
8
|
|
7
9
|
unless @required
|
@@ -96,40 +98,42 @@ module Fog
|
|
96
98
|
|
97
99
|
def self.data
|
98
100
|
@data ||= Hash.new do |hash, key|
|
101
|
+
owner_id = Fog::AWS::Mock.owner_id
|
99
102
|
hash[key] = {
|
100
103
|
:deleted_at => {},
|
101
|
-
:addresses
|
102
|
-
:instances
|
103
|
-
:key_pairs
|
104
|
-
:limits
|
104
|
+
:addresses => {},
|
105
|
+
:instances => {},
|
106
|
+
:key_pairs => {},
|
107
|
+
:limits => { :addresses => 5 },
|
108
|
+
:owner_id => owner_id,
|
105
109
|
:security_groups => {
|
106
110
|
'default' => {
|
107
111
|
'groupDescription' => 'default group',
|
108
112
|
'groupName' => 'default',
|
109
113
|
'ipPermissions' => [
|
110
114
|
{
|
111
|
-
'groups' => [{'groupName' => 'default', 'userId' =>
|
115
|
+
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
|
112
116
|
'fromPort' => -1,
|
113
117
|
'toPort' => -1,
|
114
118
|
'ipProtocol' => 'icmp',
|
115
119
|
'ipRanges' => []
|
116
120
|
},
|
117
121
|
{
|
118
|
-
'groups' => [{'groupName' => 'default', 'userId' =>
|
122
|
+
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
|
119
123
|
'fromPort' => 0,
|
120
124
|
'toPort' => 65535,
|
121
125
|
'ipProtocol' => 'tcp',
|
122
126
|
'ipRanges' => []
|
123
127
|
},
|
124
128
|
{
|
125
|
-
'groups' => [{'groupName' => 'default', 'userId' =>
|
129
|
+
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
|
126
130
|
'fromPort' => 0,
|
127
131
|
'toPort' => 65535,
|
128
132
|
'ipProtocol' => 'udp',
|
129
133
|
'ipRanges' => []
|
130
134
|
}
|
131
135
|
],
|
132
|
-
'ownerId' =>
|
136
|
+
'ownerId' => owner_id
|
133
137
|
}
|
134
138
|
},
|
135
139
|
:snapshots => {},
|
@@ -146,8 +150,8 @@ module Fog
|
|
146
150
|
|
147
151
|
def initialize(options={})
|
148
152
|
@aws_access_key_id = options[:aws_access_key_id]
|
149
|
-
@owner_id = Fog::AWS::Mock.owner_id
|
150
153
|
@data = self.class.data[@aws_access_key_id]
|
154
|
+
@owner_id = @data[:owner_id]
|
151
155
|
end
|
152
156
|
|
153
157
|
end
|
@@ -210,15 +214,23 @@ module Fog
|
|
210
214
|
}
|
211
215
|
)
|
212
216
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
217
|
+
begin
|
218
|
+
response = @connection.request({
|
219
|
+
:body => body,
|
220
|
+
:expects => 200,
|
221
|
+
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
|
222
|
+
:idempotent => idempotent,
|
223
|
+
:host => @host,
|
224
|
+
:method => 'POST',
|
225
|
+
:parser => parser
|
226
|
+
})
|
227
|
+
rescue Excon::Errors::Error => error
|
228
|
+
if match = error.message.match(/<Code>(.*)<\/Code><Message>(.*)<\/Message>/)
|
229
|
+
raise Fog::AWS::EC2::Error.new("#{match[1]} => #{match[2]}")
|
230
|
+
else
|
231
|
+
raise error
|
232
|
+
end
|
233
|
+
end
|
222
234
|
|
223
235
|
response
|
224
236
|
end
|
@@ -30,8 +30,9 @@ module Fog
|
|
30
30
|
{ :bits => 32, :cores => 5, :disk => 350, :id => 'c1.medium', :name => 'High-CPU Medium', :ram => 1740.8},
|
31
31
|
{ :bits => 64, :cores => 20, :disk => 1690, :id => 'c1.xlarge', :name => 'High-CPU Extra Large', :ram => 7168},
|
32
32
|
|
33
|
-
{ :bits => 64, :cores =>
|
34
|
-
{ :bits => 64, :cores =>
|
33
|
+
{ :bits => 64, :cores => 6.5, :disk => 420, :id => 'm2.xlarge', :name => 'High-Memory Extra Large', :ram => 17510.4},
|
34
|
+
{ :bits => 64, :cores => 13, :disk => 850, :id => 'm2.2xlarge', :name => 'High Memory Double Extra Large', :ram => 35020.8},
|
35
|
+
{ :bits => 64, :cores => 26, :disk => 1690, :id => 'm2.4xlarge', :name => 'High Memory Quadruple Extra Large', :ram => 70041.6},
|
35
36
|
]
|
36
37
|
load(data)
|
37
38
|
self
|
@@ -43,11 +43,12 @@ module Fog
|
|
43
43
|
'requestId' => Fog::AWS::Mock.request_id,
|
44
44
|
'return' => true
|
45
45
|
}
|
46
|
-
|
47
|
-
|
48
|
-
raise
|
46
|
+
response
|
47
|
+
elsif !instance
|
48
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID '#{instance_id}' does not exist")
|
49
|
+
elsif !address
|
50
|
+
raise Fog::AWS::EC2::Error.new("AuthFailure => The address '#{public_ip}' does not belong to you.")
|
49
51
|
end
|
50
|
-
response
|
51
52
|
end
|
52
53
|
|
53
54
|
end
|
@@ -54,24 +54,23 @@ module Fog
|
|
54
54
|
response.body = {
|
55
55
|
'requestId' => Fog::AWS::Mock.request_id
|
56
56
|
}.merge!(data)
|
57
|
-
|
58
|
-
|
59
|
-
raise
|
57
|
+
response
|
58
|
+
elsif !instance
|
59
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID '#{instance_id}' does not exist.")
|
60
|
+
elsif !volume
|
61
|
+
raise Fog::AWS::EC2::Error.new("InvalidVolume.NotFound => The volume '#{volume_id}' does not exist.")
|
60
62
|
end
|
61
63
|
else
|
62
|
-
|
63
|
-
response.body = {
|
64
|
-
'Code' => 'MissingParameter'
|
65
|
-
}
|
64
|
+
message = 'MissingParameter => '
|
66
65
|
if !instance_id
|
67
|
-
|
66
|
+
message << 'The request must contain the parameter instance_id'
|
68
67
|
elsif !volume_id
|
69
|
-
|
68
|
+
message << 'The request must contain the parameter volume_id'
|
70
69
|
else
|
71
|
-
|
70
|
+
message << 'The request must contain the parameter device'
|
72
71
|
end
|
72
|
+
raise Fog::AWS::EC2::Error.new(message)
|
73
73
|
end
|
74
|
-
response
|
75
74
|
end
|
76
75
|
|
77
76
|
end
|
@@ -37,33 +37,47 @@ module Fog
|
|
37
37
|
def authorize_security_group_ingress(options = {})
|
38
38
|
response = Excon::Response.new
|
39
39
|
group = @data[:security_groups][options['GroupName']]
|
40
|
-
group['ipPermissions'] ||= []
|
41
40
|
|
42
|
-
if
|
43
|
-
['
|
41
|
+
if group
|
42
|
+
group['ipPermissions'] ||= []
|
43
|
+
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
44
|
+
['tcp', 'udp'].each do |protocol|
|
45
|
+
group['ipPermissions'] << {
|
46
|
+
'groups' => [{'groupName' => options['GroupName'], 'userId' => @owner_id}],
|
47
|
+
'fromPort' => 1,
|
48
|
+
'ipRanges' => [],
|
49
|
+
'ipProtocol' => protocol,
|
50
|
+
'toPort' => 65535
|
51
|
+
}
|
52
|
+
end
|
44
53
|
group['ipPermissions'] << {
|
45
54
|
'groups' => [{'groupName' => options['GroupName'], 'userId' => @owner_id}],
|
46
|
-
'fromPort' => 1,
|
55
|
+
'fromPort' => -1,
|
47
56
|
'ipRanges' => [],
|
48
|
-
'ipProtocol' =>
|
49
|
-
'toPort' =>
|
57
|
+
'ipProtocol' => 'icmp',
|
58
|
+
'toPort' => -1
|
50
59
|
}
|
60
|
+
else
|
61
|
+
group['ipPermissions'] << {
|
62
|
+
'groups' => [],
|
63
|
+
'fromPort' => options['FromPort'],
|
64
|
+
'ipRanges' => [],
|
65
|
+
'ipProtocol' => options['IpProtocol'],
|
66
|
+
'toPort' => options['ToPort']
|
67
|
+
}
|
68
|
+
if options['CidrIp']
|
69
|
+
group['ipPermissions'].last['ipRanges'] << { 'cidrIp' => options['CidrIp'] }
|
70
|
+
end
|
51
71
|
end
|
52
|
-
|
53
|
-
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'ipRanges' => [{ 'cidrIp' => options['CidrIp'] }],
|
57
|
-
'ipProtocol' => options['IpProtocol'],
|
58
|
-
'toPort' => options['ToPort']
|
72
|
+
response.status = 200
|
73
|
+
response.body = {
|
74
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
75
|
+
'return' => true
|
59
76
|
}
|
77
|
+
response
|
78
|
+
else
|
79
|
+
raise Fog::AWS::EC2::Error.new("InvalidGroup.NotFound => The security group '#{options['GroupName']}' does not exist")
|
60
80
|
end
|
61
|
-
response.status = 200
|
62
|
-
response.body = {
|
63
|
-
'requestId' => Fog::AWS::Mock.request_id,
|
64
|
-
'return' => true
|
65
|
-
}
|
66
|
-
response
|
67
81
|
end
|
68
82
|
|
69
83
|
end
|
@@ -40,11 +40,10 @@ module Fog
|
|
40
40
|
response.body = {
|
41
41
|
'requestId' => Fog::AWS::Mock.request_id
|
42
42
|
}.merge!(data)
|
43
|
+
response
|
43
44
|
else
|
44
|
-
|
45
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
45
|
+
raise Fog::AWS::EC2::Error.new("InvalidKeyPair.Duplicate => The keypair '#{key_name}' already exists.")
|
46
46
|
end
|
47
|
-
response
|
48
47
|
end
|
49
48
|
|
50
49
|
end
|
@@ -31,8 +31,8 @@ module Fog
|
|
31
31
|
response = Excon::Response.new
|
32
32
|
unless @data[:security_groups][name]
|
33
33
|
data = {
|
34
|
-
'groupDescription' => description,
|
35
|
-
'groupName' => name,
|
34
|
+
'groupDescription' => CGI.escape(description).gsub('%20', '+'),
|
35
|
+
'groupName' => CGI.escape(name).gsub('%20', '+'),
|
36
36
|
'ipPermissions' => [],
|
37
37
|
'ownerId' => @owner_id
|
38
38
|
}
|
@@ -41,11 +41,10 @@ module Fog
|
|
41
41
|
'requestId' => Fog::AWS::Mock.request_id,
|
42
42
|
'return' => true
|
43
43
|
}
|
44
|
+
response
|
44
45
|
else
|
45
|
-
|
46
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
46
|
+
raise Fog::AWS::EC2::Error.new("InvalidGroup.Duplicate => The security group '#{name}' already exists")
|
47
47
|
end
|
48
|
-
response
|
49
48
|
end
|
50
49
|
|
51
50
|
end
|
@@ -34,11 +34,10 @@ module Fog
|
|
34
34
|
'requestId' => Fog::AWS::Mock.request_id,
|
35
35
|
'return' => true
|
36
36
|
}
|
37
|
+
response
|
37
38
|
else
|
38
|
-
|
39
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
39
|
+
raise Fog::AWS::EC2::Error.new("InvalidGroup.NotFound => The security group '#{name}' does not exist")
|
40
40
|
end
|
41
|
-
response
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
@@ -34,11 +34,10 @@ module Fog
|
|
34
34
|
'requestId' => Fog::AWS::Mock.request_id,
|
35
35
|
'return' => true
|
36
36
|
}
|
37
|
+
response
|
37
38
|
else
|
38
|
-
|
39
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
39
|
+
raise Fog::AWS::EC2::Error.new("InvalidSnapshot.NotFound => The snapshot '#{snapshot_id}' does not exist.")
|
40
40
|
end
|
41
|
-
response
|
42
41
|
end
|
43
42
|
|
44
43
|
end
|
@@ -36,11 +36,10 @@ module Fog
|
|
36
36
|
'requestId' => Fog::AWS::Mock.request_id,
|
37
37
|
'return' => true
|
38
38
|
}
|
39
|
+
response
|
39
40
|
else
|
40
|
-
|
41
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
41
|
+
raise Fog::AWS::EC2::Error.new("InvalidVolume.NotFound => The volume '#{volume_id}' does not exist.")
|
42
42
|
end
|
43
|
-
response
|
44
43
|
end
|
45
44
|
|
46
45
|
end
|
@@ -42,11 +42,10 @@ module Fog
|
|
42
42
|
'requestId' => Fog::AWS::Mock.request_id,
|
43
43
|
'addressesSet' => addresses_set
|
44
44
|
}
|
45
|
+
response
|
45
46
|
else
|
46
|
-
|
47
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
47
|
+
raise Fog::AWS::EC2::Error.new("InvalidAddress.NotFound => Address #{public_ip.inspect} not found.")
|
48
48
|
end
|
49
|
-
response
|
50
49
|
end
|
51
50
|
|
52
51
|
end
|
@@ -44,12 +44,16 @@ module Fog
|
|
44
44
|
availability_zone_info = zones.values
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
if zone_name.length == 0 || zone_name.length == availability_zone_info.length
|
48
|
+
response.status = 200
|
49
|
+
response.body = {
|
50
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
51
|
+
'availabilityZoneInfo' => availability_zone_info
|
52
|
+
}
|
53
|
+
response
|
54
|
+
else
|
55
|
+
raise Fog::AWS::EC2::Error.new("InvalidParameterValue => Invalid availability zone: #{zone_name.inspect}")
|
56
|
+
end
|
53
57
|
end
|
54
58
|
|
55
59
|
end
|
@@ -115,11 +115,10 @@ module Fog
|
|
115
115
|
'requestId' => Fog::AWS::Mock.request_id,
|
116
116
|
'reservationSet' => reservation_set.values
|
117
117
|
}
|
118
|
+
response
|
118
119
|
else
|
119
|
-
|
120
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
120
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID #{instance_id.inspect} does not exist")
|
121
121
|
end
|
122
|
-
response
|
123
122
|
end
|
124
123
|
|
125
124
|
end
|
@@ -44,11 +44,10 @@ module Fog
|
|
44
44
|
key.reject {|key,value| !['keyFingerprint', 'keyName'].include?(key)}
|
45
45
|
end
|
46
46
|
}
|
47
|
+
response
|
47
48
|
else
|
48
|
-
|
49
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
49
|
+
raise Fog::AWS::EC2::Error.new("InvalidKeyPair.NotFound => The key pair #{key_name.inspect} does not exist")
|
50
50
|
end
|
51
|
-
response
|
52
51
|
end
|
53
52
|
|
54
53
|
end
|
@@ -41,12 +41,16 @@ module Fog
|
|
41
41
|
region_info = regions.values
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
if region_name.length == 0 || region_name.length == region_info.length
|
45
|
+
response.status = 200
|
46
|
+
response.body = {
|
47
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
48
|
+
'regionInfo' => region_info
|
49
|
+
}
|
50
|
+
response
|
51
|
+
else
|
52
|
+
raise Fog::AWS::EC2::Error.new("InvalidParameterValue => Invalid region: #{region_name.inspect}")
|
53
|
+
end
|
50
54
|
end
|
51
55
|
|
52
56
|
end
|
@@ -52,11 +52,10 @@ module Fog
|
|
52
52
|
'requestId' => Fog::AWS::Mock.request_id,
|
53
53
|
'securityGroupInfo' => security_group_info
|
54
54
|
}
|
55
|
+
response
|
55
56
|
else
|
56
|
-
|
57
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
57
|
+
raise Fog::AWS::EC2::Error.new("InvalidGroup.NotFound => The security group #{group_name.inspect} does not exist")
|
58
58
|
end
|
59
|
-
response
|
60
59
|
end
|
61
60
|
|
62
61
|
end
|
@@ -66,11 +66,10 @@ module Fog
|
|
66
66
|
'requestId' => Fog::AWS::Mock.request_id,
|
67
67
|
'snapshotSet' => snapshot_set
|
68
68
|
}
|
69
|
+
response
|
69
70
|
else
|
70
|
-
|
71
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
71
|
+
raise Fog::AWS::EC2::Error.new("InvalidSnapshot.NotFound => The snapshot #{snapshot_id.inspect} does not exist.")
|
72
72
|
end
|
73
|
-
response
|
74
73
|
end
|
75
74
|
|
76
75
|
end
|
@@ -72,11 +72,10 @@ module Fog
|
|
72
72
|
'requestId' => Fog::AWS::Mock.request_id,
|
73
73
|
'volumeSet' => volume_set
|
74
74
|
}
|
75
|
+
response
|
75
76
|
else
|
76
|
-
|
77
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
77
|
+
raise Fog::AWS::EC2::Error.new("InvalidVolume.NotFound => The volume #{volume_id.inspect} does not exist.")
|
78
78
|
end
|
79
|
-
response
|
80
79
|
end
|
81
80
|
|
82
81
|
end
|
@@ -44,11 +44,10 @@ module Fog
|
|
44
44
|
response.body = {
|
45
45
|
'requestId' => Fog::AWS::Mock.request_id
|
46
46
|
}.merge!(data)
|
47
|
+
response
|
47
48
|
else
|
48
|
-
|
49
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
49
|
+
raise Fog::AWS::EC2::Error.new("InvalidVolume.NotFound => The volume '#{volume_id}' does not exist.")
|
50
50
|
end
|
51
|
-
response
|
52
51
|
end
|
53
52
|
|
54
53
|
end
|
@@ -40,11 +40,10 @@ module Fog
|
|
40
40
|
'requestId' => Fog::AWS::Mock.request_id,
|
41
41
|
'return' => true
|
42
42
|
}
|
43
|
+
response
|
43
44
|
else
|
44
|
-
|
45
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
45
|
+
raise Fog::AWS::EC2::Error.new("AuthFailure => The address '#{public_ip}' does not belong to you.")
|
46
46
|
end
|
47
|
-
response
|
48
47
|
end
|
49
48
|
|
50
49
|
end
|
@@ -38,11 +38,10 @@ module Fog
|
|
38
38
|
'requestId' => Fog::AWS::Mock.request_id,
|
39
39
|
'timestamp' => Time.now
|
40
40
|
}
|
41
|
-
|
42
|
-
|
43
|
-
raise
|
41
|
+
response
|
42
|
+
else;
|
43
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID '#{instance_id}' does not exist")
|
44
44
|
end
|
45
|
-
response
|
46
45
|
end
|
47
46
|
|
48
47
|
end
|
@@ -38,11 +38,10 @@ module Fog
|
|
38
38
|
'requestId' => Fog::AWS::Mock.request_id,
|
39
39
|
'return' => true
|
40
40
|
}
|
41
|
+
response
|
41
42
|
else
|
42
|
-
|
43
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
43
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID #{instance_id.inspect} does not exist")
|
44
44
|
end
|
45
|
-
response
|
46
45
|
end
|
47
46
|
|
48
47
|
end
|
@@ -31,11 +31,10 @@ module Fog
|
|
31
31
|
'requestId' => Fog::AWS::Mock.request_id,
|
32
32
|
'return' => true
|
33
33
|
}
|
34
|
+
response
|
34
35
|
else
|
35
|
-
|
36
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
36
|
+
raise Fog::AWS::EC2::Error.new("AuthFailure => The address '#{public_ip}' does not belong to you.")
|
37
37
|
end
|
38
|
-
response
|
39
38
|
end
|
40
39
|
|
41
40
|
end
|
@@ -35,27 +35,36 @@ module Fog
|
|
35
35
|
class Mock
|
36
36
|
|
37
37
|
def revoke_security_group_ingress(options = {})
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
response = Excon::Response.new
|
39
|
+
group = @data[:security_groups][options['GroupName']]
|
40
|
+
if group
|
41
|
+
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
42
|
+
group['ipPermissions'].delete_if {|permission|
|
43
|
+
permission['groups'].first['groupName'] == options['GroupName']
|
44
|
+
}
|
45
|
+
else
|
46
|
+
ingress = group['ipPermissions'].select {|permission|
|
47
|
+
permission['fromPort'] == options['FromPort'] &&
|
48
|
+
permission['ipProtocol'] == options['IpProtocol'] &&
|
49
|
+
permission['toPort'] == options['ToPort'] &&
|
50
|
+
(
|
51
|
+
permission['ipRanges'].empty? ||
|
52
|
+
(
|
53
|
+
permission['ipRanges'].first &&
|
54
|
+
permission['ipRanges'].first['cidrIp'] == options['CidrIp']
|
55
|
+
)
|
56
|
+
)
|
57
|
+
}.first
|
58
|
+
group['ipPermissions'].delete(ingress)
|
59
|
+
end
|
53
60
|
response.status = 200
|
54
61
|
response.body = {
|
55
62
|
'requestId' => Fog::AWS::Mock.request_id,
|
56
63
|
'return' => true
|
57
64
|
}
|
58
65
|
response
|
66
|
+
else
|
67
|
+
raise Fog::AWS::EC2::Error.new("InvalidGroup.NotFound => The security group '#{options['GroupName']}' does not exist")
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
@@ -77,11 +77,11 @@ module Fog
|
|
77
77
|
detach_volume(volume['volumeId'])
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
81
|
+
response
|
80
82
|
else
|
81
|
-
|
82
|
-
raise(Excon::Errors.status_error({:expects => 200}, response))
|
83
|
+
raise Fog::AWS::EC2::Error.new("InvalidInstanceID.NotFound => The instance ID '#{instance_id}' does not exist")
|
83
84
|
end
|
84
|
-
response
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
@@ -43,6 +43,9 @@ module Fog
|
|
43
43
|
|
44
44
|
def put_object(bucket_name, object_name, data, options = {})
|
45
45
|
data = Fog::AWS::S3.parse_data(data)
|
46
|
+
unless data[:body].is_a?(String)
|
47
|
+
data[:body] = data[:body].read
|
48
|
+
end
|
46
49
|
response = Excon::Response.new
|
47
50
|
if (bucket = @data[:buckets][bucket_name])
|
48
51
|
response.status = 200
|
@@ -94,10 +94,10 @@ describe 'EC2.describe_instances' do
|
|
94
94
|
end
|
95
95
|
describe 'failure' do
|
96
96
|
|
97
|
-
it 'should raise a
|
97
|
+
it 'should raise a Fog::AWS::EC2::Error if the instance does not exist' do
|
98
98
|
lambda {
|
99
99
|
AWS[:ec2].describe_instances('i-00000000')
|
100
|
-
}.should raise_error(
|
100
|
+
}.should raise_error(Fog::AWS::EC2::Error)
|
101
101
|
end
|
102
102
|
|
103
103
|
end
|
@@ -25,10 +25,10 @@ describe 'EC2.get_console_output' do
|
|
25
25
|
end
|
26
26
|
describe 'failure' do
|
27
27
|
|
28
|
-
it "should raise a
|
28
|
+
it "should raise a Fog::AWS::EC2::Error if the instance does not exist" do
|
29
29
|
lambda {
|
30
30
|
AWS[:ec2].get_console_output('i-00000000')
|
31
|
-
}.should raise_error(
|
31
|
+
}.should raise_error(Fog::AWS::EC2::Error)
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -20,10 +20,10 @@ describe 'EC2.reboot_instances' do
|
|
20
20
|
end
|
21
21
|
describe 'failure' do
|
22
22
|
|
23
|
-
it "should raise a
|
23
|
+
it "should raise a Fog::AWS::EC2::Error if the instance does not exist" do
|
24
24
|
lambda {
|
25
25
|
AWS[:ec2].reboot_instances('i-00000000')
|
26
|
-
}.should raise_error(
|
26
|
+
}.should raise_error(Fog::AWS::EC2::Error)
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -25,10 +25,10 @@ describe 'EC2.terminate_instances' do
|
|
25
25
|
end
|
26
26
|
describe 'failure' do
|
27
27
|
|
28
|
-
it 'should raise a
|
28
|
+
it 'should raise a Fog::AWS::EC2::Error if the instance does not exist' do
|
29
29
|
lambda {
|
30
30
|
AWS[:ec2].terminate_instances('i-00000000')
|
31
|
-
}.should raise_error(
|
31
|
+
}.should raise_error(Fog::AWS::EC2::Error)
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -22,28 +22,12 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
|
|
22
22
|
AWS[:ec2].describe_addresses(@public_ip).body
|
23
23
|
end
|
24
24
|
|
25
|
-
tests("#associate_addresses('#{@server.identity}', '#{@public_Ip}')") do
|
26
|
-
|
27
|
-
formats(AWS::EC2::Formats::BASIC) do
|
28
|
-
AWS[:ec2].associate_address(@server.identity, @public_ip).body
|
29
|
-
end
|
30
|
-
|
31
|
-
tests('server.ip_address').returns(@public_ip) do
|
32
|
-
@server.reload.ip_address
|
33
|
-
end
|
34
|
-
|
25
|
+
tests("#associate_addresses('#{@server.identity}', '#{@public_Ip}')").formats(AWS::EC2::Formats::BASIC) do
|
26
|
+
AWS[:ec2].associate_address(@server.identity, @public_ip).body
|
35
27
|
end
|
36
28
|
|
37
|
-
tests("#dissassociate_address('#{@public_ip}')") do
|
38
|
-
|
39
|
-
formats(AWS::EC2::Formats::BASIC) do
|
40
|
-
AWS[:ec2].disassociate_address(@public_ip).body
|
41
|
-
end
|
42
|
-
|
43
|
-
test("server.ip_address is not #{@public_ip}") do
|
44
|
-
@server.reload.ip_address != @public_ip
|
45
|
-
end
|
46
|
-
|
29
|
+
tests("#dissassociate_address('#{@public_ip}')").formats(AWS::EC2::Formats::BASIC) do
|
30
|
+
AWS[:ec2].disassociate_address(@public_ip).body
|
47
31
|
end
|
48
32
|
|
49
33
|
tests("#release_address('#{@public_ip}')").formats(AWS::EC2::Formats::BASIC) do
|
@@ -55,23 +39,27 @@ Shindo.tests('AWS::EC2 | address requests', ['aws']) do
|
|
55
39
|
|
56
40
|
@address = AWS[:ec2].addresses.create
|
57
41
|
|
58
|
-
tests("#describe_addresses('127.0.0.1')").raises(
|
42
|
+
tests("#describe_addresses('127.0.0.1')").raises(Fog::AWS::EC2::Error) do
|
59
43
|
AWS[:ec2].describe_addresses('127.0.0.1')
|
60
44
|
end
|
61
45
|
|
62
|
-
tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(
|
46
|
+
tests("#associate_addresses('i-00000000', '#{@address.identity}')").raises(Fog::AWS::EC2::Error) do
|
63
47
|
AWS[:ec2].associate_address('i-00000000', @address.identity)
|
64
48
|
end
|
65
49
|
|
66
|
-
tests("#associate_addresses('#{@server.identity}', '127.0.0.1')").raises(
|
50
|
+
tests("#associate_addresses('#{@server.identity}', '127.0.0.1')").raises(Fog::AWS::EC2::Error) do
|
67
51
|
AWS[:ec2].associate_address(@server.identity, '127.0.0.1')
|
68
52
|
end
|
69
53
|
|
70
|
-
tests("#
|
54
|
+
tests("#associate_addresses('i-00000000', '127.0.0.1')").raises(Fog::AWS::EC2::Error) do
|
55
|
+
AWS[:ec2].associate_address('i-00000000', '127.0.0.1')
|
56
|
+
end
|
57
|
+
|
58
|
+
tests("#disassociate_addresses('127.0.0.1') raises BadRequest error").raises(Fog::AWS::EC2::Error) do
|
71
59
|
AWS[:ec2].disassociate_address('127.0.0.1')
|
72
60
|
end
|
73
61
|
|
74
|
-
tests("#release_address('127.0.0.1')").raises(
|
62
|
+
tests("#release_address('127.0.0.1')").raises(Fog::AWS::EC2::Error) do
|
75
63
|
AWS[:ec2].release_address('127.0.0.1')
|
76
64
|
end
|
77
65
|
|
@@ -14,7 +14,7 @@ Shindo.tests('AWS::EC2 | availability zone requests', ['aws']) do
|
|
14
14
|
|
15
15
|
tests('failure') do
|
16
16
|
|
17
|
-
tests("#describe_availability_zones('not-a-zone')").raises(
|
17
|
+
tests("#describe_availability_zones('not-a-zone')").raises(Fog::AWS::EC2::Error) do
|
18
18
|
AWS[:ec2].describe_availability_zones('not-a-zone')
|
19
19
|
end
|
20
20
|
|
@@ -29,11 +29,11 @@ Shindo.tests('AWS::EC2 | key pair requests', ['aws']) do
|
|
29
29
|
|
30
30
|
@key_pair = AWS[:ec2].key_pairs.create(:name => 'fog_key_pair')
|
31
31
|
|
32
|
-
tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(
|
32
|
+
tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(Fog::AWS::EC2::Error) do
|
33
33
|
AWS[:ec2].create_key_pair(@key_pair.name)
|
34
34
|
end
|
35
35
|
|
36
|
-
tests("#describe_key_pair('not_a_key_name')").raises(
|
36
|
+
tests("#describe_key_pair('not_a_key_name')").raises(Fog::AWS::EC2::Error) do
|
37
37
|
AWS[:ec2].describe_key_pairs('not_a_key_name').body
|
38
38
|
end
|
39
39
|
|
@@ -14,7 +14,7 @@ Shindo.tests('AWS::EC2 | region requests', ['aws']) do
|
|
14
14
|
|
15
15
|
tests('failure') do
|
16
16
|
|
17
|
-
tests("#describe_regions('not-a-region')").raises(
|
17
|
+
tests("#describe_regions('not-a-region')").raises(Fog::AWS::EC2::Error) do
|
18
18
|
AWS[:ec2].describe_regions('not-a-region')
|
19
19
|
end
|
20
20
|
end
|
@@ -59,11 +59,11 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
|
|
59
59
|
|
60
60
|
@security_group = AWS[:ec2].security_groups.create(:description => 'tests group', :name => 'fog_security_group')
|
61
61
|
|
62
|
-
tests("duplicate #create_security_group(#{@security_group.name}, #{@security_group.description})").raises(
|
62
|
+
tests("duplicate #create_security_group(#{@security_group.name}, #{@security_group.description})").raises(Fog::AWS::EC2::Error) do
|
63
63
|
AWS[:ec2].create_security_group(@security_group.name, @security_group.description)
|
64
64
|
end
|
65
65
|
|
66
|
-
tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(
|
66
|
+
tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::EC2::Error) do
|
67
67
|
AWS[:ec2].authorize_security_group_ingress({
|
68
68
|
'FromPort' => 80,
|
69
69
|
'GroupName' => 'not_a_group_name',
|
@@ -72,7 +72,7 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
|
|
72
72
|
})
|
73
73
|
end
|
74
74
|
|
75
|
-
tests("#authorize_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(
|
75
|
+
tests("#authorize_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::EC2::Error) do
|
76
76
|
AWS[:ec2].authorize_security_group_ingress({
|
77
77
|
'GroupName' => 'not_a_group_name',
|
78
78
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
@@ -80,11 +80,11 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
|
|
80
80
|
})
|
81
81
|
end
|
82
82
|
|
83
|
-
tests("#describe_security_group('not_a_group_name)").raises(
|
83
|
+
tests("#describe_security_group('not_a_group_name)").raises(Fog::AWS::EC2::Error) do
|
84
84
|
AWS[:ec2].describe_security_groups('not_a_group_name')
|
85
85
|
end
|
86
86
|
|
87
|
-
tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(
|
87
|
+
tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Fog::AWS::EC2::Error) do
|
88
88
|
AWS[:ec2].revoke_security_group_ingress({
|
89
89
|
'FromPort' => 80,
|
90
90
|
'GroupName' => 'not_a_group_name',
|
@@ -93,7 +93,7 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
|
|
93
93
|
})
|
94
94
|
end
|
95
95
|
|
96
|
-
tests("#revoke_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(
|
96
|
+
tests("#revoke_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Fog::AWS::EC2::Error) do
|
97
97
|
AWS[:ec2].revoke_security_group_ingress({
|
98
98
|
'GroupName' => 'not_a_group_name',
|
99
99
|
'SourceSecurityGroupName' => 'not_a_group_name',
|
@@ -101,7 +101,7 @@ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
|
|
101
101
|
})
|
102
102
|
end
|
103
103
|
|
104
|
-
tests("#delete_security_group('not_a_group_name')").raises(
|
104
|
+
tests("#delete_security_group('not_a_group_name')").raises(Fog::AWS::EC2::Error) do
|
105
105
|
AWS[:ec2].delete_security_group('not_a_group_name')
|
106
106
|
end
|
107
107
|
|
@@ -28,11 +28,11 @@ Shindo.tests('AWS::EC2 | snapshot requests', ['aws']) do
|
|
28
28
|
end
|
29
29
|
tests ('failure') do
|
30
30
|
|
31
|
-
tests("#describe_snapshot('snap-00000000')").raises(
|
31
|
+
tests("#describe_snapshot('snap-00000000')").raises(Fog::AWS::EC2::Error) do
|
32
32
|
AWS[:ec2].describe_snapshots('snap-00000000')
|
33
33
|
end
|
34
34
|
|
35
|
-
tests("#delete_snapshot('snap-00000000')").raises(
|
35
|
+
tests("#delete_snapshot('snap-00000000')").raises(Fog::AWS::EC2::Error) do
|
36
36
|
AWS[:ec2].delete_snapshot('snap-00000000')
|
37
37
|
end
|
38
38
|
|
@@ -41,23 +41,23 @@ Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
|
|
41
41
|
|
42
42
|
@volume = AWS[:ec2].volumes.create(:availability_zone => @server.availability_zone, :size => 1)
|
43
43
|
|
44
|
-
tests("#describe_volume('vol-00000000')").raises(
|
44
|
+
tests("#describe_volume('vol-00000000')").raises(Fog::AWS::EC2::Error) do
|
45
45
|
AWS[:ec2].describe_volumes('vol-00000000')
|
46
46
|
end
|
47
47
|
|
48
|
-
tests("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh')").raises(
|
48
|
+
tests("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh')").raises(Fog::AWS::EC2::Error) do
|
49
49
|
AWS[:ec2].attach_volume('i-00000000', @volume.identity, '/dev/sdh')
|
50
50
|
end
|
51
51
|
|
52
|
-
tests("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh')").raises(
|
52
|
+
tests("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh')").raises(Fog::AWS::EC2::Error) do
|
53
53
|
AWS[:ec2].attach_volume(@server.identity, 'vol-00000000', '/dev/sdh')
|
54
54
|
end
|
55
55
|
|
56
|
-
tests("#detach_volume('vol-00000000')").raises(
|
56
|
+
tests("#detach_volume('vol-00000000')").raises(Fog::AWS::EC2::Error) do
|
57
57
|
AWS[:ec2].detach_volume('vol-00000000')
|
58
58
|
end
|
59
59
|
|
60
|
-
tests("#delete_volume('vol-00000000')").raises(
|
60
|
+
tests("#delete_volume('vol-00000000')").raises(Fog::AWS::EC2::Error) do
|
61
61
|
AWS[:ec2].delete_volume('vol-00000000')
|
62
62
|
end
|
63
63
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-26 00:00:00 -07:00
|
18
18
|
default_executable: fog
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|