Class: OpenStack::Volume::Volume
- Defined in:
- lib/openstack/volume/volume.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#availability_zone ⇒ Object
readonly
Returns the value of attribute availability_zone.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#display_description ⇒ Object
readonly
Returns the value of attribute display_description.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#snapshot_id ⇒ Object
readonly
Returns the value of attribute snapshot_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#volume_type ⇒ Object
readonly
Returns the value of attribute volume_type.
Instance Method Summary collapse
- #delete! ⇒ Object
- #extend!(size) ⇒ Object
-
#initialize(connection, volume_info) ⇒ Volume
constructor
A new instance of Volume.
- #populate(volume_info = nil) ⇒ Object
- #status!(status, attach_status = nil) ⇒ Object
Constructor Details
#initialize(connection, volume_info) ⇒ Volume
Returns a new instance of Volume.
19 20 21 22 23 |
# File 'lib/openstack/volume/volume.rb', line 19 def initialize(connection, volume_info) @connection = connection.connection @volume_path = connection.volume_path self.populate(volume_info) end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
14 15 16 |
# File 'lib/openstack/volume/volume.rb', line 14 def @attachments end |
#availability_zone ⇒ Object (readonly)
Returns the value of attribute availability_zone.
12 13 14 |
# File 'lib/openstack/volume/volume.rb', line 12 def availability_zone @availability_zone end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/openstack/volume/volume.rb', line 6 def connection @connection end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
15 16 17 |
# File 'lib/openstack/volume/volume.rb', line 15 def created_at @created_at end |
#display_description ⇒ Object (readonly)
Returns the value of attribute display_description.
8 9 10 |
# File 'lib/openstack/volume/volume.rb', line 8 def display_description @display_description end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
7 8 9 |
# File 'lib/openstack/volume/volume.rb', line 7 def display_name @display_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/openstack/volume/volume.rb', line 5 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/openstack/volume/volume.rb', line 11 def @metadata end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/openstack/volume/volume.rb', line 9 def size @size end |
#snapshot_id ⇒ Object (readonly)
Returns the value of attribute snapshot_id.
13 14 15 |
# File 'lib/openstack/volume/volume.rb', line 13 def snapshot_id @snapshot_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
17 18 19 |
# File 'lib/openstack/volume/volume.rb', line 17 def status @status end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
16 17 18 |
# File 'lib/openstack/volume/volume.rb', line 16 def updated_at @updated_at end |
#volume_type ⇒ Object (readonly)
Returns the value of attribute volume_type.
10 11 12 |
# File 'lib/openstack/volume/volume.rb', line 10 def volume_type @volume_type end |
Instance Method Details
#delete! ⇒ Object
66 67 68 69 70 |
# File 'lib/openstack/volume/volume.rb', line 66 def delete! response = @connection.req("DELETE", "/#{@volume_path}/#{@id}") OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) true end |
#extend!(size) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/openstack/volume/volume.rb', line 45 def extend!(size) data = JSON.generate({'os-extend' => {'new_size' => size}}) response = @connection.req('POST', "/#{@volume_path}/#{@id}/action", {:data => data}) OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) self.populate true end |
#populate(volume_info = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/openstack/volume/volume.rb', line 25 def populate(volume_info = nil) if not volume_info and @id response = @connection.req("GET", "/#{@volume_path}/#{@id}") volume_info = JSON.parse(response.body)["volume"] end @id = volume_info["id"] @display_name = volume_info["display_name"] || volume_info["displayName"] || volume_info["name"] @display_description = volume_info["display_description"] || volume_info["displayDescription"] @size = volume_info["size"] @volume_type = volume_info["volume_type"] || volume_info["volumeType"] @metadata = volume_info["metadata"] @availability_zone = volume_info["availability_zone"] || volume_info["availabilityZone"] @snapshot_id = volume_info["snapshot_id"] || volume_info["snapshotId"] @attachments = volume_info["attachments"] @created_at = volume_info["created_at"] || volume_info["createdAt"] @updated_at = volume_info["updated_at"] @status = volume_info["status"] end |
#status!(status, attach_status = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/openstack/volume/volume.rb', line 53 def status!(status, attach_status = nil) data = {'status' => status} if attach_status data.merge!({'attach_status' => attach_status}) end response = @connection.req('POST', "/#{@volume_path}/#{@id}/action", { :data => JSON.generate({'os-reset_status' => data}) }) OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) self.populate true end |