class OpenStack::Nova::Compute::Image

An OpenStack Image

Attributes

Public Class Methods

find_all_by_name(name) click to toggle source

Returns the list of Image instances with the specified name

Attributes

  • name : A string

# File lib/open_stack/nova/compute/image.rb, line 73
def self.find_all_by_name(name)
  all.reject! { |image| image.name != name }
end
find_by_name(name) click to toggle source

Returns the first Image instance with the specified name

Attributes

  • name : A string

# File lib/open_stack/nova/compute/image.rb, line 81
def self.find_by_name(name)
  all.detect { |image| image.name == name }
end

Public Instance Methods

image_type() click to toggle source

Returns the type of image: image or snapshot

# File lib/open_stack/nova/compute/image.rb, line 91
def image_type
  metadata.image_type
rescue NoMethodError
  'image'
end
server() click to toggle source

Returns the Server instance to which this image belongs to (if applicable)

# File lib/open_stack/nova/compute/image.rb, line 86
def server
  Server.find(server_id) if server_id.present?
end
snapshot?() click to toggle source

True if this image is a snapshot

# File lib/open_stack/nova/compute/image.rb, line 98
def snapshot?
  image_type != 'image'
end

Protected Instance Methods

initialize(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/open_stack/nova/compute/image.rb, line 49
def initialize(attributes = {}, persisted = false) # :notnew:
  attributes = attributes.with_indifferent_access
  new_attributes = {
      :id => attributes[:id],
      :name => attributes[:name],
      :min_ram => attributes[:minRam],
      :min_disk => attributes[:minDisk],
      :progress => attributes[:progress],
      :status => attributes[:status],
      :metadata => attributes[:metadata],
      :user_id => attributes[:user_id],
      :tenant_id => attributes[:tenant_id],
      :server_id => attributes[:server].present? ? attributes[:server][:id] : nil,
      :updated_at => attributes[:updated].present? ? DateTime.strptime(attributes[:updated], OpenStack::DATETIME_FORMAT) : nil,
      :created_at => attributes[:created].present? ? DateTime.strptime(attributes[:created], OpenStack::DATETIME_FORMAT) : nil
  }

  super(new_attributes, persisted)
end