class OneviewSDK::API300::C7000::EnclosureGroup

Enclosure group resource implementation on API300 C7000

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::API200::EnclosureGroup::new
# File lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb, line 24
def initialize(client, params = {}, api_ver = nil)
  @data ||= {}
  # Default values:
  @data['type'] ||= 'EnclosureGroupV300'
  @data['enclosureCount'] ||= 1
  @data['interconnectBayMappingCount'] ||= 8
  super
end

Public Instance Methods

add_logical_interconnect_group(lig, enclosureIndex = nil) click to toggle source

Adds the logical interconnect group @param [OneviewSDK::LogicalInterconnectGroup] lig Logical Interconnect Group @param [Integer] enclosureIndex Enclosure index of bay to add LIG to. If nil, interconnects will be added for all enclosures @raise [OneviewSDK::NotFound] if the LIG uri is not set and cannot be retrieved @return [OneviewSDK::API300::C7000::EnclosureGroup] self

# File lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb, line 38
def add_logical_interconnect_group(lig, enclosureIndex = nil)
  lig.retrieve! unless lig['uri']
  raise(NotFound, "The logical interconnect group #{lig['name']} was not found") unless lig['uri']
  lig['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
    entry['logicalLocation']['locationEntries'].each do |location|
      next unless location['type'] == 'Bay' && entry['permittedInterconnectTypeUri']
      add_lig_to_bay(location['relativeValue'], lig, enclosureIndex)
    end
  end
  self
end
create_interconnect_bay_mapping() click to toggle source

Creates the interconnect bay mapping @return [OneviewSDK::API300::C7000::EnclosureGroup] self

# File lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb, line 52
def create_interconnect_bay_mapping
  @data['interconnectBayMappings'] = []
  1.upto(@data['enclosureCount']) do |enclosureIndex|
    1.upto(@data['interconnectBayMappingCount']) do |bay_number|
      entry = {
        'enclosureIndex' => enclosureIndex,
        'interconnectBay' => bay_number,
        'logicalInterconnectGroupUri' => nil
      }
      @data['interconnectBayMappings'] << entry
    end
  end
  self
end

Private Instance Methods

add_lig_to_bay(bay, lig, enclosureIndex) click to toggle source

Add logical interconnect group to bay @param [Integer] bay Bay number @param [OneviewSDK::LogicalInterconnectGroup] lig Logical Interconnect Group @param [Integer] enclosureIndex Enclosure index of bay to add LIG to. If nil, interconnects will be added for all enclosures

# File lib/oneview-sdk/resource/api300/c7000/enclosure_group.rb, line 73
def add_lig_to_bay(bay, lig, enclosureIndex)
  @data['interconnectBayMappings'].each do |location|
    next unless location['interconnectBay'] == bay
    if enclosureIndex
      next unless location['enclosureIndex'] == enclosureIndex
      location['logicalInterconnectGroupUri'] = lig['uri']
      location['enclosureIndex'] = enclosureIndex
      break
    else
      location['logicalInterconnectGroupUri'] = lig['uri']
    end
  end
end