Class: Fog::Compute::HPV2::VolumeAttachment

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hp/models/compute_v2/volume_attachment.rb

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ VolumeAttachment

Returns a new instance of VolumeAttachment.



13
14
15
16
17
18
# File 'lib/fog/hp/models/compute_v2/volume_attachment.rb', line 13

def initialize(new_attributes = {})
  super(new_attributes)
  # server_id needs to be the same as the server from the attachments collection
  server_id = server.id if server
  self
end

Instance Method Details

#destroyObject Also known as: detach



27
28
29
30
31
# File 'lib/fog/hp/models/compute_v2/volume_attachment.rb', line 27

def destroy
  requires :server_id, :volume_id
  service.detach_volume(server_id, volume_id)
  true
end

#saveObject



20
21
22
23
24
25
# File 'lib/fog/hp/models/compute_v2/volume_attachment.rb', line 20

def save
  requires :server_id, :volume_id, :device
  data = service.attach_volume(server_id, volume_id, device)
  merge_attributes(data.body['volumeAttachment'])
  true
end