geemus-fog 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +94 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +76 -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/aws/ec2.rb +159 -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 +26 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +32 -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 +28 -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 +24 -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 +27 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +48 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +26 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +29 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +32 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +24 -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 +74 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +31 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +80 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +49 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +92 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +81 -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 +75 -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 +143 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/aws.rb +127 -0
- data/lib/fog/connection.rb +122 -0
- data/lib/fog/errors.rb +131 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/lib/fog.rb +22 -0
- data/spec/aws/ec2/allocate_address_spec.rb +20 -0
- data/spec/aws/ec2/associate_address_spec.rb +22 -0
- data/spec/aws/ec2/attach_volume_spec.rb +33 -0
- data/spec/aws/ec2/authorize_security_group_ingress_spec.rb +25 -0
- data/spec/aws/ec2/create_key_pair_spec.rb +27 -0
- data/spec/aws/ec2/create_security_group_spec.rb +25 -0
- data/spec/aws/ec2/create_snapshot_spec.rb +27 -0
- data/spec/aws/ec2/create_volume_spec.rb +25 -0
- data/spec/aws/ec2/delete_key_pair_spec.rb +20 -0
- data/spec/aws/ec2/delete_security_group_spec.rb +22 -0
- data/spec/aws/ec2/delete_snapshot_spec.rb +25 -0
- data/spec/aws/ec2/delete_volume_spec.rb +22 -0
- data/spec/aws/ec2/describe_addresses_spec.rb +34 -0
- data/spec/aws/ec2/describe_availability_zones_spec.rb +25 -0
- data/spec/aws/ec2/describe_images_spec.rb +41 -0
- data/spec/aws/ec2/describe_instances_spec.rb +76 -0
- data/spec/aws/ec2/describe_key_pairs_spec.rb +38 -0
- data/spec/aws/ec2/describe_regions_spec.rb +23 -0
- data/spec/aws/ec2/describe_security_groups_spec.rb +47 -0
- data/spec/aws/ec2/describe_snapshot_spec.rb +44 -0
- data/spec/aws/ec2/describe_volumes_spec.rb +46 -0
- data/spec/aws/ec2/detach_volume_spec.rb +33 -0
- data/spec/aws/ec2/disassociate_address_spec.rb +23 -0
- data/spec/aws/ec2/get_console_output_spec.rb +22 -0
- data/spec/aws/ec2/reboot_instances_spec.rb +20 -0
- data/spec/aws/ec2/release_address_spec.rb +22 -0
- data/spec/aws/ec2/revoke_security_group_ingress_spec.rb +31 -0
- data/spec/aws/ec2/run_instances_spec.rb +43 -0
- data/spec/aws/ec2/terminate_instances_spec.rb +25 -0
- data/spec/aws/s3/copy_object_spec.rb +57 -0
- data/spec/aws/s3/delete_bucket_spec.rb +21 -0
- data/spec/aws/s3/delete_object_spec.rb +31 -0
- data/spec/aws/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/s3/get_bucket_spec.rb +42 -0
- data/spec/aws/s3/get_object_spec.rb +40 -0
- data/spec/aws/s3/get_request_payment_spec.rb +26 -0
- data/spec/aws/s3/get_service_spec.rb +32 -0
- data/spec/aws/s3/head_object_spec.rb +27 -0
- data/spec/aws/s3/put_bucket_spec.rb +22 -0
- data/spec/aws/s3/put_object_spec.rb +34 -0
- data/spec/aws/s3/put_request_payment_spec.rb +25 -0
- data/spec/aws/simpledb/batch_put_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/create_domain_spec.rb +20 -0
- data/spec/aws/simpledb/delete_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/delete_domain_spec.rb +20 -0
- data/spec/aws/simpledb/domain_metadata_spec.rb +42 -0
- data/spec/aws/simpledb/get_attributes_spec.rb +30 -0
- data/spec/aws/simpledb/list_domains_spec.rb +29 -0
- data/spec/aws/simpledb/put_attributes_spec.rb +21 -0
- data/spec/aws/simpledb/select_spec.rb +7 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +74 -0
- metadata +256 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module S3
|
5
|
+
|
6
|
+
class GetService < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@bucket = {}
|
10
|
+
@response = { 'Owner' => {}, 'Buckets' => [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_element(name)
|
14
|
+
case name
|
15
|
+
when 'Bucket'
|
16
|
+
@response['Buckets'] << @bucket
|
17
|
+
@bucket = {}
|
18
|
+
when 'CreationDate'
|
19
|
+
@bucket['CreationDate'] = Time.parse(@value)
|
20
|
+
when 'DisplayName', 'ID'
|
21
|
+
@response['Owner'][name] = @value
|
22
|
+
when 'Name'
|
23
|
+
@bucket[name] = @value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module SimpleDB
|
5
|
+
|
6
|
+
class Basic < Fog::Parsers::Base
|
7
|
+
|
8
|
+
def initialize(nil_string)
|
9
|
+
@nil_string = nil_string
|
10
|
+
reset
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_element(name)
|
14
|
+
case(name)
|
15
|
+
when 'BoxUsage'
|
16
|
+
response[name] = @value.to_f
|
17
|
+
when 'RequestId'
|
18
|
+
response[name] = @value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def sdb_decode(value)
|
23
|
+
value.eql?(@nil_string) ? nil : value
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module AWS
|
4
|
+
module SimpleDB
|
5
|
+
|
6
|
+
class DomainMetadata < Fog::Parsers::AWS::SimpleDB::Basic
|
7
|
+
|
8
|
+
def reset
|
9
|
+
@response = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_element(name)
|
13
|
+
case name
|
14
|
+
when 'AttributeNameCount', 'AttributeNamesSizeBytes', 'AttributeValueCount', 'AttributeValuesSizeBytes', 'ItemCount', 'ItemNamesSizeBytes'
|
15
|
+
response[name] = @value.to_i
|
16
|
+
when 'BoxUsage'
|
17
|
+
response[name] = @value.to_f
|
18
|
+
when 'RequestId'
|
19
|
+
response[name] = @value
|
20
|
+
when 'Timestamp'
|
21
|
+
response[name] = Time.at(@value.to_i)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -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
|
+
@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,26 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class EC2
|
4
|
+
|
5
|
+
# Associate an elastic IP address with an instance
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * instance_id<~String> - Id of instance to associate address with
|
9
|
+
# * public_ip<~String> - Public ip to assign to instance
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Fog::AWS::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'requestId'<~String> - Id of request
|
15
|
+
# * 'return'<~Boolean> - success?
|
16
|
+
def associate_address(instance_id, public_ip)
|
17
|
+
request({
|
18
|
+
'Action' => 'AssociateAddress',
|
19
|
+
'InstanceId' => instance_id,
|
20
|
+
'PublicIp' => public_ip
|
21
|
+
}, Fog::Parsers::AWS::EC2::Basic.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class EC2
|
4
|
+
|
5
|
+
# Attach an Amazon EBS volume with a running instance, exposing as specified device
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * volume_id<~String> - Id of amazon EBS volume to associate with instance
|
9
|
+
# * instance_id<~String> - Id of instance to associate volume with
|
10
|
+
# * device<~String> - Specifies how the device is exposed to the instance (e.g. "/dev/sdh")
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Fog::AWS::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'attachTime'<~Time> - Time of attachment was initiated at
|
16
|
+
# * 'device'<~String> - Device as it is exposed to the instance
|
17
|
+
# * 'instanceId'<~String> - Id of instance for volume
|
18
|
+
# * 'requestId'<~String> - Id of request
|
19
|
+
# * 'status'<~String> - Status of volume
|
20
|
+
# * 'volumeId'<~String> - Reference to volume
|
21
|
+
def attach_volume(volume_id, instance_id, device)
|
22
|
+
request({
|
23
|
+
'Action' => 'AttachVolume',
|
24
|
+
'VolumeId' => volume_id,
|
25
|
+
'InstanceId' => instance_id,
|
26
|
+
'Device' => device
|
27
|
+
}, Fog::Parsers::AWS::EC2::AttachVolume.new)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
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 @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
|
+
@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 @data[:security_groups][name]
|
39
|
+
data = {
|
40
|
+
'GroupDescription' => description,
|
41
|
+
'GroupName' => name,
|
42
|
+
'ipPermissions' => [],
|
43
|
+
'OwnerId' => Fog::AWS::Mock.owner_id
|
44
|
+
}
|
45
|
+
@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,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class EC2
|
4
|
+
|
5
|
+
# Create a snapshot of an EBS volume and store it in S3
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * volume_id<~String> - Id of EBS volume to snapshot
|
9
|
+
#
|
10
|
+
# ==== Returns
|
11
|
+
# * response<~Fog::AWS::Response>:
|
12
|
+
# * body<~Hash>:
|
13
|
+
# * 'progress'<~String> - The percentage progress of the snapshot
|
14
|
+
# * 'requestId'<~String> - id of request
|
15
|
+
# * 'snapshotId'<~String> - id of snapshot
|
16
|
+
# * 'startTime'<~Time> - timestamp when snapshot was initiated
|
17
|
+
# * 'status'<~String> - state of snapshot
|
18
|
+
# * 'volumeId'<~String> - id of volume snapshot targets
|
19
|
+
def create_snapshot(volume_id)
|
20
|
+
request({
|
21
|
+
'Action' => 'CreateSnapshot',
|
22
|
+
'VolumeId' => volume_id
|
23
|
+
}, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Create an EBS volume
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * availability_zone<~String> - availability zone to create volume in
|
11
|
+
# * size<~Integer> - Size in GiBs for volume. Must be between 1 and 1024.
|
12
|
+
# * snapshot_id<~String> - Optional, snapshot to create volume from
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Fog::AWS::Response>:
|
16
|
+
# * body<~Hash>:
|
17
|
+
# * 'availabilityZone'<~String> - Availability zone for volume
|
18
|
+
# * 'createTime'<~Time> - Timestamp for creation
|
19
|
+
# * 'size'<~Integer> - Size in GiBs for volume
|
20
|
+
# * 'snapshotId'<~String> - Snapshot volume was created from, if any
|
21
|
+
# * 'status's<~String> - State of volume
|
22
|
+
# * 'volumeId'<~String> - Reference to volume
|
23
|
+
def create_volume(availability_zone, size, snapshot_id = nil)
|
24
|
+
request({
|
25
|
+
'Action' => 'CreateVolume',
|
26
|
+
'AvailabilityZone' => availability_zone,
|
27
|
+
'Size' => size,
|
28
|
+
'SnapshotId' => snapshot_id
|
29
|
+
}, Fog::Parsers::AWS::EC2::CreateVolume.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 create_volume(availability_zone, size, snapshot_id = nil)
|
43
|
+
response = Fog::Response.new
|
44
|
+
response.status = 200
|
45
|
+
volume_id = Fog::AWS::Mock.volume_id
|
46
|
+
data = {
|
47
|
+
'availabilityZone' => availability_zone,
|
48
|
+
'attachmentSet' => [],
|
49
|
+
'createTime' => Time.now,
|
50
|
+
'size' => size,
|
51
|
+
'snapshotId' => snapshot_id || '',
|
52
|
+
'status' => 'creating',
|
53
|
+
'volumeId' => volume_id
|
54
|
+
}
|
55
|
+
@data[:volumes][volume_id] = data
|
56
|
+
response.body = {
|
57
|
+
'requestId' => Fog::AWS::Mock.request_id
|
58
|
+
}.merge!(data.reject {|key,value| !['availabilityZone','createTime','size','snapshotId','status','volumeId'].include?(key) })
|
59
|
+
response
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Delete a key pair that you own
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * key_name<~String> - Name of the key pair.
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Fog::AWS::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> id of request
|
16
|
+
# * 'return'<~Boolean> - success?
|
17
|
+
def delete_key_pair(key_name)
|
18
|
+
request({
|
19
|
+
'Action' => 'DeleteKeyPair',
|
20
|
+
'KeyName' => key_name
|
21
|
+
}, Fog::Parsers::AWS::EC2::Basic.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
else
|
29
|
+
|
30
|
+
module Fog
|
31
|
+
module AWS
|
32
|
+
class EC2
|
33
|
+
|
34
|
+
def delete_key_pair(key_name)
|
35
|
+
response = Fog::Response.new
|
36
|
+
@data[:key_pairs].delete(key_name)
|
37
|
+
response.status = 200
|
38
|
+
response.body = {
|
39
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
40
|
+
'return' => true
|
41
|
+
}
|
42
|
+
response
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
unless Fog.mocking?
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module AWS
|
5
|
+
class EC2
|
6
|
+
|
7
|
+
# Delete a security group that you own
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * group_name<~String> - Name of the security group.
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Fog::AWS::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * 'requestId'<~String> - Id of request
|
16
|
+
# * 'return'<~Boolean> - success?
|
17
|
+
def delete_security_group(name)
|
18
|
+
request({
|
19
|
+
'Action' => 'DeleteSecurityGroup',
|
20
|
+
'GroupName' => name
|
21
|
+
}, Fog::Parsers::AWS::EC2::Basic.new)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
else
|
29
|
+
|
30
|
+
module Fog
|
31
|
+
module AWS
|
32
|
+
class EC2
|
33
|
+
def delete_security_group(name)
|
34
|
+
response = Fog::Response.new
|
35
|
+
if @data[:security_groups][name]
|
36
|
+
@data[:security_groups].delete(name)
|
37
|
+
response.status = 200
|
38
|
+
response.body = {
|
39
|
+
'requestId' => Fog::AWS::Mock.request_id,
|
40
|
+
'return' => true
|
41
|
+
}
|
42
|
+
else
|
43
|
+
response.status = 400
|
44
|
+
raise(Fog::Errors.status_error(200, 400, response))
|
45
|
+
end
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|