Sha256: f5050bce40133957088278688f83f96150aa1900eea94c2f39df32bd7e14d048

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Google

      class Image < Fog::Model

        identity :name

        attribute :kind
        attribute :creation_timestamp, :aliases => 'creationTimestamp'
        attribute :description

        # This attribute is not available in the representation of an
        # 'image' returned by the GCE servser (see GCE API). However,
        # images are a global resource and a user can query for images
        # across projects. Therefore we try to remember which project
        # the image belongs to by tracking it in this attribute.
        attribute :project

        # A RawDisk, e.g. -
        # {
        #   :source         => url_to_gcs_file,
        #   :container_type => 'TAR',
        #   :sha1Checksum   => ,
        # }
        attribute :raw_disk

        attribute :status

        def preferred_kernel=(args)
          Fog::Logger.deprecation("preferred_kernel= is no longer used [light_black](#{caller.first})[/]")
        end
        def preferred_kernel
          Fog::Logger.deprecation("preferred_kernel is no longer used [light_black](#{caller.first})[/]")
          nil
        end

        def reload
          requires :name

          data = service.get_image(name, self.project).body

          self.merge_attributes(data)
          self
        end

        def save
          requires :name
          requires :raw_disk

          options = {
            'rawDisk'         => raw_disk,
            'description'     => description,
          }

          service.insert_image(name, options)

          data = service.backoff_if_unfound {
            service.get_image(self.name).body
          }

          # Track the name of the project in which we insert the image
          data.merge!('project' => service.project)
          self.project = self.service.project

          service.images.merge_attributes(data)
        end

        def resource_url
          "#{self.project}/global/images/#{name}"
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-maestrodev-1.18.0.20131219033443 lib/fog/google/models/compute/image.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/google/models/compute/image.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/google/models/compute/image.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/google/models/compute/image.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/google/models/compute/image.rb