Method: OneviewSDK::API200::ServerProfile#add_volume_attachment

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

#add_volume_attachment(volume, attachment_options = {}) ⇒ Object

Adds volume attachment entry with associated Volume in Server profile

Parameters:

  • volume (OneviewSDK::Volume)

    Volume Resource to add an attachment

  • attachment_options (Hash) (defaults to: {})

    Options of the new attachment

Options Hash (attachment_options):

  • 'id' (Fixnum)

    The ID of the attached storage volume. Do not use it if you want it to be created automatically.

  • 'lun' (String)

    The logical unit number.

  • 'lunType' (String)

    The logical unit number type: Auto or Manual.

  • 'permanent' (Boolean)

    Required. If true, indicates that the volume will persist when the profile is deleted. If false, then the volume will be deleted when the profile is deleted.

  • 'storagePaths' (Array)

    A list of host-to-target path associations.

Returns:

  • Returns the connection hash if found, otherwise returns nil

Raises:



198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/oneview-sdk/resource/api200/server_profile.rb', line 198

def add_volume_attachment(volume, attachment_options = {})
  raise IncompleteResource, 'Volume not found!' unless volume.retrieve!
  # Convert symbols keys to string
  attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]
  self['sanStorage'] ||= {}
  self['sanStorage']['volumeAttachments'] ||= []
  self['sanStorage']['manageSanStorage'] ||= true
  attachment_options['id'] ||= 0
  attachment_options['volumeUri'] = volume['uri']
  attachment_options['volumeStoragePoolUri'] = volume['storagePoolUri']
  attachment_options['volumeStorageSystemUri'] = volume['storageSystemUri']

  self['sanStorage']['volumeAttachments'] << attachment_options
end