Class: Fog::Compute::IBM::Image
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::IBM::Image
show all
- Defined in:
- lib/rackspace-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, #connection
Instance Method Summary
collapse
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(new_attributes = {}) ⇒ Image
Returns a new instance of Image.
38
39
40
41
|
# File 'lib/rackspace-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/rackspace-fog/ibm/models/compute/image.rb', line 58
def clone(name, description)
connection.clone_image(id, name, description).body['ImageID']
end
|
#destroy ⇒ Object
62
63
64
65
|
# File 'lib/rackspace-fog/ibm/models/compute/image.rb', line 62
def destroy
requires :id
connection.delete_image(id).body['success']
end
|
#ready? ⇒ Boolean
54
55
56
|
# File 'lib/rackspace-fog/ibm/models/compute/image.rb', line 54
def ready?
state == 'Available'
end
|
#save ⇒ Object
43
44
45
46
47
48
|
# File 'lib/rackspace-fog/ibm/models/compute/image.rb', line 43
def save
requires :id, :volume_id
data = connection.create_image(id, volume_id)
merge_attributes(data.body)
data.body['success']
end
|
#state ⇒ Object
50
51
52
|
# File 'lib/rackspace-fog/ibm/models/compute/image.rb', line 50
def state
STATES[attributes[:state]]
end
|