Method: OneviewSDK::API200::ServerProfile#remove_volume_attachment

Defined in:
lib/oneview-sdk/resource/api200/server_profile.rb

#remove_volume_attachment(id) ⇒ Object

Removes a volume attachment entry in the Server profile

Parameters:

  • id (Fixnum)

    ID number of the attachment entry

Returns:

  • Returns the volume hash if found, otherwise returns nil



268
269
270
271
272
273
274
275
276
277
278
# File 'lib/oneview-sdk/resource/api200/server_profile.rb', line 268

def remove_volume_attachment(id)
  self['sanStorage'] ||= {}
  self['sanStorage']['volumeAttachments'] ||= []
  return if self['sanStorage'].empty? || self['sanStorage']['volumeAttachments'].empty?

  volume_attachment = nil
  self['sanStorage']['volumeAttachments'].each do |entry|
    volume_attachment = self['sanStorage']['volumeAttachments'].delete(entry) if entry['id'] == id
  end
  volume_attachment
end