Class: Fog::Compute::IBM::Image
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::IBM::Image
- 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
- #clone(name, description) ⇒ Object
- #destroy ⇒ Object
-
#initialize(new_attributes = {}) ⇒ Image
constructor
A new instance of Image.
- #ready? ⇒ Boolean
- #save ⇒ Object
- #state ⇒ Object
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 |
#destroy ⇒ Object
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
53 54 55 |
# File 'lib/fog/ibm/models/compute/image.rb', line 53 def ready? state == 'Available' end |
#save ⇒ Object
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 |
#state ⇒ Object
49 50 51 |
# File 'lib/fog/ibm/models/compute/image.rb', line 49 def state STATES[attributes[:state]] end |