Class: OneviewSDK::API200::LogicalInterconnectGroup

Inherits:
Resource show all
Defined in:
lib/oneview-sdk/resource/api200/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 collapse

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

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.


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 26

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['enclosureType'] ||= 'C7000'
  @data['state'] ||= 'Active'
  @data['uplinkSets'] ||= []
  @data['type'] ||= 'logical-interconnect-groupV3'
  @data['interconnectMapTemplate'] ||= {}
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] ||= []

  # User friendly values:
  @bay_count = 8

  # Create all entries if empty
  parse_interconnect_map_template if @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] == []
end

Instance Attribute Details

#bay_countObject (readonly)

Returns the value of attribute bay_count


20
21
22
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 20

def bay_count
  @bay_count
end

Class Method Details

.get_default_settings(client) ⇒ Hash

Get the logical interconnect group default settings

Parameters:

Returns:

  • (Hash)

    The logical interconnect group settings


46
47
48
49
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 46

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

Instance Method Details

#add_interconnect(bay, type) ⇒ Object

Adds an interconnect

Parameters:

  • bay (Fixnum)

    Bay number

  • type (String)

    Interconnect type

Raises:

  • (StandardError)

    if a invalid type is given then raises an error


55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 55

def add_interconnect(bay, type)
  @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
    entry['logicalLocation']['locationEntries'].each do |location|
      if location['type'] == 'Bay' && location['relativeValue'] == bay
        entry['permittedInterconnectTypeUri'] = OneviewSDK::Interconnect.get_type(@client, type)['uri']
      end
    end
  end
rescue StandardError
  list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] }
  raise "Interconnect type #{type} not found! Supported types: #{list}"
end

Adds an uplink set

Parameters:

  • uplink_set (OneviewSDK::LIGUplinkSet)

70
71
72
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 70

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

#get_settingsHash

Gets the logical interconnect group settings

Returns:

  • (Hash)

    The logical interconnect group settings


76
77
78
79
80
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 76

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

#update(attributes = {}) ⇒ Object

Saves the current data attributes to the Logical Interconnect Group

Parameters:

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

    attributes to be updated

Returns:

  • Updated instance of the Logical Interconnect Group


85
86
87
88
89
90
91
92
93
94
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 85

def update(attributes = {})
  set_all(attributes)
  update_options = {
    'If-Match' =>  @data.delete('eTag'),
    'Body' => @data
  }
  response = @client.rest_put(@data['uri'], update_options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
end