mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge changes. Begin server definitions.
This commit is contained in:
parent
8fcee51407
commit
873d969d9c
6 changed files with 85 additions and 35 deletions
|
@ -15,10 +15,14 @@ module Fog
|
|||
request :create_image
|
||||
request :update_image
|
||||
|
||||
model_path 'fog/serverlove/models/compute'
|
||||
model :image
|
||||
collection :images
|
||||
|
||||
request :get_servers
|
||||
|
||||
model :server
|
||||
collection :servers
|
||||
|
||||
class Mock
|
||||
|
||||
def initialize(options)
|
||||
|
@ -64,6 +68,7 @@ module Fog
|
|||
end.join("\n")
|
||||
end
|
||||
|
||||
# TODO
|
||||
def raise_if_error!(response)
|
||||
case response.status
|
||||
when 400 then
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
|
||||
class Drive < Fog::Model
|
||||
|
||||
identity :drive
|
||||
|
||||
attribute :name
|
||||
attribute :user
|
||||
attribute :size
|
||||
attribute :claimed
|
||||
attribute :status
|
||||
attribute :encryption_cipher, :aliases => 'encryption:cipher'
|
||||
|
||||
def save
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.destroy_drive(identity)
|
||||
self
|
||||
end
|
||||
|
||||
def self.create(args)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
28
lib/fog/serverlove/models/compute/server.rb
Normal file
28
lib/fog/serverlove/models/compute/server.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
|
||||
class Server < Fog::Model
|
||||
|
||||
identity :server
|
||||
|
||||
attribute :server
|
||||
attribute :status
|
||||
attribute :user
|
||||
attribute :started
|
||||
|
||||
def save
|
||||
# TODO
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.destroy_server(identity)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
lib/fog/serverlove/models/compute/servers.rb
Normal file
25
lib/fog/serverlove/models/compute/servers.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/serverlove/models/compute/drive'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
|
||||
class Servers < Fog::Collection
|
||||
|
||||
model Fog::Compute::Serverlove::Server
|
||||
|
||||
def all
|
||||
data = connection.get_servers.body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(server_id)
|
||||
load(connection.get_drive(server_id).body)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
13
lib/fog/serverlove/requests/compute/get_server.rb
Normal file
13
lib/fog/serverlove/requests/compute/get_server.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
class Real
|
||||
|
||||
def get_server(server_id)
|
||||
request(:method => "get", :path => "/servers/#{server_id}/info", :expects => 200)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
lib/fog/serverlove/requests/compute/get_servers.rb
Normal file
13
lib/fog/serverlove/requests/compute/get_servers.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class Serverlove
|
||||
class Real
|
||||
|
||||
def get_servers
|
||||
request(:method => "get", :path => "/servers/info", :expects => 200)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue