1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[Brightbox] Updates reference to service

This commit is contained in:
Paul Thornthwaite 2012-12-22 23:29:21 +00:00
parent b98428b08b
commit a7bb561fe7
25 changed files with 76 additions and 79 deletions

View file

@ -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

View file

@ -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

View file

@ -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
end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
end

View file

@ -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

View file

@ -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
end

View file

@ -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
end

View file

@ -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

View file

@ -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

View file

@ -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
end

View file

@ -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
end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <Fog::Compute::Brightbox::Real> not <Fog::Connection>
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

View file

@ -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

View file

@ -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
end

View file

@ -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

View file

@ -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

View file

@ -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
end

View file

@ -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
end