2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/model'
|
|
|
|
|
2009-11-19 11:19:46 -05:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 16:50:23 -04:00
|
|
|
class Compute
|
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
|
|
|
|
|
2009-11-19 11:19:46 -05:00
|
|
|
@server_id = new_server.id
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2009-11-21 16:56:39 -05:00
|
|
|
requires :id
|
|
|
|
|
2009-11-19 11:19:46 -05:00
|
|
|
connection.delete_image(@id)
|
|
|
|
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
|
2009-11-21 16:56:39 -05:00
|
|
|
requires :server_id
|
|
|
|
|
2010-01-10 15:37:03 -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
|