class OpenStack::Nova::Compute::VolumeAttachment

A Volume attachment (this class describes an attachment of a volume to a server)

Attributes

Public Instance Methods

server() click to toggle source

Return the server to which this volume_attachment is related (if any)

# File lib/open_stack/nova/compute/volume_attachment.rb, line 83
def server
  Server.find(server_id) if server_id.present?
end
server=(server) click to toggle source

Bind the volume_attachment to a sever

Attributes

# File lib/open_stack/nova/compute/volume_attachment.rb, line 91
def server=(server)
  @attributes[:server_id] = server.id if !persisted?
end
volume() click to toggle source

Return the volume to which this volume_attachment is related (if any)

# File lib/open_stack/nova/compute/volume_attachment.rb, line 96
def volume
  Volume::Volume.find(volume_id) if volume_id.present?
end
volume=(volume) click to toggle source

Bind the volume_attachment to a volume

Attributes

  • volume - an OpenStack::Nova::Compute::Volume instance

# File lib/open_stack/nova/compute/volume_attachment.rb, line 104
def volume=(volume)
  @attributes[:volume_id] = volume.id if !persisted?
end

Protected Instance Methods

initialize(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/open_stack/nova/compute/volume_attachment.rb, line 45
def initialize(attributes = {}, persisted = false) # :notnew:
  attributes = attributes.with_indifferent_access
  new_attributes = {
      :device => attributes[:device],
  }

  new_attachment = super(new_attributes, persisted)

  if attributes[:volume].present?
    new_attachment.volume_id = attributes[:volume].id
  else
    new_attachment.volume_id = attributes[:volumeId]
  end

  if attributes[:server].present?
    new_attachment.server_id = attributes[:server].id
  else
    new_attachment.server_id = attributes[:serverId]
  end

  new_attachment.prefix_options[:server_id] = new_attachment.server_id

  new_attachment
end