fog 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -2
- data/README.md +9 -10
- data/Rakefile +15 -299
- data/changelog.txt +153 -0
- data/docs/about/contributing.markdown +1 -0
- data/docs/dns/index.markdown +1 -1
- data/docs/index.markdown +8 -3
- data/fog.gemspec +3 -3
- data/lib/fog.rb +0 -5
- data/lib/fog/aws/auto_scaling.rb +1 -1
- data/lib/fog/aws/cloud_watch.rb +1 -1
- data/lib/fog/aws/compute.rb +2 -1
- data/lib/fog/aws/dynamodb.rb +30 -64
- data/lib/fog/aws/elb.rb +1 -1
- data/lib/fog/aws/glacier.rb +1 -1
- data/lib/fog/aws/iam.rb +1 -0
- data/lib/fog/aws/models/auto_scaling/group.rb +1 -1
- data/lib/fog/aws/models/compute/server.rb +2 -0
- data/lib/fog/aws/models/compute/volume.rb +0 -1
- data/lib/fog/aws/models/iam/user.rb +1 -1
- data/lib/fog/aws/parsers/compute/describe_instances.rb +3 -1
- data/lib/fog/aws/parsers/compute/describe_reserved_instances_offerings.rb +1 -1
- data/lib/fog/aws/parsers/storage/delete_multiple_objects.rb +50 -0
- data/lib/fog/aws/rds.rb +2 -2
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
- data/lib/fog/aws/requests/compute/describe_reserved_instances_offerings.rb +11 -8
- data/lib/fog/aws/requests/compute/modify_volume_attribute.rb +51 -0
- data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +1 -0
- data/lib/fog/aws/requests/storage/delete_multiple_objects.rb +172 -0
- data/lib/fog/aws/signaturev4.rb +1 -1
- data/lib/fog/aws/sqs.rb +1 -1
- data/lib/fog/aws/storage.rb +2 -0
- data/lib/fog/bluebox/requests/compute/create_block.rb +1 -3
- data/lib/fog/brightbox/compute.rb +239 -84
- data/lib/fog/brightbox/models/compute/account.rb +9 -3
- data/lib/fog/brightbox/models/compute/server.rb +2 -1
- data/lib/fog/brightbox/models/compute/servers.rb +33 -1
- data/lib/fog/brightbox/oauth2.rb +164 -0
- data/lib/fog/brightbox/requests/compute/activate_console_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +11 -2
- data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +11 -2
- data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +9 -11
- data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +11 -2
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +11 -2
- data/lib/fog/brightbox/requests/compute/create_application.rb +11 -2
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +11 -1
- data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +13 -2
- data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +17 -2
- data/lib/fog/brightbox/requests/compute/create_image.rb +18 -2
- data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +14 -2
- data/lib/fog/brightbox/requests/compute/create_server.rb +17 -2
- data/lib/fog/brightbox/requests/compute/create_server_group.rb +11 -2
- data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_application.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_firewall_policy.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_firewall_rule.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_image.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_load_balancer.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/destroy_server_group.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_account.rb +7 -15
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_application.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +1 -3
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_image.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_interface.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +1 -5
- data/lib/fog/brightbox/requests/compute/get_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_server_group.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +9 -2
- data/lib/fog/brightbox/requests/compute/get_user.rb +7 -15
- data/lib/fog/brightbox/requests/compute/get_zone.rb +9 -2
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +6 -2
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_applications.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_images.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_server_groups.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_servers.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_users.rb +8 -2
- data/lib/fog/brightbox/requests/compute/list_zones.rb +8 -2
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +11 -2
- data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +10 -12
- data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +11 -2
- data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +11 -2
- data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +11 -2
- data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +9 -10
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +22 -3
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +18 -0
- data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +13 -1
- data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +9 -2
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/start_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/stop_server.rb +9 -2
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +9 -2
- data/lib/fog/brightbox/requests/compute/update_account.rb +32 -34
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +12 -2
- data/lib/fog/brightbox/requests/compute/update_application.rb +12 -2
- data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +13 -2
- data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +16 -1
- data/lib/fog/brightbox/requests/compute/update_image.rb +17 -2
- data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +15 -2
- data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +12 -19
- data/lib/fog/brightbox/requests/compute/update_server.rb +12 -2
- data/lib/fog/brightbox/requests/compute/update_server_group.rb +12 -2
- data/lib/fog/brightbox/requests/compute/update_user.rb +15 -2
- data/lib/fog/cloudstack/models/compute/server.rb +3 -1
- data/lib/fog/core.rb +1 -0
- data/lib/fog/core/connection.rb +1 -0
- data/lib/fog/google/storage.rb +13 -2
- data/lib/fog/libvirt/models/compute/server.rb +1 -0
- data/lib/fog/libvirt/requests/compute/list_domains.rb +2 -2
- data/lib/fog/openstack.rb +57 -58
- data/lib/fog/openstack/compute.rb +15 -14
- data/lib/fog/openstack/identity.rb +10 -2
- data/lib/fog/openstack/image.rb +1 -1
- data/lib/fog/openstack/models/compute/flavor.rb +5 -1
- data/lib/fog/openstack/models/compute/security_group.rb +1 -1
- data/lib/fog/openstack/models/compute/server.rb +5 -0
- data/lib/fog/openstack/models/identity/users.rb +1 -2
- data/lib/fog/openstack/requests/compute/create_flavor.rb +4 -1
- data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
- data/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
- data/lib/fog/openstack/requests/compute/list_tenants.rb +1 -0
- data/lib/fog/openstack/requests/compute/release_address.rb +13 -1
- data/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
- data/lib/fog/openstack/requests/identity/create_role.rb +1 -1
- data/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
- data/lib/fog/openstack/volume.rb +2 -1
- data/lib/fog/rackspace/models/compute_v2/server.rb +27 -0
- data/lib/fog/rackspace/models/compute_v2/servers.rb +8 -0
- data/lib/fog/rackspace/models/dns/record.rb +14 -1
- data/lib/fog/rackspace/models/storage/file.rb +68 -2
- data/lib/fog/rackspace/requests/compute_v2/create_server.rb +3 -0
- data/lib/fog/version.rb +5 -0
- data/lib/fog/vsphere/compute.rb +74 -8
- data/lib/fog/vsphere/models/compute/cluster.rb +31 -0
- data/lib/fog/vsphere/models/compute/clusters.rb +26 -0
- data/lib/fog/vsphere/models/compute/datacenter.rb +35 -0
- data/lib/fog/vsphere/models/compute/datacenters.rb +23 -0
- data/lib/fog/vsphere/models/compute/datastore.rb +24 -0
- data/lib/fog/vsphere/models/compute/datastores.rb +25 -0
- data/lib/fog/vsphere/models/compute/folder.rb +28 -0
- data/lib/fog/vsphere/models/compute/folders.rb +27 -0
- data/lib/fog/vsphere/models/compute/interface.rb +39 -0
- data/lib/fog/vsphere/models/compute/interfaces.rb +33 -0
- data/lib/fog/vsphere/models/compute/network.rb +21 -0
- data/lib/fog/vsphere/models/compute/networks.rb +25 -0
- data/lib/fog/vsphere/models/compute/resource_pool.rb +23 -0
- data/lib/fog/vsphere/models/compute/resource_pools.rb +26 -0
- data/lib/fog/vsphere/models/compute/server.rb +78 -12
- data/lib/fog/vsphere/models/compute/servers.rb +16 -20
- data/lib/fog/vsphere/models/compute/template.rb +13 -0
- data/lib/fog/vsphere/models/compute/templates.rb +23 -0
- data/lib/fog/vsphere/models/compute/volume.rb +45 -0
- data/lib/fog/vsphere/models/compute/volumes.rb +33 -0
- data/lib/fog/vsphere/requests/compute/create_vm.rb +114 -0
- data/lib/fog/vsphere/requests/compute/get_cluster.rb +25 -0
- data/lib/fog/vsphere/requests/compute/get_datacenter.rb +29 -0
- data/lib/fog/vsphere/requests/compute/get_datastore.rb +25 -0
- data/lib/fog/vsphere/requests/compute/get_folder.rb +73 -0
- data/lib/fog/vsphere/requests/compute/get_network.rb +25 -0
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +26 -0
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +62 -0
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +37 -0
- data/lib/fog/vsphere/requests/compute/list_datacenters.rb +34 -0
- data/lib/fog/vsphere/requests/compute/list_datastores.rb +40 -0
- data/lib/fog/vsphere/requests/compute/list_folders.rb +45 -0
- data/lib/fog/vsphere/requests/compute/list_networks.rb +38 -0
- data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +39 -0
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -166
- data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +52 -0
- data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +51 -0
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +6 -8
- data/lib/fog/vsphere/requests/compute/vm_destroy.rb +1 -8
- data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +1 -2
- data/lib/tasks/changelog_task.rb +98 -0
- data/lib/tasks/documentation_task.rb +155 -0
- data/lib/tasks/test_task.rb +46 -0
- data/tests/aws/models/iam/users_tests.rb +16 -2
- data/tests/aws/requests/auto_scaling/notification_configuration_tests.rb +1 -0
- data/tests/aws/requests/auto_scaling/tag_tests.rb +1 -0
- data/tests/aws/requests/compute/instance_tests.rb +2 -0
- data/tests/aws/requests/compute/volume_tests.rb +8 -0
- data/tests/aws/requests/storage/object_tests.rb +18 -1
- data/tests/aws/requests/storage/versioning_tests.rb +70 -0
- data/tests/brightbox/compute_tests.rb +96 -4
- data/tests/brightbox/models/compute/account_tests.rb +15 -0
- data/tests/brightbox/oauth2_tests.rb +103 -0
- data/tests/brightbox/requests/compute/account_tests.rb +9 -2
- data/tests/brightbox/requests/compute/interface_tests.rb +18 -4
- data/tests/dns/models/record_tests.rb +17 -3
- data/tests/openstack/requests/compute/address_tests.rb +22 -19
- data/tests/openstack/requests/compute/flavor_tests.rb +4 -2
- data/tests/openstack/requests/compute/limit_tests.rb +60 -0
- data/tests/openstack/requests/compute/quota_tests.rb +16 -3
- data/tests/openstack/requests/compute/security_group_tests.rb +1 -1
- data/tests/rackspace/models/compute_v2/servers_tests.rb +6 -0
- data/tests/rackspace/models/storage/file_tests.rb +172 -0
- data/tests/rackspace/requests/dns/helper.rb +12 -26
- data/tests/vsphere/compute_tests.rb +3 -3
- data/tests/vsphere/models/compute/server_tests.rb +1 -2
- data/tests/vsphere/requests/compute/list_virtual_machines_tests.rb +5 -13
- data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -2
- metadata +59 -11
- data/lib/fog/vsphere/requests/compute/datacenters.rb +0 -34
- data/lib/fog/vsphere/requests/compute/find_vm_by_ref.rb +0 -41
- data/lib/fog/vsphere/requests/compute/vm_create.rb +0 -97
- data/tests/vsphere/requests/compute/find_vm_by_ref_tests.rb +0 -26
- data/tests/vsphere/requests/compute/vm_create_tests.rb +0 -20
|
@@ -32,7 +32,7 @@ module Fog
|
|
|
32
32
|
attribute :load_balancers_used
|
|
33
33
|
attribute :library_ftp_host
|
|
34
34
|
attribute :library_ftp_user
|
|
35
|
-
# This is always returned as
|
|
35
|
+
# This is always returned as nil unless after a call to reset_ftp_password
|
|
36
36
|
attribute :library_ftp_password
|
|
37
37
|
|
|
38
38
|
# Boolean flags
|
|
@@ -51,13 +51,19 @@ module Fog
|
|
|
51
51
|
attribute :users
|
|
52
52
|
attribute :zones
|
|
53
53
|
|
|
54
|
+
# Resets the account's image library FTP password returning the new value
|
|
55
|
+
#
|
|
56
|
+
# @return [String] Newly issue FTP password
|
|
57
|
+
#
|
|
54
58
|
def reset_ftp_password
|
|
55
59
|
requires :identity
|
|
56
|
-
connection.reset_ftp_password_account
|
|
60
|
+
data = connection.reset_ftp_password_account(identity)
|
|
61
|
+
merge_attributes(data)
|
|
62
|
+
library_ftp_password
|
|
57
63
|
end
|
|
58
64
|
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
end
|
|
62
68
|
end
|
|
63
|
-
end
|
|
69
|
+
end
|
|
@@ -184,9 +184,10 @@ module Fog
|
|
|
184
184
|
# Soft reboots often timeout if the OS missed the request so we do more
|
|
185
185
|
# error checking trying to detect the timeout
|
|
186
186
|
#
|
|
187
|
-
# @
|
|
187
|
+
# @todo Needs cleaner error handling when the OS times out
|
|
188
188
|
def soft_reboot
|
|
189
189
|
shutdown
|
|
190
|
+
# FIXME Using side effect of wait_for's (evaluated block) to detect timeouts
|
|
190
191
|
if wait_for(20) { ! ready? }
|
|
191
192
|
# Server is now down, start it up again
|
|
192
193
|
start
|
|
@@ -14,6 +14,38 @@ module Fog
|
|
|
14
14
|
load(data)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Creates a server and maps an Cloud IP
|
|
18
|
+
#
|
|
19
|
+
# By default the public SSH key you have registered with
|
|
20
|
+
# Brightbox is already made available in an AWS compatible
|
|
21
|
+
# metdata service.
|
|
22
|
+
#
|
|
23
|
+
# @todo Support uploading of arbitary SSH keys
|
|
24
|
+
#
|
|
25
|
+
# @param [Hash] options
|
|
26
|
+
# @option options [String] name Name for the server
|
|
27
|
+
# @option options [String] flavor_id Identifier for virtual hardware type to request
|
|
28
|
+
# @option options [String] image_id Identifier for image to use when creating
|
|
29
|
+
# @option options [String] zone_id Identifer for preferred zone to locate server in
|
|
30
|
+
# @option options [Array<String>] server_groups List of group identifiers for the server to join
|
|
31
|
+
#
|
|
32
|
+
# @return Fog::Compute::Brightbox::Server
|
|
33
|
+
#
|
|
34
|
+
def bootstrap(options = {})
|
|
35
|
+
server = create(options)
|
|
36
|
+
|
|
37
|
+
# Ensure server is now available
|
|
38
|
+
server.wait_for { ready? }
|
|
39
|
+
|
|
40
|
+
# To get a public IP address we need to map a cloud IP address
|
|
41
|
+
cip = connection.cloud_ips.allocate
|
|
42
|
+
cip.map(server)
|
|
43
|
+
cip.wait_for { mapped? }
|
|
44
|
+
|
|
45
|
+
# Reload so the public IP is now available
|
|
46
|
+
server.reload
|
|
47
|
+
end
|
|
48
|
+
|
|
17
49
|
def get(identifier)
|
|
18
50
|
return nil if identifier.nil? || identifier == ""
|
|
19
51
|
data = connection.get_server(identifier)
|
|
@@ -26,4 +58,4 @@ module Fog
|
|
|
26
58
|
|
|
27
59
|
end
|
|
28
60
|
end
|
|
29
|
-
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# This module covers Brightbox's partial implementation of OAuth 2.0
|
|
2
|
+
# and enables fog clients to implement several authentictication strategies
|
|
3
|
+
#
|
|
4
|
+
# @see http://tools.ietf.org/html/draft-ietf-oauth-v2-10
|
|
5
|
+
#
|
|
6
|
+
module Fog::Brightbox::OAuth2
|
|
7
|
+
|
|
8
|
+
# This builds the simplest form of requesting an access token
|
|
9
|
+
# based on the arguments passed in
|
|
10
|
+
#
|
|
11
|
+
# @param [Fog::Connection] connection
|
|
12
|
+
# @param [CredentialSet] credentials
|
|
13
|
+
#
|
|
14
|
+
# @return [Excon::Response]
|
|
15
|
+
def request_access_token(connection, credentials)
|
|
16
|
+
token_strategy = credentials.best_grant_strategy
|
|
17
|
+
|
|
18
|
+
header_content = "#{credentials.client_id}:#{credentials.client_secret}"
|
|
19
|
+
encoded_credentials = Base64.encode64(header_content).chomp
|
|
20
|
+
|
|
21
|
+
connection.request({
|
|
22
|
+
:path => "/token",
|
|
23
|
+
:expects => 200,
|
|
24
|
+
:headers => {
|
|
25
|
+
'Authorization' => "Basic #{encoded_credentials}",
|
|
26
|
+
'Content-Type' => 'application/json'
|
|
27
|
+
},
|
|
28
|
+
:method => 'POST',
|
|
29
|
+
:body => Fog::JSON.encode(token_strategy.authorization_body_data)
|
|
30
|
+
})
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Encapsulates credentials required to request access tokens from the
|
|
34
|
+
# Brightbox authorisation servers
|
|
35
|
+
#
|
|
36
|
+
# @todo Interface to update certain credentials (after password change)
|
|
37
|
+
#
|
|
38
|
+
class CredentialSet
|
|
39
|
+
attr_reader :client_id, :client_secret, :username, :password
|
|
40
|
+
attr_reader :access_token, :refresh_token
|
|
41
|
+
#
|
|
42
|
+
# @param [String] client_id
|
|
43
|
+
# @param [String] client_secret
|
|
44
|
+
# @param [Hash] options
|
|
45
|
+
# @option options [String] :username
|
|
46
|
+
# @option options [String] :password
|
|
47
|
+
#
|
|
48
|
+
def initialize(client_id, client_secret, options = {})
|
|
49
|
+
@client_id = client_id
|
|
50
|
+
@client_secret = client_secret
|
|
51
|
+
@username = options[:username]
|
|
52
|
+
@password = options[:password]
|
|
53
|
+
@access_token = options[:access_token]
|
|
54
|
+
@refresh_token = options[:refresh_token]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Returns true if user details are available
|
|
58
|
+
# @return [Boolean]
|
|
59
|
+
def user_details?
|
|
60
|
+
!!(@username && @password)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Is an access token available for these credentials?
|
|
64
|
+
def access_token?
|
|
65
|
+
!!@access_token
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Is a refresh token available for these credentials?
|
|
69
|
+
def refresh_token?
|
|
70
|
+
!!@refresh_token
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Updates the credentials with newer tokens
|
|
74
|
+
def update_tokens(access_token, refresh_token = nil)
|
|
75
|
+
@access_token = access_token
|
|
76
|
+
@refresh_token = refresh_token
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Based on available credentials returns the best strategy
|
|
80
|
+
#
|
|
81
|
+
# @todo Add a means to dictate which should or shouldn't be used
|
|
82
|
+
#
|
|
83
|
+
def best_grant_strategy
|
|
84
|
+
if refresh_token?
|
|
85
|
+
RefreshTokenStrategy.new(self)
|
|
86
|
+
elsif user_details?
|
|
87
|
+
UserCredentialsStrategy.new(self)
|
|
88
|
+
else
|
|
89
|
+
ClientCredentialsStrategy.new(self)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# This strategy class is the basis for OAuth2 grant types
|
|
95
|
+
#
|
|
96
|
+
# @abstract Need to implement {#authorization_body_data} to return a
|
|
97
|
+
# Hash matching the expected parameter form for the OAuth request
|
|
98
|
+
#
|
|
99
|
+
# @todo Strategies should be able to validate if credentials are suitable
|
|
100
|
+
# so just client credentials cannot be used with user strategies
|
|
101
|
+
#
|
|
102
|
+
class GrantTypeStrategy
|
|
103
|
+
def initialize(credentials)
|
|
104
|
+
@credentials = credentials
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def authorization_body_data
|
|
108
|
+
raise "Not implemented"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# This implements client based authentication/authorization
|
|
113
|
+
# based on the existing trust relationship using the `none`
|
|
114
|
+
# grant type.
|
|
115
|
+
#
|
|
116
|
+
class ClientCredentialsStrategy < GrantTypeStrategy
|
|
117
|
+
def authorization_body_data
|
|
118
|
+
{
|
|
119
|
+
"grant_type" => "none",
|
|
120
|
+
"client_id" => @credentials.client_id
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# This passes user details through so the returned token
|
|
126
|
+
# carries the privileges of the user not account limited
|
|
127
|
+
# by the client
|
|
128
|
+
#
|
|
129
|
+
class UserCredentialsStrategy < GrantTypeStrategy
|
|
130
|
+
def authorization_body_data
|
|
131
|
+
{
|
|
132
|
+
"grant_type" => "password",
|
|
133
|
+
"client_id" => @credentials.client_id,
|
|
134
|
+
"username" => @credentials.username,
|
|
135
|
+
"password" => @credentials.password
|
|
136
|
+
}
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# This strategy attempts to use a refresh_token gained during an earlier
|
|
141
|
+
# request to reuse the credentials given originally
|
|
142
|
+
#
|
|
143
|
+
class RefreshTokenStrategy < GrantTypeStrategy
|
|
144
|
+
def authorization_body_data
|
|
145
|
+
{
|
|
146
|
+
"grant_type" => "refresh_token",
|
|
147
|
+
"client_id" => @credentials.client_id,
|
|
148
|
+
"refresh_token" => @credentials.refresh_token
|
|
149
|
+
}
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
private
|
|
154
|
+
|
|
155
|
+
# This updates the current credentials if passed a valid response
|
|
156
|
+
#
|
|
157
|
+
# @param [CredentialSet] credentials Credentials to update
|
|
158
|
+
# @param [Excon::Response] response Response object to parse value from
|
|
159
|
+
#
|
|
160
|
+
def update_credentials_from_response(credentials, response)
|
|
161
|
+
response_data = Fog::JSON.decode(response.body)
|
|
162
|
+
credentials.update_tokens(response_data["access_token"], response_data["refresh_token"])
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -2,7 +2,14 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Enable console access via VNC to the server for 15 minutes.
|
|
6
|
+
#
|
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
|
8
|
+
#
|
|
9
|
+
# @return [Hash] The JSON response parsed to a Hash
|
|
10
|
+
#
|
|
11
|
+
# @see https://api.gb1.brightbox.com/1.0/#server_activate_console_server
|
|
12
|
+
#
|
|
6
13
|
def activate_console_server(identifier)
|
|
7
14
|
return nil if identifier.nil? || identifier == ""
|
|
8
15
|
request("post", "/1.0/servers/#{identifier}/activate_console", [202])
|
|
@@ -11,4 +18,4 @@ module Fog
|
|
|
11
18
|
end
|
|
12
19
|
end
|
|
13
20
|
end
|
|
14
|
-
end
|
|
21
|
+
end
|
|
@@ -2,7 +2,16 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Adds a number of listeners to the load balancer to enable balancing across nodes for those settings.
|
|
6
|
+
#
|
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
|
8
|
+
# @param [Hash] options
|
|
9
|
+
# @option options [Array] :listeners Array of Listener parameters. Timeout is optional and specified in milliseconds.
|
|
10
|
+
#
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
12
|
+
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_listeners_load_balancer
|
|
14
|
+
#
|
|
6
15
|
def add_listeners_load_balancer(identifier, options)
|
|
7
16
|
return nil if identifier.nil? || identifier == ""
|
|
8
17
|
request("post", "/1.0/load_balancers/#{identifier}/add_listeners", [202], options)
|
|
@@ -11,4 +20,4 @@ module Fog
|
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
22
|
end
|
|
14
|
-
end
|
|
23
|
+
end
|
|
@@ -2,7 +2,16 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Add a number of nodes to the load balancer
|
|
6
|
+
#
|
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
|
8
|
+
# @param [Hash] options
|
|
9
|
+
# @option options [Array] :nodes Array of Node parameters
|
|
10
|
+
#
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
12
|
+
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_nodes_load_balancer
|
|
14
|
+
#
|
|
6
15
|
def add_nodes_load_balancer(identifier, options)
|
|
7
16
|
return nil if identifier.nil? || identifier == ""
|
|
8
17
|
request("post", "/1.0/load_balancers/#{identifier}/add_nodes", [202], options)
|
|
@@ -11,4 +20,4 @@ module Fog
|
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
22
|
end
|
|
14
|
-
end
|
|
23
|
+
end
|
|
@@ -2,20 +2,18 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
6
|
-
# Add a number of servers to a server group
|
|
5
|
+
# Add a number of servers to the server group.
|
|
7
6
|
#
|
|
8
|
-
#
|
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
|
8
|
+
# @param [Hash] options
|
|
9
|
+
# @option options [Array<Hash>] :servers Array of Hashes containing `{"server" => server_id}` for each server to add
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
# * identifier (String) - The identifier of the server group to add to
|
|
12
|
-
# * options
|
|
13
|
-
# * servers (Array) - An Array of Hashes containing {"server" => server_id} for each server to add
|
|
14
|
-
# [\[{"server" => "srv-abcde"}, {"server" => "srv-fghij"}\]]
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
15
12
|
#
|
|
16
|
-
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#server_group_add_servers_server_group
|
|
17
14
|
#
|
|
18
|
-
#
|
|
15
|
+
# @example
|
|
16
|
+
# Compute[:brightbox].add_servers_server_group "grp-12345", :servers => [{"server" => "srv-abcde"}, {"server" => "srv-fghij"}]
|
|
19
17
|
#
|
|
20
18
|
def add_servers_server_group(identifier, options)
|
|
21
19
|
return nil if identifier.nil? || identifier == ""
|
|
@@ -25,4 +23,4 @@ module Fog
|
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
end
|
|
28
|
-
end
|
|
26
|
+
end
|
|
@@ -2,7 +2,16 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Applies firewall policy to given server group
|
|
6
|
+
#
|
|
7
|
+
# @param [String] identifier Unique reference to identify the resource
|
|
8
|
+
# @param [Hash] options
|
|
9
|
+
# @option options [String] :server_group Server Group to apply to
|
|
10
|
+
#
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
12
|
+
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#firewall_policy_apply_to_firewall_policy
|
|
14
|
+
#
|
|
6
15
|
def apply_to_firewall_policy(identifier, options)
|
|
7
16
|
return nil if identifier.nil? || identifier == ""
|
|
8
17
|
request("post", "/1.0/firewall_policies/#{identifier}/apply_to", [202], options)
|
|
@@ -11,4 +20,4 @@ module Fog
|
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
22
|
end
|
|
14
|
-
end
|
|
23
|
+
end
|
|
@@ -2,7 +2,16 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Create a new API client for the account.
|
|
6
|
+
#
|
|
7
|
+
# @param [Hash] options
|
|
8
|
+
# @option options [String] :name
|
|
9
|
+
# @option options [String] :description
|
|
10
|
+
#
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
12
|
+
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#api_client_create_api_client
|
|
14
|
+
#
|
|
6
15
|
def create_api_client(options)
|
|
7
16
|
request("post", "/1.0/api_clients", [201], options)
|
|
8
17
|
end
|
|
@@ -10,4 +19,4 @@ module Fog
|
|
|
10
19
|
end
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
|
-
end
|
|
22
|
+
end
|
|
@@ -2,7 +2,16 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Create a new application for the user.
|
|
6
|
+
#
|
|
7
|
+
# @param [Hash] options
|
|
8
|
+
# @option options [String] :name
|
|
9
|
+
# @option options [String] :description
|
|
10
|
+
#
|
|
11
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
12
|
+
#
|
|
13
|
+
# @see https://api.gb1.brightbox.com/1.0/#application_create_application
|
|
14
|
+
#
|
|
6
15
|
def create_application(options)
|
|
7
16
|
request("post", "/1.0/applications", [201], options)
|
|
8
17
|
end
|
|
@@ -10,4 +19,4 @@ module Fog
|
|
|
10
19
|
end
|
|
11
20
|
end
|
|
12
21
|
end
|
|
13
|
-
end
|
|
22
|
+
end
|
|
@@ -2,7 +2,17 @@ module Fog
|
|
|
2
2
|
module Compute
|
|
3
3
|
class Brightbox
|
|
4
4
|
class Real
|
|
5
|
-
|
|
5
|
+
# Requests a new cloud IP address for the account.
|
|
6
|
+
#
|
|
7
|
+
# @param [Hash] options
|
|
8
|
+
# @option options [String] :reverse_dns Reverse DNS hostname
|
|
9
|
+
# @option options [String] :name Name for Cloud IP
|
|
10
|
+
# @option options [Array] :port_translators Port on which external clients connect and port on which your service is listening.
|
|
11
|
+
#
|
|
12
|
+
# @return [Hash, nil] The JSON response parsed to a Hash or nil if no options passed
|
|
13
|
+
#
|
|
14
|
+
# @see https://api.gb1.brightbox.com/1.0/#cloud_ip_create_cloud_ip
|
|
15
|
+
#
|
|
6
16
|
def create_cloud_ip(options = {})
|
|
7
17
|
request("post", "/1.0/cloud_ips", [201], options)
|
|
8
18
|
end
|