fog 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +106 -17
- data/bin/fog +1 -1
- data/changelog.txt +17 -0
- data/docs/_layouts/default.html +2 -1
- data/docs/about/contributing.markdown +1 -1
- data/docs/compute/index.markdown +104 -0
- data/docs/index.markdown +1 -0
- data/docs/storage/index.markdown +17 -0
- data/fog.gemspec +3 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/elb.rb +1 -0
- data/lib/fog/aws/iam.rb +1 -0
- data/lib/fog/aws/rds.rb +1 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +5 -5
- data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -1
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +3 -3
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -1
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +1 -1
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +5 -5
- data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -2
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +6 -6
- data/lib/fog/aws/ses.rb +1 -0
- data/lib/fog/aws/simpledb.rb +8 -2
- data/lib/fog/bin.rb +2 -2
- data/lib/fog/cdn/aws.rb +8 -2
- data/lib/fog/cdn/rackspace.rb +8 -2
- data/lib/fog/compute/aws.rb +12 -3
- data/lib/fog/compute/bluebox.rb +8 -2
- data/lib/fog/compute/ecloud.rb +9 -4
- data/lib/fog/compute/go_grid.rb +8 -2
- data/lib/fog/compute/linode.rb +38 -6
- data/lib/fog/compute/models/aws/volumes.rb +4 -4
- data/lib/fog/compute/models/bluebox/server.rb +3 -3
- data/lib/fog/compute/models/brightbox/server.rb +9 -9
- data/lib/fog/compute/models/linode/data_center.rb +12 -0
- data/lib/fog/compute/models/linode/data_centers.rb +26 -0
- data/lib/fog/compute/models/linode/disk.rb +62 -0
- data/lib/fog/compute/models/linode/disks.rb +40 -0
- data/lib/fog/compute/models/linode/flavor.rb +23 -0
- data/lib/fog/compute/models/linode/flavors.rb +32 -0
- data/lib/fog/compute/models/linode/image.rb +14 -0
- data/lib/fog/compute/models/linode/images.rb +33 -0
- data/lib/fog/compute/models/linode/ip.rb +30 -0
- data/lib/fog/compute/models/linode/ips.rb +40 -0
- data/lib/fog/compute/models/linode/kernel.rb +12 -0
- data/lib/fog/compute/models/linode/kernels.rb +32 -0
- data/lib/fog/compute/models/linode/server.rb +88 -0
- data/lib/fog/compute/models/linode/servers.rb +32 -0
- data/lib/fog/compute/models/linode/stack_script.rb +13 -0
- data/lib/fog/compute/models/linode/stack_scripts.rb +32 -0
- data/lib/fog/compute/models/rackspace/server.rb +2 -2
- data/lib/fog/compute/models/slicehost/server.rb +2 -2
- data/lib/fog/compute/models/voxel/server.rb +3 -3
- data/lib/fog/compute/new_servers.rb +8 -2
- data/lib/fog/compute/rackspace.rb +8 -2
- data/lib/fog/compute/requests/aws/allocate_address.rb +4 -2
- data/lib/fog/compute/requests/aws/associate_address.rb +4 -2
- data/lib/fog/compute/requests/aws/attach_volume.rb +4 -2
- data/lib/fog/compute/requests/aws/authorize_security_group_ingress.rb +5 -3
- data/lib/fog/compute/requests/aws/create_image.rb +2 -1
- data/lib/fog/compute/requests/aws/create_key_pair.rb +4 -2
- data/lib/fog/compute/requests/aws/create_security_group.rb +5 -3
- data/lib/fog/compute/requests/aws/create_snapshot.rb +6 -4
- data/lib/fog/compute/requests/aws/create_tags.rb +7 -5
- data/lib/fog/compute/requests/aws/create_volume.rb +4 -2
- data/lib/fog/compute/requests/aws/delete_key_pair.rb +3 -1
- data/lib/fog/compute/requests/aws/delete_security_group.rb +4 -2
- data/lib/fog/compute/requests/aws/delete_snapshot.rb +3 -1
- data/lib/fog/compute/requests/aws/delete_tags.rb +5 -3
- data/lib/fog/compute/requests/aws/delete_volume.rb +4 -2
- data/lib/fog/compute/requests/aws/deregister_image.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_addresses.rb +3 -1
- data/lib/fog/compute/requests/aws/describe_availability_zones.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_images.rb +3 -1
- data/lib/fog/compute/requests/aws/describe_instances.rb +12 -10
- data/lib/fog/compute/requests/aws/describe_key_pairs.rb +3 -1
- data/lib/fog/compute/requests/aws/describe_regions.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_reserved_instances.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_reserved_instances_offerings.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_security_groups.rb +3 -1
- data/lib/fog/compute/requests/aws/describe_snapshots.rb +5 -3
- data/lib/fog/compute/requests/aws/describe_tags.rb +2 -0
- data/lib/fog/compute/requests/aws/describe_volumes.rb +9 -7
- data/lib/fog/compute/requests/aws/detach_volume.rb +3 -1
- data/lib/fog/compute/requests/aws/disassociate_address.rb +4 -2
- data/lib/fog/compute/requests/aws/get_console_output.rb +3 -1
- data/lib/fog/compute/requests/aws/get_password_data.rb +15 -1
- data/lib/fog/compute/requests/aws/import_key_pair.rb +4 -2
- data/lib/fog/compute/requests/aws/modify_image_attributes.rb +4 -0
- data/lib/fog/compute/requests/aws/modify_snapshot_attribute.rb +4 -0
- data/lib/fog/compute/requests/aws/monitor_instances.rb +3 -1
- data/lib/fog/compute/requests/aws/reboot_instances.rb +4 -2
- data/lib/fog/compute/requests/aws/register_image.rb +4 -0
- data/lib/fog/compute/requests/aws/release_address.rb +3 -1
- data/lib/fog/compute/requests/aws/revoke_security_group_ingress.rb +3 -1
- data/lib/fog/compute/requests/aws/run_instances.rb +12 -6
- data/lib/fog/compute/requests/aws/start_instances.rb +2 -0
- data/lib/fog/compute/requests/aws/stop_instances.rb +2 -0
- data/lib/fog/compute/requests/aws/terminate_instances.rb +5 -3
- data/lib/fog/compute/requests/aws/unmonitor_instances.rb +3 -1
- data/lib/fog/compute/requests/go_grid/grid_image_get.rb +1 -1
- data/lib/fog/compute/requests/go_grid/grid_image_list.rb +1 -1
- data/lib/fog/compute/requests/linode/avail_datacenters.rb +1 -2
- data/lib/fog/compute/requests/linode/avail_distributions.rb +1 -2
- data/lib/fog/compute/requests/linode/avail_kernels.rb +6 -5
- data/lib/fog/compute/requests/linode/avail_linodeplans.rb +9 -3
- data/lib/fog/compute/requests/linode/avail_stackscripts.rb +3 -15
- data/lib/fog/compute/requests/linode/linode_boot.rb +15 -0
- data/lib/fog/compute/requests/linode/linode_config_create.rb +21 -0
- data/lib/fog/compute/requests/linode/linode_config_list.rb +18 -0
- data/lib/fog/compute/requests/linode/linode_create.rb +3 -4
- data/lib/fog/compute/requests/linode/linode_delete.rb +0 -1
- data/lib/fog/compute/requests/linode/linode_disk_create.rb +21 -0
- data/lib/fog/compute/requests/linode/linode_disk_createfromdistribution.rb +22 -0
- data/lib/fog/compute/requests/linode/linode_disk_createfromstackscript.rb +24 -0
- data/lib/fog/compute/requests/linode/linode_disk_delete.rb +19 -0
- data/lib/fog/compute/requests/linode/linode_disk_list.rb +19 -0
- data/lib/fog/compute/requests/linode/linode_ip_addprivate.rb +15 -0
- data/lib/fog/compute/requests/linode/linode_ip_list.rb +19 -0
- data/lib/fog/compute/requests/linode/linode_list.rb +0 -1
- data/lib/fog/compute/requests/linode/linode_reboot.rb +1 -2
- data/lib/fog/compute/requests/linode/linode_shutdown.rb +15 -0
- data/lib/fog/compute/requests/linode/linode_update.rb +15 -0
- data/lib/fog/compute/requests/linode/stackscript_list.rb +31 -0
- data/lib/fog/compute/requests/rackspace/confirm_resized_server.rb +3 -3
- data/lib/fog/compute/requests/rackspace/create_image.rb +2 -2
- data/lib/fog/compute/requests/rackspace/create_server.rb +2 -2
- data/lib/fog/compute/requests/rackspace/delete_image.rb +2 -2
- data/lib/fog/compute/requests/rackspace/delete_server.rb +2 -2
- data/lib/fog/compute/requests/rackspace/list_images_detail.rb +2 -2
- data/lib/fog/compute/requests/rackspace/list_servers_detail.rb +2 -2
- data/lib/fog/compute/requests/rackspace/resize_server.rb +4 -4
- data/lib/fog/compute/requests/rackspace/revert_resized_server.rb +4 -4
- data/lib/fog/compute/slicehost.rb +8 -2
- data/lib/fog/compute/storm_on_demand.rb +12 -1
- data/lib/fog/compute/voxel.rb +8 -2
- data/lib/fog/core/mock.rb +14 -1
- data/lib/fog/dns/aws.rb +8 -2
- data/lib/fog/dns/bluebox.rb +8 -2
- data/lib/fog/dns/dnsimple.rb +15 -3
- data/lib/fog/dns/linode.rb +8 -2
- data/lib/fog/dns/slicehost.rb +8 -2
- data/lib/fog/dns/zerigo.rb +8 -2
- data/lib/fog/providers/aws.rb +5 -10
- data/lib/fog/providers/linode.rb +0 -3
- data/lib/fog/storage.rb +6 -4
- data/lib/fog/storage/aws.rb +8 -2
- data/lib/fog/storage/google.rb +8 -2
- data/lib/fog/storage/local.rb +8 -2
- data/lib/fog/storage/models/aws/file.rb +0 -1
- data/lib/fog/storage/models/google/file.rb +1 -5
- data/lib/fog/storage/models/local/file.rb +1 -1
- data/lib/fog/storage/models/rackspace/file.rb +1 -5
- data/lib/fog/storage/rackspace.rb +8 -2
- data/lib/fog/storage/requests/aws/copy_object.rb +2 -2
- data/lib/fog/storage/requests/aws/delete_bucket.rb +3 -3
- data/lib/fog/storage/requests/aws/delete_object.rb +1 -1
- data/lib/fog/storage/requests/aws/get_bucket.rb +1 -1
- data/lib/fog/storage/requests/aws/get_bucket_acl.rb +1 -1
- data/lib/fog/storage/requests/aws/get_bucket_location.rb +1 -1
- data/lib/fog/storage/requests/aws/get_object.rb +1 -1
- data/lib/fog/storage/requests/aws/get_object_acl.rb +1 -1
- data/lib/fog/storage/requests/aws/get_request_payment.rb +1 -1
- data/lib/fog/storage/requests/aws/get_service.rb +1 -1
- data/lib/fog/storage/requests/aws/put_bucket.rb +3 -3
- data/lib/fog/storage/requests/aws/put_object.rb +3 -3
- data/lib/fog/storage/requests/aws/put_request_payment.rb +1 -1
- data/lib/fog/storage/requests/google/copy_object.rb +2 -2
- data/lib/fog/storage/requests/google/delete_bucket.rb +3 -3
- data/lib/fog/storage/requests/google/delete_object.rb +1 -1
- data/lib/fog/storage/requests/google/get_bucket.rb +1 -1
- data/lib/fog/storage/requests/google/get_bucket_acl.rb +1 -1
- data/lib/fog/storage/requests/google/get_object.rb +1 -1
- data/lib/fog/storage/requests/google/get_object_acl.rb +1 -1
- data/lib/fog/storage/requests/google/get_service.rb +2 -2
- data/lib/fog/storage/requests/google/put_bucket.rb +3 -3
- data/lib/fog/storage/requests/google/put_object.rb +3 -3
- data/lib/fog/terremark/requests/shared/get_network.rb +1 -1
- data/lib/fog/terremark/requests/shared/get_organization.rb +1 -1
- data/lib/fog/terremark/requests/shared/get_organizations.rb +1 -1
- data/lib/fog/terremark/requests/shared/get_public_ips.rb +1 -1
- data/lib/fog/terremark/requests/shared/get_vdc.rb +1 -1
- data/lib/fog/terremark/shared.rb +4 -0
- data/lib/fog/terremark/vcloud.rb +11 -1
- data/spec/ecloud/bin_spec.rb +8 -2
- data/spec/ecloud/spec_helper.rb +3 -3
- data/tests/compute/helper.rb +1 -3
- data/tests/compute/models/aws/server_tests.rb +3 -2
- data/tests/compute/requests/aws/instance_tests.rb +12 -9
- data/tests/compute/requests/aws/key_pair_tests.rb +1 -1
- data/tests/compute/requests/aws/volume_tests.rb +2 -2
- data/tests/compute/requests/brightbox/helper.rb +3 -0
- data/tests/compute/requests/linode/kernel_tests.rb +27 -0
- data/tests/compute/requests/linode/linode_tests.rb +62 -4
- data/tests/compute/requests/linode/stackscripts_tests.rb +35 -0
- data/tests/compute/requests/rackspace/resize_tests.rb +2 -2
- data/tests/compute/requests/voxel/server_tests.rb +1 -0
- data/tests/core/credential_tests.rb +7 -2
- data/tests/core/parser_tests.rb +1 -1
- data/tests/helper.rb +1 -1
- data/tests/helpers/compute/server_helper.rb +6 -0
- data/tests/helpers/formats_helper.rb +2 -0
- data/tests/helpers/mock_helper.rb +8 -1
- data/tests/helpers/model_helper.rb +1 -3
- data/tests/helpers/responds_to_helper.rb +2 -2
- data/tests/storage/helper.rb +1 -1
- data/tests/storage/models/directories_tests.rb +8 -4
- data/tests/storage/models/directory_test.rb +15 -11
- data/tests/storage/models/file_tests.rb +6 -6
- data/tests/storage/models/files_tests.rb +5 -5
- metadata +105 -55
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/compute/models/linode/server'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Linode
|
6
|
+
class Compute
|
7
|
+
class Servers < Fog::Collection
|
8
|
+
model Fog::Linode::Compute::Server
|
9
|
+
|
10
|
+
def all
|
11
|
+
load servers
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new servers(id).first
|
16
|
+
rescue Fog::Linode::Compute::NotFound
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def servers(id=nil)
|
22
|
+
connection.linode_list(id).body['DATA'].map { |server| map_server server }
|
23
|
+
end
|
24
|
+
|
25
|
+
def map_server(server)
|
26
|
+
server = server.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
|
27
|
+
server.merge! :id => server[:linodeid], :name => server[:label]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/compute/models/linode/stack_script'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Linode
|
6
|
+
class Compute
|
7
|
+
class StackScripts < Fog::Collection
|
8
|
+
model Fog::Linode::Compute::StackScript
|
9
|
+
|
10
|
+
def all
|
11
|
+
load stackscripts
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
new stackscripts(id).first
|
16
|
+
rescue Fog::Linode::Compute::NotFound
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def stackscripts(id=nil)
|
22
|
+
connection.stackscript_list(id).body['DATA'].map { |script| map_stackscript script }
|
23
|
+
end
|
24
|
+
|
25
|
+
def map_stackscript(script)
|
26
|
+
script = script.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
|
27
|
+
script.merge! :id => script[:stackscriptid], :name => script[:label]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -16,7 +16,7 @@ module Fog
|
|
16
16
|
attribute :name
|
17
17
|
attribute :personality
|
18
18
|
attribute :progress
|
19
|
-
attribute :status
|
19
|
+
attribute :state, :aliases => 'status'
|
20
20
|
|
21
21
|
attr_reader :password
|
22
22
|
attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
|
@@ -75,7 +75,7 @@ module Fog
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def ready?
|
78
|
-
|
78
|
+
self.state == 'ACTIVE'
|
79
79
|
end
|
80
80
|
|
81
81
|
def reboot(type = 'SOFT')
|
@@ -16,7 +16,7 @@ module Fog
|
|
16
16
|
attribute :image_id, :aliases => 'image-id'
|
17
17
|
attribute :name
|
18
18
|
attribute :progress
|
19
|
-
attribute :status
|
19
|
+
attribute :state, :aliases => 'status'
|
20
20
|
|
21
21
|
attr_accessor :password
|
22
22
|
alias_method :'root-password=', :password=
|
@@ -71,7 +71,7 @@ module Fog
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def ready?
|
74
|
-
|
74
|
+
self.state == 'active'
|
75
75
|
end
|
76
76
|
|
77
77
|
def reboot(type = 'SOFT')
|
@@ -32,7 +32,7 @@ module Fog
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def ready?
|
35
|
-
|
35
|
+
self.state == 'SUCCEEDED'
|
36
36
|
end
|
37
37
|
|
38
38
|
def private_ip_address
|
@@ -49,8 +49,8 @@ module Fog
|
|
49
49
|
true
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
@
|
52
|
+
def state
|
53
|
+
@state ||= connection.voxcloud_status(id).body['devices'].first['status']
|
54
54
|
end
|
55
55
|
|
56
56
|
def save
|
@@ -25,6 +25,10 @@ module Fog
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.reset
|
29
|
+
@data = nil
|
30
|
+
end
|
31
|
+
|
28
32
|
def initialize(options={})
|
29
33
|
unless options.delete(:provider)
|
30
34
|
location = caller.first
|
@@ -34,12 +38,14 @@ module Fog
|
|
34
38
|
end
|
35
39
|
|
36
40
|
@new_server_username = options[:new_servers_username]
|
37
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
def data
|
44
|
+
self.class.data[@new_server_username]
|
38
45
|
end
|
39
46
|
|
40
47
|
def reset_data
|
41
48
|
self.class.data.delete(@new_server_username)
|
42
|
-
@data = self.class.data[@new_server_username]
|
43
49
|
end
|
44
50
|
|
45
51
|
end
|
@@ -53,6 +53,10 @@ module Fog
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def self.reset
|
57
|
+
@data = nil
|
58
|
+
end
|
59
|
+
|
56
60
|
def initialize(options={})
|
57
61
|
unless options.delete(:provider)
|
58
62
|
location = caller.first
|
@@ -62,12 +66,14 @@ module Fog
|
|
62
66
|
end
|
63
67
|
|
64
68
|
@rackspace_username = options[:rackspace_username]
|
65
|
-
|
69
|
+
end
|
70
|
+
|
71
|
+
def data
|
72
|
+
self.class.data[@rackspace_username]
|
66
73
|
end
|
67
74
|
|
68
75
|
def reset_data
|
69
76
|
self.class.data.delete(@rackspace_username)
|
70
|
-
@data = self.class.data[@rackspace_username]
|
71
77
|
end
|
72
78
|
|
73
79
|
end
|
@@ -12,6 +12,8 @@ module Fog
|
|
12
12
|
# * body<~Hash>:
|
13
13
|
# * 'publicIp'<~String> - The acquired address
|
14
14
|
# * 'requestId'<~String> - Id of the request
|
15
|
+
#
|
16
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AllocateAddress.html]
|
15
17
|
def allocate_address
|
16
18
|
request(
|
17
19
|
'Action' => 'AllocateAddress',
|
@@ -25,14 +27,14 @@ module Fog
|
|
25
27
|
|
26
28
|
def allocate_address
|
27
29
|
response = Excon::Response.new
|
28
|
-
if describe_addresses.body['addressesSet'].size <
|
30
|
+
if describe_addresses.body['addressesSet'].size < self.data[:limits][:addresses]
|
29
31
|
response.status = 200
|
30
32
|
public_ip = Fog::AWS::Mock.ip_address
|
31
33
|
data ={
|
32
34
|
'instanceId' => nil,
|
33
35
|
'publicIp' => public_ip
|
34
36
|
}
|
35
|
-
|
37
|
+
self.data[:addresses][public_ip] = data
|
36
38
|
response.body = {
|
37
39
|
'publicIp' => public_ip,
|
38
40
|
'requestId' => Fog::AWS::Mock.request_id
|
@@ -16,6 +16,8 @@ module Fog
|
|
16
16
|
# * body<~Hash>:
|
17
17
|
# * 'requestId'<~String> - Id of request
|
18
18
|
# * 'return'<~Boolean> - success?
|
19
|
+
#
|
20
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AssociateAddress.html]
|
19
21
|
def associate_address(instance_id, public_ip)
|
20
22
|
request(
|
21
23
|
'Action' => 'AssociateAddress',
|
@@ -33,8 +35,8 @@ module Fog
|
|
33
35
|
def associate_address(instance_id, public_ip)
|
34
36
|
response = Excon::Response.new
|
35
37
|
response.status = 200
|
36
|
-
instance =
|
37
|
-
address =
|
38
|
+
instance = self.data[:instances][instance_id]
|
39
|
+
address = self.data[:addresses][public_ip]
|
38
40
|
if instance && address
|
39
41
|
address['instanceId'] = instance_id
|
40
42
|
instance['originalIpAddress'] = instance['ipAddress']
|
@@ -21,6 +21,8 @@ module Fog
|
|
21
21
|
# * 'requestId'<~String> - Id of request
|
22
22
|
# * 'status'<~String> - Status of volume
|
23
23
|
# * 'volumeId'<~String> - Reference to volume
|
24
|
+
#
|
25
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVolume.html]
|
24
26
|
def attach_volume(instance_id, volume_id, device)
|
25
27
|
request(
|
26
28
|
'Action' => 'AttachVolume',
|
@@ -40,8 +42,8 @@ module Fog
|
|
40
42
|
response = Excon::Response.new
|
41
43
|
if instance_id && volume_id && device
|
42
44
|
response.status = 200
|
43
|
-
instance =
|
44
|
-
volume =
|
45
|
+
instance = self.data[:instances][instance_id]
|
46
|
+
volume = self.data[:volumes][volume_id]
|
45
47
|
if instance && volume
|
46
48
|
unless volume['status'] == 'available'
|
47
49
|
raise Fog::AWS::Compute::Error.new("Client.VolumeInUse => Volume #{volume_id} is unavailable")
|
@@ -24,6 +24,8 @@ module Fog
|
|
24
24
|
# * body<~Hash>:
|
25
25
|
# * 'requestId'<~String> - Id of request
|
26
26
|
# * 'return'<~Boolean> - success?
|
27
|
+
#
|
28
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AuthorizeSecurityGroupIngress.html]
|
27
29
|
def authorize_security_group_ingress(group_name, options = {})
|
28
30
|
if group_name.is_a?(Hash)
|
29
31
|
location = caller.first
|
@@ -56,14 +58,14 @@ module Fog
|
|
56
58
|
end
|
57
59
|
|
58
60
|
response = Excon::Response.new
|
59
|
-
group =
|
61
|
+
group = self.data[:security_groups][group_name]
|
60
62
|
|
61
63
|
if group
|
62
64
|
group['ipPermissions'] ||= []
|
63
65
|
if group_name && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
|
64
66
|
['tcp', 'udp'].each do |protocol|
|
65
67
|
group['ipPermissions'] << {
|
66
|
-
'groups' => [{'groupName' => group_name, 'userId' =>
|
68
|
+
'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
|
67
69
|
'fromPort' => 1,
|
68
70
|
'ipRanges' => [],
|
69
71
|
'ipProtocol' => protocol,
|
@@ -71,7 +73,7 @@ module Fog
|
|
71
73
|
}
|
72
74
|
end
|
73
75
|
group['ipPermissions'] << {
|
74
|
-
'groups' => [{'groupName' => group_name, 'userId' =>
|
76
|
+
'groups' => [{'groupName' => group_name, 'userId' => self.data[:owner_id]}],
|
75
77
|
'fromPort' => -1,
|
76
78
|
'ipRanges' => [],
|
77
79
|
'ipProtocol' => 'icmp',
|
@@ -18,7 +18,8 @@ module Fog
|
|
18
18
|
# * body<~Hash>:
|
19
19
|
# * 'imageId'<~String> - The ID of the created AMI.
|
20
20
|
# * 'requestId'<~String> - Id of request.
|
21
|
-
|
21
|
+
#
|
22
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html]
|
22
23
|
def create_image(instance_id, name, description, no_reboot = false)
|
23
24
|
request(
|
24
25
|
'Action' => 'CreateImage',
|
@@ -17,6 +17,8 @@ module Fog
|
|
17
17
|
# * 'keyMaterial'<~String> - Unencrypted encoded PEM private key
|
18
18
|
# * 'keyName'<~String> - Name of key
|
19
19
|
# * 'requestId'<~String> - Id of request
|
20
|
+
#
|
21
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html]
|
20
22
|
def create_key_pair(key_name)
|
21
23
|
request(
|
22
24
|
'Action' => 'CreateKeyPair',
|
@@ -31,14 +33,14 @@ module Fog
|
|
31
33
|
|
32
34
|
def create_key_pair(key_name)
|
33
35
|
response = Excon::Response.new
|
34
|
-
unless
|
36
|
+
unless self.data[:key_pairs][key_name]
|
35
37
|
response.status = 200
|
36
38
|
data = {
|
37
39
|
'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
|
38
40
|
'keyMaterial' => Fog::AWS::Mock.key_material,
|
39
41
|
'keyName' => key_name
|
40
42
|
}
|
41
|
-
|
43
|
+
self.data[:key_pairs][key_name] = data
|
42
44
|
response.body = {
|
43
45
|
'requestId' => Fog::AWS::Mock.request_id
|
44
46
|
}.merge!(data)
|
@@ -16,6 +16,8 @@ module Fog
|
|
16
16
|
# * body<~Hash>:
|
17
17
|
# * 'requestId'<~String> - Id of request
|
18
18
|
# * 'return'<~Boolean> - success?
|
19
|
+
#
|
20
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSecurityGroup.html]
|
19
21
|
def create_security_group(name, description)
|
20
22
|
request(
|
21
23
|
'Action' => 'CreateSecurityGroup',
|
@@ -31,14 +33,14 @@ module Fog
|
|
31
33
|
|
32
34
|
def create_security_group(name, description)
|
33
35
|
response = Excon::Response.new
|
34
|
-
unless
|
36
|
+
unless self.data[:security_groups][name]
|
35
37
|
data = {
|
36
38
|
'groupDescription' => description,
|
37
39
|
'groupName' => name,
|
38
40
|
'ipPermissions' => [],
|
39
|
-
'ownerId' =>
|
41
|
+
'ownerId' => self.data[:owner_id]
|
40
42
|
}
|
41
|
-
|
43
|
+
self.data[:security_groups][name] = data
|
42
44
|
response.body = {
|
43
45
|
'requestId' => Fog::AWS::Mock.request_id,
|
44
46
|
'return' => true
|
@@ -19,6 +19,8 @@ module Fog
|
|
19
19
|
# * 'startTime'<~Time> - timestamp when snapshot was initiated
|
20
20
|
# * 'status'<~String> - state of snapshot
|
21
21
|
# * 'volumeId'<~String> - id of volume snapshot targets
|
22
|
+
#
|
23
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html]
|
22
24
|
def create_snapshot(volume_id, description = nil)
|
23
25
|
request(
|
24
26
|
'Action' => 'CreateSnapshot',
|
@@ -40,12 +42,12 @@ module Fog
|
|
40
42
|
|
41
43
|
def create_snapshot(volume_id, description = nil)
|
42
44
|
response = Excon::Response.new
|
43
|
-
if volume =
|
45
|
+
if volume = self.data[:volumes][volume_id]
|
44
46
|
response.status = 200
|
45
47
|
snapshot_id = Fog::AWS::Mock.snapshot_id
|
46
48
|
data = {
|
47
49
|
'description' => description,
|
48
|
-
'ownerId' =>
|
50
|
+
'ownerId' => self.data[:owner_id],
|
49
51
|
'progress' => nil,
|
50
52
|
'snapshotId' => snapshot_id,
|
51
53
|
'startTime' => Time.now,
|
@@ -53,11 +55,11 @@ module Fog
|
|
53
55
|
'volumeId' => volume_id,
|
54
56
|
'volumeSize' => volume['size']
|
55
57
|
}
|
56
|
-
|
58
|
+
self.data[:snapshots][snapshot_id] = data
|
57
59
|
response.body = {
|
58
60
|
'requestId' => Fog::AWS::Mock.request_id
|
59
61
|
}.merge!(data)
|
60
|
-
|
62
|
+
self.data[:snapshots][snapshot_id]['tagSet'] = {}
|
61
63
|
else
|
62
64
|
response.status = 400
|
63
65
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
@@ -16,6 +16,8 @@ module Fog
|
|
16
16
|
# * body<~Hash>:
|
17
17
|
# * 'requestId'<~String> - Id of request
|
18
18
|
# * 'return'<~Boolean> - success?
|
19
|
+
#
|
20
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html]
|
19
21
|
def create_tags(resources, tags)
|
20
22
|
resources = [*resources]
|
21
23
|
for key, value in tags
|
@@ -51,7 +53,7 @@ module Fog
|
|
51
53
|
when /^vol\-[a-z0-9]{8}$/i
|
52
54
|
'volume'
|
53
55
|
end
|
54
|
-
if type &&
|
56
|
+
if type && self.data[:"#{type}s"][resource_id]
|
55
57
|
{ 'resourceId' => resource_id, 'resourceType' => type }
|
56
58
|
else
|
57
59
|
raise(Fog::Service::NotFound.new("The #{type} ID '#{resource_id}' does not exist"))
|
@@ -59,11 +61,11 @@ module Fog
|
|
59
61
|
end
|
60
62
|
|
61
63
|
tags.each do |key, value|
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
self.data[:tags][key] ||= {}
|
65
|
+
self.data[:tags][key][value] ||= []
|
66
|
+
self.data[:tags][key][value] = self.data[:tags][key][value] & tagged
|
65
67
|
|
66
|
-
tagged.each {|resource|
|
68
|
+
tagged.each {|resource| self.data[:"#{resource['resourceType']}s"][resource['resourceId']]['tagSet'][key] = value}
|
67
69
|
end
|
68
70
|
|
69
71
|
response = Excon::Response.new
|
@@ -21,6 +21,8 @@ module Fog
|
|
21
21
|
# * 'snapshotId'<~String> - Snapshot volume was created from, if any
|
22
22
|
# * 'status's<~String> - State of volume
|
23
23
|
# * 'volumeId'<~String> - Reference to volume
|
24
|
+
#
|
25
|
+
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html]
|
24
26
|
def create_volume(availability_zone, size, snapshot_id = nil)
|
25
27
|
request(
|
26
28
|
'Action' => 'CreateVolume',
|
@@ -38,7 +40,7 @@ module Fog
|
|
38
40
|
def create_volume(availability_zone, size, snapshot_id = nil)
|
39
41
|
response = Excon::Response.new
|
40
42
|
if availability_zone && size
|
41
|
-
if snapshot_id &&
|
43
|
+
if snapshot_id && !self.data[:snapshots][snapshot_id]
|
42
44
|
raise Fog::AWS::Compute::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
|
43
45
|
end
|
44
46
|
|
@@ -54,7 +56,7 @@ module Fog
|
|
54
56
|
'tagSet' => {},
|
55
57
|
'volumeId' => volume_id
|
56
58
|
}
|
57
|
-
|
59
|
+
self.data[:volumes][volume_id] = data
|
58
60
|
response.body = {
|
59
61
|
'requestId' => Fog::AWS::Mock.request_id
|
60
62
|
}.merge!(data.reject {|key,value| !['availabilityZone','createTime','size','snapshotId','status','volumeId'].include?(key) })
|