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
@@ -60,11 +60,7 @@ module Fog
|
|
60
60
|
options['Content-Type'] = content_type if content_type
|
61
61
|
data = connection.put_object(directory.key, key, body, options)
|
62
62
|
merge_attributes(data.headers)
|
63
|
-
|
64
|
-
self.content_length = body.size
|
65
|
-
else
|
66
|
-
self.content_length = ::File.size(body.path)
|
67
|
-
end
|
63
|
+
self.content_length = Fog::Storage.get_body_size(body)
|
68
64
|
true
|
69
65
|
end
|
70
66
|
|
@@ -45,6 +45,10 @@ module Fog
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.reset
|
49
|
+
@data = nil
|
50
|
+
end
|
51
|
+
|
48
52
|
def initialize(options={})
|
49
53
|
unless options.delete(:provider)
|
50
54
|
location = caller.first
|
@@ -56,12 +60,14 @@ module Fog
|
|
56
60
|
require 'mime/types'
|
57
61
|
@rackspace_api_key = options[:rackspace_api_key]
|
58
62
|
@rackspace_username = options[:rackspace_username]
|
59
|
-
|
63
|
+
end
|
64
|
+
|
65
|
+
def data
|
66
|
+
self.class.data[@rackspace_username]
|
60
67
|
end
|
61
68
|
|
62
69
|
def reset_data
|
63
70
|
self.class.data.delete(@rackspace_username)
|
64
|
-
@data = self.class.data[@rackspace_username]
|
65
71
|
end
|
66
72
|
|
67
73
|
end
|
@@ -47,9 +47,9 @@ module Fog
|
|
47
47
|
|
48
48
|
def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
|
49
49
|
response = Excon::Response.new
|
50
|
-
source_bucket =
|
50
|
+
source_bucket = self.data[:buckets][source_bucket_name]
|
51
51
|
source_object = source_bucket && source_bucket[:objects][source_object_name]
|
52
|
-
target_bucket =
|
52
|
+
target_bucket = self.data[:buckets][target_bucket_name]
|
53
53
|
|
54
54
|
if source_object && target_bucket
|
55
55
|
response.status = 200
|
@@ -30,14 +30,14 @@ module Fog
|
|
30
30
|
|
31
31
|
def delete_bucket(bucket_name)
|
32
32
|
response = Excon::Response.new
|
33
|
-
if
|
33
|
+
if self.data[:buckets][bucket_name].nil?
|
34
34
|
response.status = 404
|
35
35
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
36
|
-
elsif
|
36
|
+
elsif self.data[:buckets][bucket_name] && !self.data[:buckets][bucket_name][:objects].empty?
|
37
37
|
response.status = 409
|
38
38
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
39
39
|
else
|
40
|
-
|
40
|
+
self.data[:buckets].delete(bucket_name)
|
41
41
|
response.status = 204
|
42
42
|
end
|
43
43
|
response
|
@@ -67,7 +67,7 @@ module Fog
|
|
67
67
|
Fog::Mock.not_implemented
|
68
68
|
end
|
69
69
|
response = Excon::Response.new
|
70
|
-
if bucket =
|
70
|
+
if bucket = self.data[:buckets][bucket_name]
|
71
71
|
contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
|
72
72
|
(options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
|
73
73
|
(options['marker'] && object['Key'] <= options['marker'])
|
@@ -36,7 +36,7 @@ module Fog
|
|
36
36
|
|
37
37
|
def get_bucket_location(bucket_name)
|
38
38
|
response = Excon::Response.new
|
39
|
-
if bucket =
|
39
|
+
if bucket = self.data[:buckets][bucket_name]
|
40
40
|
response.status = 200
|
41
41
|
response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
|
42
42
|
else
|
@@ -65,7 +65,7 @@ module Fog
|
|
65
65
|
raise ArgumentError.new('object_name is required')
|
66
66
|
end
|
67
67
|
response = Excon::Response.new
|
68
|
-
if (bucket =
|
68
|
+
if (bucket = self.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
|
69
69
|
if options['If-Match'] && options['If-Match'] != object['ETag']
|
70
70
|
response.status = 412
|
71
71
|
elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified'])
|
@@ -61,7 +61,7 @@ module Fog
|
|
61
61
|
|
62
62
|
def get_object_acl(bucket_name, object_name)
|
63
63
|
response = Excon::Response.new
|
64
|
-
if acl =
|
64
|
+
if acl = self.data[:acls][:object][bucket_name] && self.data[:acls][:object][bucket_name][object_name]
|
65
65
|
response.status = 200
|
66
66
|
response.body = acl
|
67
67
|
else
|
@@ -36,7 +36,7 @@ module Fog
|
|
36
36
|
|
37
37
|
def get_request_payment(bucket_name)
|
38
38
|
response = Excon::Response.new
|
39
|
-
if bucket =
|
39
|
+
if bucket = self.data[:buckets][bucket_name]
|
40
40
|
response.status = 200
|
41
41
|
response.body = { 'Payer' => bucket['Payer'] }
|
42
42
|
else
|
@@ -39,7 +39,7 @@ module Fog
|
|
39
39
|
def get_service
|
40
40
|
response = Excon::Response.new
|
41
41
|
response.headers['Status'] = 200
|
42
|
-
buckets =
|
42
|
+
buckets = self.data[:buckets].values.map do |bucket|
|
43
43
|
bucket.reject do |key, value|
|
44
44
|
!['CreationDate', 'Name'].include?(key)
|
45
45
|
end
|
@@ -48,7 +48,7 @@ DATA
|
|
48
48
|
if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
|
49
49
|
raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
|
50
50
|
else
|
51
|
-
|
51
|
+
self.data[:acls][:bucket][bucket_name] = self.class.acls(acl)
|
52
52
|
end
|
53
53
|
|
54
54
|
response = Excon::Response.new
|
@@ -65,8 +65,8 @@ DATA
|
|
65
65
|
else
|
66
66
|
bucket['LocationConstraint'] = nil
|
67
67
|
end
|
68
|
-
unless
|
69
|
-
|
68
|
+
unless self.data[:buckets][bucket_name]
|
69
|
+
self.data[:buckets][bucket_name] = bucket
|
70
70
|
end
|
71
71
|
response
|
72
72
|
end
|
@@ -52,8 +52,8 @@ module Fog
|
|
52
52
|
if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
|
53
53
|
raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
|
54
54
|
else
|
55
|
-
|
56
|
-
|
55
|
+
self.data[:acls][:object][bucket_name] ||= {}
|
56
|
+
self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
|
57
57
|
end
|
58
58
|
|
59
59
|
data = Fog::Storage.parse_data(data)
|
@@ -61,7 +61,7 @@ module Fog
|
|
61
61
|
data[:body] = data[:body].read
|
62
62
|
end
|
63
63
|
response = Excon::Response.new
|
64
|
-
if (bucket =
|
64
|
+
if (bucket = self.data[:buckets][bucket_name])
|
65
65
|
response.status = 200
|
66
66
|
object = {
|
67
67
|
:body => data[:body],
|
@@ -43,9 +43,9 @@ module Fog
|
|
43
43
|
|
44
44
|
def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
|
45
45
|
response = Excon::Response.new
|
46
|
-
source_bucket =
|
46
|
+
source_bucket = self.data[:buckets][source_bucket_name]
|
47
47
|
source_object = source_bucket && source_bucket[:objects][source_object_name]
|
48
|
-
target_bucket =
|
48
|
+
target_bucket = self.data[:buckets][target_bucket_name]
|
49
49
|
|
50
50
|
if source_object && target_bucket
|
51
51
|
response.status = 200
|
@@ -26,14 +26,14 @@ module Fog
|
|
26
26
|
|
27
27
|
def delete_bucket(bucket_name)
|
28
28
|
response = Excon::Response.new
|
29
|
-
if
|
29
|
+
if self.data[:buckets][bucket_name].nil?
|
30
30
|
response.status = 404
|
31
31
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
32
|
-
elsif
|
32
|
+
elsif self.data[:buckets][bucket_name] && !self.data[:buckets][bucket_name][:objects].empty?
|
33
33
|
response.status = 409
|
34
34
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
35
35
|
else
|
36
|
-
|
36
|
+
self.data[:buckets].delete(bucket_name)
|
37
37
|
response.status = 204
|
38
38
|
end
|
39
39
|
response
|
@@ -29,7 +29,7 @@ module Fog
|
|
29
29
|
|
30
30
|
def delete_object(bucket_name, object_name)
|
31
31
|
response = Excon::Response.new
|
32
|
-
if bucket =
|
32
|
+
if bucket = self.data[:buckets][bucket_name]
|
33
33
|
if object = bucket[:objects][object_name]
|
34
34
|
response.status = 204
|
35
35
|
bucket[:objects].delete(object_name)
|
@@ -64,7 +64,7 @@ module Fog
|
|
64
64
|
response = Excon::Response.new
|
65
65
|
name = /(\w+\.?)*/.match(bucket_name)
|
66
66
|
if bucket_name == name.to_s
|
67
|
-
if bucket =
|
67
|
+
if bucket = self.data[:buckets][bucket_name]
|
68
68
|
contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
|
69
69
|
(options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
|
70
70
|
(options['marker'] && object['Key'] <= options['marker'])
|
@@ -62,7 +62,7 @@ module Fog
|
|
62
62
|
raise ArgumentError.new('object_name is required')
|
63
63
|
end
|
64
64
|
response = Excon::Response.new
|
65
|
-
if (bucket =
|
65
|
+
if (bucket = self.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
|
66
66
|
if options['If-Match'] && options['If-Match'] != object['ETag']
|
67
67
|
response.status = 412
|
68
68
|
elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified'])
|
@@ -58,7 +58,7 @@ module Fog
|
|
58
58
|
|
59
59
|
def get_object_acl(bucket_name, object_name)
|
60
60
|
response = Excon::Response.new
|
61
|
-
if acl =
|
61
|
+
if acl = self.data[:acls][:object][bucket_name] && self.data[:acls][:object][bucket_name][object_name]
|
62
62
|
response.status = 200
|
63
63
|
response.body = acl
|
64
64
|
else
|
@@ -35,14 +35,14 @@ module Fog
|
|
35
35
|
def get_service
|
36
36
|
response = Excon::Response.new
|
37
37
|
response.headers['Status'] = 200
|
38
|
-
buckets =
|
38
|
+
buckets = self.data[:buckets].values.map do |bucket|
|
39
39
|
bucket.reject do |key, value|
|
40
40
|
!['CreationDate', 'Name'].include?(key)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
response.body = {
|
44
44
|
'Buckets' => buckets,
|
45
|
-
'Owner' => { '
|
45
|
+
'Owner' => { 'ID' => 'some_id'}
|
46
46
|
}
|
47
47
|
response
|
48
48
|
end
|
@@ -44,7 +44,7 @@ DATA
|
|
44
44
|
if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
|
45
45
|
raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
|
46
46
|
else
|
47
|
-
|
47
|
+
self.data[:acls][:bucket][bucket_name] = self.class.acls(options[acl])
|
48
48
|
end
|
49
49
|
response = Excon::Response.new
|
50
50
|
response.status = 200
|
@@ -60,8 +60,8 @@ DATA
|
|
60
60
|
else
|
61
61
|
bucket['LocationConstraint'] = ''
|
62
62
|
end
|
63
|
-
if
|
64
|
-
|
63
|
+
if self.data[:buckets][bucket_name].nil?
|
64
|
+
self.data[:buckets][bucket_name] = bucket
|
65
65
|
else
|
66
66
|
response.status = 409
|
67
67
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
@@ -46,8 +46,8 @@ module Fog
|
|
46
46
|
if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
|
47
47
|
raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
|
48
48
|
else
|
49
|
-
|
50
|
-
|
49
|
+
self.data[:acls][:object][bucket_name] ||= {}
|
50
|
+
self.data[:acls][:object][bucket_name][object_name] = self.class.acls(acl)
|
51
51
|
end
|
52
52
|
|
53
53
|
data = Fog::Storage.parse_data(data)
|
@@ -55,7 +55,7 @@ module Fog
|
|
55
55
|
data[:body] = data[:body].read
|
56
56
|
end
|
57
57
|
response = Excon::Response.new
|
58
|
-
if (bucket =
|
58
|
+
if (bucket = self.data[:buckets][bucket_name])
|
59
59
|
response.status = 200
|
60
60
|
object = {
|
61
61
|
:body => data[:body],
|
@@ -28,7 +28,7 @@ module Fog
|
|
28
28
|
def get_network(network_id)
|
29
29
|
network_id = network_id.to_i
|
30
30
|
response = Excon::Response.new
|
31
|
-
if network =
|
31
|
+
if network = self.data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:id] == network_id }
|
32
32
|
|
33
33
|
body = { "links" => [],
|
34
34
|
"type" => "application/vnd.vmware.vcloud.network+xml",
|
@@ -36,7 +36,7 @@ module Fog
|
|
36
36
|
organization_id = organization_id.to_i
|
37
37
|
response = Excon::Response.new
|
38
38
|
|
39
|
-
if org =
|
39
|
+
if org = self.data[:organizations].detect { |org| org[:info][:id] == organization_id }
|
40
40
|
|
41
41
|
body = { "name" => org[:info][:name],
|
42
42
|
"href" => "#{@base_url}/org/#{org[:info][:id]}",
|
@@ -31,7 +31,7 @@ module Fog
|
|
31
31
|
|
32
32
|
def get_organizations
|
33
33
|
response = Excon::Response.new
|
34
|
-
org_list =
|
34
|
+
org_list = self.data[:organizations].map do |organization|
|
35
35
|
{ "name" => organization[:info][:name],
|
36
36
|
"href" => "#{@base_url}/org/#{organization[:info][:id]}",
|
37
37
|
"type" => "application/vnd.vmware.vcloud.org+xml"
|
@@ -35,7 +35,7 @@ module Fog
|
|
35
35
|
vdc_id = vdc_id.to_i
|
36
36
|
response = Excon::Response.new
|
37
37
|
|
38
|
-
if vdc =
|
38
|
+
if vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
|
39
39
|
body = { "PublicIpAddresses" => [] }
|
40
40
|
vdc[:public_ips].each do |ip|
|
41
41
|
ip = { "name" => ip[:name],
|
@@ -37,7 +37,7 @@ module Fog
|
|
37
37
|
vdc_id = vdc_id.to_i
|
38
38
|
response = Excon::Response.new
|
39
39
|
|
40
|
-
if vdc =
|
40
|
+
if vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == vdc_id }
|
41
41
|
|
42
42
|
body = { "name" => vdc[:name],
|
43
43
|
"href" => "#{@base_url}/vdc/#{vdc[:id]}",
|
data/lib/fog/terremark/shared.rb
CHANGED
data/lib/fog/terremark/vcloud.rb
CHANGED
@@ -106,8 +106,18 @@ module Fog
|
|
106
106
|
@base_url = Fog::Terremark::Vcloud::Defaults::SCHEME + "://" +
|
107
107
|
Fog::Terremark::Vcloud::Defaults::HOST +
|
108
108
|
Fog::Terremark::Vcloud::Defaults::PATH
|
109
|
-
|
109
|
+
|
110
|
+
@terremark_username = options[:terremark_vcloud_username]
|
111
|
+
end
|
112
|
+
|
113
|
+
def data
|
114
|
+
self.class.data[@terremark_username]
|
110
115
|
end
|
116
|
+
|
117
|
+
def reset_data
|
118
|
+
self.class.data.delete(@terremark_username)
|
119
|
+
end
|
120
|
+
|
111
121
|
end
|
112
122
|
|
113
123
|
end
|
data/spec/ecloud/bin_spec.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
require 'ecloud/spec_helper'
|
2
2
|
|
3
3
|
describe 'Ecloud' do
|
4
|
-
it { Ecloud.should be_available }
|
5
4
|
|
6
|
-
it
|
5
|
+
it do
|
6
|
+
pending unless Ecloud.available?
|
7
|
+
Ecloud.should have_at_least(1).services
|
8
|
+
end
|
7
9
|
|
8
10
|
describe "when indexing it like an array" do
|
11
|
+
|
12
|
+
|
9
13
|
describe "with a service that exists" do
|
10
14
|
it "should return something when indexed with a configured service" do
|
15
|
+
pending unless Ecloud.available?
|
11
16
|
Ecloud[:compute].should_not be_nil
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
15
20
|
describe "with a service that does not exist" do
|
16
21
|
it "should raise an ArgumentError" do
|
22
|
+
pending unless Ecloud.available?
|
17
23
|
lambda {Ecloud[:foozle]}.should raise_error(ArgumentError)
|
18
24
|
end
|
19
25
|
end
|