class OneviewSDK::API300::Synergy::SASLogicalInterconnectGroup

SAS Logical interconnect group resource implementation

Constants

BASE_URI

Attributes

bay_count[R]

Public Class Methods

new(client, params = {}, api_ver = nil) click to toggle source

Create a resource object, associate it with a client, and set its properties. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Hash] params The options for this resource (key-value pairs) @param [Integer] api_ver The api version to use when interracting with this resource.

Calls superclass method OneviewSDK::Resource::new
# File lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb, line 27
def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['enclosureType'] ||= 'SY12000'
  @data['enclosureIndexes'] ||= [1]
  @data['state'] ||= 'Active'
  @data['type'] ||= 'sas-logical-interconnect-group'
  @data['interconnectBaySet'] ||= 1
  @data['interconnectMapTemplate'] ||= {}
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] ||= []
end

Public Instance Methods

add_interconnect(bay, type, enclosure_index = 1) click to toggle source

Adds an interconnect @param [Fixnum] bay Bay number @param [String] type Interconnect type @raise [StandardError] if a invalid type is given then raises an error

# File lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb, line 43
def add_interconnect(bay, type, enclosure_index = 1)
  parse_interconnect_map_template(bay, enclosure_index)
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
    entry['logicalLocation']['locationEntries'].each do |location|
      if location['type'] == 'Bay' && location['relativeValue'] == bay
        entry['permittedInterconnectTypeUri'] = OneviewSDK::API300::Synergy::SASInterconnect.get_type(@client, type)['uri']
      end
    end
  end
rescue StandardError
  list = OneviewSDK::API300::Synergy::SASInterconnect.get_types(@client).map { |t| t['name'] }
  raise "SAS Interconnect type '#{type}' not found! Supported types: #{list}"
end

Private Instance Methods

parse_interconnect_map_template(bay, enclosure_index) click to toggle source

Parse interconnect map template structure for specified bay

# File lib/oneview-sdk/resource/api300/synergy/sas_logical_interconnect_group.rb, line 60
def parse_interconnect_map_template(bay, enclosure_index)
  entry = {
    'logicalLocation' => {
      'locationEntries' => [
        { 'relativeValue' => bay, 'type' => 'Bay' },
        { 'relativeValue' => 1, 'type' => 'Enclosure' }
      ]
    },
    'enclosureIndex' => enclosure_index,
    'permittedInterconnectTypeUri' => nil
  }

  # If no interconnect map entry templates exist yet, add the specified entry
  first_run = @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].empty?
  return @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << entry if first_run

  # Verifies if the bay specified in the entry is already added, otherwise adds it
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |single_entry|
    single_entry['logicalLocation']['locationEntries'].each do |location|
      return true if location['type'] == 'Bay' && location['relativeValue'] == bay
    end
  end
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << entry
end