Sha256: c4b52a0e97b8194cf28ed10593eda3b8dc594752609a4a8fc496c44a3b87b42c

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

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

        #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
        attribute :location
        attribute :copy_from


        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'])
          self
        end

        def update
          requires :name
          merge_attributes(connection.update_image(self.attributes).body['image'])
          self
        end

        def destroy
          requires :id
          connection.delete_image(self.id)
          true
        end

        def add_member(member_id)
          requires :id
          connection.add_member_to_image(self.id, member_id)
        end

        def remove_member(member_id)
          requires :id
          connection.remove_member_from_image(self.id, member_id)
        end

        def update_members(members)
          requires :id
          connection.update_image_members(self.id, members)
        end

        def members
          requires :id
          connection.get_image_members(self.id).body['members']
        end

        def metadata
          requires :id
          connection.get_image(self.id).headers
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/openstack/models/image/image.rb
fog-nirvanix-1.8.1 lib/fog/openstack/models/image/image.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/openstack/models/image/image.rb
fog-sgonyea-1.8.1 lib/fog/openstack/models/image/image.rb
fog-1.8.0 lib/fog/openstack/models/image/image.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/openstack/models/image/image.rb
fog-1.7.0 lib/fog/openstack/models/image/image.rb