class OneviewSDK::API300::Synergy::LogicalInterconnectGroup

Logical interconnect group resource implementation

Constants

BASE_URI

Public Class Methods

get_default_settings(client) click to toggle source

Get the logical interconnect group default settings @return [Hash] The logical interconnect group settings

# File lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb, line 44
def self.get_default_settings(client)
  response = client.rest_get(BASE_URI + '/defaultSettings')
  client.response_handler(response)
end
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/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['uplinkSets'] ||= []
  @data['internalNetworkUris'] ||= []
  @data['type'] ||= 'logical-interconnect-groupV300'
  @data['interconnectBaySet'] ||= 1
  @data['interconnectMapTemplate'] ||= {}
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] ||= []
  @data['redundancyType'] ||= 'Redundant'
end

Public Instance Methods

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

Adds an interconnect @param [Fixnum] bay Bay number @param [String] type Interconnect type @param [String, OneviewSDK::LogicalDownlink] logical_downlink Name of logical downlink or LogicalDownlink object @return [Hash] interconnectMapEntryTemplates entry that was added @raise [StandardError] if a invalid type is given then raises an error

# File lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb, line 75
def add_interconnect(bay, type, logical_downlink = nil, enclosure_index = nil)
  enclosure_index ||= type.include?('Virtual Connect SE 16Gb FC Module') ? -1 : 1
  entry = parse_interconnect_map_template(bay, enclosure_index)
  entry['logicalDownlinkUri'] ||= nil # Default value in case of no specified logical downlink
  if logical_downlink
    ld = logical_downlink if logical_downlink.class < OneviewSDK::Resource
    ld ||= OneviewSDK::API300::Synergy::LogicalDownlink.find_by(@client, name: logical_downlink).first
    entry['logicalDownlinkUri'] = ld['uri']
  end
  entry['logicalLocation']['locationEntries'].each do |location|
    if location['type'] == 'Bay' && location['relativeValue'] == bay
      entry['permittedInterconnectTypeUri'] = OneviewSDK::API300::Synergy::Interconnect.get_type(@client, type)['uri']
    end
  end
  entry
rescue StandardError
  raise 'Interconnect type or Logical Downlink not found!'
end
add_internal_network(network) click to toggle source

Adds an internal network to the LIG @param [OneviewSDK::EthernetNetwork] network Network object

# File lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb, line 65
def add_internal_network(network)
  @data['internalNetworkUris'] << network['uri'] unless @data['internalNetworkUris'].include?(network['uri'])
end
get_settings() click to toggle source

Gets the logical interconnect group settings @return [Hash] The logical interconnect group settings

# File lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb, line 51
def get_settings
  get_uri = @data['uri'] + '/settings'
  response = @client.rest_get(get_uri, {}, @api_version)
  @client.response_handler(response)
end

Private Instance Methods

parse_interconnect_map_template(bay, enclosure_index) click to toggle source

Parse interconnect map template structure for specified bay @return the entry that was added (or already existed)

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

  # Add the interconnect if it is not already specified
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |temp|
    same_bay = temp['logicalLocation']['locationEntries'].include? entry['logicalLocation']['locationEntries'][0]
    same_enc = temp['logicalLocation']['locationEntries'].include? entry['logicalLocation']['locationEntries'][1]
    return temp if same_bay && same_enc
  end
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << entry
  entry
end