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

[brightbox] Added support for Brightbox cloud API beta (http://beta.brightbox.com)

This commit is contained in:
Paul Thornthwaite 2010-11-08 12:21:31 +00:00 committed by geemus
parent a449d0dafb
commit 0ec77fc5a5
63 changed files with 1813 additions and 0 deletions

View file

@ -102,6 +102,7 @@ Play around and use the console to explore or check out the {getting started gui
You should try out the (varying) support fog has for:
* {AWS}[http://aws.amazon.com] [{Compute}[http://aws.amazon.com/ec2], {ELB}[http://aws.amazon.com/elasticloadbalancing], {Storage}[http://aws.amazon.com/s3], {SimpleDB}[http://aws.amazon.com/simpledb]]
* {Blue Box Group}[http://www.blueboxgrp.com] [{Compute}[http://www.blueboxgrp.com/blocks]]
* {Brightbox}[http://www.brightbox.co.uk] [{Compute}[http://beta.brightbox.com/]]
* {Google}[http://www.google.com] [{Storage}[http://code.google.com/apis/storage]]
* {Rackspace}[http://www.rackspace.com] [{Compute}[http://www.rackspacecloud.com/cloud_hosting_products/servers], {Storage}[http://www.rackspacecloud.com/cloud_hosting_products/files]]
* {Slicehost}[http://www.slicehost.com] [{Compute}[http://www.slicehost.com]]

View file

@ -72,6 +72,7 @@ end
require 'fog/aws'
require 'fog/bluebox'
require 'fog/brightbox'
require 'fog/go_grid'
require 'fog/linode'
require 'fog/local'

7
lib/fog/brightbox.rb Normal file
View file

@ -0,0 +1,7 @@
module Fog
module Brightbox
extend Fog::Provider
service_path 'fog/brightbox'
service 'compute'
end
end

23
lib/fog/brightbox/bin.rb Normal file
View file

@ -0,0 +1,23 @@
class Brightbox < Fog::Bin
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Brightbox::Compute.new
end
end
@@connections[service]
end
def services
[:compute]
end
def account
@@connections[:compute].account
end
end
end

View file

@ -0,0 +1,129 @@
module Fog
module Brightbox
class Compute < Fog::Service
API_URL = "https://api.gb1.brightbox.com/"
requires :brightbox_client_id, :brightbox_secret
model_path 'fog/brightbox/models/compute'
model :account # Singular resource, no collection
collection :servers
model :server
collection :flavors
model :flavor
collection :images
model :image
collection :zones
model :zone
collection :cloud_ips
model :cloud_ip
collection :users
model :user
request_path 'fog/brightbox/requests/compute'
request :create_api_client
request :create_cloud_ip
request :create_image
request :create_server
request :destroy_api_client
request :destroy_cloud_ip
request :destroy_image
request :destroy_server
request :get_account
request :get_api_client
request :get_cloud_ip
request :get_image
request :get_interface
request :get_server
request :get_server_type
request :get_user
request :get_zone
request :list_api_clients
request :list_cloud_ips
request :list_images
request :list_server_types
request :list_servers
request :list_users
request :list_zones
request :map_cloud_ip
request :rebuild_server
request :reset_ftp_password_account
request :resize_server
request :restart_server
request :shutdown_server
request :snapshot_server
request :start_server
request :stop_server
request :unmap_cloud_ip
request :update_account
request :update_api_client
request :update_image
request :update_server
request :update_user
class Mock
def request(options)
raise "Not implemented"
end
end
class Real
def initialize(options)
require "json"
# Currently authentication and api endpoints are the same but may change
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id] || nil
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret] || nil
@connection = Fog::Connection.new(@api_url)
end
def request(params)
begin
get_oauth_token if @oauth_token.nil?
response = authenticated_request(params)
rescue Excon::Errors::Unauthorized => e
get_oauth_token
response = authenticated_request(params)
end
response
end
def account
Fog::Brightbox::Compute::Account.new(JSON.parse(get_account.body))
end
private
def get_oauth_token(options = {})
auth_url = options[:brightbox_auth_url] || @auth_url
connection = Fog::Connection.new(auth_url)
@authentication_body = {'client_id' => @brightbox_client_id, 'grant_type' => 'none'}.to_json
response = connection.request({
:path => "/token",
:expects => 200,
:headers => {
'Authorization' => "Basic " + Base64.encode64("#{@brightbox_client_id}:#{@brightbox_secret}").chomp,
'Content-Type' => 'application/json'
},
:method => 'POST',
:body => @authentication_body
})
@oauth_token = JSON.parse(response.body)["access_token"]
return @oauth_token
end
def authenticated_request(options)
headers = options[:headers] || {}
headers.merge!("Authorization" => "OAuth #{@oauth_token}")
options[:headers] = headers
@connection.request(options)
end
end
end
end
end

View file

@ -0,0 +1,52 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class Account < Fog::Model
identity :id
attribute :resource_type
attribute :url
attribute :name
attribute :status
attribute :address_1
attribute :address_2
attribute :city
attribute :county
attribute :postcode
attribute :country_code
attribute :country_name
attribute :vat_registration_number
attribute :telephone_number
attribute :telephone_verified
attribute :ram_limit
attribute :ram_used
attribute :limits_cloudips
attribute :library_ftp_host
attribute :library_ftp_user
# This is always returned as null/nil unless performing a reset_ftp_password request
attribute :library_ftp_password
attribute :created_at
attribute :owner_id, :aliases => "owner", :squash => "id"
attribute :clients
attribute :images
attribute :servers
attribute :users
attribute :zones
def reset_ftp_password
requires :identity
response = connection.reset_ftp_password_account(identity)
JSON.parse(response.body)["library_ftp_password"]
end
end
end
end
end

View file

@ -0,0 +1,43 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class CloudIp < Fog::Model
identity :id
attribute :url
attribute :name
attribute :status
attribute :resource_type
attribute :description
attribute :reverse_dns
attribute :public_ip
attribute :account_id, :aliases => "account", :squash => "id"
attribute :interface_id, :aliases => "interface", :squash => "id"
attribute :server_id, :aliases => "server", :squash => "id"
def map(interface_to_map)
requires :identity
connection.map_cloud_ip(identity, :interface => interface_to_map)
end
def unmap
requires :identity
connection.unmap_cloud_ip(identity)
end
def destroy
requires :identity
connection.destroy_cloud_ip(identity)
end
end
end
end
end

View file

@ -0,0 +1,34 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/cloud_ip'
module Fog
module Brightbox
class Compute
class CloudIps < Fog::Collection
model Fog::Brightbox::Compute::CloudIp
def all
data = JSON.parse(connection.list_cloud_ips.body)
load(data)
end
def get(identifier)
return nil if identifier.nil? || identifier == ""
data = JSON.parse(connection.get_cloud_ip(identifier).body)
new(data)
rescue Excon::Errors::NotFound
nil
end
def allocate
data = JSON.parse(connection.create_cloud_ip.body)
new(data)
end
end
end
end
end

View file

@ -0,0 +1,33 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class Flavor < Fog::Model
identity :id
attribute :url
attribute :name
attribute :status
attribute :handle
attribute :bits
attribute :cores
attribute :disk, :aliases => "disk_size"
attribute :ram
attribute :resource_type
attribute :description
def bits
0 # This is actually based on the Image type used. 32bit or 64bit Images are supported
end
end
end
end
end

View file

@ -0,0 +1,28 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/flavor'
module Fog
module Brightbox
class Compute
class Flavors < Fog::Collection
model Fog::Brightbox::Compute::Flavor
def all
data = connection.list_server_types.body
load(JSON.parse(data))
end
def get(identifier)
response = connection.get_server_type(identifier)
new(JSON.parse(response.body))
rescue Excon::Errors::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,53 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class Image < Fog::Model
identity :id
attribute :url
attribute :name
attribute :status
attribute :source
attribute :source_type
attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
attribute :owner_id, :aliases => "owner", :squash => "id"
attribute :arch
attribute :resource_type
attribute :description
attribute :public
attribute :official
attribute :virtual_size
attribute :disk_size
attribute :created_at
def save
requires :source, :arch
options = {
:source => @source,
:arch => @arch,
:name => @name,
:description => @description
}.delete_if {|k,v| v.nil? || v == "" }
response = connection.create_image(options)
data = JSON.parse(response.body)
merge_attributes(data)
true
end
def destroy
requires :identity
connection.destroy_image(identity)
true
end
end
end
end
end

View file

@ -0,0 +1,28 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/image'
module Fog
module Brightbox
class Compute
class Images < Fog::Collection
model Fog::Brightbox::Compute::Image
def all
data = connection.list_images.body
load(JSON.parse(data))
end
def get(identifier)
response = connection.get_image(identifier)
new(JSON.parse(response.body))
rescue Excon::Errors::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,98 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class Server < Fog::Model
identity :id
attribute :url
attribute :name
attribute :status
attribute :hostname
attribute :created_at, :type => :time
attribute :deleted_at, :type => :time
attribute :started_at, :type => :time
attribute :user_data
attribute :resource_type
attribute :description
attribute :account_id, :aliases => "account", :squash => "id"
attribute :image_id, :aliases => "image", :squash => "id"
attribute :flavor_id, :aliases => "server_type", :squash => "id"
attribute :zone_id, :aliases => "zone", :squash => "id"
attribute :snapshots
attribute :cloud_ips
attribute :interfaces
def snapshot
requires :identity
connection.snapshot_server(identity)
end
def reboot(type = "soft")
requires :identity
connection.restart_server(identity, :type => type)
true
end
def start
requires :identity
connection.start_server(identity)
true
end
def stop
requires :identity
connection.stop_server(identity)
true
end
def shutdown
requires :identity
connection.shutdown_server(identity)
true
end
def destroy
requires :identity
connection.destroy_server(identity)
true
end
def flavor
requires :flavor_id
connection.flavors.get(@flavor_id)
end
def image
requires :image_id
connection.images.get(@image_id)
end
def ready?
status == 'active'
end
def save
requires :image_id
options = {
:image => @image_id,
:server_type => @flavor_id,
:name => @name,
:zone => @zone_id,
:user_data => @user_data
}.delete_if {|k,v| v.nil? || v == "" }
response = connection.create_server(options)
data = JSON.parse(response.body)
merge_attributes(data)
true
end
end
end
end
end

View file

@ -0,0 +1,29 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/server'
module Fog
module Brightbox
class Compute
class Servers < Fog::Collection
model Fog::Brightbox::Compute::Server
def all
data = JSON.parse(connection.list_servers.body)
load(data)
end
def get(identifier)
return nil if identifier.nil? || identifier == ""
data = JSON.parse(connection.get_server(identifier).body)
new(data)
rescue Excon::Errors::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,40 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class User < Fog::Model
identity :id
attribute :url
attribute :resource_type
attribute :name
attribute :email_address
attribute :email_verified
attribute :ssh_key
attribute :account_id, :aliases => "default_account", :squash => "id"
attribute :accounts
def save
requires :identity
options = {
:email_address => @email_address,
:ssh_key => @ssh_key,
:name => @name
}
response = connection.update_user(identity, options)
data = JSON.parse(response.body)
merge_attributes(data)
true
end
end
end
end
end

View file

@ -0,0 +1,29 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/user'
module Fog
module Brightbox
class Compute
class Users < Fog::Collection
model Fog::Brightbox::Compute::User
def all
data = JSON.parse(connection.list_users.body)
load(data)
end
def get(identifier)
return nil if identifier.nil? || identifier == ""
data = JSON.parse(connection.get_user(identifier).body)
new(data)
rescue Excon::Errors::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,21 @@
require 'fog/core/model'
module Fog
module Brightbox
class Compute
class Zone < Fog::Model
identity :id
attribute :url
attribute :handle
attribute :status
attribute :resource_type
attribute :description
end
end
end
end

View file

@ -0,0 +1,29 @@
require 'fog/core/collection'
require 'fog/brightbox/models/compute/zone'
module Fog
module Brightbox
class Compute
class Zones < Fog::Collection
model Fog::Brightbox::Compute::Zone
def all
data = JSON.parse(connection.list_zones.body)
load(data)
end
def get(identifier)
return nil if identifier.nil? || identifier == ""
data = JSON.parse(connection.get_zone(identifier).body)
new(data)
rescue Excon::Errors::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def create_api_client(options = {})
request(
:expects => [201],
:method => 'POST',
:path => "/1.0/api_clients",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def create_api_client(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def create_cloud_ip(options = {})
request(
:expects => [201],
:method => 'POST',
:path => "/1.0/cloud_ips",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def create_cloud_ip(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def create_image(options = {})
request(
:expects => [201],
:method => 'POST',
:path => "/1.0/images",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def create_image(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def create_server(options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def create_server(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def destroy_api_client(identifier, options = {})
request(
:expects => [200],
:method => 'DELETE',
:path => "/1.0/api_clients/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def destroy_api_client(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def destroy_cloud_ip(identifier, options = {})
request(
:expects => [200],
:method => 'DELETE',
:path => "/1.0/cloud_ips/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def destroy_cloud_ip(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def destroy_image(identifier, options = {})
request(
:expects => [202],
:method => 'DELETE',
:path => "/1.0/images/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def destroy_image(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def destroy_server(identifier, options = {})
request(
:expects => [202],
:method => 'DELETE',
:path => "/1.0/servers/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def destroy_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_account(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/account",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_account(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_api_client(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/api_clients/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_api_client(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_cloud_ip(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/cloud_ips/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_cloud_ip(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_image(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/images/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_image(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_interface(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/interfaces/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_interface(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_server(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/servers/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_server_type(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/server_types/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_server_type(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_user(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/users/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_user(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def get_zone(identifier, options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/zones/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def get_zone(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_api_clients(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/api_clients",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_api_clients(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_cloud_ips(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/cloud_ips",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_cloud_ips(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_images(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/images",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_images(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_server_types(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/server_types",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_server_types(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_servers(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/servers",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_servers(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_users(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/users",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_users(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def list_zones(options = {})
request(
:expects => [200],
:method => 'GET',
:path => "/1.0/zones",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def list_zones(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def map_cloud_ip(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/cloud_ips/#{identifier}/map",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def map_cloud_ip(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def rebuild_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/rebuild",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def rebuild_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def reset_ftp_password_account(options = {})
request(
:expects => [200],
:method => 'POST',
:path => "/1.0/account/reset_ftp_password",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def reset_ftp_password_account(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def resize_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/resize",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def resize_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def restart_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/restart",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def restart_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def shutdown_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/shutdown",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def shutdown_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def snapshot_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/snapshot",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def snapshot_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def start_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/start",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def start_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def stop_server(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/servers/#{identifier}/stop",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def stop_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def unmap_cloud_ip(identifier, options = {})
request(
:expects => [202],
:method => 'POST',
:path => "/1.0/cloud_ips/#{identifier}/unmap",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def unmap_cloud_ip(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def update_account(options = {})
request(
:expects => [200],
:method => 'PUT',
:path => "/1.0/account",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def update_account(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def update_api_client(identifier, options = {})
request(
:expects => [200],
:method => 'PUT',
:path => "/1.0/api_clients/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def update_api_client(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def update_image(identifier, options = {})
request(
:expects => [200],
:method => 'PUT',
:path => "/1.0/images/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def update_image(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def update_server(identifier, options = {})
request(
:expects => [200],
:method => 'PUT',
:path => "/1.0/servers/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def update_server(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,27 @@
module Fog
module Brightbox
class Compute
class Real
def update_user(identifier, options = {})
request(
:expects => [200],
:method => 'PUT',
:path => "/1.0/users/#{identifier}",
:headers => {"Content-Type" => "application/json"},
:body => options.to_json
)
end
end
class Mock
def update_user(identifier, options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -7,6 +7,7 @@ module Fog
[
::AWS,
::Bluebox,
::Brightbox,
::GoGrid,
::Google,
::Linode,
@ -68,6 +69,7 @@ end
require 'fog/aws/bin'
require 'fog/bluebox/bin'
require 'fog/brightbox/bin'
require 'fog/go_grid/bin'
require 'fog/google/bin'
require 'fog/linode/bin'

View file

@ -9,6 +9,9 @@ module Fog
when 'Bluebox'
require 'fog/bluebox'
Fog::Bluebox::Compute.new(attributes)
when 'Brightbox'
require 'fog/brightbox'
Fog::Brightbox::Compute.new(attributes)
when 'GoGrid'
require 'fog/go_grid'
Fog::GoGrid::Compute.new(attributes)

View file

@ -34,6 +34,8 @@ module Fog
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
:bluebox_customer_id: INTENTIONALLY_LEFT_BLANK
:brightbox_client_id: INTENTIONALLY_LEFT_BLANK
:brightbox_secret: INTENTIONALLY_LEFT_BLANK
:go_grid_api_key: INTENTIONALLY_LEFT_BLANK
:go_grid_shared_secret: INTENTIONALLY_LEFT_BLANK
:local_root: INTENTIONALLY_LEFT_BLANK

View file

@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../../shared_examples/flavors_examples'
describe 'Fog::Brightbox::Compute::Flavors' do
if Fog.mocking?
it "needs to have mocks implemented"
else
it_should_behave_like "Flavors"
end
subject { @flavor = @flavors.all.first }
before(:each) do
@flavors = Brightbox[:compute].flavors
end
end

View file

@ -0,0 +1,28 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../../shared_examples/server_examples'
describe 'Fog::Brightbox::Compute::Server' do
if Fog.mocking?
it "needs to have mocks implemented"
else
it_should_behave_like "Server"
end
subject {
@image_id = "img-9vxqi" # Ubuntu Maverick 10.10 server
@server = @servers.new(:image_id => @image_id)
}
before(:each) do
@servers = Brightbox[:compute].servers
end
after(:each) do
if @server && !@server.new_record?
@server.wait_for { ready? }
@server.destroy.should be_true
end
end
end

View file

@ -0,0 +1,29 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../../shared_examples/servers_examples'
describe 'Fog::Brightbox::Compute::Servers' do
if Fog.mocking?
it "needs to have mocks implemented"
else
it_should_behave_like "Servers"
end
subject {
@image_id = "img-9vxqi" # Ubuntu Maverick 10.10 server
@server = @servers.new(:image_id => @image_id)
@server
}
before(:each) do
@servers = Brightbox[:compute].servers
end
after(:each) do
if @server && !@server.new_record?
@server.wait_for { ready? }
@server.destroy.should be_true
end
end
end