Sha256: 78141ac144e4b12103365324a85e80c468966e02f847c9df7e24e7d16374bf89

Contents?: true

Size: 1.73 KB

Versions: 16

Compression:

Stored size: 1.73 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 = connection.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)
          connection.clone_image(id, name, description).body['ImageID']
        end

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

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 9 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/ibm/models/compute/image.rb
fog-nirvanix-1.8.1 lib/fog/ibm/models/compute/image.rb
fog-parser-fix-1.6.1 lib/fog/ibm/models/compute/image.rb
fog-test-again-1.6.0 lib/fog/ibm/models/compute/image.rb
fog-parser-fix-1.6.0 lib/fog/ibm/models/compute/image.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/ibm/models/compute/image.rb
fog-sgonyea-1.8.1 lib/fog/ibm/models/compute/image.rb
fog-1.8.0 lib/fog/ibm/models/compute/image.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/ibm/models/compute/image.rb
fog-1.7.0 lib/fog/ibm/models/compute/image.rb
fog-1.6.0 lib/fog/ibm/models/compute/image.rb
fog-1.5.0 lib/fog/ibm/models/compute/image.rb
fog-1.4.0 lib/fog/ibm/models/compute/image.rb
michiels-fog-1.3.1 lib/fog/ibm/models/compute/image.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/ibm/models/compute/image.rb
fog-1.3.1 lib/fog/ibm/models/compute/image.rb