mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
6500fa46bf
* Request tests for accounts, api_clients, cloud_ips, images, interfaces, server types, user and zones * Added 'ready?' methods to CloudIp and Image models * Reworked brightbox helper to include Format patterns for all of the * Added "hack" to allow select objects to be one class OR NilClass for fields that may be a JSON string or null if unset * Some tests are not enabled (commented out) because they need manual steps (such as uploading Image to your account before registration)
56 lines
1.2 KiB
Ruby
56 lines
1.2 KiB
Ruby
require 'fog/core/model'
|
|
|
|
module Fog
|
|
module Brightbox
|
|
class Compute
|
|
|
|
class Image < Fog::Model
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
|
attribute :name
|
|
attribute :status
|
|
attribute :source
|
|
attribute :source_type
|
|
|
|
attribute :ancestor_id, :aliases => "ancestor", :squash => "id"
|
|
attribute :owner_id, :aliases => "owner", :squash => "id"
|
|
attribute :arch
|
|
|
|
attribute :resource_type
|
|
attribute :description
|
|
attribute :public
|
|
attribute :official
|
|
attribute :virtual_size
|
|
attribute :disk_size
|
|
attribute :created_at
|
|
|
|
def ready?
|
|
status == "available"
|
|
end
|
|
|
|
def save
|
|
requires :source, :arch
|
|
options = {
|
|
:source => source,
|
|
:arch => arch,
|
|
:name => name,
|
|
:description => description
|
|
}.delete_if {|k,v| v.nil? || v == "" }
|
|
data = connection.create_image(options)
|
|
merge_attributes(data)
|
|
true
|
|
end
|
|
|
|
def destroy
|
|
requires :identity
|
|
connection.destroy_image(identity)
|
|
true
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|