2010-10-04 14:02:08 -07:00
|
|
|
require 'fog/core/model'
|
2010-03-19 18:29:42 -07:00
|
|
|
|
2009-11-19 08:19:46 -08:00
|
|
|
module Fog
|
2011-06-16 16:28:54 -07:00
|
|
|
module Compute
|
|
|
|
class Rackspace
|
2009-11-19 08:19:46 -08:00
|
|
|
|
|
|
|
class Image < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
2010-09-07 11:30:02 -07:00
|
|
|
attribute :created_at, :aliases => 'created'
|
|
|
|
attribute :updated_at, :aliases => 'updated'
|
2010-05-21 14:43:29 -07:00
|
|
|
attribute :progress
|
2009-11-19 08:19:46 -08:00
|
|
|
attribute :status
|
2010-09-07 11:30:02 -07:00
|
|
|
attribute :server_id, :aliases => 'serverId'
|
2009-11-19 08:19:46 -08:00
|
|
|
|
|
|
|
def server=(new_server)
|
2009-11-21 13:56:39 -08:00
|
|
|
requires :id
|
|
|
|
|
2010-11-19 13:45:45 -08:00
|
|
|
self.server_id = new_server.id
|
2009-11-19 08:19:46 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2009-11-21 13:56:39 -08:00
|
|
|
requires :id
|
|
|
|
|
2010-11-19 13:45:45 -08:00
|
|
|
connection.delete_image(id)
|
2009-11-19 08:19:46 -08:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-05-21 14:43:29 -07:00
|
|
|
def ready?
|
|
|
|
status == 'ACTIVE'
|
|
|
|
end
|
|
|
|
|
2009-11-19 08:19:46 -08:00
|
|
|
def save
|
2010-10-04 16:08:34 -07:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
2009-11-21 13:56:39 -08:00
|
|
|
requires :server_id
|
|
|
|
|
2010-11-19 13:45:45 -08:00
|
|
|
data = connection.create_image(server_id, 'name' => name)
|
2009-11-19 08:19:46 -08:00
|
|
|
merge_attributes(data.body['image'])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|