mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[serverlove|compute] Updates reference to service
This commit is contained in:
parent
bc26c4e433
commit
80f27b434c
4 changed files with 25 additions and 25 deletions
|
@ -8,44 +8,44 @@ module Fog
|
|||
|
||||
identity :id, :aliases => 'drive'
|
||||
|
||||
attribute :name
|
||||
attribute :name
|
||||
attribute :user
|
||||
attribute :size
|
||||
attribute :claimed
|
||||
attribute :status
|
||||
attribute :imaging
|
||||
attribute :encryption_cipher, :aliases => 'encryption:cipher'
|
||||
|
||||
|
||||
def save
|
||||
attributes = {}
|
||||
|
||||
|
||||
if(identity)
|
||||
attributes = connection.update_image(identity, allowed_attributes).body
|
||||
attributes = service.update_image(identity, allowed_attributes).body
|
||||
else
|
||||
requires :name
|
||||
requires :size
|
||||
attributes = connection.create_image(allowed_attributes).body
|
||||
attributes = service.create_image(allowed_attributes).body
|
||||
end
|
||||
|
||||
|
||||
merge_attributes(attributes)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def load_standard_image(standard_image_uuid)
|
||||
requires :identity
|
||||
connection.load_standard_image(identity, standard_image_uuid)
|
||||
service.load_standard_image(identity, standard_image_uuid)
|
||||
end
|
||||
|
||||
|
||||
def ready?
|
||||
status.upcase == 'ACTIVE'
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.destroy_image(identity)
|
||||
service.destroy_image(identity)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def allowed_attributes
|
||||
allowed = [:name, :size]
|
||||
attributes.select {|k,v| allowed.include? k}
|
||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
|||
model Fog::Compute::Serverlove::Image
|
||||
|
||||
def all
|
||||
data = connection.get_images.body
|
||||
data = service.get_images.body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(image_id)
|
||||
data = connection.get_image(image_id).body
|
||||
data = service.get_image(image_id).body
|
||||
new(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
class Server < Fog::Model
|
||||
|
||||
identity :id, :aliases => 'server'
|
||||
|
||||
|
||||
attribute :name
|
||||
attribute :cpu
|
||||
attribute :mem
|
||||
|
@ -21,33 +21,33 @@ module Fog
|
|||
attribute :persistent
|
||||
attribute :vnc
|
||||
attribute :vnc_password, :aliases => 'vnc:password'
|
||||
attribute :status
|
||||
attribute :status
|
||||
attribute :user
|
||||
attribute :started
|
||||
attribute :nic_0_model, :aliases => 'nic:0:model'
|
||||
attribute :nic_0_dhcp, :aliases => 'nic:0:dhcp'
|
||||
|
||||
|
||||
def save
|
||||
attributes = {}
|
||||
|
||||
|
||||
if(identity)
|
||||
attributes = connection.update_server(identity, allowed_attributes).body
|
||||
attributes = service.update_server(identity, allowed_attributes).body
|
||||
else
|
||||
requires :name
|
||||
requires :cpu
|
||||
attributes = connection.create_server(self.defaults.merge(allowed_attributes)).body
|
||||
attributes = service.create_server(self.defaults.merge(allowed_attributes)).body
|
||||
end
|
||||
|
||||
|
||||
merge_attributes(attributes)
|
||||
self
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.destroy_server(identity)
|
||||
service.destroy_server(identity)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
def allowed_attributes
|
||||
allowed = [
|
||||
:name, :cpu, :smp, :mem, :persistent,
|
||||
|
@ -57,7 +57,7 @@ module Fog
|
|||
]
|
||||
attributes.select {|k,v| allowed.include? k}
|
||||
end
|
||||
|
||||
|
||||
def self.defaults
|
||||
# TODO: Document default settings.
|
||||
# Note that VNC password standards are strict (need explaining)
|
||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
|||
model Fog::Compute::Serverlove::Server
|
||||
|
||||
def all
|
||||
data = connection.get_servers.body
|
||||
data = service.get_servers.body
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(server_id)
|
||||
data = connection.get_server(server_id).body
|
||||
data = service.get_server(server_id).body
|
||||
new(data)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue