Class: OneviewSDK::API500::C7000::ServerProfile

Inherits:
OneviewSDK::API300::C7000::ServerProfile show all
Defined in:
lib/oneview-sdk/resource/api500/c7000/server_profile.rb

Overview

Server Profile resource implementation on API500 C7000

Constant Summary

Constants inherited from OneviewSDK::API200::ServerProfile

OneviewSDK::API200::ServerProfile::BASE_URI, OneviewSDK::API200::ServerProfile::UNIQUE_IDENTIFIERS

Constants inherited from Resource

Resource::BASE_URI, Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from OneviewSDK::API200::ServerProfile

#add_connection, #add_volume_attachment, #get_available_hardware, #get_available_networks, get_available_networks, get_available_servers, get_available_storage_system, get_available_storage_systems, get_available_targets, #get_compliance_preview, #get_messages, get_profile_ports, #get_server_hardware, #get_transformation, #remove_connection, #remove_volume_attachment, #set_enclosure, #set_enclosure_group, #set_firmware_driver, #set_server_hardware, #set_server_hardware_type, #update_from_template

Methods included from ResourceHelper::PatchOperation

#patch

Methods inherited from Resource

#==, #[], #[]=, build_query, #create, #create!, #deep_merge!, #delete, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update

Constructor Details

#initialize(client, params = {}, api_ver = nil) ⇒ ServerProfile

Create a resource object, associate it with a client, and set its properties.

Parameters:

  • The client object for the OneView appliance

  • (defaults to: {})

    The options for this resource (key-value pairs)

  • (defaults to: nil)

    The api version to use when interacting with this resource.



24
25
26
27
28
29
# File 'lib/oneview-sdk/resource/api500/c7000/server_profile.rb', line 24

def initialize(client, params = {}, api_ver = nil)
  @data ||= {}
  # Default values
  @data['type'] ||= 'ServerProfileV7'
  super
end

Instance Method Details

#create_volume_with_attachment(storage_pool, volume_options, attachment_options = {}) ⇒ Object

Adds volume attachment entry and creates a new Volume associated in the Server profile

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.

Raises:

Parameters:

  • Volume Resource to add an attachment

  • Options to create a new Volume. Please refer to OneviewSDK::Volume documentation for the data necessary to create a new Volume.

  • (defaults to: {})

    Options of the new attachment

Returns:

  • Returns the connection hash if found, otherwise returns nil



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/oneview-sdk/resource/api500/c7000/server_profile.rb', line 43

def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
  raise IncompleteResource, 'Storage Pool not found!' unless storage_pool.retrieve!
  # Convert symbols keys to string in volume_options and attachment_options
  volume_options = Hash[volume_options.map { |k, v| [k.to_s, v] }]
  attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]

  self['sanStorage'] ||= {}
  self['sanStorage']['volumeAttachments'] ||= []

  attachment_options['id'] ||= 0
  attachment_options['volumeStoragePoolUri'] = storage_pool['uri']
  attachment_options['volumeStorageSystemUri'] = storage_pool['storageSystemUri']
  attachment_options['volumeName'] = volume_options['name']
  attachment_options['volumeDescription'] = volume_options['description']
  attachment_options['volumeProvisionType'] = volume_options['provisioningType']
  attachment_options['volumeProvisionedCapacityBytes'] = volume_options['size']

  # Defaults
  attachment_options['permanent'] ||= true
  attachment_options['lunType'] ||= 'Auto'
  attachment_options['lun'] ||= nil
  attachment_options['storagePaths'] ||= []
  attachment_options['volumeShareable'] = false

  self['sanStorage']['manageSanStorage'] ||= true
  self['sanStorage']['volumeAttachments'] << attachment_options
end

#get_profile_templateObject

Retrieves the profile template for a given server profile.

Returns:

  • Returns a ServerProfileTemplate instance



73
74
75
76
77
# File 'lib/oneview-sdk/resource/api500/c7000/server_profile.rb', line 73

def get_profile_template
  response = @client.rest_get("#{@data['uri']}/new-profile-template")
  variant = self.class.name.split('::').at(-2)
  OneviewSDK.resource_named('ServerProfileTemplate', @client.api_version, variant).new(client, @client.response_handler(response))
end