fog 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/README.rdoc +16 -7
- data/fog.gemspec +102 -27
- data/lib/fog.rb +3 -2
- data/lib/fog/aws/cdn.rb +2 -1
- data/lib/fog/aws/compute.rb +3 -2
- data/lib/fog/aws/iam.rb +8 -0
- data/lib/fog/aws/models/compute/flavors.rb +2 -1
- data/lib/fog/aws/models/compute/server.rb +3 -0
- data/lib/fog/aws/models/compute/volume.rb +9 -8
- data/lib/fog/aws/models/storage/file.rb +24 -14
- data/lib/fog/aws/models/storage/files.rb +4 -14
- data/lib/fog/aws/parsers/cdn/distribution.rb +16 -1
- data/lib/fog/aws/parsers/cdn/get_distribution_list.rb +13 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +2 -0
- data/lib/fog/aws/parsers/iam/create_group.rb +2 -2
- data/lib/fog/aws/parsers/iam/create_user.rb +26 -0
- data/lib/fog/aws/parsers/iam/list_group_policies.rb +28 -0
- data/lib/fog/aws/parsers/iam/list_groups.rb +1 -1
- data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/initiate_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/list_multipart_uploads.rb +56 -0
- data/lib/fog/aws/parsers/storage/list_parts.rb +40 -0
- data/lib/fog/aws/requests/cdn/get_distribution.rb +11 -1
- data/lib/fog/aws/requests/cdn/get_distribution_list.rb +9 -1
- data/lib/fog/aws/requests/cdn/post_distribution.rb +16 -5
- data/lib/fog/aws/requests/cdn/put_distribution_config.rb +102 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +1 -0
- data/lib/fog/aws/requests/compute/run_instances.rb +1 -1
- data/lib/fog/aws/requests/iam/add_user_to_group.rb +42 -0
- data/lib/fog/aws/requests/iam/create_group.rb +7 -3
- data/lib/fog/aws/requests/iam/create_user.rb +47 -0
- data/lib/fog/aws/requests/iam/delete_group.rb +5 -1
- data/lib/fog/aws/requests/iam/delete_group_policy.rb +42 -0
- data/lib/fog/aws/requests/iam/delete_user.rb +40 -0
- data/lib/fog/aws/requests/iam/list_group_policies.rb +47 -0
- data/lib/fog/aws/requests/iam/list_groups.rb +9 -4
- data/lib/fog/aws/requests/iam/put_group_policy.rb +44 -0
- data/lib/fog/aws/requests/iam/remove_user_from_group.rb +42 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
- data/lib/fog/aws/requests/storage/abort_multipart_upload.rb +38 -0
- data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +60 -0
- data/lib/fog/aws/requests/storage/get_service.rb +1 -1
- data/lib/fog/aws/requests/storage/initiate_multipart_upload.rb +55 -0
- data/lib/fog/aws/requests/storage/list_multipart_uploads.rb +68 -0
- data/lib/fog/aws/requests/storage/list_parts.rb +67 -0
- data/lib/fog/aws/requests/storage/put_object.rb +12 -5
- data/lib/fog/aws/requests/storage/upload_part.rb +51 -0
- data/lib/fog/aws/storage.rb +12 -6
- data/lib/fog/brightbox.rb +7 -0
- data/lib/fog/brightbox/bin.rb +23 -0
- data/lib/fog/brightbox/compute.rb +134 -0
- data/lib/fog/brightbox/models/compute/account.rb +51 -0
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +43 -0
- data/lib/fog/brightbox/models/compute/cloud_ips.rb +34 -0
- data/lib/fog/brightbox/models/compute/flavor.rb +33 -0
- data/lib/fog/brightbox/models/compute/flavors.rb +28 -0
- data/lib/fog/brightbox/models/compute/image.rb +52 -0
- data/lib/fog/brightbox/models/compute/images.rb +28 -0
- data/lib/fog/brightbox/models/compute/server.rb +94 -0
- data/lib/fog/brightbox/models/compute/servers.rb +29 -0
- data/lib/fog/brightbox/models/compute/user.rb +39 -0
- data/lib/fog/brightbox/models/compute/users.rb +29 -0
- data/lib/fog/brightbox/models/compute/zone.rb +21 -0
- data/lib/fog/brightbox/models/compute/zones.rb +29 -0
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_image.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_interface.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_user.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_zone.rb +28 -0
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_images.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_servers.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_users.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_zones.rb +27 -0
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/resize_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/start_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/stop_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_account.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_image.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_server.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_user.rb +29 -0
- data/lib/fog/core/attributes.rb +3 -3
- data/lib/fog/core/bin.rb +2 -0
- data/lib/fog/core/compute.rb +5 -2
- data/lib/fog/core/credentials.rb +2 -0
- data/lib/fog/core/service.rb +24 -12
- data/lib/fog/google/models/storage/file.rb +23 -14
- data/lib/fog/google/models/storage/files.rb +4 -14
- data/lib/fog/google/requests/storage/get_bucket.rb +0 -1
- data/lib/fog/google/requests/storage/put_object.rb +9 -2
- data/lib/fog/rackspace/models/storage/file.rb +3 -3
- data/lib/fog/rackspace/models/storage/files.rb +5 -13
- data/spec/aws/models/compute/server_spec.rb +0 -3
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +11 -0
- data/spec/core/attributes_spec.rb +52 -0
- data/spec/vcloud/bin_spec.rb +1 -1
- data/spec/vcloud/vcloud_spec.rb +1 -1
- data/tests/aws/models/compute/flavors_tests.rb +5 -0
- data/tests/aws/models/compute/server_tests.rb +6 -0
- data/tests/aws/models/compute/servers_tests.rb +6 -0
- data/tests/aws/requests/storage/bucket_tests.rb +1 -1
- data/tests/aws/requests/storage/multipart_upload_tests.rb +135 -0
- data/tests/bluebox/models/compute/flavors_tests.rb +5 -0
- data/tests/bluebox/models/compute/server_tests.rb +5 -0
- data/tests/bluebox/models/compute/servers_tests.rb +6 -0
- data/tests/brightbox/helper.rb +0 -0
- data/tests/brightbox/models/compute/flavors_tests.rb +5 -0
- data/tests/brightbox/models/compute/server_tests.rb +6 -0
- data/tests/brightbox/models/compute/servers_tests.rb +6 -0
- data/tests/google/requests/storage/bucket_tests.rb +78 -0
- data/tests/google/requests/storage/object_tests.rb +81 -0
- data/tests/helper.rb +19 -4
- data/tests/helpers/collection_tests.rb +51 -0
- data/tests/helpers/compute/flavors_tests.rb +34 -0
- data/tests/helpers/compute/server_tests.rb +19 -0
- data/tests/helpers/compute/servers_tests.rb +11 -0
- data/tests/helpers/model_tests.rb +28 -0
- data/tests/helpers/storage/directories_tests.rb +4 -36
- data/tests/helpers/storage/directory_tests.rb +8 -22
- data/tests/helpers/storage/file_tests.rb +8 -25
- data/tests/helpers/storage/files_tests.rb +5 -39
- data/tests/local/models/storage/directories_tests.rb +1 -1
- data/tests/local/models/storage/directory_tests.rb +1 -1
- data/tests/local/models/storage/file_tests.rb +1 -1
- data/tests/local/models/storage/files_tests.rb +1 -1
- data/tests/rackspace/models/compute/flavors_tests.rb +5 -0
- data/tests/rackspace/models/compute/server_tests.rb +6 -0
- data/tests/rackspace/models/compute/servers_tests.rb +6 -0
- data/tests/rackspace/models/storage/directories_tests.rb +1 -1
- data/tests/rackspace/models/storage/directory_tests.rb +1 -1
- data/tests/rackspace/models/storage/file_tests.rb +1 -1
- data/tests/rackspace/models/storage/files_tests.rb +1 -1
- data/tests/slicehost/models/compute/flavors_tests.rb +5 -0
- data/tests/slicehost/models/compute/server_tests.rb +6 -0
- data/tests/slicehost/models/compute/servers_tests.rb +6 -0
- metadata +108 -31
- data/spec/aws/models/compute/flavors_spec.rb +0 -14
- data/spec/aws/models/compute/servers_spec.rb +0 -21
- data/spec/bluebox/models/compute/flavors_spec.rb +0 -17
- data/spec/bluebox/models/compute/server_spec.rb +0 -29
- data/spec/bluebox/models/compute/servers_spec.rb +0 -31
- data/spec/google/requests/storage/copy_object_spec.rb +0 -61
- data/spec/google/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/google/requests/storage/delete_object_spec.rb +0 -38
- data/spec/google/requests/storage/get_bucket_spec.rb +0 -110
- data/spec/google/requests/storage/get_object_spec.rb +0 -58
- data/spec/google/requests/storage/get_service_spec.rb +0 -32
- data/spec/google/requests/storage/head_object_spec.rb +0 -26
- data/spec/google/requests/storage/put_bucket_spec.rb +0 -21
- data/spec/google/requests/storage/put_object_spec.rb +0 -43
- data/spec/rackspace/models/compute/flavors_spec.rb +0 -18
- data/spec/rackspace/models/compute/server_spec.rb +0 -55
- data/spec/rackspace/models/compute/servers_spec.rb +0 -22
- data/spec/shared_examples/flavors_examples.rb +0 -16
- data/spec/shared_examples/server_examples.rb +0 -43
- data/spec/shared_examples/servers_examples.rb +0 -37
- data/spec/slicehost/models/compute/flavors_spec.rb +0 -18
- data/spec/slicehost/models/compute/server_spec.rb +0 -55
- data/spec/slicehost/models/compute/servers_spec.rb +0 -26
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class Storage
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Upload a part for a multipart upload
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * bucket_name<~String> - Name of bucket to add part to
|
10
|
+
# * object_name<~String> - Name of object to add part to
|
11
|
+
# * upload_id<~String> - Id of upload to add part to
|
12
|
+
# * part_number<~String> - Index of part in upload
|
13
|
+
# * data<~File||String> - Content for part
|
14
|
+
# * options<~Hash>:
|
15
|
+
# * 'Content-MD5'<~String> - Base64 encoded 128-bit MD5 digest of message
|
16
|
+
#
|
17
|
+
# ==== Returns
|
18
|
+
# * response<~Excon::Response>:
|
19
|
+
# * headers<~Hash>:
|
20
|
+
# * 'ETag'<~String> - etag of new object (will be needed to complete upload)
|
21
|
+
#
|
22
|
+
# ==== See Also
|
23
|
+
# http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadUploadPart.html
|
24
|
+
#
|
25
|
+
def upload_part(bucket_name, object_name, upload_id, part_number, data, options = {})
|
26
|
+
data = parse_data(data)
|
27
|
+
headers = options
|
28
|
+
headers['Content-Length'] = data[:headers]['Content-Length']
|
29
|
+
request({
|
30
|
+
:body => data[:body],
|
31
|
+
:expects => 200,
|
32
|
+
:headers => headers,
|
33
|
+
:host => "#{bucket_name}.#{@host}",
|
34
|
+
:method => 'PUT',
|
35
|
+
:path => CGI.escape(object_name),
|
36
|
+
:query => {'uploadId' => upload_id, 'partNumber' => part_number}
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Real
|
41
|
+
|
42
|
+
class Mock # :nodoc:all
|
43
|
+
|
44
|
+
def upload_part(bucket_name, object_name, upload_id, part_number, data, options = {})
|
45
|
+
Fog::Mock.not_implemented
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Mock
|
49
|
+
end # Storage
|
50
|
+
end # AWS
|
51
|
+
end # Fog
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -11,6 +11,8 @@ module Fog
|
|
11
11
|
model :file
|
12
12
|
|
13
13
|
request_path 'fog/aws/requests/storage'
|
14
|
+
request :abort_multipart_upload
|
15
|
+
request :complete_multipart_upload
|
14
16
|
request :copy_object
|
15
17
|
request :delete_bucket
|
16
18
|
request :delete_object
|
@@ -27,6 +29,9 @@ module Fog
|
|
27
29
|
request :get_request_payment
|
28
30
|
request :get_service
|
29
31
|
request :head_object
|
32
|
+
request :initiate_multipart_upload
|
33
|
+
request :list_multipart_uploads
|
34
|
+
request :list_parts
|
30
35
|
request :post_object_hidden_fields
|
31
36
|
request :put_bucket
|
32
37
|
request :put_bucket_acl
|
@@ -35,6 +40,7 @@ module Fog
|
|
35
40
|
request :put_object
|
36
41
|
request :put_object_url
|
37
42
|
request :put_request_payment
|
43
|
+
request :upload_part
|
38
44
|
|
39
45
|
module Utils
|
40
46
|
|
@@ -219,7 +225,7 @@ DATA
|
|
219
225
|
for key, value in amz_headers
|
220
226
|
canonical_amz_headers << "#{key}:#{value}\n"
|
221
227
|
end
|
222
|
-
string_to_sign <<
|
228
|
+
string_to_sign << canonical_amz_headers
|
223
229
|
|
224
230
|
subdomain = params[:host].split(".#{@host}").first
|
225
231
|
unless subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
@@ -228,7 +234,7 @@ DATA
|
|
228
234
|
if params[:path]
|
229
235
|
params[:path] = "#{subdomain}/#{params[:path]}"
|
230
236
|
else
|
231
|
-
params[:path] =
|
237
|
+
params[:path] = subdomain
|
232
238
|
end
|
233
239
|
subdomain = nil
|
234
240
|
end
|
@@ -237,15 +243,15 @@ DATA
|
|
237
243
|
unless subdomain.nil? || subdomain == @host
|
238
244
|
canonical_resource << "#{CGI.escape(subdomain).downcase}/"
|
239
245
|
end
|
240
|
-
canonical_resource <<
|
246
|
+
canonical_resource << params[:path].to_s
|
241
247
|
canonical_resource << '?'
|
242
248
|
for key in (params[:query] || {}).keys
|
243
|
-
if
|
244
|
-
canonical_resource << "#{key}&"
|
249
|
+
if %w{acl location logging notification partNumber policy requestPayment torrent uploadId uploads versionId versioning versions}.include?(key)
|
250
|
+
canonical_resource << "#{key}#{"=#{params[:query][key]}" unless params[:query][key].nil?}&"
|
245
251
|
end
|
246
252
|
end
|
247
253
|
canonical_resource.chop!
|
248
|
-
string_to_sign <<
|
254
|
+
string_to_sign << canonical_resource
|
249
255
|
|
250
256
|
signed_string = @hmac.sign(string_to_sign)
|
251
257
|
signature = Base64.encode64(signed_string).chomp!
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Brightbox < Fog::Bin
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def [](service)
|
5
|
+
@@connections ||= Hash.new do |hash, key|
|
6
|
+
hash[key] = case key
|
7
|
+
when :compute
|
8
|
+
Fog::Brightbox::Compute.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
@@connections[service]
|
12
|
+
end
|
13
|
+
|
14
|
+
def services
|
15
|
+
[:compute]
|
16
|
+
end
|
17
|
+
|
18
|
+
def account
|
19
|
+
@@connections[:compute].account
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Fog
|
2
|
+
module Brightbox
|
3
|
+
class Compute < Fog::Service
|
4
|
+
|
5
|
+
API_URL = "https://api.gb1.brightbox.com/"
|
6
|
+
|
7
|
+
requires :brightbox_client_id, :brightbox_secret
|
8
|
+
|
9
|
+
model_path 'fog/brightbox/models/compute'
|
10
|
+
model :account # Singular resource, no collection
|
11
|
+
collection :servers
|
12
|
+
model :server
|
13
|
+
collection :flavors
|
14
|
+
model :flavor
|
15
|
+
collection :images
|
16
|
+
model :image
|
17
|
+
collection :zones
|
18
|
+
model :zone
|
19
|
+
collection :cloud_ips
|
20
|
+
model :cloud_ip
|
21
|
+
collection :users
|
22
|
+
model :user
|
23
|
+
|
24
|
+
request_path 'fog/brightbox/requests/compute'
|
25
|
+
request :create_api_client
|
26
|
+
request :create_cloud_ip
|
27
|
+
request :create_image
|
28
|
+
request :create_server
|
29
|
+
request :destroy_api_client
|
30
|
+
request :destroy_cloud_ip
|
31
|
+
request :destroy_image
|
32
|
+
request :destroy_server
|
33
|
+
request :get_account
|
34
|
+
request :get_api_client
|
35
|
+
request :get_cloud_ip
|
36
|
+
request :get_image
|
37
|
+
request :get_interface
|
38
|
+
request :get_server
|
39
|
+
request :get_server_type
|
40
|
+
request :get_user
|
41
|
+
request :get_zone
|
42
|
+
request :list_api_clients
|
43
|
+
request :list_cloud_ips
|
44
|
+
request :list_images
|
45
|
+
request :list_server_types
|
46
|
+
request :list_servers
|
47
|
+
request :list_users
|
48
|
+
request :list_zones
|
49
|
+
request :map_cloud_ip
|
50
|
+
request :reset_ftp_password_account
|
51
|
+
request :resize_server
|
52
|
+
request :shutdown_server
|
53
|
+
request :snapshot_server
|
54
|
+
request :start_server
|
55
|
+
request :stop_server
|
56
|
+
request :unmap_cloud_ip
|
57
|
+
request :update_account
|
58
|
+
request :update_api_client
|
59
|
+
request :update_image
|
60
|
+
request :update_server
|
61
|
+
request :update_user
|
62
|
+
|
63
|
+
class Mock
|
64
|
+
|
65
|
+
def initialize(options)
|
66
|
+
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
|
67
|
+
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
|
68
|
+
end
|
69
|
+
|
70
|
+
def request(options)
|
71
|
+
raise "Not implemented"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class Real
|
76
|
+
|
77
|
+
def initialize(options)
|
78
|
+
require "json"
|
79
|
+
# Currently authentication and api endpoints are the same but may change
|
80
|
+
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
|
81
|
+
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
|
82
|
+
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
|
83
|
+
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
|
84
|
+
@connection = Fog::Connection.new(@api_url)
|
85
|
+
end
|
86
|
+
|
87
|
+
def request(params)
|
88
|
+
begin
|
89
|
+
get_oauth_token if @oauth_token.nil?
|
90
|
+
response = authenticated_request(params)
|
91
|
+
rescue Excon::Errors::Unauthorized => e
|
92
|
+
get_oauth_token
|
93
|
+
response = authenticated_request(params)
|
94
|
+
end
|
95
|
+
unless response.body.empty?
|
96
|
+
response = JSON.parse(response.body)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def account
|
101
|
+
Fog::Brightbox::Compute::Account.new(get_account)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
def get_oauth_token(options = {})
|
106
|
+
auth_url = options[:brightbox_auth_url] || @auth_url
|
107
|
+
|
108
|
+
connection = Fog::Connection.new(auth_url)
|
109
|
+
@authentication_body = {'client_id' => @brightbox_client_id, 'grant_type' => 'none'}.to_json
|
110
|
+
|
111
|
+
response = connection.request({
|
112
|
+
:path => "/token",
|
113
|
+
:expects => 200,
|
114
|
+
:headers => {
|
115
|
+
'Authorization' => "Basic " + Base64.encode64("#{@brightbox_client_id}:#{@brightbox_secret}").chomp,
|
116
|
+
'Content-Type' => 'application/json'
|
117
|
+
},
|
118
|
+
:method => 'POST',
|
119
|
+
:body => @authentication_body
|
120
|
+
})
|
121
|
+
@oauth_token = JSON.parse(response.body)["access_token"]
|
122
|
+
return @oauth_token
|
123
|
+
end
|
124
|
+
|
125
|
+
def authenticated_request(options)
|
126
|
+
headers = options[:headers] || {}
|
127
|
+
headers.merge!("Authorization" => "OAuth #{@oauth_token}")
|
128
|
+
options[:headers] = headers
|
129
|
+
@connection.request(options)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Brightbox
|
5
|
+
class Compute
|
6
|
+
|
7
|
+
class Account < Fog::Model
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
attribute :resource_type
|
11
|
+
attribute :url
|
12
|
+
attribute :name
|
13
|
+
attribute :status
|
14
|
+
attribute :address_1
|
15
|
+
attribute :address_2
|
16
|
+
attribute :city
|
17
|
+
attribute :county
|
18
|
+
attribute :postcode
|
19
|
+
attribute :country_code
|
20
|
+
attribute :country_name
|
21
|
+
attribute :vat_registration_number
|
22
|
+
attribute :telephone_number
|
23
|
+
attribute :telephone_verified
|
24
|
+
attribute :ram_limit
|
25
|
+
attribute :ram_used
|
26
|
+
attribute :limits_cloudips
|
27
|
+
attribute :library_ftp_host
|
28
|
+
attribute :library_ftp_user
|
29
|
+
# This is always returned as null/nil unless performing a reset_ftp_password request
|
30
|
+
attribute :library_ftp_password
|
31
|
+
attribute :created_at, :type => :time
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
attribute :owner_id, :aliases => "owner", :squash => "id"
|
36
|
+
attribute :clients
|
37
|
+
attribute :images
|
38
|
+
attribute :servers
|
39
|
+
attribute :users
|
40
|
+
attribute :zones
|
41
|
+
|
42
|
+
def reset_ftp_password
|
43
|
+
requires :identity
|
44
|
+
connection.reset_ftp_password_account(identity)["library_ftp_password"]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Brightbox
|
5
|
+
class Compute
|
6
|
+
|
7
|
+
class CloudIp < Fog::Model
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
attribute :url
|
12
|
+
attribute :name
|
13
|
+
attribute :status
|
14
|
+
attribute :resource_type
|
15
|
+
attribute :description
|
16
|
+
|
17
|
+
attribute :reverse_dns
|
18
|
+
attribute :public_ip
|
19
|
+
|
20
|
+
attribute :account_id, :aliases => "account", :squash => "id"
|
21
|
+
attribute :interface_id, :aliases => "interface", :squash => "id"
|
22
|
+
attribute :server_id, :aliases => "server", :squash => "id"
|
23
|
+
|
24
|
+
def map(interface_to_map)
|
25
|
+
requires :identity
|
26
|
+
connection.map_cloud_ip(identity, :interface => interface_to_map)
|
27
|
+
end
|
28
|
+
|
29
|
+
def unmap
|
30
|
+
requires :identity
|
31
|
+
connection.unmap_cloud_ip(identity)
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
requires :identity
|
36
|
+
connection.destroy_cloud_ip(identity)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/brightbox/models/compute/cloud_ip'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Brightbox
|
6
|
+
class Compute
|
7
|
+
|
8
|
+
class CloudIps < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::Brightbox::Compute::CloudIp
|
11
|
+
|
12
|
+
def all
|
13
|
+
data = connection.list_cloud_ips
|
14
|
+
load(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(identifier)
|
18
|
+
return nil if identifier.nil? || identifier == ""
|
19
|
+
data = connection.get_cloud_ip(identifier)
|
20
|
+
new(data)
|
21
|
+
rescue Excon::Errors::NotFound
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def allocate
|
26
|
+
data = connection.create_cloud_ip
|
27
|
+
new(data)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Brightbox
|
5
|
+
class Compute
|
6
|
+
|
7
|
+
class Flavor < Fog::Model
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
attribute :url
|
12
|
+
attribute :name
|
13
|
+
attribute :status
|
14
|
+
|
15
|
+
attribute :handle
|
16
|
+
|
17
|
+
attribute :bits
|
18
|
+
attribute :cores
|
19
|
+
attribute :disk, :aliases => "disk_size"
|
20
|
+
attribute :ram
|
21
|
+
|
22
|
+
attribute :resource_type
|
23
|
+
attribute :description
|
24
|
+
|
25
|
+
def bits
|
26
|
+
0 # This is actually based on the Image type used. 32bit or 64bit Images are supported
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|