Sha256: 70aabfb1f787e4dd593e20026506d79f629dd6cb18127ee69802470759105094

Contents?: true

Size: 1.72 KB

Versions: 65

Compression:

Stored size: 1.72 KB

Contents

require 'fog/core/model'
require 'fog/ibm/models/compute/instance-types'

module Fog
  module Compute
    class IBM
      class Image < Fog::Model

        STATES = {
          0 => 'New',
          1 => 'Available',
          2 => 'Unavailable',
          3 => 'Deleted',
          4 => 'Capturing',
          5 => 'Importing',
          6 => 'Copying',
          7 => 'Failed',
        }

        identity :id

        attribute :architecture
        attribute :created_at, :aliases => 'createdTime'
        attribute :description
        attribute :documentation
        attribute :location
        attribute :manifest
        attribute :name
        attribute :owner
        attribute :platform
        attribute :product_codes, :aliases => 'productCodes'
        attribute :state
        attribute :supported_instance_types, :aliases => 'supportedInstanceTypes'
        attribute :visibility

        attribute :volume_id

        def initialize(new_attributes = {})
          super(new_attributes)
          attributes[:supported_instance_types] = Fog::Compute::IBM::InstanceTypes.new.load(attributes[:supported_instance_types]) if attributes[:supported_instance_types]
        end

        def save
          requires :id, :volume_id
          data = service.create_image(id, volume_id)
          merge_attributes(data.body)
          data.body['success']
        end

        def state
          STATES[attributes[:state]]
        end

        def ready?
          state == 'Available'
        end

        def clone(name, description)
          service.clone_image(id, name, description).body['ImageID']
        end

        def destroy
          requires :id
          service.delete_image(id).body['success']
        end

      end
    end
  end
end

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-maestrodev-1.18.0.20131209090811 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/ibm/models/compute/image.rb
gapinc-fog-1.12.1.2.1 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/ibm/models/compute/image.rb
fog-1.18.0 lib/fog/ibm/models/compute/image.rb
fog-1.17.0 lib/fog/ibm/models/compute/image.rb
fog-1.16.0 lib/fog/ibm/models/compute/image.rb