class OpenStack::Nova::Volume::Volume

An OpenStack Volume

Attributes

Public Instance Methods

attached?() click to toggle source

True if the volume is attached

# File lib/open_stack/nova/volume/volume.rb, line 78
def attached?
  !attachments.empty?
end
server() click to toggle source

The first server to which this volume is attached to (if any)

# File lib/open_stack/nova/volume/volume.rb, line 83
def server
  Compute::Server.find(attachments[0].server_id) if attached?
end
snapshot?() click to toggle source

True if the image is a snapshot

# File lib/open_stack/nova/volume/volume.rb, line 73
def snapshot?
  persisted? and snapshot_id.present?
end

Protected Instance Methods

initialize(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# 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