Class: OneviewSDK::API200::LogicalSwitchGroup

Inherits:
Resource show all
Defined in:
lib/oneview-sdk/resource/api200/logical_switch_group.rb

Overview

Logical switch group resource implementation

Constant Summary collapse

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

Constants inherited from Resource

Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

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

Constructor Details

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

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.



24
25
26
27
28
29
30
31
# 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

Instance Method Details

#set_grouping_parameters(number_of_switches, type) ⇒ Object

Define how the switches will be grouped, setting the number and the type of the switches

Parameters:

  • number_of_switches (Fixnum)

    The number of the switch inside the group [1,2]

  • type (String)

    Switch type name

Raises:

  • (StandardError)


37
38
39
40
41
42
43
44
45
46
47
48
49
# 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