Class: Fog::Compute::IBM::Image

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

Constant Summary collapse

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

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(new_attributes = {}) ⇒ Image

Returns a new instance of Image.



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

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

Instance Method Details

#clone(name, description) ⇒ Object



58
59
60
# File 'lib/fog/ibm/models/compute/image.rb', line 58

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

#destroyObject



62
63
64
65
# File 'lib/fog/ibm/models/compute/image.rb', line 62

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

#ready?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/fog/ibm/models/compute/image.rb', line 54

def ready?
  state == 'Available'
end

#saveObject



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

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

#stateObject



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

def state
  STATES[attributes[:state]]
end