diff --git a/lib/fog/brightbox/compute.rb b/lib/fog/brightbox/compute.rb index 427d9d021..1fb9d5daa 100644 --- a/lib/fog/brightbox/compute.rb +++ b/lib/fog/brightbox/compute.rb @@ -138,7 +138,7 @@ module Fog # Creates a new instance of the Brightbox Compute service # - # @note If you open a connection using just a refresh token when it + # @note If you create service using just a refresh token when it # expires the service will no longer be able to authenticate. # # @param [Hash] options @@ -209,15 +209,13 @@ module Fog # # * For API clients this is the owning account # * For User applications this is the account specified by either +account_id+ - # option on a connection or the +brightbox_account+ setting in your configuration + # option on the service or the +brightbox_account+ setting in your configuration # # @return [Fog::Compute::Brightbox::Account] # def account - Fog::Compute::Brightbox::Account.new(get_scoped_account).tap do |acc| - # Connection is more like the compute 'service' - acc.connection = self - end + account_data = get_scoped_account.merge(:service => self) + Fog::Compute::Brightbox::Account.new(account_data) end # Returns true if authentication is being performed as a user diff --git a/lib/fog/brightbox/models/compute/account.rb b/lib/fog/brightbox/models/compute/account.rb index 0850cff51..d0427234e 100644 --- a/lib/fog/brightbox/models/compute/account.rb +++ b/lib/fog/brightbox/models/compute/account.rb @@ -57,7 +57,7 @@ module Fog # def reset_ftp_password requires :identity - data = connection.reset_ftp_password_account(identity) + data = service.reset_ftp_password_account(identity) merge_attributes(data) library_ftp_password end diff --git a/lib/fog/brightbox/models/compute/accounts.rb b/lib/fog/brightbox/models/compute/accounts.rb index 9abd87164..3690944fe 100644 --- a/lib/fog/brightbox/models/compute/accounts.rb +++ b/lib/fog/brightbox/models/compute/accounts.rb @@ -10,13 +10,13 @@ module Fog model Fog::Compute::Brightbox::Account def all - data = connection.list_accounts + data = service.list_accounts load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_account(identifier) + data = service.get_account(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -26,4 +26,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/api_client.rb b/lib/fog/brightbox/models/compute/api_client.rb index 615805ea5..b899af2a9 100644 --- a/lib/fog/brightbox/models/compute/api_client.rb +++ b/lib/fog/brightbox/models/compute/api_client.rb @@ -15,20 +15,20 @@ module Fog :name => name, :description => description }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_api_client(options) + data = service.create_api_client(options) merge_attributes(data) true end def destroy requires :identity - connection.destroy_api_client(identity) + service.destroy_api_client(identity) true end def reset_secret requires :identity - connection.reset_secret_api_client(identity) + service.reset_secret_api_client(identity) true end end diff --git a/lib/fog/brightbox/models/compute/api_clients.rb b/lib/fog/brightbox/models/compute/api_clients.rb index 33ded8a33..3ff35caa6 100644 --- a/lib/fog/brightbox/models/compute/api_clients.rb +++ b/lib/fog/brightbox/models/compute/api_clients.rb @@ -8,12 +8,12 @@ module Fog model Fog::Compute::Brightbox::ApiClient def all - data = connection.list_api_clients + data = service.list_api_clients load(data) end def get(identifier = nil) - data = connection.get_api_client(identifier) + data = service.get_api_client(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/application.rb b/lib/fog/brightbox/models/compute/application.rb index 925a8a803..240936501 100644 --- a/lib/fog/brightbox/models/compute/application.rb +++ b/lib/fog/brightbox/models/compute/application.rb @@ -16,7 +16,7 @@ module Fog options = { :name => name }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_application(options) + data = service.create_application(options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/applications.rb b/lib/fog/brightbox/models/compute/applications.rb index 9c3704d93..ed2bfb67b 100644 --- a/lib/fog/brightbox/models/compute/applications.rb +++ b/lib/fog/brightbox/models/compute/applications.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Brightbox::Application def all - data = connection.list_applications + data = service.list_applications load(data) end def get(identifier) - data = connection.get_application(identifier) + data = service.get_application(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -25,4 +25,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/cloud_ip.rb b/lib/fog/brightbox/models/compute/cloud_ip.rb index 0970f4780..f29a8d438 100644 --- a/lib/fog/brightbox/models/compute/cloud_ip.rb +++ b/lib/fog/brightbox/models/compute/cloud_ip.rb @@ -36,7 +36,7 @@ module Fog else final_destination = destination end - connection.map_cloud_ip(identity, :destination => final_destination) + service.map_cloud_ip(identity, :destination => final_destination) end def mapped? @@ -45,12 +45,12 @@ module Fog def unmap requires :identity - connection.unmap_cloud_ip(identity) + service.unmap_cloud_ip(identity) end def destroy requires :identity - connection.destroy_cloud_ip(identity) + service.destroy_cloud_ip(identity) end end diff --git a/lib/fog/brightbox/models/compute/cloud_ips.rb b/lib/fog/brightbox/models/compute/cloud_ips.rb index 63526a08d..4d0308c38 100644 --- a/lib/fog/brightbox/models/compute/cloud_ips.rb +++ b/lib/fog/brightbox/models/compute/cloud_ips.rb @@ -10,20 +10,20 @@ module Fog model Fog::Compute::Brightbox::CloudIp def all - data = connection.list_cloud_ips + data = service.list_cloud_ips load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_cloud_ip(identifier) + data = service.get_cloud_ip(identifier) new(data) rescue Excon::Errors::NotFound nil end def allocate - data = connection.create_cloud_ip + data = service.create_cloud_ip new(data) end @@ -31,4 +31,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/firewall_policies.rb b/lib/fog/brightbox/models/compute/firewall_policies.rb index e56159948..d42ffbeee 100644 --- a/lib/fog/brightbox/models/compute/firewall_policies.rb +++ b/lib/fog/brightbox/models/compute/firewall_policies.rb @@ -10,13 +10,13 @@ module Fog model Fog::Compute::Brightbox::FirewallPolicy def all - data = connection.list_firewall_policies + data = service.list_firewall_policies load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_firewall_policy(identifier) + data = service.get_firewall_policy(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -26,4 +26,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/firewall_policy.rb b/lib/fog/brightbox/models/compute/firewall_policy.rb index a628574e8..70446332d 100644 --- a/lib/fog/brightbox/models/compute/firewall_policy.rb +++ b/lib/fog/brightbox/models/compute/firewall_policy.rb @@ -27,7 +27,7 @@ module Fog :name => name, :description => description }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_firewall_policy(options) + data = service.create_firewall_policy(options) merge_attributes(data) true end @@ -37,7 +37,7 @@ module Fog options = { :server_group => server_group_id } - data = connection.apply_to_firewall_policy(identity, options) + data = service.apply_to_firewall_policy(identity, options) merge_attributes(data) true end @@ -47,14 +47,14 @@ module Fog options = { :server_group => server_group_id } - data = connection.remove_firewall_policy(identity, options) + data = service.remove_firewall_policy(identity, options) merge_attributes(data) true end def destroy requires :identity - data = connection.destroy_firewall_policy(identity) + data = service.destroy_firewall_policy(identity) true end diff --git a/lib/fog/brightbox/models/compute/firewall_rule.rb b/lib/fog/brightbox/models/compute/firewall_rule.rb index 263ecc567..bdce21cb5 100644 --- a/lib/fog/brightbox/models/compute/firewall_rule.rb +++ b/lib/fog/brightbox/models/compute/firewall_rule.rb @@ -36,14 +36,14 @@ module Fog :destination_port => destination_port, :icmp_type_name => icmp_type_name }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_firewall_rule(options) + data = service.create_firewall_rule(options) merge_attributes(data) true end def destroy requires :identity - connection.destroy_firewall_rule(identity) + service.destroy_firewall_rule(identity) true end diff --git a/lib/fog/brightbox/models/compute/firewall_rules.rb b/lib/fog/brightbox/models/compute/firewall_rules.rb index 6476eae8e..f22026600 100644 --- a/lib/fog/brightbox/models/compute/firewall_rules.rb +++ b/lib/fog/brightbox/models/compute/firewall_rules.rb @@ -11,7 +11,7 @@ module Fog def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_firewall_rule(identifier) + data = service.get_firewall_rule(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -21,4 +21,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/flavors.rb b/lib/fog/brightbox/models/compute/flavors.rb index a67df22f3..908dcb67b 100644 --- a/lib/fog/brightbox/models/compute/flavors.rb +++ b/lib/fog/brightbox/models/compute/flavors.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Brightbox::Flavor def all - data = connection.list_server_types + data = service.list_server_types load(data) end def get(identifier) - data = connection.get_server_type(identifier) + data = service.get_server_type(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -25,4 +25,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/image.rb b/lib/fog/brightbox/models/compute/image.rb index ac2534b21..616e24bc5 100644 --- a/lib/fog/brightbox/models/compute/image.rb +++ b/lib/fog/brightbox/models/compute/image.rb @@ -48,14 +48,14 @@ module Fog :username => username, :description => description }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_image(options) + data = service.create_image(options) merge_attributes(data) true end def destroy requires :identity - connection.destroy_image(identity) + service.destroy_image(identity) true end diff --git a/lib/fog/brightbox/models/compute/images.rb b/lib/fog/brightbox/models/compute/images.rb index 2f3e7726c..e401ebffc 100644 --- a/lib/fog/brightbox/models/compute/images.rb +++ b/lib/fog/brightbox/models/compute/images.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Brightbox::Image def all - data = connection.list_images + data = service.list_images load(data) end def get(identifier) - data = connection.get_image(identifier) + data = service.get_image(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/load_balancer.rb b/lib/fog/brightbox/models/compute/load_balancer.rb index 0042b477b..8f7a15399 100644 --- a/lib/fog/brightbox/models/compute/load_balancer.rb +++ b/lib/fog/brightbox/models/compute/load_balancer.rb @@ -41,14 +41,14 @@ module Fog :policy => policy, :name => name }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_load_balancer(options) + data = service.create_load_balancer(options) merge_attributes(data) true end def destroy requires :identity - connection.destroy_load_balancer(identity) + service.destroy_load_balancer(identity) true end diff --git a/lib/fog/brightbox/models/compute/load_balancers.rb b/lib/fog/brightbox/models/compute/load_balancers.rb index ba170c3c3..a88b2c166 100644 --- a/lib/fog/brightbox/models/compute/load_balancers.rb +++ b/lib/fog/brightbox/models/compute/load_balancers.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Brightbox::LoadBalancer def all - data = connection.list_load_balancers + data = service.list_load_balancers load(data) end def get(identifier) - data = connection.get_load_balancer(identifier) + data = service.get_load_balancer(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index 443d9124c..519ec69e2 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -38,10 +38,9 @@ module Fog attribute :server_type def initialize(attributes={}) - # Call super first to initialize the 'connection' object for our default image + # Call super first to initialize the service object for our default image super - # FIXME connection is actually not - self.image_id ||= connection.default_image + self.image_id ||= service.default_image end def zone_id @@ -70,7 +69,7 @@ module Fog def snapshot requires :identity - connection.snapshot_server(identity) + service.snapshot_server(identity) end # Directly requesting a server reboot is not supported in the API @@ -97,36 +96,36 @@ module Fog def start requires :identity - connection.start_server(identity) + service.start_server(identity) true end def stop requires :identity - connection.stop_server(identity) + service.stop_server(identity) true end def shutdown requires :identity - connection.shutdown_server(identity) + service.shutdown_server(identity) true end def destroy requires :identity - connection.destroy_server(identity) + service.destroy_server(identity) true end def flavor requires :flavor_id - connection.flavors.get(flavor_id) + service.flavors.get(flavor_id) end def image requires :image_id - connection.images.get(image_id) + service.images.get(image_id) end # Returns the public DNS name of the server @@ -159,7 +158,7 @@ module Fog def activate_console requires :identity - response = connection.activate_console_server(identity) + response = service.activate_console_server(identity) [response["console_url"], response["console_token"], response["console_token_expires"]] end @@ -176,7 +175,7 @@ module Fog unless flavor_id.nil? || flavor_id == "" options.merge!(:server_type => flavor_id) end - data = connection.create_server(options) + data = service.create_server(options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/server_group.rb b/lib/fog/brightbox/models/compute/server_group.rb index 9a0626bf6..42c04c125 100644 --- a/lib/fog/brightbox/models/compute/server_group.rb +++ b/lib/fog/brightbox/models/compute/server_group.rb @@ -25,7 +25,7 @@ module Fog :name => name, :description => description }.delete_if {|k,v| v.nil? || v == "" } - data = connection.create_server_group(options) + data = service.create_server_group(options) merge_attributes(data) true end @@ -33,7 +33,7 @@ module Fog def servers srv_ids = server_ids.collect {|srv| srv["id"]} srv_ids.collect do |srv_id| - connection.servers.get(srv_id) + service.servers.get(srv_id) end end @@ -46,7 +46,7 @@ module Fog options = { :servers => server_references(identifiers) } - data = connection.add_servers_server_group identity, options + data = service.add_servers_server_group identity, options merge_attributes data end @@ -59,7 +59,7 @@ module Fog options = { :servers => server_references(identifiers) } - data = connection.remove_servers_server_group identity, options + data = service.remove_servers_server_group identity, options merge_attributes data end @@ -74,13 +74,13 @@ module Fog :servers => server_references(identifiers), :destination => destination_group_id } - data = connection.move_servers_server_group identity, options + data = service.move_servers_server_group identity, options merge_attributes data end def destroy requires :identity - connection.destroy_server_group(identity) + service.destroy_server_group(identity) true end diff --git a/lib/fog/brightbox/models/compute/server_groups.rb b/lib/fog/brightbox/models/compute/server_groups.rb index 9fe3b942a..b2c85f48c 100644 --- a/lib/fog/brightbox/models/compute/server_groups.rb +++ b/lib/fog/brightbox/models/compute/server_groups.rb @@ -10,13 +10,13 @@ module Fog model Fog::Compute::Brightbox::ServerGroup def all - data = connection.list_server_groups + data = service.list_server_groups load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_server_group(identifier) + data = service.get_server_group(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -26,4 +26,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/servers.rb b/lib/fog/brightbox/models/compute/servers.rb index 56f33ba86..d921b5d68 100644 --- a/lib/fog/brightbox/models/compute/servers.rb +++ b/lib/fog/brightbox/models/compute/servers.rb @@ -10,7 +10,7 @@ module Fog model Fog::Compute::Brightbox::Server def all - data = connection.list_servers + data = service.list_servers load(data) end @@ -38,7 +38,7 @@ module Fog server.wait_for { ready? } # To get a public IP address we need to map a cloud IP address - cip = connection.cloud_ips.allocate + cip = service.cloud_ips.allocate cip.map(server) cip.wait_for { mapped? } @@ -48,7 +48,7 @@ module Fog def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_server(identifier) + data = service.get_server(identifier) new(data) rescue Excon::Errors::NotFound nil diff --git a/lib/fog/brightbox/models/compute/user.rb b/lib/fog/brightbox/models/compute/user.rb index 5b4c86de2..9f1917813 100644 --- a/lib/fog/brightbox/models/compute/user.rb +++ b/lib/fog/brightbox/models/compute/user.rb @@ -31,7 +31,7 @@ module Fog :name => name } - data = connection.update_user(identity, options) + data = service.update_user(identity, options) merge_attributes(data) true end diff --git a/lib/fog/brightbox/models/compute/users.rb b/lib/fog/brightbox/models/compute/users.rb index ba348ec82..76d4409f0 100644 --- a/lib/fog/brightbox/models/compute/users.rb +++ b/lib/fog/brightbox/models/compute/users.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Brightbox::User def all - data = connection.list_users + data = service.list_users load(data) end def get(identifier = nil) - data = connection.get_user(identifier) + data = service.get_user(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -24,4 +24,4 @@ module Fog end end -end \ No newline at end of file +end diff --git a/lib/fog/brightbox/models/compute/zones.rb b/lib/fog/brightbox/models/compute/zones.rb index c46b4408a..60016a21f 100644 --- a/lib/fog/brightbox/models/compute/zones.rb +++ b/lib/fog/brightbox/models/compute/zones.rb @@ -10,13 +10,13 @@ module Fog model Fog::Compute::Brightbox::Zone def all - data = connection.list_zones + data = service.list_zones load(data) end def get(identifier) return nil if identifier.nil? || identifier == "" - data = connection.get_zone(identifier) + data = service.get_zone(identifier) new(data) rescue Excon::Errors::NotFound nil @@ -26,4 +26,4 @@ module Fog end end -end \ No newline at end of file +end