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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(new_attributes = {}) ⇒ VolumeAttachment

Returns a new instance of VolumeAttachment.



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

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



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

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

#saveObject



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

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