Class: OpenStack::Nova::Volume::Volume
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- Common
- Base
- OpenStack::Nova::Volume::Volume
- Defined in:
- lib/open_stack/nova/volume/volume.rb
Overview
An OpenStack Volume
Attributes
-
display_name
- Volume name -
display_description
- Volume description -
volume_type
- Volume type identifier -
size
- Volume size (GBytes) -
availability_zone
- The availability zone for the volume -
created_at
- Creation date for the volume -
snapshot_id
- The snapshot id for the volume (not nil if this volume is a snapshot) -
status
- If the volume is a snapshot, this is the status of the snapshot (i.e. available)
Instance Method Summary collapse
-
#attached? ⇒ Boolean
True if the volume is attached.
-
#initialize(attributes = {}, persisted = false) ⇒ Volume
constructor
:notnew:.
-
#server ⇒ Object
The first server to which this volume is attached to (if any).
-
#snapshot? ⇒ Boolean
True if the image is a snapshot.
Methods inherited from Base
Methods inherited from Common
collection_path, custom_method_collection_url, element_path
Methods inherited from Base
Methods inherited from ActiveResource::Base
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ Volume
:notnew:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/open_stack/nova/volume/volume.rb', line 54 def initialize(attributes = {}, persisted = false) # :notnew: attributes = attributes.with_indifferent_access new_attributes = { :id => attributes[:id], :display_name => attributes[:display_name], :display_description => attributes[:display_description], :volume_type => attributes[:volume_type], :size => attributes[:size], :status => attributes[:status], :snapshot_id => attributes[:snapshot_id], :availability_zone => attributes[:availability_zone], :attachments => attributes[:attachments] || [], :created_at => attributes[:created].present? ? DateTime.strptime(attributes[:created], OpenStack::DATETIME_FORMAT) : nil, } super(new_attributes, persisted) end |
Instance Method Details
#attached? ⇒ Boolean
True if the volume is attached
78 79 80 |
# File 'lib/open_stack/nova/volume/volume.rb', line 78 def attached? !.empty? end |
#server ⇒ Object
The first server to which this volume is attached to (if any)
83 84 85 |
# File 'lib/open_stack/nova/volume/volume.rb', line 83 def server Compute::Server.find([0].server_id) if attached? end |
#snapshot? ⇒ Boolean
True if the image is a snapshot
73 74 75 |
# File 'lib/open_stack/nova/volume/volume.rb', line 73 def snapshot? persisted? and snapshot_id.present? end |