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