mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3058 from fog/remove_providers_directory
Remove providers directory
This commit is contained in:
commit
12cc559864
155 changed files with 2 additions and 4891 deletions
2
Rakefile
2
Rakefile
|
@ -51,7 +51,7 @@ task :default => :test
|
|||
task :travis => ['test', 'test:travis']
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = File.join("**", "spec", "**", "*_spec.rb")
|
||||
t.pattern = File.join("spec", "**", "*_spec.rb")
|
||||
end
|
||||
|
||||
namespace :test do
|
||||
|
|
|
@ -69,6 +69,6 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency('ruby-libvirt','~> 0.5.0')
|
||||
end
|
||||
|
||||
s.files = `git ls-files`.split("\n") - `git ls-files -- providers/`.split("\n")
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
|
||||
end
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
# Embedded provider gems
|
||||
gem "fog-brightbox", :path => "../providers/brightbox"
|
||||
|
||||
# Shared components
|
||||
gem "fog-core", :github => "fog/fog-core"
|
||||
gem "fog-json", :github => "fog/fog-json"
|
||||
|
|
1
providers/brightbox/.gitignore
vendored
1
providers/brightbox/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
Gemfile.lock
|
|
@ -1,18 +0,0 @@
|
|||
### 0.0.2 / 2014-04-10
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* Add CHANGELOG.md to `fog-brightbox` module.
|
||||
* Add MiniTest::Specs to project. Use `rake test` to check the code.
|
||||
* Add Gemfile, Rakefile, README and LICENCE to start documenting project.
|
||||
* Remove redundant calls to `Fog.credentials`. The code flow was such that the
|
||||
credentials were being passed in to `Fog::Compute::Brightbox` anyway.
|
||||
* Isolate testing from contents of `~.fog` file which is leaking in throug the
|
||||
`Fog.credentials` global.
|
||||
|
||||
### 0.0.1 / 2014-02-19
|
||||
|
||||
Enhancements:
|
||||
|
||||
* Initial release of extracted `fog-brightbox` module. This is pretty much the
|
||||
pilot for fog modules so bear with us as we iron out the bugs.
|
|
@ -1,3 +0,0 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gemspec
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 2014 Brightbox Systems Ltd.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,50 +0,0 @@
|
|||
# Brightbox Cloud module for fog (The Ruby cloud services library)
|
||||
|
||||
This gem is a modular for the `fog` gem that allows you to manage resources in
|
||||
the Brightbox Cloud.
|
||||
|
||||
It is included by the main `fog` metagem but can used as an independent library
|
||||
in other applications.
|
||||
|
||||
This includes support for the following services:
|
||||
|
||||
* Compute
|
||||
* Images
|
||||
* Load Balancers
|
||||
* SQL Cloud instances
|
||||
|
||||
Currently all services are grouped within `compute` but will be moved to their
|
||||
own sections when standardisation of fog progresses.
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem "fog-brightbox"
|
||||
|
||||
And then execute:
|
||||
|
||||
$ bundle
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install fog-brightbox
|
||||
|
||||
## Usage
|
||||
|
||||
Please see the following references for instructions using the main `fog` gem
|
||||
and its modules:
|
||||
|
||||
* https://github.com/fog/fog
|
||||
* http://fog.io/
|
||||
* http://rubydoc.info/gems/fog/
|
||||
|
||||
## Contributing
|
||||
|
||||
`fog` modules are kept within the main repo.
|
||||
|
||||
1. Fork it ( http://github.com/fog/fog/fork )
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
5. Create new Pull Request
|
|
@ -1,8 +0,0 @@
|
|||
require "bundler/gem_tasks"
|
||||
require "rake/testtask"
|
||||
|
||||
task :default => :test
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = File.join("spec", "**", "*_spec.rb")
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'fog/brightbox/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "fog-brightbox"
|
||||
spec.version = Fog::Brightbox::VERSION
|
||||
spec.authors = ["Paul Thornthwaite"]
|
||||
spec.email = ["tokengeek@gmail.com"]
|
||||
spec.description = %q{Module for the 'fog' gem to support Brightbox Cloud}
|
||||
spec.summary = %q{This library can be used as a module for `fog` or as standalone provider
|
||||
to use the Brightbox Cloud in applications}
|
||||
spec.homepage = ""
|
||||
spec.license = "MIT"
|
||||
|
||||
spec.files = `git ls-files`.split($/)
|
||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||
spec.require_paths = ["lib"]
|
||||
|
||||
spec.add_dependency "fog-core"
|
||||
spec.add_dependency "fog-json"
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.3"
|
||||
spec.add_development_dependency "rake"
|
||||
spec.add_development_dependency "minitest"
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
require 'fog/brightbox/compute'
|
|
@ -1,303 +0,0 @@
|
|||
require 'fog/brightbox/core'
|
||||
require 'fog/brightbox/compute/shared'
|
||||
require 'fog/brightbox/compute/image_selector'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox < Fog::Service
|
||||
# Client credentials
|
||||
requires :brightbox_client_id, :brightbox_secret
|
||||
|
||||
# API endpoint settings
|
||||
recognizes :brightbox_auth_url, :brightbox_api_url
|
||||
|
||||
# User credentials (still requires client details)
|
||||
recognizes :brightbox_username, :brightbox_password, :brightbox_account
|
||||
|
||||
# Cached tokens
|
||||
recognizes :brightbox_access_token, :brightbox_refresh_token
|
||||
|
||||
# Automatic token management
|
||||
recognizes :brightbox_token_management
|
||||
|
||||
# Excon connection settings
|
||||
recognizes :persistent
|
||||
|
||||
model_path 'fog/brightbox/models/compute'
|
||||
collection :accounts
|
||||
model :account
|
||||
collection :applications
|
||||
model :application
|
||||
collection :api_clients
|
||||
model :api_client
|
||||
collection :collaborations
|
||||
model :collaboration
|
||||
collection :servers
|
||||
model :server
|
||||
collection :server_groups
|
||||
model :server_group
|
||||
collection :firewall_policies
|
||||
model :firewall_policy
|
||||
collection :firewall_rules
|
||||
model :firewall_rule
|
||||
collection :flavors
|
||||
model :flavor
|
||||
collection :images
|
||||
model :image
|
||||
collection :load_balancers
|
||||
model :load_balancer
|
||||
collection :database_servers
|
||||
model :database_server
|
||||
collection :database_snapshots
|
||||
model :database_snapshot
|
||||
collection :database_types
|
||||
model :database_type
|
||||
collection :zones
|
||||
model :zone
|
||||
collection :cloud_ips
|
||||
model :cloud_ip
|
||||
collection :users
|
||||
model :user
|
||||
collection :user_collaborations
|
||||
model :user_collaboration
|
||||
|
||||
request_path 'fog/brightbox/requests/compute'
|
||||
request :accept_user_collaboration
|
||||
request :activate_console_server
|
||||
request :add_listeners_load_balancer
|
||||
request :add_nodes_load_balancer
|
||||
request :add_servers_server_group
|
||||
request :apply_to_firewall_policy
|
||||
request :accept_user_collaboration
|
||||
request :remove_firewall_policy
|
||||
request :create_api_client
|
||||
request :create_application
|
||||
request :create_cloud_ip
|
||||
request :create_collaboration
|
||||
request :create_firewall_policy
|
||||
request :create_firewall_rule
|
||||
request :create_image
|
||||
request :create_load_balancer
|
||||
request :create_database_server
|
||||
request :create_server
|
||||
request :create_server_group
|
||||
request :delete_api_client
|
||||
request :delete_application
|
||||
request :delete_cloud_ip
|
||||
request :delete_collaboration
|
||||
request :delete_firewall_policy
|
||||
request :delete_firewall_rule
|
||||
request :delete_image
|
||||
request :delete_load_balancer
|
||||
request :delete_database_server
|
||||
request :delete_database_snapshot
|
||||
request :delete_server
|
||||
request :delete_server_group
|
||||
request :delete_user_collaboration
|
||||
request :get_account
|
||||
request :get_api_client
|
||||
request :get_application
|
||||
request :get_authenticated_user
|
||||
request :get_cloud_ip
|
||||
request :get_collaboration
|
||||
request :get_firewall_policy
|
||||
request :get_firewall_rule
|
||||
request :get_image
|
||||
request :get_interface
|
||||
request :get_load_balancer
|
||||
request :get_database_server
|
||||
request :get_database_snapshot
|
||||
request :get_database_type
|
||||
request :get_scoped_account
|
||||
request :get_server
|
||||
request :get_server_group
|
||||
request :get_server_type
|
||||
request :get_user
|
||||
request :get_user_collaboration
|
||||
request :get_zone
|
||||
request :list_accounts
|
||||
request :list_api_clients
|
||||
request :list_applications
|
||||
request :list_cloud_ips
|
||||
request :list_collaborations
|
||||
request :list_firewall_policies
|
||||
request :list_images
|
||||
request :list_load_balancers
|
||||
request :list_database_servers
|
||||
request :list_database_snapshots
|
||||
request :list_database_types
|
||||
request :list_server_groups
|
||||
request :list_server_types
|
||||
request :list_servers
|
||||
request :list_users
|
||||
request :list_user_collaborations
|
||||
request :list_zones
|
||||
request :map_cloud_ip
|
||||
request :move_servers_server_group
|
||||
request :reject_user_collaboration
|
||||
request :remove_listeners_load_balancer
|
||||
request :remove_nodes_load_balancer
|
||||
request :remove_servers_server_group
|
||||
request :resend_collaboration
|
||||
request :reset_ftp_password_account
|
||||
request :reset_ftp_password_scoped_account
|
||||
request :reset_password_database_server
|
||||
request :reset_secret_api_client
|
||||
request :reset_secret_application
|
||||
request :resend_collaboration
|
||||
request :reject_user_collaboration
|
||||
request :shutdown_server
|
||||
request :snapshot_database_server
|
||||
request :snapshot_server
|
||||
request :start_server
|
||||
request :stop_server
|
||||
request :unmap_cloud_ip
|
||||
request :update_account
|
||||
request :update_api_client
|
||||
request :update_application
|
||||
request :update_cloud_ip
|
||||
request :update_firewall_policy
|
||||
request :update_firewall_rule
|
||||
request :update_image
|
||||
request :update_load_balancer
|
||||
request :update_database_server
|
||||
request :update_database_snapshot
|
||||
request :update_scoped_account
|
||||
request :update_server
|
||||
request :update_server_group
|
||||
request :update_user
|
||||
|
||||
# The Mock Service allows you to run a fake instance of the Service
|
||||
# which makes no real connections.
|
||||
#
|
||||
# @todo Implement
|
||||
#
|
||||
class Mock
|
||||
include Fog::Brightbox::Compute::Shared
|
||||
|
||||
def request(method, path, expected_responses, parameters = {})
|
||||
_request
|
||||
end
|
||||
|
||||
def request_access_token(connection, credentials)
|
||||
_request
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def _request
|
||||
raise Fog::Errors::MockNotImplemented
|
||||
end
|
||||
|
||||
def select_default_image
|
||||
"img-mockd"
|
||||
end
|
||||
end
|
||||
|
||||
# The Real Service actually makes real connections to the Brightbox
|
||||
# service.
|
||||
#
|
||||
class Real
|
||||
include Fog::Brightbox::Compute::Shared
|
||||
|
||||
# Makes an API request to the given path using passed options or those
|
||||
# set with the service setup
|
||||
#
|
||||
# @todo Standard Fog behaviour is to return the Excon::Response but
|
||||
# this was unintentionally changed to be the Hash version of the
|
||||
# data in the body. This loses access to some details and should
|
||||
# be corrected in a backwards compatible manner
|
||||
#
|
||||
# @overload request(params)
|
||||
# @param [Hash] params Excon compatible options
|
||||
# @option params [String] :body text to be sent over a socket
|
||||
# @option params [Hash<Symbol, String>] :headers The default headers to supply in a request
|
||||
# @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String
|
||||
# @option params [String] :path appears after 'scheme://host:port/'
|
||||
# @option params [Fixnum] :port The port on which to connect, to the destination host
|
||||
# @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value'
|
||||
# @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used
|
||||
# @return [Excon::Response]
|
||||
# @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
|
||||
#
|
||||
# @overload request(method, path, expected_responses, params = {})
|
||||
# @param [String] method HTTP method to use for the request
|
||||
# @param [String] path The absolute path for the request
|
||||
# @param [Array<Fixnum>] expected_responses HTTP response codes that have been successful
|
||||
# @param [Hash] params Keys and values for JSON
|
||||
# @option params [String] :account_id The scoping account if required
|
||||
# @deprecated #request with multiple arguments is deprecated
|
||||
# since it is inconsistent with original fog version.
|
||||
# @return [Hash]
|
||||
def request(*args)
|
||||
if args.size == 1
|
||||
authenticated_request(*args)
|
||||
else
|
||||
Fog::Logger.deprecation("#request with multiple parameters is deprecated, use #wrapped_request instead [light_black](#{caller.first})[/]")
|
||||
wrapped_request(*args)
|
||||
end
|
||||
end
|
||||
|
||||
# Makes a request but with seperated arguments and parses the response to a hash
|
||||
#
|
||||
# @note #wrapped_request is the non-standard form of request introduced by mistake
|
||||
#
|
||||
# @param [String] method HTTP method to use for the request
|
||||
# @param [String] path The absolute path for the request
|
||||
# @param [Array<Fixnum>] expected_responses HTTP response codes that have been successful
|
||||
# @param [Hash] parameters Keys and values for JSON
|
||||
# @option parameters [String] :account_id The scoping account if required
|
||||
#
|
||||
# @return [Hash]
|
||||
def wrapped_request(method, path, expected_responses, parameters = {})
|
||||
_wrapped_request(method, path, expected_responses, parameters)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Wrapped request is the non-standard form of request introduced by mistake
|
||||
#
|
||||
# @param [String] method HTTP method to use for the request
|
||||
# @param [String] path The absolute path for the request
|
||||
# @param [Array<Fixnum>] expected_responses HTTP response codes that have been successful
|
||||
# @param [Hash] parameters Keys and values for JSON
|
||||
# @option parameters [String] :account_id The scoping account if required
|
||||
#
|
||||
# @return [Hash]
|
||||
def _wrapped_request(method, path, expected_responses, parameters = {})
|
||||
request_options = {
|
||||
:method => method.to_s.upcase,
|
||||
:path => path,
|
||||
:expects => expected_responses
|
||||
}
|
||||
|
||||
# Select the account to scope for this request
|
||||
account = scoped_account(parameters.fetch(:account_id, nil))
|
||||
request_options[:query] = { :account_id => account } if account
|
||||
|
||||
request_options[:body] = Fog::JSON.encode(parameters) unless parameters.empty?
|
||||
|
||||
response = make_request(request_options)
|
||||
|
||||
# FIXME: We should revert to returning the Excon::Request after a suitable
|
||||
# configuration option is in place to switch back to this incorrect behaviour
|
||||
if response.body.empty?
|
||||
response
|
||||
else
|
||||
Fog::JSON.decode(response.body)
|
||||
end
|
||||
end
|
||||
|
||||
# Queries the API and tries to select the most suitable official Image
|
||||
# to use if the user chooses not to select their own.
|
||||
#
|
||||
# @return [String] if image is found, the image's identifier
|
||||
# @return [NilClass] if no image found or an error occured
|
||||
#
|
||||
def select_default_image
|
||||
Fog::Brightbox::Compute::ImageSelector.new(list_images).latest_ubuntu
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
module Fog
|
||||
module Brightbox
|
||||
module Compute
|
||||
#
|
||||
# This selects the preferred image to use based on a number of
|
||||
# conditions
|
||||
#
|
||||
class ImageSelector
|
||||
# Prepares a selector with the API output
|
||||
#
|
||||
# @param [Array<Hash>] images hash matching API output for {Fog::Compute::Brightbox#list_images}
|
||||
#
|
||||
def initialize(images)
|
||||
@images = images
|
||||
end
|
||||
|
||||
# Returns current identifier of the latest version of Ubuntu
|
||||
#
|
||||
# The order of preference is:
|
||||
# * Only Official Brightbox images
|
||||
# * Only Ubuntu images
|
||||
# * Latest by name (alphanumeric sort)
|
||||
# * Latest by creation date
|
||||
#
|
||||
# @note This performs a live query against the API
|
||||
#
|
||||
# @return [String] if image matches containing the identifier
|
||||
# @return [NilClass] if no image matches
|
||||
#
|
||||
def latest_ubuntu
|
||||
@images.select do |img|
|
||||
img["official"] == true &&
|
||||
img["arch"] == "i686" &&
|
||||
img["name"] =~ /ubuntu/i
|
||||
end.sort do |a, b|
|
||||
# Reverse sort so "raring" > "precise" and "13.10" > "13.04"
|
||||
b["name"].downcase <=> a["name"].downcase
|
||||
end.first["id"]
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,229 +0,0 @@
|
|||
require "fog/brightbox/oauth2"
|
||||
|
||||
module Fog
|
||||
module Brightbox
|
||||
module Compute
|
||||
# The Shared module consists of code that was duplicated between the Real
|
||||
# and Mock implementations.
|
||||
#
|
||||
module Shared
|
||||
include Fog::Brightbox::OAuth2
|
||||
|
||||
API_URL = "https://api.gb1.brightbox.com/"
|
||||
|
||||
# Creates a new instance of the Brightbox Compute service
|
||||
#
|
||||
# @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
|
||||
# @option options [String] :brightbox_api_url
|
||||
# Override the default (or configured) API endpoint
|
||||
# @option options [String] :brightbox_auth_url
|
||||
# Override the default (or configured) API authentication endpoint
|
||||
# @option options [String] :brightbox_client_id
|
||||
# Client identifier to authenticate with (overrides configured)
|
||||
# @option options [String] :brightbox_secret
|
||||
# Client secret to authenticate with (overrides configured)
|
||||
# @option options [String] :brightbox_username
|
||||
# Email or user identifier for user based authentication
|
||||
# @option options [String] :brightbox_password
|
||||
# Password for user based authentication
|
||||
# @option options [String] :brightbox_account
|
||||
# Account identifier to scope this connection to
|
||||
# @option options [String] :connection_options
|
||||
# Settings to pass to underlying {Fog::Core::Connection}
|
||||
# @option options [Boolean] :persistent
|
||||
# Sets a persistent HTTP {Fog::Core::Connection}
|
||||
# @option options [String] :brightbox_access_token
|
||||
# Sets the OAuth access token to use rather than requesting a new token
|
||||
# @option options [String] :brightbox_refresh_token
|
||||
# Sets the refresh token to use when requesting a newer access token
|
||||
# @option options [String] (true) :brightbox_token_management
|
||||
# Overide the existing behaviour to request access tokens if expired
|
||||
#
|
||||
def initialize(options)
|
||||
# Currently authentication and api endpoints are the same but may change
|
||||
@auth_url = options[:brightbox_auth_url] || API_URL
|
||||
@auth_connection = Fog::Core::Connection.new(@auth_url)
|
||||
|
||||
@api_url = options[:brightbox_api_url] || API_URL
|
||||
@connection_options = options[:connection_options] || {}
|
||||
@persistent = options[:persistent] || false
|
||||
@connection = Fog::Core::Connection.new(@api_url, @persistent, @connection_options)
|
||||
|
||||
# Authentication options
|
||||
client_id = options[:brightbox_client_id]
|
||||
client_secret = options[:brightbox_secret]
|
||||
|
||||
username = options[:brightbox_username]
|
||||
password = options[:brightbox_password]
|
||||
@configured_account = options[:brightbox_account]
|
||||
# Request account can be changed at anytime and changes behaviour of future requests
|
||||
@scoped_account = @configured_account
|
||||
|
||||
credential_options = { :username => username, :password => password }
|
||||
@credentials = CredentialSet.new(client_id, client_secret, credential_options)
|
||||
|
||||
# If existing tokens have been cached, allow continued use of them in the service
|
||||
@credentials.update_tokens(options[:brightbox_access_token], options[:brightbox_refresh_token])
|
||||
|
||||
@token_management = options.fetch(:brightbox_token_management, true)
|
||||
end
|
||||
|
||||
# Sets the scoped account for future requests
|
||||
# @param [String] scoped_account Identifier of the account to scope request to
|
||||
def scoped_account=(scoped_account)
|
||||
@scoped_account = scoped_account
|
||||
end
|
||||
|
||||
# This returns the account identifier that the request should be scoped by
|
||||
# based on the options passed to the request and current configuration
|
||||
#
|
||||
# @param [String] options_account Any identifier passed into the request
|
||||
#
|
||||
# @return [String, nil] The account identifier to scope the request to or nil
|
||||
def scoped_account(options_account = nil)
|
||||
[options_account, @scoped_account].compact.first
|
||||
end
|
||||
|
||||
# Resets the scoped account back to intially configured one
|
||||
def scoped_account_reset
|
||||
@scoped_account = @configured_account
|
||||
end
|
||||
|
||||
# Returns the scoped account being used for requests
|
||||
#
|
||||
# * For API clients this is the owning account
|
||||
# * For User applications this is the account specified by either +account_id+
|
||||
# option on the service or the +brightbox_account+ setting in your configuration
|
||||
#
|
||||
# @return [Fog::Compute::Brightbox::Account]
|
||||
#
|
||||
def account
|
||||
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
|
||||
# @return [Boolean]
|
||||
def authenticating_as_user?
|
||||
@credentials.user_details?
|
||||
end
|
||||
|
||||
# Returns true if an access token is set
|
||||
# @return [Boolean]
|
||||
def access_token_available?
|
||||
!! @credentials.access_token
|
||||
end
|
||||
|
||||
# Returns the current access token or nil
|
||||
# @return [String,nil]
|
||||
def access_token
|
||||
@credentials.access_token
|
||||
end
|
||||
|
||||
# Returns the current refresh token or nil
|
||||
# @return [String,nil]
|
||||
def refresh_token
|
||||
@credentials.refresh_token
|
||||
end
|
||||
|
||||
# Returns the current token expiry time in seconds or nil
|
||||
# @return [Number,nil]
|
||||
def expires_in
|
||||
@credentials.expires_in
|
||||
end
|
||||
|
||||
# Requests a new access token
|
||||
#
|
||||
# @return [String] New access token
|
||||
def get_access_token
|
||||
begin
|
||||
get_access_token!
|
||||
rescue Excon::Errors::Unauthorized, Excon::Errors::BadRequest
|
||||
@credentials.update_tokens(nil, nil)
|
||||
end
|
||||
@credentials.access_token
|
||||
end
|
||||
|
||||
# Requests a new access token and raises if there is a problem
|
||||
#
|
||||
# @return [String] New access token
|
||||
# @raise [Excon::Errors::BadRequest] The credentials are expired or incorrect
|
||||
#
|
||||
def get_access_token!
|
||||
response = request_access_token(@auth_connection, @credentials)
|
||||
update_credentials_from_response(@credentials, response)
|
||||
@credentials.access_token
|
||||
end
|
||||
|
||||
# Returns an identifier for the default image for use
|
||||
#
|
||||
# Currently tries to find the latest version of Ubuntu (i686) from
|
||||
# Brightbox.
|
||||
#
|
||||
# Highly recommended that you actually select the image you want to run
|
||||
# on your servers yourself!
|
||||
#
|
||||
# @return [String] if image is found, returns the identifier
|
||||
# @return [NilClass] if no image is found or an error occurs
|
||||
#
|
||||
def default_image
|
||||
return @default_image_id unless @default_image_id.nil?
|
||||
@default_image_id = Fog.credentials[:brightbox_default_image] || select_default_image
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# This makes a request of the API based on the configured setting for
|
||||
# token management.
|
||||
#
|
||||
# @param [Hash] options Excon compatible options
|
||||
# @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
|
||||
#
|
||||
# @return [Hash] Data of response body
|
||||
#
|
||||
def make_request(options)
|
||||
if @token_management
|
||||
managed_token_request(options)
|
||||
else
|
||||
authenticated_request(options)
|
||||
end
|
||||
end
|
||||
|
||||
# This request checks for access tokens and will ask for a new one if
|
||||
# it receives Unauthorized from the API before repeating the request
|
||||
#
|
||||
# @param [Hash] options Excon compatible options
|
||||
#
|
||||
# @return [Excon::Response]
|
||||
def managed_token_request(options)
|
||||
get_access_token unless access_token_available?
|
||||
authenticated_request(options)
|
||||
rescue Excon::Errors::Unauthorized
|
||||
get_access_token
|
||||
authenticated_request(options)
|
||||
end
|
||||
|
||||
# This request makes an authenticated request of the API using currently
|
||||
# setup credentials.
|
||||
#
|
||||
# @param [Hash] options Excon compatible options
|
||||
#
|
||||
# @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
|
||||
#
|
||||
# @return [Excon::Response]
|
||||
def authenticated_request(options)
|
||||
headers = options[:headers] || {}
|
||||
headers.merge!("Authorization" => "OAuth #{@credentials.access_token}", "Content-Type" => "application/json")
|
||||
options[:headers] = headers
|
||||
# TODO: This is just a wrapper around a call to Excon::Connection#request
|
||||
# so can be extracted from Compute by passing in the connection,
|
||||
# credentials and options
|
||||
@connection.request(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
require 'fog/core'
|
||||
require 'fog/json'
|
||||
|
||||
module Fog
|
||||
module Brightbox
|
||||
extend Fog::Provider
|
||||
|
||||
service(:compute, 'Compute')
|
||||
end
|
||||
end
|
|
@ -1,65 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Account < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
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 :verified_telephone
|
||||
attribute :verified_ip
|
||||
attribute :ram_limit
|
||||
attribute :ram_used
|
||||
attribute :cloud_ips_limit
|
||||
attribute :cloud_ips_used
|
||||
attribute :load_balancers_limit
|
||||
attribute :load_balancers_used
|
||||
attribute :library_ftp_host
|
||||
attribute :library_ftp_user
|
||||
# This is always returned as nil unless after a call to reset_ftp_password
|
||||
attribute :library_ftp_password
|
||||
|
||||
# Boolean flags
|
||||
attribute :valid_credit_card
|
||||
attribute :telephone_verified
|
||||
|
||||
# Times
|
||||
attribute :created_at, :type => :time
|
||||
attribute :verified_at, :type => :time
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :owner_id, :aliases => "owner", :squash => "id"
|
||||
attribute :clients
|
||||
attribute :images
|
||||
attribute :servers
|
||||
attribute :users
|
||||
attribute :zones
|
||||
|
||||
# Resets the account's image library FTP password returning the new value
|
||||
#
|
||||
# @return [String] Newly issue FTP password
|
||||
#
|
||||
def reset_ftp_password
|
||||
requires :identity
|
||||
data = service.reset_ftp_password_account(identity)
|
||||
merge_attributes(data)
|
||||
library_ftp_password
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/account'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Accounts < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Account
|
||||
|
||||
def all
|
||||
data = service.list_accounts
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_account(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class ApiClient < Fog::Model
|
||||
identity :id
|
||||
attribute :name
|
||||
attribute :description
|
||||
attribute :secret
|
||||
attribute :revoked_at, :type => :time
|
||||
attribute :account_id
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
options = {
|
||||
:name => name,
|
||||
:description => description
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_api_client(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_api_client(identity)
|
||||
true
|
||||
end
|
||||
|
||||
def reset_secret
|
||||
requires :identity
|
||||
service.reset_secret_api_client(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require "fog/core/collection"
|
||||
require "fog/brightbox/models/compute/api_client"
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class ApiClients < Fog::Collection
|
||||
model Fog::Compute::Brightbox::ApiClient
|
||||
|
||||
def all
|
||||
data = service.list_api_clients
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier = nil)
|
||||
data = service.get_api_client(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Application < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :name
|
||||
attribute :secret
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
options = {
|
||||
:name => name
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_application(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/application'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Applications < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Application
|
||||
|
||||
def all
|
||||
data = service.list_applications
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_application(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class CloudIp < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :description
|
||||
|
||||
attribute :reverse_dns
|
||||
attribute :public_ip
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account_id, :aliases => "account", :squash => "id"
|
||||
attribute :interface_id, :aliases => "interface", :squash => "id"
|
||||
attribute :server_id, :aliases => "server", :squash => "id"
|
||||
attribute :load_balancer, :alias => "load_balancer", :squash => "id"
|
||||
attribute :server_group, :alias => "server_group", :squash => "id"
|
||||
attribute :database_server, :alias => "database_server", :squash => "id"
|
||||
attribute :port_translators
|
||||
attribute :name
|
||||
|
||||
# Attempt to map or point the Cloud IP to the destination resource.
|
||||
#
|
||||
# @param [Object] destination
|
||||
#
|
||||
def map(destination)
|
||||
requires :identity
|
||||
if destination.respond_to?(:mapping_identity)
|
||||
final_destination = destination.mapping_identity
|
||||
elsif destination.respond_to?(:identity)
|
||||
final_destination = destination.identity
|
||||
else
|
||||
final_destination = destination
|
||||
end
|
||||
service.map_cloud_ip(identity, :destination => final_destination)
|
||||
end
|
||||
|
||||
def mapped?
|
||||
status == "mapped"
|
||||
end
|
||||
|
||||
def unmap
|
||||
requires :identity
|
||||
service.unmap_cloud_ip(identity)
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_cloud_ip(identity)
|
||||
end
|
||||
|
||||
def destination_id
|
||||
server_id || load_balancer || server_group || database_server || interface_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/cloud_ip'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class CloudIps < Fog::Collection
|
||||
model Fog::Compute::Brightbox::CloudIp
|
||||
|
||||
def all
|
||||
data = service.list_cloud_ips
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_cloud_ip(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def allocate
|
||||
data = service.create_cloud_ip
|
||||
new(data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Collaboration < Fog::Model
|
||||
identity :id
|
||||
attribute :status
|
||||
attribute :email
|
||||
attribute :role
|
||||
attribute :role_label
|
||||
attribute :account
|
||||
attribute :user
|
||||
attribute :inviter
|
||||
|
||||
def account_id
|
||||
account['id'] || account[:id]
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
|
||||
options = {
|
||||
:role => role,
|
||||
:email => email
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
|
||||
data = service.create_collaboration(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def resend
|
||||
requires :identity
|
||||
data = service.resend_collaboration(identity)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
data = service.destroy_collaboration(identity)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
require "fog/core/collection"
|
||||
require "fog/brightbox/models/compute/collaboration"
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Collaborations < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Collaboration
|
||||
|
||||
def all
|
||||
data = service.list_collaborations
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_collaboration(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
# Invites a user (via an email) to collaborate on the currently scoped
|
||||
# account at the +role+ level.
|
||||
#
|
||||
# @param [String] email The email address to use for the invitation
|
||||
# @param [String] role The role being granted. Only (+admin+ is
|
||||
# currently supported
|
||||
# @return [Fog::Compute::Brightbox::Collaboration]
|
||||
#
|
||||
def invite(email, role)
|
||||
return nil if email.nil? || email == ""
|
||||
return nil if role.nil? || role == ""
|
||||
options = { :email => email, :role => role }
|
||||
data = service.create_collaboration(options)
|
||||
new(data)
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_collaboration(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,97 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseServer < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :description
|
||||
attribute :state, :aliases => "status"
|
||||
|
||||
attribute :admin_username
|
||||
attribute :admin_password
|
||||
|
||||
attribute :database_engine
|
||||
attribute :database_version
|
||||
|
||||
attribute :maintenance_weekday
|
||||
attribute :maintenance_hour
|
||||
|
||||
attribute :created_at, :type => :time
|
||||
attribute :updated_at, :type => :time
|
||||
attribute :deleted_at, :type => :time
|
||||
|
||||
attribute :allow_access
|
||||
|
||||
attribute :flavor_id, "alias" => "database_server_type", :squash => "id"
|
||||
attribute :zone_id, "alias" => "zone", :squash => "id"
|
||||
|
||||
attribute :cloud_ips
|
||||
|
||||
def save
|
||||
options = {
|
||||
:name => name,
|
||||
:description => description
|
||||
}
|
||||
|
||||
options[:allow_access] = allow_access if allow_access
|
||||
|
||||
# These may be nil which sets them to default values upstream
|
||||
# TODO: Dirty track the values so we don't send them when already nil
|
||||
options[:maintenance_weekday] = maintenance_weekday
|
||||
options[:maintenance_hour] = maintenance_hour
|
||||
|
||||
if persisted?
|
||||
data = update_database_server(options)
|
||||
else
|
||||
options[:engine] = database_engine if database_engine
|
||||
options[:version] = database_version if database_version
|
||||
options[:database_type] = flavor_id if flavor_id
|
||||
options[:zone] = zone_id if zone_id
|
||||
|
||||
data = create_database_server(options)
|
||||
end
|
||||
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == "active"
|
||||
end
|
||||
|
||||
def snapshot
|
||||
requires :identity
|
||||
merge_attributes(service.snapshot_database_server(identity))
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
merge_attributes(service.destroy_database_server(identity))
|
||||
true
|
||||
end
|
||||
|
||||
def reset_password
|
||||
requires :identity
|
||||
merge_attributes(service.reset_password_database_server(identity))
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_database_server(options)
|
||||
service.create_database_server(options)
|
||||
end
|
||||
|
||||
def update_database_server(options)
|
||||
service.update_database_server(identity, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/database_server'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseServers < Fog::Collection
|
||||
model Fog::Compute::Brightbox::DatabaseServer
|
||||
|
||||
def all
|
||||
data = service.list_database_servers
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_database_server(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseSnapshot < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :description
|
||||
attribute :state, :aliases => "status"
|
||||
|
||||
attribute :database_engine
|
||||
attribute :database_version
|
||||
|
||||
attribute :size
|
||||
|
||||
attribute :created_at, :type => :time
|
||||
attribute :updated_at, :type => :time
|
||||
attribute :deleted_at, :type => :time
|
||||
|
||||
def save
|
||||
options = {
|
||||
:name => name,
|
||||
:description => description
|
||||
}
|
||||
data = update_database_snapshot(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == "available"
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
merge_attributes(service.destroy_database_snapshot(identity))
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_database_snapshot(options)
|
||||
service.update_database_snaphot(identity, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/database_snapshot'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseSnapshots < Fog::Collection
|
||||
model Fog::Compute::Brightbox::DatabaseSnapshot
|
||||
|
||||
def all
|
||||
data = service.list_database_snapshots
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_database_snapshot(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseType < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :description
|
||||
|
||||
attribute :disk, :aliases => "disk_size"
|
||||
attribute :ram
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/database_type'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class DatabaseTypes < Fog::Collection
|
||||
model Fog::Compute::Brightbox::DatabaseType
|
||||
|
||||
def all
|
||||
data = service.list_database_types
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_database_type(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/firewall_policy'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class FirewallPolicies < Fog::Collection
|
||||
model Fog::Compute::Brightbox::FirewallPolicy
|
||||
|
||||
def all
|
||||
data = service.list_firewall_policies
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_firewall_policy(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,61 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class FirewallPolicy < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :description
|
||||
|
||||
attribute :default
|
||||
|
||||
attribute :server_group_id, :aliases => "server_group", :squash => "id"
|
||||
attribute :created_at, :type => :time
|
||||
attribute :rules
|
||||
|
||||
# Sticking with existing Fog behaviour, save does not update but creates a new resource
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
options = {
|
||||
:server_group => server_group_id,
|
||||
:name => name,
|
||||
:description => description
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_firewall_policy(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def apply_to(server_group_id)
|
||||
requires :identity
|
||||
options = {
|
||||
:server_group => server_group_id
|
||||
}
|
||||
data = service.apply_to_firewall_policy(identity, options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def remove(server_group_id)
|
||||
requires :identity
|
||||
options = {
|
||||
:server_group => server_group_id
|
||||
}
|
||||
data = service.remove_firewall_policy(identity, options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_firewall_policy(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class FirewallRule < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :description
|
||||
|
||||
attribute :source
|
||||
attribute :source_port
|
||||
attribute :destination
|
||||
attribute :destination_port
|
||||
attribute :protocol
|
||||
attribute :icmp_type_name
|
||||
attribute :created_at, :type => :time
|
||||
|
||||
attribute :firewall_policy_id, :aliases => "firewall_policy", :squash => "id"
|
||||
|
||||
# Sticking with existing Fog behaviour, save does not update but creates a new resource
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :firewall_policy_id
|
||||
options = {
|
||||
:firewall_policy => firewall_policy_id,
|
||||
:protocol => protocol,
|
||||
:description => description,
|
||||
:source => source,
|
||||
:source_port => source_port,
|
||||
:destination => destination,
|
||||
:destination_port => destination_port,
|
||||
:icmp_type_name => icmp_type_name
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_firewall_rule(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_firewall_rule(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/firewall_rule'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class FirewallRules < Fog::Collection
|
||||
model Fog::Compute::Brightbox::FirewallRule
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_firewall_rule(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Flavor < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
attribute :description
|
||||
|
||||
attribute :handle
|
||||
|
||||
attribute :bits
|
||||
attribute :cores
|
||||
attribute :disk, :aliases => "disk_size"
|
||||
attribute :ram
|
||||
|
||||
def bits
|
||||
0 # This is actually based on the Image type used. 32bit or 64bit Images are supported
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/flavor'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Flavors < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Flavor
|
||||
|
||||
def all
|
||||
data = service.list_server_types
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_server_type(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,62 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Image < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :username
|
||||
attribute :status
|
||||
attribute :description
|
||||
|
||||
attribute :source
|
||||
attribute :source_type
|
||||
attribute :arch
|
||||
attribute :virtual_size
|
||||
attribute :disk_size
|
||||
attribute :licence_name
|
||||
|
||||
# Boolean flags
|
||||
attribute :public
|
||||
attribute :official
|
||||
attribute :compatibility_mode
|
||||
|
||||
# Times
|
||||
attribute :created_at, :type => :time
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
|
||||
attribute :owner_id, :aliases => "owner", :squash => "id"
|
||||
|
||||
def ready?
|
||||
status == "available"
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :source, :arch
|
||||
options = {
|
||||
:source => source,
|
||||
:arch => arch,
|
||||
:name => name,
|
||||
:username => username,
|
||||
:description => description
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_image(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_image(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/image'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Images < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Image
|
||||
|
||||
def all
|
||||
data = service.list_images
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_image(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,105 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class LoadBalancer < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :name
|
||||
attribute :status
|
||||
|
||||
attribute :policy
|
||||
attribute :nodes
|
||||
attribute :healthcheck
|
||||
attribute :listeners
|
||||
|
||||
# These SSL attributes act only as setters. You can not read certs or keys via the API
|
||||
attribute :certificate_pem
|
||||
attribute :certificate_private_key
|
||||
|
||||
# These SSL attributes act only as getters for metadata
|
||||
attribute :certificate_valid_from
|
||||
attribute :certificate_expires_at
|
||||
attribute :certificate_issuer
|
||||
attribute :certificate_subject
|
||||
|
||||
# Times
|
||||
attribute :created_at, :type => :time
|
||||
attribute :deleted_at, :type => :time
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account
|
||||
attribute :server
|
||||
attribute :cloud_ip
|
||||
|
||||
def ready?
|
||||
status == 'active'
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :nodes, :listeners, :healthcheck
|
||||
options = {
|
||||
:nodes => nodes,
|
||||
:listeners => listeners,
|
||||
:healthcheck => healthcheck,
|
||||
:policy => policy,
|
||||
:name => name,
|
||||
:certificate_pem => certificate_pem,
|
||||
:certificate_private_key => certificate_private_key
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_load_balancer(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_load_balancer(identity)
|
||||
true
|
||||
end
|
||||
|
||||
# SSL cert metadata for expiration of certificate
|
||||
def certificate_expires_at
|
||||
attributes[:certificate_expires_at]
|
||||
end
|
||||
|
||||
# SSL cert metadata for subject
|
||||
def certificate_subject
|
||||
attributes[:certificate_subject]
|
||||
end
|
||||
|
||||
# Sets the certificate metadata from the JSON object that contains it.
|
||||
#
|
||||
# It is used by fog's attribute setting and should not be used for attempting to set a
|
||||
# certificate on a load balancer.
|
||||
#
|
||||
# @private
|
||||
def certificate=(cert_metadata)
|
||||
if cert_metadata
|
||||
attributes[:certificate_valid_from] = time_or_original(cert_metadata["valid_from"])
|
||||
attributes[:certificate_expires_at] = time_or_original(cert_metadata["expires_at"])
|
||||
attributes[:certificate_issuer] = cert_metadata["issuer"]
|
||||
attributes[:certificate_subject] = cert_metadata["subject"]
|
||||
else
|
||||
attributes[:certificate_valid_from] = nil
|
||||
attributes[:certificate_expires_at] = nil
|
||||
attributes[:certificate_issuer] = nil
|
||||
attributes[:certificate_subject] = nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def time_or_original(value)
|
||||
Time.parse(value)
|
||||
rescue TypeError, ArgumentError
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/load_balancer'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class LoadBalancers < Fog::Collection
|
||||
model Fog::Compute::Brightbox::LoadBalancer
|
||||
|
||||
def all
|
||||
data = service.list_load_balancers
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
data = service.get_load_balancer(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,214 +0,0 @@
|
|||
require 'fog/compute/models/server'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Server < Fog::Compute::Server
|
||||
identity :id
|
||||
attribute :resource_type
|
||||
attribute :url
|
||||
|
||||
attribute :name
|
||||
attribute :state, :aliases => 'status'
|
||||
|
||||
attribute :hostname
|
||||
attribute :fqdn
|
||||
attribute :user_data
|
||||
attribute :console_url
|
||||
attribute :fqdn
|
||||
attribute :console_token
|
||||
|
||||
# Times
|
||||
attribute :created_at, :type => :time
|
||||
attribute :started_at, :type => :time
|
||||
attribute :console_token_expires, :type => :time
|
||||
attribute :deleted_at, :type => :time
|
||||
|
||||
# Links - to be replaced
|
||||
attribute :account_id, :aliases => "account", :squash => "id"
|
||||
attribute :image_id, :aliases => "image", :squash => "id"
|
||||
|
||||
attribute :snapshots
|
||||
attribute :cloud_ips
|
||||
attribute :interfaces
|
||||
attribute :server_groups
|
||||
attribute :zone
|
||||
attribute :server_type
|
||||
|
||||
def initialize(attributes = {})
|
||||
# Call super first to initialize the service object for our default image
|
||||
super
|
||||
self.image_id ||= service.default_image
|
||||
end
|
||||
|
||||
def zone_id
|
||||
if t_zone_id = attributes[:zone_id]
|
||||
t_zone_id
|
||||
elsif zone
|
||||
zone[:id] || zone['id']
|
||||
end
|
||||
end
|
||||
|
||||
def flavor_id
|
||||
if t_flavour_id = attributes[:flavor_id]
|
||||
t_flavour_id
|
||||
elsif server_type
|
||||
server_type[:id] || server_type['id']
|
||||
end
|
||||
end
|
||||
|
||||
def zone_id=(incoming_zone_id)
|
||||
attributes[:zone_id] = incoming_zone_id
|
||||
end
|
||||
|
||||
def flavor_id=(incoming_flavour_id)
|
||||
attributes[:flavor_id] = incoming_flavour_id
|
||||
end
|
||||
|
||||
def snapshot
|
||||
requires :identity
|
||||
service.snapshot_server(identity)
|
||||
end
|
||||
|
||||
# Directly requesting a server reboot is not supported in the API
|
||||
# so needs to attempt a shutdown/stop, wait and start again.
|
||||
#
|
||||
# Default behaviour is a hard reboot because it is more reliable
|
||||
# because the state of the server's OS is irrelevant.
|
||||
#
|
||||
# @param [Boolean] use_hard_reboot
|
||||
# @return [Boolean]
|
||||
def reboot(use_hard_reboot = true)
|
||||
requires :identity
|
||||
if ready?
|
||||
if use_hard_reboot
|
||||
hard_reboot
|
||||
else
|
||||
soft_reboot
|
||||
end
|
||||
else
|
||||
# Not able to reboot if not ready in the first place
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def start
|
||||
requires :identity
|
||||
service.start_server(identity)
|
||||
true
|
||||
end
|
||||
|
||||
def stop
|
||||
requires :identity
|
||||
service.stop_server(identity)
|
||||
true
|
||||
end
|
||||
|
||||
def shutdown
|
||||
requires :identity
|
||||
service.shutdown_server(identity)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_server(identity)
|
||||
true
|
||||
end
|
||||
|
||||
def flavor
|
||||
requires :flavor_id
|
||||
service.flavors.get(flavor_id)
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
service.images.get(image_id)
|
||||
end
|
||||
|
||||
# Returns the public DNS name of the server
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
def dns_name
|
||||
["public", fqdn].join(".")
|
||||
end
|
||||
|
||||
def private_ip_address
|
||||
if interfaces.empty?
|
||||
nil
|
||||
else
|
||||
interfaces.first["ipv4_address"]
|
||||
end
|
||||
end
|
||||
|
||||
def public_ip_address
|
||||
if cloud_ips.empty?
|
||||
nil
|
||||
else
|
||||
cloud_ips.first["public_ip"]
|
||||
end
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == "active"
|
||||
end
|
||||
|
||||
def activate_console
|
||||
requires :identity
|
||||
response = service.activate_console_server(identity)
|
||||
[response["console_url"], response["console_token"], response["console_token_expires"]]
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
requires :image_id
|
||||
options = {
|
||||
:image => image_id,
|
||||
:name => name,
|
||||
:zone => zone_id,
|
||||
:user_data => user_data,
|
||||
:server_groups => server_groups
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
|
||||
options.merge!(:server_type => flavor_id) unless flavor_id.nil? || flavor_id == ""
|
||||
|
||||
data = service.create_server(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
# Replaces the server's identifier with it's interface's identifier for Cloud IP mapping
|
||||
#
|
||||
# @return [String] the identifier to pass to a Cloud IP mapping request
|
||||
def mapping_identity
|
||||
interfaces.first["id"]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Hard reboots are fast, avoiding the OS by doing a "power off"
|
||||
def hard_reboot
|
||||
stop
|
||||
wait_for { !ready? }
|
||||
start
|
||||
end
|
||||
|
||||
# Soft reboots often timeout if the OS missed the request so we do more
|
||||
# error checking trying to detect the timeout
|
||||
#
|
||||
# @todo Needs cleaner error handling when the OS times out
|
||||
def soft_reboot
|
||||
shutdown
|
||||
# FIXME: Using side effect of wait_for's (evaluated block) to detect timeouts
|
||||
begin
|
||||
wait_for(20) { !ready? }
|
||||
start
|
||||
rescue Fog::Errors::Timeout
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,93 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
# A server group is a collection of servers
|
||||
#
|
||||
# Certain actions can accept a server group and affect all members
|
||||
class ServerGroup < Fog::Model
|
||||
identity :id
|
||||
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
attribute :name
|
||||
attribute :description
|
||||
attribute :default
|
||||
attribute :created_at, :type => :time
|
||||
|
||||
attribute :server_ids, :aliases => "servers"
|
||||
|
||||
def save
|
||||
options = {
|
||||
:name => name,
|
||||
:description => description
|
||||
}.delete_if { |k, v| v.nil? || v == "" }
|
||||
data = service.create_server_group(options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def servers
|
||||
srv_ids = server_ids.map { |srv| srv["id"] }
|
||||
srv_ids.map do |srv_id|
|
||||
service.servers.get(srv_id)
|
||||
end
|
||||
end
|
||||
|
||||
# Adds specified servers to this server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to add
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def add_servers(identifiers)
|
||||
requires :identity
|
||||
options = {
|
||||
:servers => server_references(identifiers)
|
||||
}
|
||||
data = service.add_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
# Removes specified servers from this server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to remove
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def remove_servers(identifiers)
|
||||
requires :identity
|
||||
options = {
|
||||
:servers => server_references(identifiers)
|
||||
}
|
||||
data = service.remove_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
# Moves specified servers from this server group to the specified destination server group
|
||||
#
|
||||
# @param [Array] identifiers array of server identifier strings to move
|
||||
# @param [String] destination_group_id destination server group identifier
|
||||
# @return [Fog::Compute::ServerGroup]
|
||||
def move_servers(identifiers, destination_group_id)
|
||||
requires :identity
|
||||
options = {
|
||||
:servers => server_references(identifiers),
|
||||
:destination => destination_group_id
|
||||
}
|
||||
data = service.move_servers_server_group identity, options
|
||||
merge_attributes data
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_server_group(identity)
|
||||
true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def server_references(identifiers)
|
||||
identifiers.map { |id| { "server" => id } }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/server_group'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class ServerGroups < Fog::Collection
|
||||
model Fog::Compute::Brightbox::ServerGroup
|
||||
|
||||
def all
|
||||
data = service.list_server_groups
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_server_group(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,57 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/server'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Servers < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Server
|
||||
|
||||
def all
|
||||
data = service.list_servers
|
||||
load(data)
|
||||
end
|
||||
|
||||
# Creates a server and maps an Cloud IP
|
||||
#
|
||||
# By default the public SSH key you have registered with
|
||||
# Brightbox is already made available in an AWS compatible
|
||||
# metdata service.
|
||||
#
|
||||
# @todo Support uploading of arbitary SSH keys
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] name Name for the server
|
||||
# @option options [String] flavor_id Identifier for virtual hardware type to request
|
||||
# @option options [String] image_id Identifier for image to use when creating
|
||||
# @option options [String] zone_id Identifer for preferred zone to locate server in
|
||||
# @option options [Array<String>] server_groups List of group identifiers for the server to join
|
||||
#
|
||||
# @return Fog::Compute::Brightbox::Server
|
||||
#
|
||||
def bootstrap(options = {})
|
||||
server = create(options)
|
||||
|
||||
# Ensure server is now available
|
||||
server.wait_for { ready? }
|
||||
|
||||
# To get a public IP address we need to map a cloud IP address
|
||||
cip = service.cloud_ips.allocate
|
||||
cip.map(server)
|
||||
cip.wait_for { mapped? }
|
||||
|
||||
# Reload so the public IP is now available
|
||||
server.reload
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_server(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,39 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class User < Fog::Model
|
||||
identity :id
|
||||
attribute :resource_type
|
||||
attribute :url
|
||||
|
||||
attribute :name
|
||||
attribute :email_address
|
||||
attribute :ssh_key
|
||||
|
||||
# Boolean flags
|
||||
attribute :email_verified
|
||||
attribute :messaging_pref
|
||||
|
||||
# Links - to be replaced
|
||||
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
|
||||
}
|
||||
|
||||
data = service.update_user(identity, options)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class UserCollaboration < Fog::Model
|
||||
identity :id
|
||||
attribute :status
|
||||
attribute :email
|
||||
attribute :role
|
||||
attribute :role_label
|
||||
attribute :account
|
||||
attribute :user
|
||||
attribute :inviter
|
||||
|
||||
def account_id
|
||||
account['id'] || account[:id]
|
||||
end
|
||||
|
||||
def accept
|
||||
requires :identity
|
||||
data = service.accept_user_collaboration(identity)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def reject
|
||||
requires :identity
|
||||
data = service.reject_user_collaboration(identity)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
data = service.destroy_user_collaboration(identity)
|
||||
merge_attributes(data)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
require "fog/core/collection"
|
||||
require "fog/brightbox/models/compute/user_collaboration"
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class UserCollaborations < Fog::Collection
|
||||
model Fog::Compute::Brightbox::UserCollaboration
|
||||
|
||||
def all
|
||||
data = service.list_user_collaborations
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_user_collaboration(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
service.destroy_user_collaboration(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/user'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Users < Fog::Collection
|
||||
model Fog::Compute::Brightbox::User
|
||||
|
||||
def all
|
||||
data = service.list_users
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier = nil)
|
||||
data = service.get_user(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Zone < Fog::Model
|
||||
identity :id
|
||||
attribute :url
|
||||
attribute :resource_type
|
||||
|
||||
attribute :status
|
||||
attribute :handle
|
||||
|
||||
attribute :description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/brightbox/models/compute/zone'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Zones < Fog::Collection
|
||||
model Fog::Compute::Brightbox::Zone
|
||||
|
||||
def all
|
||||
data = service.list_zones
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
data = service.get_zone(identifier)
|
||||
new(data)
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,165 +0,0 @@
|
|||
# This module covers Brightbox's partial implementation of OAuth 2.0
|
||||
# and enables fog clients to implement several authentictication strategies
|
||||
#
|
||||
# @see http://tools.ietf.org/html/draft-ietf-oauth-v2-10
|
||||
#
|
||||
module Fog::Brightbox::OAuth2
|
||||
# This builds the simplest form of requesting an access token
|
||||
# based on the arguments passed in
|
||||
#
|
||||
# @param [Fog::Core::Connection] connection
|
||||
# @param [CredentialSet] credentials
|
||||
#
|
||||
# @return [Excon::Response]
|
||||
def request_access_token(connection, credentials)
|
||||
token_strategy = credentials.best_grant_strategy
|
||||
|
||||
header_content = "#{credentials.client_id}:#{credentials.client_secret}"
|
||||
encoded_credentials = Base64.encode64(header_content).chomp
|
||||
|
||||
connection.request(
|
||||
:path => "/token",
|
||||
:expects => 200,
|
||||
:headers => {
|
||||
'Authorization' => "Basic #{encoded_credentials}",
|
||||
'Content-Type' => 'application/json'
|
||||
},
|
||||
:method => 'POST',
|
||||
:body => Fog::JSON.encode(token_strategy.authorization_body_data)
|
||||
)
|
||||
end
|
||||
|
||||
# Encapsulates credentials required to request access tokens from the
|
||||
# Brightbox authorisation servers
|
||||
#
|
||||
# @todo Interface to update certain credentials (after password change)
|
||||
#
|
||||
class CredentialSet
|
||||
attr_reader :client_id, :client_secret, :username, :password
|
||||
attr_reader :access_token, :refresh_token, :expires_in
|
||||
#
|
||||
# @param [String] client_id
|
||||
# @param [String] client_secret
|
||||
# @param [Hash] options
|
||||
# @option options [String] :username
|
||||
# @option options [String] :password
|
||||
#
|
||||
def initialize(client_id, client_secret, options = {})
|
||||
@client_id = client_id
|
||||
@client_secret = client_secret
|
||||
@username = options[:username]
|
||||
@password = options[:password]
|
||||
@access_token = options[:access_token]
|
||||
@refresh_token = options[:refresh_token]
|
||||
@expires_in = options[:expires_in]
|
||||
end
|
||||
|
||||
# Returns true if user details are available
|
||||
# @return [Boolean]
|
||||
def user_details?
|
||||
!!(@username && @password)
|
||||
end
|
||||
|
||||
# Is an access token available for these credentials?
|
||||
def access_token?
|
||||
!!@access_token
|
||||
end
|
||||
|
||||
# Is a refresh token available for these credentials?
|
||||
def refresh_token?
|
||||
!!@refresh_token
|
||||
end
|
||||
|
||||
# Updates the credentials with newer tokens
|
||||
def update_tokens(access_token, refresh_token = nil, expires_in = nil)
|
||||
@access_token = access_token
|
||||
@refresh_token = refresh_token
|
||||
@expires_in = expires_in
|
||||
end
|
||||
|
||||
# Based on available credentials returns the best strategy
|
||||
#
|
||||
# @todo Add a means to dictate which should or shouldn't be used
|
||||
#
|
||||
def best_grant_strategy
|
||||
if refresh_token?
|
||||
RefreshTokenStrategy.new(self)
|
||||
elsif user_details?
|
||||
UserCredentialsStrategy.new(self)
|
||||
else
|
||||
ClientCredentialsStrategy.new(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# This strategy class is the basis for OAuth2 grant types
|
||||
#
|
||||
# @abstract Need to implement {#authorization_body_data} to return a
|
||||
# Hash matching the expected parameter form for the OAuth request
|
||||
#
|
||||
# @todo Strategies should be able to validate if credentials are suitable
|
||||
# so just client credentials cannot be used with user strategies
|
||||
#
|
||||
class GrantTypeStrategy
|
||||
def initialize(credentials)
|
||||
@credentials = credentials
|
||||
end
|
||||
|
||||
def authorization_body_data
|
||||
raise "Not implemented"
|
||||
end
|
||||
end
|
||||
|
||||
# This implements client based authentication/authorization
|
||||
# based on the existing trust relationship using the `none`
|
||||
# grant type.
|
||||
#
|
||||
class ClientCredentialsStrategy < GrantTypeStrategy
|
||||
def authorization_body_data
|
||||
{
|
||||
"grant_type" => "none",
|
||||
"client_id" => @credentials.client_id
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# This passes user details through so the returned token
|
||||
# carries the privileges of the user not account limited
|
||||
# by the client
|
||||
#
|
||||
class UserCredentialsStrategy < GrantTypeStrategy
|
||||
def authorization_body_data
|
||||
{
|
||||
"grant_type" => "password",
|
||||
"client_id" => @credentials.client_id,
|
||||
"username" => @credentials.username,
|
||||
"password" => @credentials.password
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# This strategy attempts to use a refresh_token gained during an earlier
|
||||
# request to reuse the credentials given originally
|
||||
#
|
||||
class RefreshTokenStrategy < GrantTypeStrategy
|
||||
def authorization_body_data
|
||||
{
|
||||
"grant_type" => "refresh_token",
|
||||
"client_id" => @credentials.client_id,
|
||||
"refresh_token" => @credentials.refresh_token
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# This updates the current credentials if passed a valid response
|
||||
#
|
||||
# @param [CredentialSet] credentials Credentials to update
|
||||
# @param [Excon::Response] response Response object to parse value from
|
||||
#
|
||||
def update_credentials_from_response(credentials, response)
|
||||
response_data = Fog::JSON.decode(response.body)
|
||||
credentials.update_tokens(response_data["access_token"], response_data["refresh_token"], response_data["expires_in"])
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Accepts the collaboration and gaining permitted access
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#user_collaboration_accept_user_collaboration
|
||||
#
|
||||
def accept_user_collaboration(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/user/collaborations/#{identifier}/accept", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Enable console access via VNC to the server for 15 minutes.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_activate_console_server
|
||||
#
|
||||
def activate_console_server(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/servers/#{identifier}/activate_console", [202])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Adds a number of listeners to the load balancer to enable balancing across nodes for those settings.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
# @param [Hash] options
|
||||
# @option options [Array] :listeners Array of Listener parameters. Timeout is optional and specified in milliseconds.
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_listeners_load_balancer
|
||||
#
|
||||
def add_listeners_load_balancer(identifier, options)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/load_balancers/#{identifier}/add_listeners", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Add a number of nodes to the load balancer
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
# @param [Hash] options
|
||||
# @option options [Array] :nodes Array of Node parameters
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_add_nodes_load_balancer
|
||||
#
|
||||
def add_nodes_load_balancer(identifier, options)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/load_balancers/#{identifier}/add_nodes", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Add a number of servers to the server group.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
# @param [Hash] options
|
||||
# @option options [Array<Hash>] :servers Array of Hashes containing
|
||||
# +{"server" => server_id}+ for each server to add
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_group_add_servers_server_group
|
||||
#
|
||||
# @example
|
||||
# options = {
|
||||
# :servers => [
|
||||
# {"server" => "srv-abcde"},
|
||||
# {"server" => "srv-fghij"}
|
||||
# ]
|
||||
# }
|
||||
# Compute[:brightbox].add_servers_server_group "grp-12345", options
|
||||
#
|
||||
def add_servers_server_group(identifier, options)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/server_groups/#{identifier}/add_servers", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Applies firewall policy to given server group
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
# @param [Hash] options
|
||||
# @option options [String] :server_group Server Group to apply to
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_policy_apply_to_firewall_policy
|
||||
#
|
||||
def apply_to_firewall_policy(identifier, options)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("post", "/1.0/firewall_policies/#{identifier}/apply_to", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new API client for the account.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :name
|
||||
# @option options [String] :description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#api_client_create_api_client
|
||||
#
|
||||
def create_api_client(options)
|
||||
wrapped_request("post", "/1.0/api_clients", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new application for the user.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :name
|
||||
# @option options [String] :description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#application_create_application
|
||||
#
|
||||
def create_application(options)
|
||||
wrapped_request("post", "/1.0/applications", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Requests a new cloud IP address for the account.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :reverse_dns Reverse DNS hostname
|
||||
# @option options [String] :name Name for Cloud IP
|
||||
# @option options [Array] :port_translators Port on which external clients connect and port on which your service is listening.
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#cloud_ip_create_cloud_ip
|
||||
#
|
||||
def create_cloud_ip(options = {})
|
||||
wrapped_request("post", "/1.0/cloud_ips", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Creates a new collaboration for a user for the account
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :email Email address of user to invite
|
||||
# @option options [String] :role Role to grant to the user. Currently only `admin`
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#collaboration_create_collaboration
|
||||
#
|
||||
def create_collaboration(options)
|
||||
wrapped_request("post", "/1.0/collaborations", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# @param [Hash] options
|
||||
# @option options [String] :name
|
||||
# @option options [String] :description
|
||||
# @option options [String] :version Database version to request
|
||||
# @option options [Array] :allow_access ...
|
||||
# @option options [String] :snapshot
|
||||
# @option options [String] :zone
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_server_create_database_server
|
||||
#
|
||||
def create_database_server(options)
|
||||
wrapped_request("post", "/1.0/database_servers", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new firewall policy for the account.
|
||||
#
|
||||
# Optionally applying to a server group at creation time.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :server_group
|
||||
# @option options [String] :name Editable label
|
||||
# @option options [String] :description Longer editable description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_policy_create_firewall_policy
|
||||
#
|
||||
def create_firewall_policy(options)
|
||||
wrapped_request("post", "/1.0/firewall_policies", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new firewall rule for a firewall policy.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :firewall_policy
|
||||
# @option options [String] :protocol
|
||||
# @option options [String] :source Required unless destination is set.
|
||||
# @option options [String] :source_port
|
||||
# @option options [String] :destination Required unless source is set
|
||||
# @option options [String] :destination_port
|
||||
# @option options [String] :icmp_type_name
|
||||
# @option options [String] :description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_rule_create_firewall_rule
|
||||
#
|
||||
def create_firewall_rule(options)
|
||||
wrapped_request("post", "/1.0/firewall_rules", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new image for the account by registering it against an image stored within the Brightbox cloud image library.
|
||||
#
|
||||
# The disk image must be in place before you can attempt to create a reference in the API.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :source Filename of the image file uploaded to /incoming via FTP
|
||||
# @option options [String] :arch OS architecture this image is built for
|
||||
# @option options [String] :name Name for this image. If no name is specified, a name will be autogenerated based on the source filename & current time. Can be modified later.
|
||||
# @option options [String] :username Username for the image
|
||||
# @option options [Boolean] :public
|
||||
# @option options [Boolean] :compatibility_mode
|
||||
# @option options [String] :description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#image_create_image
|
||||
#
|
||||
def create_image(options)
|
||||
wrapped_request("post", "/1.0/images", [201], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new load balancer for the account.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :name Editable label
|
||||
# @option options [Array] :nodes Array of Node parameters
|
||||
# @option options [String] :policy Method of Load balancing to use
|
||||
# @option options [Array] :listeners What port to listen on, port to pass through to and protocol (tcp, http or http+ws) of listener. Timeout is optional and specified in milliseconds (default is 50000).
|
||||
# @option options [String] :healthcheck Healthcheck options - only "port" and "type" required
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_create_load_balancer
|
||||
#
|
||||
def create_load_balancer(options)
|
||||
wrapped_request("post", "/1.0/load_balancers", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new server for the account based on the required disk image.
|
||||
#
|
||||
# Optionally can setup the type of server, zone to locate it, groups to join and custom metadata.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :image
|
||||
# @option options [String] :name Editable label
|
||||
# @option options [String] :server_type
|
||||
# @option options [String] :zone Zone in which to create new Server
|
||||
# @option options [String] :user_data
|
||||
# @option options [Array] :server_groups Array of server groups to add server to
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_create_server
|
||||
#
|
||||
def create_server(options)
|
||||
wrapped_request("post", "/1.0/servers", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Create a new server group for the account.
|
||||
#
|
||||
# @param [Hash] options
|
||||
# @option options [String] :name Editable user label
|
||||
# @option options [String] :description Editable user description
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
# @return [NilClass] if no options were passed
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_group_create_server_group
|
||||
#
|
||||
def create_server_group(options)
|
||||
wrapped_request("post", "/1.0/server_groups", [202], options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the API client.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#api_client_delete_api_client
|
||||
#
|
||||
def delete_api_client(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/api_clients/#{identifier}", [200])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_api_client+ instead
|
||||
#
|
||||
def destroy_api_client(identifier)
|
||||
delete_api_client(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the application.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#application_delete_application
|
||||
#
|
||||
def delete_application(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/applications/#{identifier}", [200])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_application+ instead
|
||||
#
|
||||
def destroy_application(identifier)
|
||||
delete_application(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Release the cloud IP address from the account's ownership.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#cloud_ip_delete_cloud_ip
|
||||
#
|
||||
def delete_cloud_ip(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/cloud_ips/#{identifier}", [200])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_cloud_ip+ instead
|
||||
#
|
||||
def destroy_cloud_ip(identifier)
|
||||
delete_cloud_ip(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Cancels or completes the collaboration
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#collaboration_delete_collaboration
|
||||
#
|
||||
def delete_collaboration(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/collaborations/#{identifier}", [200])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_collaboration+ instead
|
||||
#
|
||||
def destroy_collaboration(identifier)
|
||||
delete_collaboration(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_server_delete_database_server
|
||||
#
|
||||
def delete_database_server(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/database_servers/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_database_server+ instead
|
||||
#
|
||||
def destroy_database_server(identifier)
|
||||
delete_database_server(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_snapshot_delete_database_snapshot
|
||||
#
|
||||
def delete_database_snapshot(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/database_snapshots/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_database_snapshot+ instead
|
||||
#
|
||||
def destroy_database_snapshot(identifier)
|
||||
delete_database_snapshot(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the firewall policy if not in use.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_policy_delete_firewall_policy
|
||||
#
|
||||
def delete_firewall_policy(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/firewall_policies/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_firewall_policy+ instead
|
||||
#
|
||||
def destroy_firewall_policy(identifier)
|
||||
delete_firewall_policy(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the firewall rule.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_rule_delete_firewall_rule
|
||||
#
|
||||
def delete_firewall_rule(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/firewall_rules/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_firewall_rule+ instead
|
||||
#
|
||||
def destroy_firewall_rule(identifier)
|
||||
delete_firewall_rule(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the image.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#image_delete_image
|
||||
#
|
||||
def delete_image(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/images/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_image+ instead
|
||||
#
|
||||
def destroy_image(identifier)
|
||||
delete_image(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the LoadBalancer
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_delete_load_balancer
|
||||
#
|
||||
def delete_load_balancer(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/load_balancers/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_load_balancer+ instead
|
||||
#
|
||||
def destroy_load_balancer(identifier)
|
||||
delete_load_balancer(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the server and free up the resources.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_delete_server
|
||||
#
|
||||
def delete_server(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/servers/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_server+ instead
|
||||
#
|
||||
def destroy_server(identifier)
|
||||
delete_server(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Destroy the server group if not in use.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_group_delete_server_group
|
||||
#
|
||||
def delete_server_group(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/server_groups/#{identifier}", [202])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_server_group+ instead
|
||||
#
|
||||
def destroy_server_group(identifier)
|
||||
delete_server_group(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Ends an existing 'accepted' collaboration
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#user_collaboration_delete_user_collaboration
|
||||
#
|
||||
def delete_user_collaboration(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("delete", "/1.0/user/collaborations/#{identifier}", [200])
|
||||
end
|
||||
|
||||
# Old format of the delete request.
|
||||
#
|
||||
# @deprecated Use +#delete_user_collaboration+ instead
|
||||
#
|
||||
def destroy_user_collaboration(identifier)
|
||||
delete_user_collaboration(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the account.
|
||||
#
|
||||
# @overload get_account(identifier)
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @overload get_account()
|
||||
# @deprecated Use {Fog::Compute::Brightbox::Real#get_scoped_account} instead
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#account_get_account
|
||||
#
|
||||
def get_account(identifier = nil)
|
||||
if identifier.nil? || identifier.empty?
|
||||
Fog::Logger.deprecation("get_account() without a parameter is deprecated, use get_scoped_account instead [light_black](#{caller.first})[/]")
|
||||
get_scoped_account
|
||||
else
|
||||
wrapped_request("get", "/1.0/accounts/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the API client.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#api_client_get_api_client
|
||||
#
|
||||
def get_api_client(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/api_clients/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the application.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#application_get_application
|
||||
#
|
||||
def get_application(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/applications/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Requests details about authenticated user from the API
|
||||
#
|
||||
# @return [Hash] The JSON response parsed to a Hash
|
||||
#
|
||||
def get_authenticated_user
|
||||
wrapped_request("get", "/1.0/user", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the cloud IP address.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#cloud_ip_get_cloud_ip
|
||||
#
|
||||
def get_cloud_ip(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/cloud_ips/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Shows details of one collaboration
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#collaboration_get_collaboration
|
||||
#
|
||||
def get_collaboration(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/collaborations/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_server_get_database_server
|
||||
#
|
||||
def get_database_server(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/database_servers/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_snapshot_get_database_snapshot
|
||||
#
|
||||
def get_database_snapshot(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/database_snapshots/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get details of the database server type.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#database_type_get_database_type
|
||||
#
|
||||
def get_database_type(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/database_types/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get details of the firewall policy
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_policy_get_firewall_policy
|
||||
#
|
||||
def get_firewall_policy(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/firewall_policies/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the firewall rule.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#firewall_rule_get_firewall_rule
|
||||
#
|
||||
def get_firewall_rule(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/firewall_rules/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the image.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#image_get_image
|
||||
#
|
||||
def get_image(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/images/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the interface.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#interface_get_interface
|
||||
#
|
||||
def get_interface(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/interfaces/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the load balancer.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#load_balancer_get_load_balancer
|
||||
#
|
||||
def get_load_balancer(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/load_balancers/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Requests details about currently scoped account
|
||||
#
|
||||
# @return [Hash] The JSON response parsed to a Hash
|
||||
def get_scoped_account
|
||||
wrapped_request("get", "/1.0/account", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the server.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_get_server
|
||||
#
|
||||
def get_server(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/servers/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get details of the server group.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_group_get_server_group
|
||||
#
|
||||
def get_server_group(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/server_groups/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Brightbox
|
||||
class Real
|
||||
# Get full details of the server type.
|
||||
#
|
||||
# @param [String] identifier Unique reference to identify the resource
|
||||
#
|
||||
# @return [Hash] if successful Hash version of JSON object
|
||||
#
|
||||
# @see https://api.gb1.brightbox.com/1.0/#server_type_get_server_type
|
||||
#
|
||||
def get_server_type(identifier)
|
||||
return nil if identifier.nil? || identifier == ""
|
||||
wrapped_request("get", "/1.0/server_types/#{identifier}", [200])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue