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 Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Image

Returns a new instance of Image.



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

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



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

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

#destroyObject



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

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

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  state == 'Available'
end

#saveObject



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

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

#stateObject



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

def state
  STATES[attributes[:state]]
end