Class: OneviewSDK::API200::LogicalSwitchGroup
- Defined in:
- lib/oneview-sdk/resource/api200/logical_switch_group.rb
Overview
Logical switch group resource implementation
Direct Known Subclasses
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
-
#initialize(client, params = {}, api_ver = nil) ⇒ LogicalSwitchGroup
constructor
Create a resource object, associate it with a client, and set its properties.
-
#set_grouping_parameters(number_of_switches, type) ⇒ Object
Define how the switches will be grouped, setting the number and the type of the switches.
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.
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
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 |