2012-02-23 05:57:48 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Image
|
|
|
|
class OpenStack
|
|
|
|
|
|
|
|
class Image < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :size
|
|
|
|
attribute :disk_format
|
|
|
|
attribute :container_format
|
|
|
|
attribute :id
|
|
|
|
attribute :checksum
|
|
|
|
|
2012-02-27 07:12:52 -05:00
|
|
|
#detailed
|
|
|
|
attribute :min_disk
|
|
|
|
attribute :created_at
|
|
|
|
attribute :deleted_at
|
|
|
|
attribute :updated_at
|
|
|
|
attribute :deleted
|
|
|
|
attribute :protected
|
|
|
|
attribute :is_public
|
|
|
|
attribute :status
|
|
|
|
attribute :min_ram
|
|
|
|
attribute :owner
|
|
|
|
attribute :properties
|
2012-02-29 00:48:12 -05:00
|
|
|
attribute :location
|
2012-05-09 05:49:26 -04:00
|
|
|
attribute :copy_from
|
2012-02-27 07:12:52 -05:00
|
|
|
|
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def initialize(attributes)
|
|
|
|
@connection = attributes[:connection]
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name
|
|
|
|
identity ? update : create
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
requires :name
|
|
|
|
merge_attributes(connection.create_image(self.attributes).body['image'])
|
2012-10-02 01:52:45 -04:00
|
|
|
self
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
requires :name
|
|
|
|
merge_attributes(connection.update_image(self.attributes).body['image'])
|
2012-02-27 07:12:52 -05:00
|
|
|
self
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
2012-02-27 07:12:52 -05:00
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.delete_image(self.id)
|
|
|
|
true
|
|
|
|
end
|
2012-02-27 07:12:52 -05:00
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def add_member(member_id)
|
|
|
|
requires :id
|
|
|
|
connection.add_member_to_image(self.id, member_id)
|
|
|
|
end
|
2012-02-27 07:12:52 -05:00
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def remove_member(member_id)
|
|
|
|
requires :id
|
|
|
|
connection.remove_member_from_image(self.id, member_id)
|
|
|
|
end
|
2012-02-27 07:12:52 -05:00
|
|
|
|
2012-07-18 01:31:01 -04:00
|
|
|
def update_members(members)
|
|
|
|
requires :id
|
|
|
|
connection.update_image_members(self.id, members)
|
|
|
|
end
|
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def members
|
|
|
|
requires :id
|
|
|
|
connection.get_image_members(self.id).body['members']
|
|
|
|
end
|
2012-02-23 05:57:48 -05:00
|
|
|
|
2012-02-28 02:31:19 -05:00
|
|
|
def metadata
|
|
|
|
requires :id
|
|
|
|
connection.get_image(self.id).headers
|
|
|
|
end
|
|
|
|
|
2012-02-27 07:12:52 -05:00
|
|
|
end
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|