mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[slicehost] rename slices to compute for consistency
This commit is contained in:
parent
eb6bca6f34
commit
136442206f
51 changed files with 979 additions and 905 deletions
|
@ -1,91 +1,18 @@
|
|||
module Fog
|
||||
class Slicehost < Fog::Service
|
||||
module Slicehost
|
||||
|
||||
requires :slicehost_password
|
||||
extend Fog::Provider
|
||||
|
||||
model_path 'fog/slicehost/models'
|
||||
model :flavor
|
||||
collection :flavors
|
||||
model :image
|
||||
collection :images
|
||||
model :server
|
||||
collection :servers
|
||||
|
||||
request_path 'fog/slicehost/requests'
|
||||
request :create_slice
|
||||
request :delete_slice
|
||||
request :get_backups
|
||||
request :get_flavor
|
||||
request :get_flavors
|
||||
request :get_image
|
||||
request :get_images
|
||||
request :get_slice
|
||||
request :get_slices
|
||||
request :reboot_slice
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {}
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=data.keys)
|
||||
for key in [*keys]
|
||||
data.delete(key)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@slicehost_password = options[:slicehost_password]
|
||||
@data = self.class.data[@slicehost_password]
|
||||
end
|
||||
service_path 'fog/slicehost'
|
||||
service :compute
|
||||
|
||||
def self.new(attributes = {})
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Fog::Slicehost#new is deprecated, use Fog::Bluebox::Compute#new instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
Fog::Slicehost::Compute.new(attributes)
|
||||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
@slicehost_password = options[:slicehost_password]
|
||||
@host = options[:host] || "api.slicehost.com"
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
params[:headers] ||= {}
|
||||
params[:headers].merge!({
|
||||
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}"
|
||||
})
|
||||
case params[:method]
|
||||
when 'DELETE', 'GET', 'HEAD'
|
||||
params[:headers]['Accept'] = 'application/xml'
|
||||
when 'POST', 'PUT'
|
||||
params[:headers]['Content-Type'] = 'application/xml'
|
||||
end
|
||||
|
||||
begin
|
||||
response = @connection.request(params.merge!({:host => @host}))
|
||||
rescue Excon::Errors::Error => error
|
||||
raise case error
|
||||
when Excon::Errors::NotFound
|
||||
Fog::Slicehost::NotFound.slurp(error)
|
||||
else
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,21 +9,27 @@ module Slicehost
|
|||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
hash[key] = case key
|
||||
when :compute
|
||||
Fog::Slicehost::Compute.new
|
||||
when :slices
|
||||
Fog::Slicehost.new
|
||||
location = caller.first
|
||||
warning = "[yellow][WARN] Slicehost[:blocks] is deprecated, use Bluebox[:compute] instead[/]"
|
||||
warning << " [light_black](" << location << ")[/] "
|
||||
Formatador.display_line(warning)
|
||||
Fog::Slicehost::Compute.new
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:slices]
|
||||
[:compute]
|
||||
end
|
||||
|
||||
for collection in Fog::Slicehost.collections
|
||||
for collection in Fog::Slicehost::Compute.collections
|
||||
module_eval <<-EOS, __FILE__, __LINE__
|
||||
def #{collection}
|
||||
self[:slices].#{collection}
|
||||
self[:compute].#{collection}
|
||||
end
|
||||
EOS
|
||||
end
|
||||
|
|
93
lib/fog/slicehost/compute.rb
Normal file
93
lib/fog/slicehost/compute.rb
Normal file
|
@ -0,0 +1,93 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute < Fog::Service
|
||||
|
||||
requires :slicehost_password
|
||||
|
||||
model_path 'fog/slicehost/models/compute'
|
||||
model :flavor
|
||||
collection :flavors
|
||||
model :image
|
||||
collection :images
|
||||
model :server
|
||||
collection :servers
|
||||
|
||||
request_path 'fog/slicehost/requests/compute'
|
||||
request :create_slice
|
||||
request :delete_slice
|
||||
request :get_backups
|
||||
request :get_flavor
|
||||
request :get_flavors
|
||||
request :get_image
|
||||
request :get_images
|
||||
request :get_slice
|
||||
request :get_slices
|
||||
request :reboot_slice
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {}
|
||||
end
|
||||
end
|
||||
|
||||
def self.reset_data(keys=data.keys)
|
||||
for key in [*keys]
|
||||
data.delete(key)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@slicehost_password = options[:slicehost_password]
|
||||
@data = self.class.data[@slicehost_password]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
include Collections
|
||||
|
||||
def initialize(options={})
|
||||
@slicehost_password = options[:slicehost_password]
|
||||
@host = options[:host] || "api.slicehost.com"
|
||||
@port = options[:port] || 443
|
||||
@scheme = options[:scheme] || 'https'
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
def reload
|
||||
@connection.reset
|
||||
end
|
||||
|
||||
def request(params)
|
||||
params[:headers] ||= {}
|
||||
params[:headers].merge!({
|
||||
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}"
|
||||
})
|
||||
case params[:method]
|
||||
when 'DELETE', 'GET', 'HEAD'
|
||||
params[:headers]['Accept'] = 'application/xml'
|
||||
when 'POST', 'PUT'
|
||||
params[:headers]['Content-Type'] = 'application/xml'
|
||||
end
|
||||
|
||||
begin
|
||||
response = @connection.request(params.merge!({:host => @host}))
|
||||
rescue Excon::Errors::Error => error
|
||||
raise case error
|
||||
when Excon::Errors::NotFound
|
||||
Fog::Slicehost::NotFound.slurp(error)
|
||||
else
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
45
lib/fog/slicehost/models/compute/flavor.rb
Normal file
45
lib/fog/slicehost/models/compute/flavor.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Flavor < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
attribute :price
|
||||
attribute :ram
|
||||
|
||||
def bits
|
||||
# 64
|
||||
raise StandardError.new("Figure me out!?!")
|
||||
end
|
||||
|
||||
def cores
|
||||
# # 2 quad-cores >= 2Ghz = 8 cores
|
||||
# 8 * case ram
|
||||
# when 256
|
||||
# 1/64.0
|
||||
# when 512
|
||||
# 1/32.0
|
||||
# when 1024
|
||||
# 1/16.0
|
||||
# when 2048
|
||||
# 1/8.0
|
||||
# when 4096
|
||||
# 1/4.0
|
||||
# when 8192
|
||||
# 1/2.0
|
||||
# when 15872
|
||||
# 1
|
||||
# end
|
||||
raise StandardError.new("Figure me out!?!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
27
lib/fog/slicehost/models/compute/flavors.rb
Normal file
27
lib/fog/slicehost/models/compute/flavors.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/flavor'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Flavors < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Flavor
|
||||
|
||||
def all
|
||||
data = connection.get_flavors.body['flavors']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(flavor_id)
|
||||
connection.get_flavor(flavor_id)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
17
lib/fog/slicehost/models/compute/image.rb
Normal file
17
lib/fog/slicehost/models/compute/image.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Image < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
27
lib/fog/slicehost/models/compute/images.rb
Normal file
27
lib/fog/slicehost/models/compute/images.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/image'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Images < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Image
|
||||
|
||||
def all
|
||||
data = connection.get_images.body['images']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(image_id)
|
||||
connection.get_image(image_id)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
64
lib/fog/slicehost/models/compute/server.rb
Normal file
64
lib/fog/slicehost/models/compute/server.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Server < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :addresses
|
||||
attribute :backup_id, :aliases => 'backup-id'
|
||||
attribute :bandwidth_in, :aliases => 'bw-in'
|
||||
attribute :bandwidth_out, :aliases => 'bw-out'
|
||||
attribute :flavor_id, :aliases => 'flavor-id'
|
||||
attribute :image_id, :aliases => 'image-id'
|
||||
attribute :name
|
||||
attribute :password, :aliases => 'root-password'
|
||||
attribute :progress
|
||||
attribute :status
|
||||
|
||||
def initialize(attributes={})
|
||||
@flavor_id ||= 1
|
||||
super
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_slice(@id)
|
||||
true
|
||||
end
|
||||
|
||||
def flavor
|
||||
requires :flavor_id
|
||||
connection.flavors.get(@flavor_id)
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
connection.images.get(@image_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@status == 'active'
|
||||
end
|
||||
|
||||
def reboot(type = 'SOFT')
|
||||
requires :id
|
||||
connection.reboot_server(@id, type)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :flavor_id, :image_id, :name
|
||||
data = connection.create_slice(@flavor_id, @image_id, @name)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/slicehost/models/compute/servers.rb
Normal file
31
lib/fog/slicehost/models/compute/servers.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/server'
|
||||
|
||||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
|
||||
class Servers < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Server
|
||||
|
||||
def all
|
||||
data = connection.get_slices.body['slices']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(server_id)
|
||||
if server_id && server = connection.get_slice(server_id).body
|
||||
new(server)
|
||||
elsif !server_id
|
||||
nil
|
||||
end
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Flavor < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
attribute :price
|
||||
attribute :ram
|
||||
|
||||
def bits
|
||||
# 64
|
||||
raise StandardError.new("Figure me out!?!")
|
||||
end
|
||||
|
||||
def cores
|
||||
# # 2 quad-cores >= 2Ghz = 8 cores
|
||||
# 8 * case ram
|
||||
# when 256
|
||||
# 1/64.0
|
||||
# when 512
|
||||
# 1/32.0
|
||||
# when 1024
|
||||
# 1/16.0
|
||||
# when 2048
|
||||
# 1/8.0
|
||||
# when 4096
|
||||
# 1/4.0
|
||||
# when 8192
|
||||
# 1/2.0
|
||||
# when 15872
|
||||
# 1
|
||||
# end
|
||||
raise StandardError.new("Figure me out!?!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/flavor'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Flavors < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Flavor
|
||||
|
||||
def all
|
||||
data = connection.get_flavors.body['flavors']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(flavor_id)
|
||||
connection.get_flavor(flavor_id)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Image < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/image'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Images < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Image
|
||||
|
||||
def all
|
||||
data = connection.get_images.body['images']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(image_id)
|
||||
connection.get_image(image_id)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,62 +0,0 @@
|
|||
require 'fog/model'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Server < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :addresses
|
||||
attribute :backup_id, :aliases => 'backup-id'
|
||||
attribute :bandwidth_in, :aliases => 'bw-in'
|
||||
attribute :bandwidth_out, :aliases => 'bw-out'
|
||||
attribute :flavor_id, :aliases => 'flavor-id'
|
||||
attribute :image_id, :aliases => 'image-id'
|
||||
attribute :name
|
||||
attribute :password, :aliases => 'root-password'
|
||||
attribute :progress
|
||||
attribute :status
|
||||
|
||||
def initialize(attributes={})
|
||||
@flavor_id ||= 1
|
||||
super
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_slice(@id)
|
||||
true
|
||||
end
|
||||
|
||||
def flavor
|
||||
requires :flavor_id
|
||||
connection.flavors.get(@flavor_id)
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
connection.images.get(@image_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@status == 'active'
|
||||
end
|
||||
|
||||
def reboot(type = 'SOFT')
|
||||
requires :id
|
||||
connection.reboot_server(@id, type)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :flavor_id, :image_id, :name
|
||||
data = connection.create_slice(@flavor_id, @image_id, @name)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
require 'fog/collection'
|
||||
require 'fog/slicehost/models/server'
|
||||
|
||||
module Fog
|
||||
class Slicehost
|
||||
|
||||
class Servers < Fog::Collection
|
||||
|
||||
model Fog::Slicehost::Server
|
||||
|
||||
def all
|
||||
data = connection.get_slices.body['slices']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(server_id)
|
||||
if server_id && server = connection.get_slice(server_id).body
|
||||
new(server)
|
||||
elsif !server_id
|
||||
nil
|
||||
end
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
31
lib/fog/slicehost/parsers/compute/create_slice.rb
Normal file
31
lib/fog/slicehost/parsers/compute/create_slice.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class CreateSlice < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@response['addresses'] ||= []
|
||||
@response['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@response[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@response[name] = @value.to_f
|
||||
when 'name', 'root-password', 'status'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
32
lib/fog/slicehost/parsers/compute/get_backups.rb
Normal file
32
lib/fog/slicehost/parsers/compute/get_backups.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetBackups < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@backup = {}
|
||||
@response = { 'backups' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'backup'
|
||||
@response['backups'] << @backup
|
||||
@backup = {}
|
||||
when 'date'
|
||||
@backup[name] = Time.parse(@value)
|
||||
when 'id', 'slice-id'
|
||||
@backup[name] = @value.to_i
|
||||
when 'name'
|
||||
@backup[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/slicehost/parsers/compute/get_flavor.rb
Normal file
26
lib/fog/slicehost/parsers/compute/get_flavor.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetFlavor < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id', 'price', 'ram'
|
||||
@response[name] = @value.to_i
|
||||
when 'name'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/slicehost/parsers/compute/get_flavors.rb
Normal file
30
lib/fog/slicehost/parsers/compute/get_flavors.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetFlavors < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@flavor = {}
|
||||
@response = { 'flavors' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'flavor'
|
||||
@response['flavors'] << @flavor
|
||||
@flavor = {}
|
||||
when 'id', 'price', 'ram'
|
||||
@flavor[name] = @value.to_i
|
||||
when 'name'
|
||||
@flavor[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/slicehost/parsers/compute/get_image.rb
Normal file
26
lib/fog/slicehost/parsers/compute/get_image.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetImage < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id'
|
||||
@response[name] = @value.to_i
|
||||
when 'name'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/slicehost/parsers/compute/get_images.rb
Normal file
30
lib/fog/slicehost/parsers/compute/get_images.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetImages < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@image = {}
|
||||
@response = { 'images' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id'
|
||||
@image[name] = @value.to_i
|
||||
when 'image'
|
||||
@response['images'] << @image
|
||||
@image = {}
|
||||
when 'name'
|
||||
@image[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/slicehost/parsers/compute/get_slice.rb
Normal file
31
lib/fog/slicehost/parsers/compute/get_slice.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetSlice < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@response['addresses'] ||= []
|
||||
@response['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@response[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@response[name] = @value.to_f
|
||||
when 'name', 'status'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
35
lib/fog/slicehost/parsers/compute/get_slices.rb
Normal file
35
lib/fog/slicehost/parsers/compute/get_slices.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetSlices < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@slice = {}
|
||||
@response = { 'slices' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@slice['addresses'] ||= []
|
||||
@slice['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@slice[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@slice[name] = @value.to_f
|
||||
when 'name', 'status'
|
||||
@slice[name] = @value
|
||||
when 'slice'
|
||||
@response['slices'] << @slice
|
||||
@slice = {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class CreateSlice < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@response['addresses'] ||= []
|
||||
@response['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@response[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@response[name] = @value.to_f
|
||||
when 'name', 'root-password', 'status'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetBackups < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@backup = {}
|
||||
@response = { 'backups' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'backup'
|
||||
@response['backups'] << @backup
|
||||
@backup = {}
|
||||
when 'date'
|
||||
@backup[name] = Time.parse(@value)
|
||||
when 'id', 'slice-id'
|
||||
@backup[name] = @value.to_i
|
||||
when 'name'
|
||||
@backup[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetFlavor < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id', 'price', 'ram'
|
||||
@response[name] = @value.to_i
|
||||
when 'name'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetFlavors < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@flavor = {}
|
||||
@response = { 'flavors' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'flavor'
|
||||
@response['flavors'] << @flavor
|
||||
@flavor = {}
|
||||
when 'id', 'price', 'ram'
|
||||
@flavor[name] = @value.to_i
|
||||
when 'name'
|
||||
@flavor[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetImage < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id'
|
||||
@response[name] = @value.to_i
|
||||
when 'name'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetImages < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@image = {}
|
||||
@response = { 'images' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id'
|
||||
@image[name] = @value.to_i
|
||||
when 'image'
|
||||
@response['images'] << @image
|
||||
@image = {}
|
||||
when 'name'
|
||||
@image[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetSlice < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@response['addresses'] ||= []
|
||||
@response['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@response[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@response[name] = @value.to_f
|
||||
when 'name', 'status'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
|
||||
class GetSlices < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@slice = {}
|
||||
@response = { 'slices' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'address'
|
||||
@slice['addresses'] ||= []
|
||||
@slice['addresses'] << @value
|
||||
when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress'
|
||||
@slice[name] = @value.to_i
|
||||
when 'bw-in', 'bw-out'
|
||||
@slice[name] = @value.to_f
|
||||
when 'name', 'status'
|
||||
@slice[name] = @value
|
||||
when 'slice'
|
||||
@response['slices'] << @slice
|
||||
@slice = {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
49
lib/fog/slicehost/requests/compute/create_slice.rb
Normal file
49
lib/fog/slicehost/requests/compute/create_slice.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/create_slice'
|
||||
|
||||
# Get list of slices
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
# * name<~String> - Name of slice
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'root-password'<~String> - Root password of slice
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def create_slice(flavor_id, image_id, name)
|
||||
request(
|
||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><slice><flavor-id type="integer">#{flavor_id}</flavor-id><image-id type="integer">#{image_id}</image-id><name>#{name}</name></slice>},
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::CreateSlice.new,
|
||||
:path => 'slices.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_slice(flavor_id, image_id, name)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
45
lib/fog/slicehost/requests/compute/delete_slice.rb
Normal file
45
lib/fog/slicehost/requests/compute/delete_slice.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
# Get list of slices
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
# * name<~String> - Name of slice
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'root-password'<~String> - Root password of slice
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def delete_slice(slice_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "slices/#{slice_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def delete_slice(slice_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
37
lib/fog/slicehost/requests/compute/get_backups.rb
Normal file
37
lib/fog/slicehost/requests/compute/get_backups.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_backups'
|
||||
|
||||
# Get list of backups
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'date'<~Time> - Timestamp of backup creation
|
||||
# * 'id'<~Integer> - Id of the backup
|
||||
# * 'name'<~String> - Name of the backup
|
||||
# * 'slice-id'<~Integer> - Id of slice the backup was made from
|
||||
def get_backups
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetBackups.new,
|
||||
:path => 'backups.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_backups
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
lib/fog/slicehost/requests/compute/get_flavor.rb
Normal file
40
lib/fog/slicehost/requests/compute/get_flavor.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_flavor'
|
||||
|
||||
# Get details of a flavor
|
||||
#
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the flavor
|
||||
# * 'name'<~String> - Name of the flavor
|
||||
# * 'price'<~Integer> - Price in cents
|
||||
# * 'ram'<~Integer> - Amount of ram for the flavor
|
||||
def get_flavor(flavor_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetFlavor.new,
|
||||
:path => "flavors/#{flavor_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_flavor(flavor_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
37
lib/fog/slicehost/requests/compute/get_flavors.rb
Normal file
37
lib/fog/slicehost/requests/compute/get_flavors.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_flavors'
|
||||
|
||||
# Get list of flavors
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the flavor
|
||||
# * 'name'<~String> - Name of the flavor
|
||||
# * 'price'<~Integer> - Price in cents
|
||||
# * 'ram'<~Integer> - Amount of ram for the flavor
|
||||
def get_flavors
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetFlavors.new,
|
||||
:path => 'flavors.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_flavors
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
38
lib/fog/slicehost/requests/compute/get_image.rb
Normal file
38
lib/fog/slicehost/requests/compute/get_image.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_image'
|
||||
|
||||
# Get details of an image
|
||||
#
|
||||
# ==== Parameters
|
||||
# * image_id<~Integer> - Id of image to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the image
|
||||
# * 'name'<~String> - Name of the image
|
||||
def get_image(image_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetImage.new,
|
||||
:path => "images/#{image_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_image(image_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
35
lib/fog/slicehost/requests/compute/get_images.rb
Normal file
35
lib/fog/slicehost/requests/compute/get_images.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_images'
|
||||
|
||||
# Get list of images
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the image
|
||||
# * 'name'<~String> - Name of the image
|
||||
def get_images
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetImages.new,
|
||||
:path => 'images.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_images
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
46
lib/fog/slicehost/requests/compute/get_slice.rb
Normal file
46
lib/fog/slicehost/requests/compute/get_slice.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_slice'
|
||||
|
||||
# Get details of a slice
|
||||
#
|
||||
# ==== Parameters
|
||||
# * slice_id<~Integer> - Id of slice to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def get_slice(slice_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetSlice.new,
|
||||
:path => "/slices/#{slice_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slice(id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
43
lib/fog/slicehost/requests/compute/get_slices.rb
Normal file
43
lib/fog/slicehost/requests/compute/get_slices.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_slices'
|
||||
|
||||
# Get list of slices
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def get_slices
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetSlices.new,
|
||||
:path => 'slices.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slices
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
44
lib/fog/slicehost/requests/compute/reboot_slice.rb
Normal file
44
lib/fog/slicehost/requests/compute/reboot_slice.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
# Reboot slice
|
||||
# ==== Parameters
|
||||
# * slice_id<~Integer> - Id of server to reboot
|
||||
# * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def reboot_slice(slice_id, type = 'SOFT')
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetSlice.new,
|
||||
:path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slice(id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/create_slice'
|
||||
|
||||
# Get list of slices
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
# * name<~String> - Name of slice
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'root-password'<~String> - Root password of slice
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def create_slice(flavor_id, image_id, name)
|
||||
request(
|
||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><slice><flavor-id type="integer">#{flavor_id}</flavor-id><image-id type="integer">#{image_id}</image-id><name>#{name}</name></slice>},
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Slicehost::CreateSlice.new,
|
||||
:path => 'slices.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_slice(flavor_id, image_id, name)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
# Get list of slices
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
# * name<~String> - Name of slice
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'root-password'<~String> - Root password of slice
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def delete_slice(slice_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "slices/#{slice_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def delete_slice(slice_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_backups'
|
||||
|
||||
# Get list of backups
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'date'<~Time> - Timestamp of backup creation
|
||||
# * 'id'<~Integer> - Id of the backup
|
||||
# * 'name'<~String> - Name of the backup
|
||||
# * 'slice-id'<~Integer> - Id of slice the backup was made from
|
||||
def get_backups
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetBackups.new,
|
||||
:path => 'backups.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_backups
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_flavor'
|
||||
|
||||
# Get details of a flavor
|
||||
#
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the flavor
|
||||
# * 'name'<~String> - Name of the flavor
|
||||
# * 'price'<~Integer> - Price in cents
|
||||
# * 'ram'<~Integer> - Amount of ram for the flavor
|
||||
def get_flavor(flavor_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetFlavor.new,
|
||||
:path => "flavors/#{flavor_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_flavor(flavor_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_flavors'
|
||||
|
||||
# Get list of flavors
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the flavor
|
||||
# * 'name'<~String> - Name of the flavor
|
||||
# * 'price'<~Integer> - Price in cents
|
||||
# * 'ram'<~Integer> - Amount of ram for the flavor
|
||||
def get_flavors
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetFlavors.new,
|
||||
:path => 'flavors.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_flavors
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_image'
|
||||
|
||||
# Get details of an image
|
||||
#
|
||||
# ==== Parameters
|
||||
# * image_id<~Integer> - Id of image to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the image
|
||||
# * 'name'<~String> - Name of the image
|
||||
def get_image(image_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetImage.new,
|
||||
:path => "images/#{image_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_image(image_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_images'
|
||||
|
||||
# Get list of images
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'id'<~Integer> - Id of the image
|
||||
# * 'name'<~String> - Name of the image
|
||||
def get_images
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetImages.new,
|
||||
:path => 'images.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_images
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_slice'
|
||||
|
||||
# Get details of a slice
|
||||
#
|
||||
# ==== Parameters
|
||||
# * slice_id<~Integer> - Id of slice to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def get_slice(slice_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetSlice.new,
|
||||
:path => "/slices/#{slice_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slice(id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,41 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/get_slices'
|
||||
|
||||
# Get list of slices
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def get_slices
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::GetSlices.new,
|
||||
:path => 'slices.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slices
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
module Fog
|
||||
class Slicehost
|
||||
class Real
|
||||
|
||||
# Reboot slice
|
||||
# ==== Parameters
|
||||
# * slice_id<~Integer> - Id of server to reboot
|
||||
# * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def reboot_slice(slice_id, type = 'SOFT')
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::Slicehost::GetSlice.new,
|
||||
:path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_slice(id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue