fog 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +29 -29
- data/fog.gemspec +24 -2
- data/lib/fog.rb +4 -15
- data/lib/fog/aws.rb +2 -2
- data/lib/fog/aws/ec2.rb +64 -101
- data/lib/fog/aws/elb.rb +19 -27
- data/lib/fog/aws/models/ec2/addresses.rb +1 -9
- data/lib/fog/aws/models/ec2/flavors.rb +1 -7
- data/lib/fog/aws/models/ec2/images.rb +1 -7
- data/lib/fog/aws/models/ec2/key_pairs.rb +1 -7
- data/lib/fog/aws/models/ec2/security_groups.rb +1 -7
- data/lib/fog/aws/models/ec2/servers.rb +1 -7
- data/lib/fog/aws/models/ec2/snapshots.rb +1 -9
- data/lib/fog/aws/models/ec2/volumes.rb +1 -9
- data/lib/fog/aws/models/s3/directories.rb +1 -7
- data/lib/fog/aws/models/s3/file.rb +5 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +2 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -0
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/delete_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_load_balancers.rb +2 -0
- data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_logging.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +2 -0
- data/lib/fog/aws/requests/s3/get_object_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -0
- data/lib/fog/aws/requests/s3/get_service.rb +2 -0
- data/lib/fog/aws/requests/s3/put_object.rb +2 -2
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -0
- data/lib/fog/aws/requests/simpledb/select.rb +2 -0
- data/lib/fog/aws/s3.rb +68 -85
- data/lib/fog/aws/simpledb.rb +15 -29
- data/lib/fog/bluebox.rb +23 -40
- data/lib/fog/bluebox/models/flavors.rb +1 -7
- data/lib/fog/bluebox/models/images.rb +1 -9
- data/lib/fog/bluebox/models/servers.rb +1 -7
- data/lib/fog/credentials.rb +2 -0
- data/lib/fog/errors.rb +20 -0
- data/lib/fog/hmac.rb +48 -0
- data/lib/fog/local.rb +9 -22
- data/lib/fog/local/models/directories.rb +1 -7
- data/lib/fog/rackspace.rb +2 -6
- data/lib/fog/rackspace/files.rb +46 -48
- data/lib/fog/rackspace/models/files/directories.rb +1 -7
- data/lib/fog/rackspace/models/servers/flavors.rb +1 -7
- data/lib/fog/rackspace/models/servers/images.rb +1 -9
- data/lib/fog/rackspace/models/servers/server.rb +37 -1
- data/lib/fog/rackspace/models/servers/servers.rb +8 -7
- data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
- data/lib/fog/rackspace/servers.rb +33 -45
- data/lib/fog/service.rb +82 -0
- data/lib/fog/slicehost.rb +28 -42
- data/lib/fog/slicehost/models/flavors.rb +1 -7
- data/lib/fog/slicehost/models/images.rb +1 -9
- data/lib/fog/slicehost/models/servers.rb +1 -7
- data/lib/fog/ssh.rb +1 -1
- data/lib/fog/vcloud.rb +20 -3
- data/lib/fog/vcloud/collection.rb +25 -5
- data/lib/fog/vcloud/model.rb +4 -0
- data/lib/fog/vcloud/parsers/get_organization.rb +2 -2
- data/lib/fog/vcloud/parsers/get_vdc.rb +2 -2
- data/lib/fog/vcloud/parsers/get_versions.rb +1 -1
- data/lib/fog/vcloud/parsers/login.rb +2 -2
- data/lib/fog/vcloud/parsers/network.rb +53 -0
- data/lib/fog/vcloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/requests/get_organization.rb +1 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +17 -4
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +35 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +9 -9
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +18 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +36 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +32 -0
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +38 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +3 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +9 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +28 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +31 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +10 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +99 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +51 -0
- data/spec/aws/models/s3/file_spec.rb +15 -0
- data/spec/vcloud/requests/get_network_spec.rb +55 -0
- data/spec/vcloud/spec_helper.rb +1 -0
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +15 -0
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +35 -0
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +28 -0
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +65 -0
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +26 -0
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +0 -2
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +54 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +63 -0
- data/tests/aws/requests/ec2/volume_tests.rb +2 -2
- data/tests/helper.rb +2 -0
- metadata +25 -3
@@ -24,7 +24,7 @@ module Fog
|
|
24
24
|
# * headers<~Hash>:
|
25
25
|
# * 'ETag'<~String> - etag of new object
|
26
26
|
def put_object(bucket_name, object_name, data, options = {})
|
27
|
-
data =
|
27
|
+
data = parse_data(data)
|
28
28
|
headers = data[:headers].merge!(options)
|
29
29
|
request({
|
30
30
|
:body => data[:body],
|
@@ -42,7 +42,7 @@ module Fog
|
|
42
42
|
class Mock
|
43
43
|
|
44
44
|
def put_object(bucket_name, object_name, data, options = {})
|
45
|
-
data =
|
45
|
+
data = parse_data(data)
|
46
46
|
unless data[:body].is_a?(String)
|
47
47
|
data[:body] = data[:body].read
|
48
48
|
end
|
data/lib/fog/aws/s3.rb
CHANGED
@@ -1,82 +1,64 @@
|
|
1
1
|
module Fog
|
2
2
|
module AWS
|
3
3
|
module S3
|
4
|
+
extend Fog::Service
|
5
|
+
|
6
|
+
requires :aws_access_key_id, :aws_secret_access_key
|
7
|
+
|
8
|
+
model_path 'fog/aws/models/s3'
|
9
|
+
model 'directories'
|
10
|
+
model 'directory'
|
11
|
+
model 'files'
|
12
|
+
model 'file'
|
13
|
+
|
14
|
+
request_path 'fog/aws/requests/s3'
|
15
|
+
request 'copy_object'
|
16
|
+
request 'delete_bucket'
|
17
|
+
request 'delete_object'
|
18
|
+
request 'get_bucket'
|
19
|
+
request 'get_bucket_acl'
|
20
|
+
request 'get_bucket_location'
|
21
|
+
request 'get_bucket_logging'
|
22
|
+
request 'get_bucket_object_versions'
|
23
|
+
request 'get_bucket_versioning'
|
24
|
+
request 'get_object'
|
25
|
+
request 'get_object_acl'
|
26
|
+
request 'get_object_torrent'
|
27
|
+
request 'get_object_url'
|
28
|
+
request 'get_request_payment'
|
29
|
+
request 'get_service'
|
30
|
+
request 'head_object'
|
31
|
+
request 'put_bucket'
|
32
|
+
request 'put_bucket_acl'
|
33
|
+
request 'put_bucket_logging'
|
34
|
+
request 'put_bucket_versioning'
|
35
|
+
request 'put_object'
|
36
|
+
request 'put_object_url'
|
37
|
+
request 'put_request_payment'
|
4
38
|
|
5
|
-
|
6
|
-
|
7
|
-
unless @required
|
8
|
-
require 'fog/aws/models/s3/directories'
|
9
|
-
require 'fog/aws/models/s3/directory'
|
10
|
-
require 'fog/aws/models/s3/files'
|
11
|
-
require 'fog/aws/models/s3/file'
|
12
|
-
require 'fog/aws/parsers/s3/access_control_list'
|
13
|
-
require 'fog/aws/parsers/s3/copy_object'
|
14
|
-
require 'fog/aws/parsers/s3/get_bucket'
|
15
|
-
require 'fog/aws/parsers/s3/get_bucket_location'
|
16
|
-
require 'fog/aws/parsers/s3/get_bucket_logging'
|
17
|
-
require 'fog/aws/parsers/s3/get_bucket_object_versions'
|
18
|
-
require 'fog/aws/parsers/s3/get_bucket_versioning'
|
19
|
-
require 'fog/aws/parsers/s3/get_request_payment'
|
20
|
-
require 'fog/aws/parsers/s3/get_service'
|
21
|
-
require 'fog/aws/requests/s3/copy_object'
|
22
|
-
require 'fog/aws/requests/s3/delete_bucket'
|
23
|
-
require 'fog/aws/requests/s3/delete_object'
|
24
|
-
require 'fog/aws/requests/s3/get_bucket'
|
25
|
-
require 'fog/aws/requests/s3/get_bucket_acl'
|
26
|
-
require 'fog/aws/requests/s3/get_bucket_location'
|
27
|
-
require 'fog/aws/requests/s3/get_bucket_logging'
|
28
|
-
require 'fog/aws/requests/s3/get_bucket_object_versions'
|
29
|
-
require 'fog/aws/requests/s3/get_bucket_versioning'
|
30
|
-
require 'fog/aws/requests/s3/get_object'
|
31
|
-
require 'fog/aws/requests/s3/get_object_acl'
|
32
|
-
require 'fog/aws/requests/s3/get_object_torrent'
|
33
|
-
require 'fog/aws/requests/s3/get_object_url'
|
34
|
-
require 'fog/aws/requests/s3/get_request_payment'
|
35
|
-
require 'fog/aws/requests/s3/get_service'
|
36
|
-
require 'fog/aws/requests/s3/head_object'
|
37
|
-
require 'fog/aws/requests/s3/put_bucket'
|
38
|
-
require 'fog/aws/requests/s3/put_bucket_acl'
|
39
|
-
require 'fog/aws/requests/s3/put_bucket_logging'
|
40
|
-
require 'fog/aws/requests/s3/put_bucket_versioning'
|
41
|
-
require 'fog/aws/requests/s3/put_object'
|
42
|
-
require 'fog/aws/requests/s3/put_object_url'
|
43
|
-
require 'fog/aws/requests/s3/put_request_payment'
|
44
|
-
@required = true
|
45
|
-
end
|
46
|
-
|
47
|
-
if Fog.mocking?
|
48
|
-
Fog::AWS::S3::Mock.new(options)
|
49
|
-
else
|
50
|
-
Fog::AWS::S3::Real.new(options)
|
51
|
-
end
|
52
|
-
end
|
39
|
+
module Utils
|
53
40
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
41
|
+
def parse_data(data)
|
42
|
+
metadata = {
|
43
|
+
:body => nil,
|
44
|
+
:headers => {}
|
45
|
+
}
|
46
|
+
|
47
|
+
if data.is_a?(String)
|
48
|
+
metadata[:body] = data
|
49
|
+
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
50
|
+
else
|
51
|
+
filename = ::File.basename(data.path)
|
52
|
+
unless (mime_types = MIME::Types.of(filename)).empty?
|
53
|
+
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
54
|
+
end
|
55
|
+
metadata[:body] = data
|
56
|
+
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
67
57
|
end
|
68
|
-
metadata[:
|
69
|
-
metadata
|
58
|
+
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
59
|
+
metadata
|
70
60
|
end
|
71
|
-
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
72
|
-
metadata
|
73
|
-
end
|
74
61
|
|
75
|
-
def self.reset_data(keys=Mock.data.keys)
|
76
|
-
Mock.reset_data(keys)
|
77
|
-
end
|
78
|
-
|
79
|
-
module Utils
|
80
62
|
def url(params, expires)
|
81
63
|
params[:headers]['Date'] = expires.to_i
|
82
64
|
query = [params[:query]].compact
|
@@ -85,9 +67,11 @@ module Fog
|
|
85
67
|
query << "Expires=#{params[:headers]['Date']}"
|
86
68
|
"http://#{params[:host]}/#{params[:path]}?#{query.join('&')}"
|
87
69
|
end
|
70
|
+
|
88
71
|
end
|
89
72
|
|
90
73
|
class Mock
|
74
|
+
include Collections
|
91
75
|
include Utils
|
92
76
|
|
93
77
|
def self.data
|
@@ -115,7 +99,10 @@ module Fog
|
|
115
99
|
end
|
116
100
|
|
117
101
|
class Real
|
102
|
+
include Collections
|
118
103
|
include Utils
|
104
|
+
extend Fog::Deprecation
|
105
|
+
deprecate(:reset, :reload)
|
119
106
|
|
120
107
|
# Initialize connection to S3
|
121
108
|
#
|
@@ -135,14 +122,10 @@ module Fog
|
|
135
122
|
# ==== Returns
|
136
123
|
# * S3 object with connection to aws.
|
137
124
|
def initialize(options={})
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
|
143
|
-
end
|
144
|
-
@hmac = HMAC::SHA1.new(@aws_secret_access_key)
|
145
|
-
@host = options[:host] || case options[:region]
|
125
|
+
@aws_access_key_id = options[:aws_access_key_id]
|
126
|
+
@aws_secret_access_key = options[:aws_secret_access_key]
|
127
|
+
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
|
128
|
+
@host = options[:host] || case options[:region]
|
146
129
|
when 'ap-southeast-1'
|
147
130
|
's3-ap-southeast-1.amazonaws.com'
|
148
131
|
when 'us-west-1'
|
@@ -150,12 +133,12 @@ module Fog
|
|
150
133
|
else
|
151
134
|
's3.amazonaws.com'
|
152
135
|
end
|
153
|
-
@port
|
154
|
-
@scheme
|
155
|
-
|
136
|
+
@port = options[:port] || 443
|
137
|
+
@scheme = options[:scheme] || 'https'
|
138
|
+
reload
|
156
139
|
end
|
157
140
|
|
158
|
-
def
|
141
|
+
def reload
|
159
142
|
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
160
143
|
end
|
161
144
|
|
@@ -217,8 +200,8 @@ DATA
|
|
217
200
|
canonical_resource.chop!
|
218
201
|
string_to_sign << "#{canonical_resource}"
|
219
202
|
|
220
|
-
|
221
|
-
signature = Base64.encode64(
|
203
|
+
signed_string = @hmac.sign(string_to_sign)
|
204
|
+
signature = Base64.encode64(signed_string).chomp!
|
222
205
|
end
|
223
206
|
end
|
224
207
|
end
|
data/lib/fog/aws/simpledb.rb
CHANGED
@@ -1,38 +1,23 @@
|
|
1
1
|
module Fog
|
2
2
|
module AWS
|
3
3
|
module SimpleDB
|
4
|
+
extend Fog::Service
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
unless @required
|
8
|
-
require 'fog/aws/parsers/simpledb/domain_metadata'
|
9
|
-
require 'fog/aws/parsers/simpledb/get_attributes'
|
10
|
-
require 'fog/aws/parsers/simpledb/list_domains'
|
11
|
-
require 'fog/aws/parsers/simpledb/select'
|
12
|
-
require 'fog/aws/requests/simpledb/batch_put_attributes'
|
13
|
-
require 'fog/aws/requests/simpledb/create_domain'
|
14
|
-
require 'fog/aws/requests/simpledb/delete_attributes'
|
15
|
-
require 'fog/aws/requests/simpledb/delete_domain'
|
16
|
-
require 'fog/aws/requests/simpledb/domain_metadata'
|
17
|
-
require 'fog/aws/requests/simpledb/get_attributes'
|
18
|
-
require 'fog/aws/requests/simpledb/list_domains'
|
19
|
-
require 'fog/aws/requests/simpledb/put_attributes'
|
20
|
-
require 'fog/aws/requests/simpledb/select'
|
21
|
-
@required = true
|
22
|
-
end
|
6
|
+
requires :aws_access_key_id, :aws_secret_access_key
|
23
7
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
8
|
+
request_path 'fog/aws/requests/simpledb'
|
9
|
+
request 'batch_put_attributes'
|
10
|
+
request 'create_domain'
|
11
|
+
request 'delete_attributes'
|
12
|
+
request 'delete_domain'
|
13
|
+
request 'domain_metadata'
|
14
|
+
request 'get_attributes'
|
15
|
+
request 'list_domains'
|
16
|
+
request 'put_attributes'
|
17
|
+
request 'select'
|
34
18
|
|
35
19
|
class Mock
|
20
|
+
include Collections
|
36
21
|
|
37
22
|
def self.data
|
38
23
|
@data ||= Hash.new do |hash, key|
|
@@ -56,6 +41,7 @@ module Fog
|
|
56
41
|
end
|
57
42
|
|
58
43
|
class Real
|
44
|
+
include Collections
|
59
45
|
|
60
46
|
# Initialize connection to SimpleDB
|
61
47
|
#
|
@@ -77,7 +63,7 @@ module Fog
|
|
77
63
|
def initialize(options={})
|
78
64
|
@aws_access_key_id = options[:aws_access_key_id]
|
79
65
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
80
|
-
@hmac = HMAC
|
66
|
+
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
81
67
|
@host = options[:host] || 'sdb.amazonaws.com'
|
82
68
|
@nil_string = options[:nil_string]|| 'nil'
|
83
69
|
@port = options[:port] || 443
|