Class: OneviewSDK::API300::Synergy::Enclosure

Inherits:
C7000::Enclosure show all
Defined in:
lib/oneview-sdk/resource/api300/synergy/enclosure.rb

Overview

Enclosure resource implementation for API300 Synergy

Constant Summary

Constants inherited from OneviewSDK::API200::Enclosure

OneviewSDK::API200::Enclosure::BASE_URI, OneviewSDK::API200::Enclosure::UNIQUE_IDENTIFIERS

Constants inherited from Resource

Resource::BASE_URI, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from C7000::Enclosure

#initialize

Methods included from C7000::Scope::ScopeHelperMethods

#add_scope, #patch, #remove_scope, #replace_scopes

Methods inherited from OneviewSDK::API200::Enclosure

#configuration, #create, #delete, #environmental_configuration, #initialize, #patch, #remove, #script, #set_refresh_state, #update, #utilization

Methods inherited from Resource

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

Constructor Details

This class inherits a constructor from OneviewSDK::API300::C7000::Enclosure

Class Method Details

.update_enclosure_names(client, hostname, name = '') ⇒ Array<OneviewSDK:API300:Synergy::Enclosure>

Method for renaming all enclosures that share the same frameLinkModuleDomain. The naming pattern for the enclosures is <name><1..number of enclosures>.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • hostname (String)

    The ipv6 of the enclosure to be added

  • name (String) (defaults to: '')

    The name to be used for renaming the enclosures

Returns:

  • (Array<OneviewSDK:API300:Synergy::Enclosure>)

    which had their name changed

Raises:


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 56

def self.update_enclosure_names(client, hostname, name = '')
  raise IncompleteResource, 'Missing parameters for update_enclosure_names' unless client && hostname
  frame_link = ''

  # Retrieve the frameLinkModuleDomain of the specified enclosure, then use it to find all enclosures
  # that share that frameLinkModuleDomain.
  all_enclosures = OneviewSDK::API300::Synergy::Enclosure.find_by(client, {})
  all_enclosures.each do |encl|
    frame_link = encl['frameLinkModuleDomain'] if encl['managerBays'].first['ipAddress'] == hostname
  end
  enclosures = all_enclosures.select { |encl| encl['frameLinkModuleDomain'] == frame_link }

  # Return enclosures without modifying them if a name has not been specified
  return enclosures if name == ''

  # Updates the enclosure names and return the array containing the enclosures
  number_of_enclosures = enclosures.count
  enclosures.each do |encl|
    encl['name'] = "#{name}#{number_of_enclosures}"
    encl.update
    number_of_enclosures -= 1
  end
  enclosures
end

Instance Method Details

#addArray<OneviewSDK:API300:Synergy::Enclosure>

Note:

Calls the update_enclosure_names method to set the enclosure names

Claim/configure the enclosure and its components to the appliance

Returns:

  • (Array<OneviewSDK:API300:Synergy::Enclosure>)

    containing the added enclosures


23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 23

def add
  ensure_client
  required_attributes = %w(hostname)
  required_attributes.each { |k| raise IncompleteResource, "Missing required attribute: '#{k}'" unless @data.key?(k) }

  temp_data = @data.select { |k, _v| required_attributes.include?(k) }
  response = @client.rest_post(self.class::BASE_URI, { 'body' => temp_data }, @api_version)
  @client.response_handler(response)

  # Renames the enclosures if the @data['name'] is not nil, otherwise only returns the enclosures
  @data['name'] ||= ''
  OneviewSDK::API300::Synergy::Enclosure.update_enclosure_names(@client, @data['hostname'], @data['name'])
end

#set_enclosure_groupObject

Method is not available

Raises:


45
46
47
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 45

def set_enclosure_group(*)
  unavailable_method
end

#set_environmental_configurationObject

Method is not available

Raises:


39
40
41
# File 'lib/oneview-sdk/resource/api300/synergy/enclosure.rb', line 39

def set_environmental_configuration(*)
  unavailable_method
end