class OneviewSDK::API200::LogicalSwitchGroup

Logical switch group resource implementation

Constants

BASE_URI

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/api200/logical_switch_group.rb, line 24
def initialize(client, params = {}, api_ver = nil)
  super
  # Default values:
  @data['category'] ||= 'logical-switch-groups'
  @data['state'] ||= 'Active'
  @data['type'] ||= 'logical-switch-group'
  @data['switchMapTemplate'] ||= {}
end

Public Instance Methods

set_grouping_parameters(number_of_switches, type) click to toggle source

Define how the switches will be grouped, setting the number and the type of the switches @param [Fixnum] number_of_switches The number of the switch inside the group [1,2] @param [String] type Switch type name @raise [StandardError]

# File lib/oneview-sdk/resource/api200/logical_switch_group.rb, line 37
def set_grouping_parameters(number_of_switches, type)
  @data['switchMapTemplate']['switchMapEntryTemplates'] = []
  parse_switch_map_template(number_of_switches)
  switch_type_uri = OneviewSDK::Switch.get_type(@client, type)['uri']
  @data['switchMapTemplate']['switchMapEntryTemplates'].each do |entry|
    entry['logicalLocation']['locationEntries'].each do |location|
      entry['permittedSwitchTypeUri'] = switch_type_uri if location['type'] == 'StackingMemberId'
    end
  end
rescue StandardError
  list = OneviewSDK::Switch.get_types(@client).map { |t| t['name'] }
  raise "Switch type #{type} not found! Supported types: #{list}"
end

Private Instance Methods

parse_switch_map_template(number_of_switches) click to toggle source

Parse switch map template structure @param [Integer] number_of_switches number of switches

# File lib/oneview-sdk/resource/api200/logical_switch_group.rb, line 55
def parse_switch_map_template(number_of_switches)
  1.upto(number_of_switches) do |stacking_member_id|
    entry = {
      'logicalLocation' => {
        'locationEntries' => [
          { 'relativeValue' => stacking_member_id, 'type' => 'StackingMemberId' }
        ]
      },
      'permittedSwitchTypeUri' => nil
    }
    @data['switchMapTemplate']['switchMapEntryTemplates'] << entry
  end
end