Class: OneviewSDK::API300::Synergy::LogicalInterconnectGroup

Inherits:
Resource
  • Object
show all
Defined in:
lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb

Overview

Logical interconnect group resource implementation

Constant Summary collapse

BASE_URI =
'/rest/logical-interconnect-groups'.freeze

Constants inherited from Resource

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 Resource

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

Constructor Details

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

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

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • params (Hash) (defaults to: {})

    The options for this resource (key-value pairs)

  • api_ver (Integer) (defaults to: nil)

    The api version to use when interracting with this resource.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 25

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

Class Method Details

.get_default_settings(client) ⇒ Hash

Get the logical interconnect group default settings

Returns:

  • (Hash)

    The logical interconnect group settings


42
43
44
45
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 42

def self.get_default_settings(client)
  response = client.rest_get(BASE_URI + '/defaultSettings')
  client.response_handler(response)
end

Instance Method Details

#add_interconnect(bay, type, logical_downlink = nil, enclosure_index = nil) ⇒ Hash

Adds an interconnect

Parameters:

  • bay (Fixnum)

    Bay number

  • type (String)

    Interconnect type

  • logical_downlink (String, OneviewSDK::LogicalDownlink) (defaults to: nil)

    Name of logical downlink or LogicalDownlink object

Returns:

  • (Hash)

    interconnectMapEntryTemplates entry that was added

Raises:

  • (StandardError)

    if a invalid type is given then raises an error


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 73

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) ⇒ Object

Adds an internal network to the LIG

Parameters:

  • network (OneviewSDK::EthernetNetwork)

    Network object


63
64
65
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 63

def add_internal_network(network)
  @data['internalNetworkUris'] << network['uri'] unless @data['internalNetworkUris'].include?(network['uri'])
end

Adds a uplink set to the LIG

Parameters:

  • uplink_set (OneviewSDK::UplinkSet)

    Uplink set


57
58
59
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 57

def add_uplink_set(uplink_set)
  @data['uplinkSets'] << uplink_set.data unless @data['uplinkSets'].include?(uplink_set.data)
end

#get_settingsHash

Gets the logical interconnect group settings

Returns:

  • (Hash)

    The logical interconnect group settings


49
50
51
52
53
# File 'lib/oneview-sdk/resource/api300/synergy/logical_interconnect_group.rb', line 49

def get_settings
  get_uri = @data['uri'] + '/settings'
  response = @client.rest_get(get_uri, @api_version)
  @client.response_handler(response)
end