fog 0.0.3
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/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +135 -0
- data/benchs/headers_split_vs_match.rb +18 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +60 -0
- data/benchs/stripping.rb +26 -0
- data/lib/fog.rb +21 -0
- data/lib/fog/aws.rb +145 -0
- data/lib/fog/aws/ec2.rb +173 -0
- data/lib/fog/aws/models/ec2/address.rb +31 -0
- data/lib/fog/aws/models/ec2/addresses.rb +36 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +35 -0
- data/lib/fog/aws/models/ec2/key_pairs.rb +36 -0
- data/lib/fog/aws/models/ec2/volume.rb +47 -0
- data/lib/fog/aws/models/ec2/volumes.rb +36 -0
- data/lib/fog/aws/models/s3/bucket.rb +77 -0
- data/lib/fog/aws/models/s3/buckets.rb +83 -0
- data/lib/fog/aws/models/s3/object.rb +76 -0
- data/lib/fog/aws/models/s3/objects.rb +97 -0
- data/lib/fog/aws/models/s3/owner.rb +18 -0
- data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
- data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
- data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
- data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
- data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
- data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
- data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
- data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
- data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
- data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
- data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
- data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
- data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
- data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
- data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
- data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
- data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
- data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +59 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +71 -0
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
- data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +65 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +53 -0
- data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +64 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +114 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +78 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +62 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +55 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
- data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +134 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +80 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +79 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +53 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +100 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +82 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
- data/lib/fog/aws/requests/s3/get_service.rb +58 -0
- data/lib/fog/aws/requests/s3/head_object.rb +61 -0
- data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
- data/lib/fog/aws/requests/s3/put_object.rb +76 -0
- data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
- data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
- data/lib/fog/aws/requests/simpledb/select.rb +29 -0
- data/lib/fog/aws/s3.rb +157 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/collection.rb +77 -0
- data/lib/fog/connection.rb +130 -0
- data/lib/fog/errors.rb +145 -0
- data/lib/fog/model.rb +72 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/spec/aws/models/s3/bucket_spec.rb +130 -0
- data/spec/aws/models/s3/buckets_spec.rb +79 -0
- data/spec/aws/models/s3/object_spec.rb +121 -0
- data/spec/aws/models/s3/objects_spec.rb +112 -0
- data/spec/aws/models/s3/owner_spec.rb +18 -0
- data/spec/aws/requests/ec2/allocate_address_spec.rb +18 -0
- data/spec/aws/requests/ec2/associate_address_spec.rb +42 -0
- data/spec/aws/requests/ec2/attach_volume_spec.rb +53 -0
- data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +26 -0
- data/spec/aws/requests/ec2/create_key_pair_spec.rb +36 -0
- data/spec/aws/requests/ec2/create_security_group_spec.rb +34 -0
- data/spec/aws/requests/ec2/create_snapshot_spec.rb +37 -0
- data/spec/aws/requests/ec2/create_volume_spec.rb +23 -0
- data/spec/aws/requests/ec2/delete_key_pair_spec.rb +21 -0
- data/spec/aws/requests/ec2/delete_security_group_spec.rb +26 -0
- data/spec/aws/requests/ec2/delete_snapshot_spec.rb +35 -0
- data/spec/aws/requests/ec2/delete_volume_spec.rb +26 -0
- data/spec/aws/requests/ec2/describe_addresses_spec.rb +38 -0
- data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +23 -0
- data/spec/aws/requests/ec2/describe_images_spec.rb +39 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +86 -0
- data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +42 -0
- data/spec/aws/requests/ec2/describe_regions_spec.rb +21 -0
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +51 -0
- data/spec/aws/requests/ec2/describe_snapshots_spec.rb +54 -0
- data/spec/aws/requests/ec2/describe_volumes_spec.rb +50 -0
- data/spec/aws/requests/ec2/detach_volume_spec.rb +43 -0
- data/spec/aws/requests/ec2/disassociate_address_spec.rb +35 -0
- data/spec/aws/requests/ec2/get_console_output_spec.rb +23 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +21 -0
- data/spec/aws/requests/ec2/release_address_spec.rb +26 -0
- data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +32 -0
- data/spec/aws/requests/ec2/run_instances_spec.rb +41 -0
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +35 -0
- data/spec/aws/requests/s3/copy_object_spec.rb +62 -0
- data/spec/aws/requests/s3/delete_bucket_spec.rb +36 -0
- data/spec/aws/requests/s3/delete_object_spec.rb +37 -0
- data/spec/aws/requests/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/requests/s3/get_bucket_spec.rb +110 -0
- data/spec/aws/requests/s3/get_object_spec.rb +45 -0
- data/spec/aws/requests/s3/get_request_payment_spec.rb +30 -0
- data/spec/aws/requests/s3/get_service_spec.rb +33 -0
- data/spec/aws/requests/s3/head_object_spec.rb +28 -0
- data/spec/aws/requests/s3/put_bucket_spec.rb +19 -0
- data/spec/aws/requests/s3/put_object_spec.rb +38 -0
- data/spec/aws/requests/s3/put_request_payment_spec.rb +29 -0
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/create_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +43 -0
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +31 -0
- data/spec/aws/requests/simpledb/list_domains_spec.rb +30 -0
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/select_spec.rb +9 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +309 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Parsers
|
|
3
|
+
module AWS
|
|
4
|
+
module SimpleDB
|
|
5
|
+
|
|
6
|
+
class GetAttributes < Fog::Parsers::AWS::SimpleDB::Basic
|
|
7
|
+
|
|
8
|
+
def reset
|
|
9
|
+
@attribute = nil
|
|
10
|
+
@response = { 'Attributes' => {} }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def end_element(name)
|
|
14
|
+
case name
|
|
15
|
+
when 'Attribute'
|
|
16
|
+
@attribute = nil
|
|
17
|
+
when 'BoxUsage'
|
|
18
|
+
response[name] = @value.to_f
|
|
19
|
+
when 'Name'
|
|
20
|
+
@attribute = @value
|
|
21
|
+
response['Attributes'][@attribute] = []
|
|
22
|
+
when 'RequestId'
|
|
23
|
+
response[name] = @value
|
|
24
|
+
when 'Value'
|
|
25
|
+
response['Attributes'][@attribute] << sdb_decode(@value)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Parsers
|
|
3
|
+
module AWS
|
|
4
|
+
module SimpleDB
|
|
5
|
+
|
|
6
|
+
class ListDomains < Fog::Parsers::AWS::SimpleDB::Basic
|
|
7
|
+
|
|
8
|
+
def reset
|
|
9
|
+
@response = { 'Domains' => [] }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def end_element(name)
|
|
13
|
+
case(name)
|
|
14
|
+
when 'BoxUsage'
|
|
15
|
+
response[name] = @value.to_f
|
|
16
|
+
when 'DomainName'
|
|
17
|
+
response['Domains'] << @value
|
|
18
|
+
when 'NextToken', 'RequestId'
|
|
19
|
+
response[name] = @value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Parsers
|
|
3
|
+
module AWS
|
|
4
|
+
module SimpleDB
|
|
5
|
+
|
|
6
|
+
class Select < Fog::Parsers::AWS::SimpleDB::Basic
|
|
7
|
+
|
|
8
|
+
def reset
|
|
9
|
+
@item_name = @attribute_name = nil
|
|
10
|
+
@response = { 'Items' => {} }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def end_element(name)
|
|
14
|
+
case name
|
|
15
|
+
when 'BoxUsage'
|
|
16
|
+
response[name] = @value.to_f
|
|
17
|
+
when 'Item'
|
|
18
|
+
@item_name = @attribute_name = nil
|
|
19
|
+
when 'Name'
|
|
20
|
+
if @item_name.nil?
|
|
21
|
+
@item_name = @value
|
|
22
|
+
response['Items'][@item_name] = {}
|
|
23
|
+
else
|
|
24
|
+
@attribute_name = @value
|
|
25
|
+
response['Items'][@item_name][@attribute_name] = []
|
|
26
|
+
end
|
|
27
|
+
when 'NextToken', 'RequestId'
|
|
28
|
+
response[name] = @value
|
|
29
|
+
when 'Value'
|
|
30
|
+
response['Items'][@item_name][@attribute_name] << sdb_decode(@value)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Acquire an elastic IP address.
|
|
8
|
+
#
|
|
9
|
+
# ==== Returns
|
|
10
|
+
# * response<~Fog::AWS::Response>:
|
|
11
|
+
# * body<~Hash>:
|
|
12
|
+
# * 'publicIp'<~String> - The acquired address
|
|
13
|
+
# * 'requestId'<~String> - Id of the request
|
|
14
|
+
def allocate_address
|
|
15
|
+
request({
|
|
16
|
+
'Action' => 'AllocateAddress'
|
|
17
|
+
}, Fog::Parsers::AWS::EC2::AllocateAddress.new)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
else
|
|
25
|
+
|
|
26
|
+
module Fog
|
|
27
|
+
module AWS
|
|
28
|
+
class EC2
|
|
29
|
+
|
|
30
|
+
def allocate_address
|
|
31
|
+
response = Fog::Response.new
|
|
32
|
+
response.status = 200
|
|
33
|
+
public_ip = Fog::AWS::Mock.ip_address
|
|
34
|
+
data ={
|
|
35
|
+
'instanceId' => '',
|
|
36
|
+
'publicIp' => public_ip
|
|
37
|
+
}
|
|
38
|
+
Fog::AWS::EC2.data[:addresses][public_ip] = data
|
|
39
|
+
response.body = {
|
|
40
|
+
'publicIp' => public_ip,
|
|
41
|
+
'requestId' => Fog::AWS::Mock.request_id
|
|
42
|
+
}
|
|
43
|
+
response
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Associate an elastic IP address with an instance
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * instance_id<~String> - Id of instance to associate address with
|
|
11
|
+
# * public_ip<~String> - Public ip to assign to instance
|
|
12
|
+
#
|
|
13
|
+
# ==== Returns
|
|
14
|
+
# * response<~Fog::AWS::Response>:
|
|
15
|
+
# * body<~Hash>:
|
|
16
|
+
# * 'requestId'<~String> - Id of request
|
|
17
|
+
# * 'return'<~Boolean> - success?
|
|
18
|
+
def associate_address(instance_id, public_ip)
|
|
19
|
+
request({
|
|
20
|
+
'Action' => 'AssociateAddress',
|
|
21
|
+
'InstanceId' => instance_id,
|
|
22
|
+
'PublicIp' => public_ip
|
|
23
|
+
}, Fog::Parsers::AWS::EC2::Basic.new)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
else
|
|
31
|
+
|
|
32
|
+
module Fog
|
|
33
|
+
module AWS
|
|
34
|
+
class EC2
|
|
35
|
+
|
|
36
|
+
def associate_address(instance_id, public_ip)
|
|
37
|
+
response = Fog::Response.new
|
|
38
|
+
response.status = 200
|
|
39
|
+
instance = Fog::AWS::EC2.data[:instances][instance_id]
|
|
40
|
+
address = Fog::AWS::EC2.data[:addresses][public_ip]
|
|
41
|
+
if instance && address
|
|
42
|
+
address['instanceId'] = instance_id
|
|
43
|
+
response.status = 200
|
|
44
|
+
response.body = {
|
|
45
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
|
46
|
+
'return' => true
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
response.status = 400
|
|
50
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
|
51
|
+
end
|
|
52
|
+
response
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Attach an Amazon EBS volume with a running instance, exposing as specified device
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * instance_id<~String> - Id of instance to associate volume with
|
|
11
|
+
# * volume_id<~String> - Id of amazon EBS volume to associate with instance
|
|
12
|
+
# * device<~String> - Specifies how the device is exposed to the instance (e.g. "/dev/sdh")
|
|
13
|
+
#
|
|
14
|
+
# ==== Returns
|
|
15
|
+
# * response<~Fog::AWS::Response>:
|
|
16
|
+
# * body<~Hash>:
|
|
17
|
+
# * 'attachTime'<~Time> - Time of attachment was initiated at
|
|
18
|
+
# * 'device'<~String> - Device as it is exposed to the instance
|
|
19
|
+
# * 'instanceId'<~String> - Id of instance for volume
|
|
20
|
+
# * 'requestId'<~String> - Id of request
|
|
21
|
+
# * 'status'<~String> - Status of volume
|
|
22
|
+
# * 'volumeId'<~String> - Reference to volume
|
|
23
|
+
def attach_volume(instance_id, volume_id, device)
|
|
24
|
+
request({
|
|
25
|
+
'Action' => 'AttachVolume',
|
|
26
|
+
'VolumeId' => volume_id,
|
|
27
|
+
'InstanceId' => instance_id,
|
|
28
|
+
'Device' => device
|
|
29
|
+
}, Fog::Parsers::AWS::EC2::AttachVolume.new)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
else
|
|
37
|
+
|
|
38
|
+
module Fog
|
|
39
|
+
module AWS
|
|
40
|
+
class EC2
|
|
41
|
+
|
|
42
|
+
def attach_volume(instance_id, volume_id, device)
|
|
43
|
+
response = Fog::Response.new
|
|
44
|
+
response.status = 200
|
|
45
|
+
instance = Fog::AWS::EC2.data[:instances][instance_id]
|
|
46
|
+
volume = Fog::AWS::EC2.data[:volumes][volume_id]
|
|
47
|
+
if instance && volume
|
|
48
|
+
data = {
|
|
49
|
+
'attachTime' => Time.now,
|
|
50
|
+
'device' => device,
|
|
51
|
+
'instanceId' => instance_id,
|
|
52
|
+
'status' => 'attaching',
|
|
53
|
+
'volumeId' => volume_id
|
|
54
|
+
}
|
|
55
|
+
volume['attachmentSet'] << data
|
|
56
|
+
response.status = 200
|
|
57
|
+
response.body = {
|
|
58
|
+
'requestId' => Fog::AWS::Mock.request_id
|
|
59
|
+
}.merge!(data)
|
|
60
|
+
else
|
|
61
|
+
response.status = 400
|
|
62
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
|
63
|
+
end
|
|
64
|
+
response
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module AWS
|
|
3
|
+
class EC2
|
|
4
|
+
|
|
5
|
+
# Add permissions to a security group
|
|
6
|
+
#
|
|
7
|
+
# ==== Parameters
|
|
8
|
+
# * options<~Hash>:
|
|
9
|
+
# * 'GroupName'<~String> - Name of group
|
|
10
|
+
# * 'SourceSecurityGroupName'<~String> - Name of security group to authorize
|
|
11
|
+
# * 'SourceSecurityGroupOwnerId'<~String> - Name of owner to authorize
|
|
12
|
+
# or
|
|
13
|
+
# * 'CidrIp' - CIDR range
|
|
14
|
+
# * 'FromPort' - Start of port range (or -1 for ICMP wildcard)
|
|
15
|
+
# * 'GroupName' - Name of group to modify
|
|
16
|
+
# * 'IpProtocol' - Ip protocol, must be in ['tcp', 'udp', 'icmp']
|
|
17
|
+
# * 'ToPort' - End of port range (or -1 for ICMP wildcard)
|
|
18
|
+
#
|
|
19
|
+
# === Returns
|
|
20
|
+
# * response<~Fog::AWS::Response>:
|
|
21
|
+
# * body<~Hash>:
|
|
22
|
+
# * 'requestId'<~String> - Id of request
|
|
23
|
+
# * 'return'<~Boolean> - success?
|
|
24
|
+
def authorize_security_group_ingress(options = {})
|
|
25
|
+
request({
|
|
26
|
+
'Action' => 'AuthorizeSecurityGroupIngress'
|
|
27
|
+
}.merge!(options), Fog::Parsers::AWS::EC2::Basic.new)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Create a new key pair
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * key_name<~String> - Unique name for key pair.
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Fog::AWS::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * 'keyFingerprint'<~String> - SHA-1 digest of DER encoded private key
|
|
16
|
+
# * 'keyMaterial'<~String> - Unencrypted encoded PEM private key
|
|
17
|
+
# * 'keyName'<~String> - Name of key
|
|
18
|
+
# * 'requestId'<~String> - Id of request
|
|
19
|
+
def create_key_pair(key_name)
|
|
20
|
+
request({
|
|
21
|
+
'Action' => 'CreateKeyPair',
|
|
22
|
+
'KeyName' => key_name
|
|
23
|
+
}, Fog::Parsers::AWS::EC2::CreateKeyPair.new)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
else
|
|
31
|
+
|
|
32
|
+
module Fog
|
|
33
|
+
module AWS
|
|
34
|
+
class EC2
|
|
35
|
+
|
|
36
|
+
def create_key_pair(key_name)
|
|
37
|
+
response = Fog::Response.new
|
|
38
|
+
unless Fog::AWS::EC2.data[:key_pairs][key_name]
|
|
39
|
+
response.status = 200
|
|
40
|
+
data = {
|
|
41
|
+
'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
|
|
42
|
+
'keyMaterial' => Fog::AWS::Mock.key_material,
|
|
43
|
+
'keyName' => key_name
|
|
44
|
+
}
|
|
45
|
+
Fog::AWS::EC2.data[:key_pairs][key_name] = data
|
|
46
|
+
response.body = {
|
|
47
|
+
'requestId' => Fog::AWS::Mock.request_id
|
|
48
|
+
}.merge!(data)
|
|
49
|
+
else
|
|
50
|
+
response.status = 400
|
|
51
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
|
52
|
+
end
|
|
53
|
+
response
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Create a new security group
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * group_name<~String> - Name of the security group.
|
|
11
|
+
# * group_description<~String> - Description of group.
|
|
12
|
+
#
|
|
13
|
+
# ==== Returns
|
|
14
|
+
# * response<~Fog::AWS::Response>:
|
|
15
|
+
# * body<~Hash>:
|
|
16
|
+
# * 'requestId'<~String> - Id of request
|
|
17
|
+
# * 'return'<~Boolean> - success?
|
|
18
|
+
def create_security_group(name, description)
|
|
19
|
+
request({
|
|
20
|
+
'Action' => 'CreateSecurityGroup',
|
|
21
|
+
'GroupName' => name,
|
|
22
|
+
'GroupDescription' => CGI.escape(description)
|
|
23
|
+
}, Fog::Parsers::AWS::EC2::Basic.new)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
else
|
|
31
|
+
|
|
32
|
+
module Fog
|
|
33
|
+
module AWS
|
|
34
|
+
class EC2
|
|
35
|
+
|
|
36
|
+
def create_security_group(name, description)
|
|
37
|
+
response = Fog::Response.new
|
|
38
|
+
unless Fog::AWS::EC2.data[:security_groups][name]
|
|
39
|
+
data = {
|
|
40
|
+
'GroupDescription' => description,
|
|
41
|
+
'GroupName' => name,
|
|
42
|
+
'ipPermissions' => [],
|
|
43
|
+
'OwnerId' => Fog::AWS::Mock.owner_id
|
|
44
|
+
}
|
|
45
|
+
Fog::AWS::EC2.data[:security_groups][name] = data
|
|
46
|
+
response.body = {
|
|
47
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
|
48
|
+
'return' => true
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
response.status = 400
|
|
52
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
|
53
|
+
end
|
|
54
|
+
response
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
unless Fog.mocking?
|
|
2
|
+
|
|
3
|
+
module Fog
|
|
4
|
+
module AWS
|
|
5
|
+
class EC2
|
|
6
|
+
|
|
7
|
+
# Create a snapshot of an EBS volume and store it in S3
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * volume_id<~String> - Id of EBS volume to snapshot
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Fog::AWS::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * 'progress'<~String> - The percentage progress of the snapshot
|
|
16
|
+
# * 'requestId'<~String> - id of request
|
|
17
|
+
# * 'snapshotId'<~String> - id of snapshot
|
|
18
|
+
# * 'startTime'<~Time> - timestamp when snapshot was initiated
|
|
19
|
+
# * 'status'<~String> - state of snapshot
|
|
20
|
+
# * 'volumeId'<~String> - id of volume snapshot targets
|
|
21
|
+
def create_snapshot(volume_id)
|
|
22
|
+
request({
|
|
23
|
+
'Action' => 'CreateSnapshot',
|
|
24
|
+
'VolumeId' => volume_id
|
|
25
|
+
}, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
else
|
|
33
|
+
|
|
34
|
+
module Fog
|
|
35
|
+
module AWS
|
|
36
|
+
class EC2
|
|
37
|
+
|
|
38
|
+
def create_snapshot(volume_id)
|
|
39
|
+
response = Fog::Response.new
|
|
40
|
+
if Fog::AWS::EC2.data[:volumes][volume_id]
|
|
41
|
+
response.status = 200
|
|
42
|
+
snapshot_id = Fog::AWS::Mock.snapshot_id
|
|
43
|
+
data = {
|
|
44
|
+
'progress' => '',
|
|
45
|
+
'snapshotId' => snapshot_id,
|
|
46
|
+
'startTime' => Time.now,
|
|
47
|
+
'status' => 'pending',
|
|
48
|
+
'volumeId' => volume_id
|
|
49
|
+
}
|
|
50
|
+
Fog::AWS::EC2.data[:snapshots][snapshot_id] = data
|
|
51
|
+
response.body = {
|
|
52
|
+
'requestId' => Fog::AWS::Mock.request_id
|
|
53
|
+
}.merge!(data)
|
|
54
|
+
else
|
|
55
|
+
response.status = 400
|
|
56
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
|
57
|
+
end
|
|
58
|
+
response
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|