Class: Rackspace::Volume
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#volume_id ⇒ Object
readonly
Returns the value of attribute volume_id.
-
#volume_type ⇒ Object
readonly
Returns the value of attribute volume_type.
Attributes inherited from Base
#account, #credentials, #logger, #region
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(params) ⇒ Volume
constructor
A new instance of Volume.
- #volume ⇒ Object
Methods inherited from Base
#log, #server_api, #storage_api
Constructor Details
#initialize(params) ⇒ Volume
Returns a new instance of Volume.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/rackspace/volume.rb', line 5 def initialize(params) super params if @volume_id = params[:volume_id] fetch_volume_by_id else @volume_type = params.fetch(:volume_type, SATA) @size = params.fetch(:size, MIN_SIZE) @name = params.fetch(:name) end end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
3 4 5 |
# File 'lib/rackspace/volume.rb', line 3 def device @device end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rackspace/volume.rb', line 3 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/rackspace/volume.rb', line 3 def size @size end |
#volume_id ⇒ Object (readonly)
Returns the value of attribute volume_id.
3 4 5 |
# File 'lib/rackspace/volume.rb', line 3 def volume_id @volume_id end |
#volume_type ⇒ Object (readonly)
Returns the value of attribute volume_type.
3 4 5 |
# File 'lib/rackspace/volume.rb', line 3 def volume_type @volume_type end |
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rackspace/volume.rb', line 16 def create log "Creating #{size}GB #{volume_type} block storage volume: #{name}" storage_api.create( size: size, name: name, volume_type: volume_type, ) self end |
#destroy ⇒ Object
26 27 28 29 30 |
# File 'lib/rackspace/volume.rb', line 26 def destroy log "Destroying volume #{name} in account #{account}" volume.destroy self end |
#volume ⇒ Object
32 33 34 |
# File 'lib/rackspace/volume.rb', line 32 def volume @volume ||= storage_api.find_by_name(name) end |