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)
|
2012-12-19 17:28:04 -05:00
|
|
|
# Old 'connection' is renamed as service and should be used instead
|
|
|
|
prepare_service_value(attributes)
|
2012-02-23 05:57:48 -05:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name
|
|
|
|
identity ? update : create
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
requires :name
|
2012-12-22 18:24:36 -05:00
|
|
|
merge_attributes(service.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
|
2012-12-22 18:24:36 -05:00
|
|
|
merge_attributes(service.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
|
2012-12-22 18:24:36 -05:00
|
|
|
service.delete_image(self.id)
|
2012-02-23 05:57:48 -05:00
|
|
|
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
|
2012-12-22 18:24:36 -05:00
|
|
|
service.add_member_to_image(self.id, member_id)
|
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 remove_member(member_id)
|
|
|
|
requires :id
|
2012-12-22 18:24:36 -05:00
|
|
|
service.remove_member_from_image(self.id, member_id)
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
2012-02-27 07:12:52 -05:00
|
|
|
|
2012-07-18 01:31:01 -04:00
|
|
|
def update_members(members)
|
|
|
|
requires :id
|
2012-12-22 18:24:36 -05:00
|
|
|
service.update_image_members(self.id, members)
|
2012-07-18 01:31:01 -04:00
|
|
|
end
|
|
|
|
|
2012-02-23 05:57:48 -05:00
|
|
|
def members
|
|
|
|
requires :id
|
2012-12-22 18:24:36 -05:00
|
|
|
service.get_image_members(self.id).body['members']
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
2012-02-23 05:57:48 -05:00
|
|
|
|
2012-02-28 02:31:19 -05:00
|
|
|
def metadata
|
|
|
|
requires :id
|
2012-12-22 18:24:36 -05:00
|
|
|
service.get_image(self.id).headers
|
2012-02-28 02:31:19 -05:00
|
|
|
end
|
|
|
|
|
2012-02-27 07:12:52 -05:00
|
|
|
end
|
2012-02-23 05:57:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|