fog 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +79 -2
- data/VERSION +1 -1
- data/fog.gemspec +28 -6
- data/lib/fog.rb +10 -7
- data/lib/fog/aws.rb +35 -9
- data/lib/fog/aws/ec2.rb +82 -69
- data/lib/fog/aws/models/ec2/address.rb +23 -1
- data/lib/fog/aws/models/ec2/addresses.rb +26 -2
- data/lib/fog/aws/models/ec2/instance.rb +135 -0
- data/lib/fog/aws/models/ec2/instances.rb +56 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +17 -2
- data/lib/fog/aws/models/ec2/key_pairs.rb +29 -3
- data/lib/fog/aws/models/ec2/security_group.rb +41 -0
- data/lib/fog/aws/models/ec2/security_groups.rb +62 -0
- data/lib/fog/aws/models/ec2/snapshot.rb +12 -12
- data/lib/fog/aws/models/ec2/snapshots.rb +43 -21
- data/lib/fog/aws/models/ec2/volume.rb +21 -10
- data/lib/fog/aws/models/ec2/volumes.rb +30 -4
- data/lib/fog/aws/models/s3/buckets.rb +5 -8
- data/lib/fog/aws/models/s3/objects.rb +4 -7
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +63 -27
- data/lib/fog/aws/requests/ec2/create_security_group.rb +3 -3
- data/lib/fog/aws/requests/ec2/describe_images.rb +65 -35
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +52 -21
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +52 -19
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +63 -27
- data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +14 -10
- data/lib/fog/aws/s3.rb +31 -35
- data/lib/fog/aws/simpledb.rb +19 -22
- data/lib/fog/collection.rb +3 -3
- data/lib/fog/connection.rb +2 -2
- data/lib/fog/errors.rb +1 -1
- data/lib/fog/model.rb +3 -3
- data/spec/aws/models/ec2/address_spec.rb +84 -0
- data/spec/aws/models/ec2/addresses_spec.rb +70 -0
- data/spec/aws/models/ec2/key_pair_spec.rb +84 -0
- data/spec/aws/models/ec2/key_pairs_spec.rb +71 -0
- data/spec/aws/models/ec2/security_group_spec.rb +84 -0
- data/spec/aws/models/ec2/security_groups_spec.rb +71 -0
- data/spec/aws/models/ec2/snapshot_spec.rb +93 -0
- data/spec/aws/models/ec2/snapshots_spec.rb +74 -0
- data/spec/aws/models/ec2/volume_spec.rb +84 -0
- data/spec/aws/models/ec2/volumes_spec.rb +70 -0
- data/spec/aws/models/s3/bucket_spec.rb +0 -1
- data/spec/aws/models/s3/buckets_spec.rb +2 -11
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +1 -1
- data/spec/aws/requests/ec2/get_console_output_spec.rb +9 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +11 -2
- data/spec/aws/requests/ec2/run_instances_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -4
- data/LICENSE +0 -20
@@ -70,6 +70,8 @@ else
|
|
70
70
|
if Time.now - instance['launchTime'] > 2
|
71
71
|
instance['instanceState'] = { :code => 16, :name => 'running' }
|
72
72
|
end
|
73
|
+
when 'rebooting'
|
74
|
+
instance['instanceState'] = { :code => 16, :name => 'running' }
|
73
75
|
when 'shutting-down'
|
74
76
|
if Time.now - Fog::AWS::EC2.data[:deleted_at][instance['instanceId']] > 2
|
75
77
|
instance['instanceState'] = { :code => 16, :name => 'terminating' }
|
@@ -1,26 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Retrieve console output for specified instance
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * instance_id<~String> - Id of instance to get console output from
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# # * response<~Fog::AWS::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'instanceId'<~String> - Id of instance
|
16
|
+
# * 'output'<~String> - Console output
|
17
|
+
# * 'requestId'<~String> - Id of request
|
18
|
+
# * 'timestamp'<~Time> - Timestamp of last update to output
|
19
|
+
def get_console_output(instance_id)
|
20
|
+
request({
|
21
|
+
'Action' => 'GetConsoleOutput',
|
22
|
+
'InstanceId' => instance_id
|
23
|
+
}, Fog::Parsers::AWS::EC2::GetConsoleOutput.new)
|
24
|
+
end
|
25
|
+
|
22
26
|
end
|
27
|
+
end
|
28
|
+
end
|
23
29
|
|
30
|
+
else
|
31
|
+
|
32
|
+
module Fog
|
33
|
+
module AWS
|
34
|
+
class EC2
|
35
|
+
|
36
|
+
def get_console_output(instance_id)
|
37
|
+
response = Fog::Response.new
|
38
|
+
if instance = Fog::AWS::EC2.data[:instances][instance_id]
|
39
|
+
response.status = 200
|
40
|
+
response.body = {
|
41
|
+
'instanceId' => instance_id,
|
42
|
+
'output' => Fog::AWS::Mock.console_output,
|
43
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
44
|
+
'timestamp' => Time.now
|
45
|
+
}
|
46
|
+
else
|
47
|
+
response.status = 400
|
48
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
49
|
+
end
|
50
|
+
response
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
24
54
|
end
|
25
55
|
end
|
56
|
+
|
26
57
|
end
|
@@ -1,24 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Reboot specified instances
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * instance_id<~Array> - Ids of instances to reboot
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# # * response<~Fog::AWS::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - success?
|
17
|
+
def reboot_instances(instance_id = [])
|
18
|
+
params = indexed_params('InstanceId', instance_id)
|
19
|
+
request({
|
20
|
+
'Action' => 'RebootInstances'
|
21
|
+
}.merge!(params), Fog::Parsers::AWS::EC2::Basic.new)
|
22
|
+
end
|
23
|
+
|
20
24
|
end
|
25
|
+
end
|
26
|
+
end
|
21
27
|
|
28
|
+
else
|
29
|
+
|
30
|
+
module Fog
|
31
|
+
module AWS
|
32
|
+
class EC2
|
33
|
+
|
34
|
+
def reboot_instances(instance_id = [])
|
35
|
+
response = Fog::Response.new
|
36
|
+
instance_id = [*instance_id]
|
37
|
+
if (Fog::AWS::EC2.data[:instances].keys & instance_id).length == instance_id.length
|
38
|
+
for instance_id in instance_id
|
39
|
+
Fog::AWS::EC2.data[:instances][instance_id]['status'] = 'rebooting'
|
40
|
+
end
|
41
|
+
response.status = 200
|
42
|
+
response.body = {
|
43
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
44
|
+
'return' => true
|
45
|
+
}
|
46
|
+
else
|
47
|
+
response.status = 400
|
48
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
49
|
+
end
|
50
|
+
response
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
22
54
|
end
|
23
55
|
end
|
56
|
+
|
24
57
|
end
|
@@ -1,32 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Remove permissions from a security group
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * options<~Hash>:
|
11
|
+
# * 'GroupName'<~String> - Name of group
|
12
|
+
# * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
|
13
|
+
# * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
|
14
|
+
# or
|
15
|
+
# * 'CidrIp' - CIDR range
|
16
|
+
# * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
|
17
|
+
# * 'GroupName' - Name of group to modify
|
18
|
+
# * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
|
19
|
+
# * 'ToPort' - End of port range (or -1 for ICMP wildcard)
|
20
|
+
#
|
21
|
+
# === Returns
|
22
|
+
# * response<~Fog::AWS::Response>:
|
23
|
+
# * body<~Hash>:
|
24
|
+
# * 'requestId'<~String> - Id of request
|
25
|
+
# * 'return'<~Boolean> - success?
|
26
|
+
def revoke_security_group_ingress(options = {})
|
27
|
+
request({
|
28
|
+
'Action' => 'RevokeSecurityGroupIngress'
|
29
|
+
}.merge!(options), Fog::Parsers::AWS::EC2::Basic.new)
|
30
|
+
end
|
31
|
+
|
28
32
|
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
else
|
37
|
+
|
38
|
+
module Fog
|
39
|
+
module AWS
|
40
|
+
class EC2
|
29
41
|
|
42
|
+
# TODO: handle the GroupName/Source/Source case
|
43
|
+
def revoke_security_group_ingress(options = {})
|
44
|
+
response = Fog::Response.new
|
45
|
+
group = Fog::AWS::EC2.data[:security_groups][options['GroupName']]
|
46
|
+
|
47
|
+
ingress = group['ipPermissions'].select {|permission|
|
48
|
+
permission['fromPort'] == options['FromPort'] &&
|
49
|
+
permission['ipProtocol'] == options['IpProtocol'] &&
|
50
|
+
permission['toPort'] == options['ToPort'] &&
|
51
|
+
permission['ipRanges'].first['cidrIp'] == options['CidrIp']
|
52
|
+
}.first
|
53
|
+
|
54
|
+
group['ipPermissions'].delete(ingress)
|
55
|
+
|
56
|
+
response.status = 200
|
57
|
+
response.body = {
|
58
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
59
|
+
'return' => true
|
60
|
+
}
|
61
|
+
response
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
30
65
|
end
|
31
66
|
end
|
67
|
+
|
32
68
|
end
|
@@ -21,7 +21,7 @@ unless Fog.mocking?
|
|
21
21
|
# * 'Placement.AvailabilityZone'<~String> - Placement constraint for instances
|
22
22
|
# * 'DeviceName'<~String> - ?
|
23
23
|
# * 'Encoding'<~String> - ?
|
24
|
-
# * '
|
24
|
+
# * 'groupId'<~String> - Name of security group for instances
|
25
25
|
# * 'InstanceType'<~String> - Type of instance to boot. Valid options
|
26
26
|
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
|
27
27
|
# default is 'm1.small'
|
@@ -39,17 +39,19 @@ else
|
|
39
39
|
class EC2
|
40
40
|
|
41
41
|
def terminate_instances(instance_id)
|
42
|
-
instance_id = [*instance_id]
|
43
42
|
response = Fog::Response.new
|
44
|
-
instance_id
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
instance_id = [*instance_id]
|
44
|
+
if (Fog::AWS::EC2.data[:instances].keys & instance_id).length == instance_id.length
|
45
|
+
for instance_id in instance_id
|
46
|
+
response.body = {
|
47
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
48
|
+
'instancesSet' => []
|
49
|
+
}
|
50
|
+
instance = Fog::AWS::EC2.data[:instances][instance_id]
|
50
51
|
Fog::AWS::EC2.data[:deleted_at][instance_id] = Time.now
|
51
52
|
instance['status'] = 'deleting'
|
52
53
|
response.status = 200
|
54
|
+
# TODO: the codes are mostly educated guessing, not certainty
|
53
55
|
code = case instance['state']
|
54
56
|
when 'pending'
|
55
57
|
0
|
@@ -59,16 +61,18 @@ else
|
|
59
61
|
32
|
60
62
|
when 'terminated'
|
61
63
|
64
|
64
|
+
when 'rebooting'
|
65
|
+
128
|
62
66
|
end
|
63
67
|
response.body['instancesSet'] << {
|
64
68
|
'instanceId' => instance_id,
|
65
69
|
'previousState' => { 'name' => instance['state'], 'code' => code },
|
66
70
|
'shutdownState' => { 'name' => 'shutting-down', 'code' => 32}
|
67
71
|
}
|
68
|
-
else
|
69
|
-
response.status = 400
|
70
|
-
raise(Fog::Errors.status_error(200, 400, response))
|
71
72
|
end
|
73
|
+
else
|
74
|
+
response.status = 400
|
75
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
72
76
|
end
|
73
77
|
response
|
74
78
|
end
|
data/lib/fog/aws/s3.rb
CHANGED
@@ -12,40 +12,36 @@ module Fog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.reload
|
15
|
-
|
16
|
-
load "
|
17
|
-
load "
|
18
|
-
load "
|
19
|
-
load "
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
load "
|
24
|
-
load "
|
25
|
-
load "
|
26
|
-
|
27
|
-
load "
|
28
|
-
|
29
|
-
|
30
|
-
load "
|
31
|
-
load "
|
32
|
-
|
33
|
-
load "
|
34
|
-
load "
|
35
|
-
|
36
|
-
|
37
|
-
load "
|
38
|
-
load "
|
39
|
-
load "
|
40
|
-
load "
|
41
|
-
load "
|
42
|
-
load "
|
43
|
-
load "
|
44
|
-
load "
|
45
|
-
load "#{requests_directory}/head_object.rb"
|
46
|
-
load "#{requests_directory}/put_bucket.rb"
|
47
|
-
load "#{requests_directory}/put_object.rb"
|
48
|
-
load "#{requests_directory}/put_request_payment.rb"
|
15
|
+
load "fog/collection.rb"
|
16
|
+
load "fog/connection.rb"
|
17
|
+
load "fog/model.rb"
|
18
|
+
load "fog/parser.rb"
|
19
|
+
load "fog/response.rb"
|
20
|
+
|
21
|
+
load "fog/aws/models/s3/bucket.rb"
|
22
|
+
load "fog/aws/models/s3/buckets.rb"
|
23
|
+
load "fog/aws/models/s3/object.rb"
|
24
|
+
load "fog/aws/models/s3/objects.rb"
|
25
|
+
load "fog/aws/models/s3/owner.rb"
|
26
|
+
|
27
|
+
load "fog/aws/parsers/s3/copy_object.rb"
|
28
|
+
load "fog/aws/parsers/s3/get_bucket.rb"
|
29
|
+
load "fog/aws/parsers/s3/get_bucket_location.rb"
|
30
|
+
load "fog/aws/parsers/s3/get_request_payment.rb"
|
31
|
+
load "fog/aws/parsers/s3/get_service.rb"
|
32
|
+
|
33
|
+
load "fog/aws/requests/s3/copy_object.rb"
|
34
|
+
load "fog/aws/requests/s3/delete_bucket.rb"
|
35
|
+
load "fog/aws/requests/s3/delete_object.rb"
|
36
|
+
load "fog/aws/requests/s3/get_bucket.rb"
|
37
|
+
load "fog/aws/requests/s3/get_bucket_location.rb"
|
38
|
+
load "fog/aws/requests/s3/get_object.rb"
|
39
|
+
load "fog/aws/requests/s3/get_request_payment.rb"
|
40
|
+
load "fog/aws/requests/s3/get_service.rb"
|
41
|
+
load "fog/aws/requests/s3/head_object.rb"
|
42
|
+
load "fog/aws/requests/s3/put_bucket.rb"
|
43
|
+
load "fog/aws/requests/s3/put_object.rb"
|
44
|
+
load "fog/aws/requests/s3/put_request_payment.rb"
|
49
45
|
|
50
46
|
if Fog.mocking?
|
51
47
|
reset_data
|
@@ -134,7 +130,7 @@ DATA
|
|
134
130
|
if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
|
135
131
|
canonical_resource << "?#{params[:query]}"
|
136
132
|
end
|
137
|
-
string_to_sign << "#{canonical_resource}"
|
133
|
+
string_to_sign << "#{canonical_resource}".downcase
|
138
134
|
|
139
135
|
hmac = @hmac.update(string_to_sign)
|
140
136
|
signature = Base64.encode64(hmac.digest).chomp!
|
data/lib/fog/aws/simpledb.rb
CHANGED
@@ -12,28 +12,25 @@ module Fog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.reload
|
15
|
-
|
16
|
-
load "
|
17
|
-
load "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
load "
|
22
|
-
load "
|
23
|
-
load "
|
24
|
-
|
25
|
-
load "
|
26
|
-
|
27
|
-
|
28
|
-
load "
|
29
|
-
load "
|
30
|
-
load "
|
31
|
-
load "
|
32
|
-
load "
|
33
|
-
load "
|
34
|
-
load "#{requests_directory}/list_domains.rb"
|
35
|
-
load "#{requests_directory}/put_attributes.rb"
|
36
|
-
load "#{requests_directory}/select.rb"
|
15
|
+
load "fog/connection.rb"
|
16
|
+
load "fog/parser.rb"
|
17
|
+
load "fog/response.rb"
|
18
|
+
|
19
|
+
load "fog/aws/parsers/simpledb/basic.rb"
|
20
|
+
load "fog/aws/parsers/simpledb/domain_metadata.rb"
|
21
|
+
load "fog/aws/parsers/simpledb/get_attributes.rb"
|
22
|
+
load "fog/aws/parsers/simpledb/list_domains.rb"
|
23
|
+
load "fog/aws/parsers/simpledb/select.rb"
|
24
|
+
|
25
|
+
load "fog/aws/requests/simpledb/batch_put_attributes.rb"
|
26
|
+
load "fog/aws/requests/simpledb/create_domain.rb"
|
27
|
+
load "fog/aws/requests/simpledb/delete_attributes.rb"
|
28
|
+
load "fog/aws/requests/simpledb/delete_domain.rb"
|
29
|
+
load "fog/aws/requests/simpledb/domain_metadata.rb"
|
30
|
+
load "fog/aws/requests/simpledb/get_attributes.rb"
|
31
|
+
load "fog/aws/requests/simpledb/list_domains.rb"
|
32
|
+
load "fog/aws/requests/simpledb/put_attributes.rb"
|
33
|
+
load "fog/aws/requests/simpledb/select.rb"
|
37
34
|
|
38
35
|
if Fog.mocking?
|
39
36
|
reset_data
|