Class: Fog::Compute::OpenStack::Image

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/models/compute/image.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes) ⇒ Image

Returns a new instance of Image.



23
24
25
26
27
# File 'lib/fog/openstack/models/compute/image.rb', line 23

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#destroyObject



44
45
46
47
48
# File 'lib/fog/openstack/models/compute/image.rb', line 44

def destroy
  requires :id
  service.delete_image(id)
  true
end

#metadataObject



29
30
31
32
33
34
35
36
# File 'lib/fog/openstack/models/compute/image.rb', line 29

def 
  @metadata ||= begin
    Fog::Compute::OpenStack::Metadata.new({
      :service => service,
      :parent => self
    })
  end
end

#metadata=(new_metadata = {}) ⇒ Object



38
39
40
41
42
# File 'lib/fog/openstack/models/compute/image.rb', line 38

def metadata=(={})
  metas = []
  .each_pair {|k,v| metas << {"key" => k, "value" => v} }
  .load(metas)
end

#ready?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/fog/openstack/models/compute/image.rb', line 50

def ready?
  status == 'ACTIVE'
end