Class: OneviewSDK::LogicalInterconnectGroup
- Defined in:
- lib/oneview-sdk/resource/logical_interconnect_group.rb
Overview
Logical interconnect group resource implementation
Constant Summary collapse
- BASE_URI =
'/rest/logical-interconnect-groups'.freeze
Instance Attribute Summary collapse
-
#bay_count ⇒ Object
readonly
Returns the value of attribute bay_count.
Attributes inherited from Resource
#api_version, #client, #data, #logger
Instance Method Summary collapse
-
#add_interconnect(bay, type) ⇒ Object
Adds an interconnect.
-
#add_uplink_set(uplink_set) ⇒ Object
Adds an uplink set.
-
#get_default_settings ⇒ Hash
Get the logical interconnect group default settings.
-
#get_settings ⇒ Hash
Gets the logical interconnect group settings.
-
#initialize(client, params = {}, api_ver = nil) ⇒ LogicalInterconnectGroup
constructor
Create a resource object, associate it with a client, and set its properties.
-
#update(attributes = {}) ⇒ Object
Saves the current data attributes to the Logical Interconnect Group.
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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 23 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_count ⇒ Object (readonly)
Returns the value of attribute bay_count.
17 18 19 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 17 def bay_count @bay_count end |
Instance Method Details
#add_interconnect(bay, type) ⇒ Object
Adds an interconnect
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 44 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 |
#add_uplink_set(uplink_set) ⇒ Object
Adds an uplink set
59 60 61 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 59 def add_uplink_set(uplink_set) @data['uplinkSets'] << uplink_set.data end |
#get_default_settings ⇒ Hash
Get the logical interconnect group default settings
65 66 67 68 69 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 65 def get_default_settings get_uri = self.class::BASE_URI + '/defaultSettings' response = @client.rest_get(get_uri, @api_version) @client.response_handler(response) end |
#get_settings ⇒ Hash
Gets the logical interconnect group settings
73 74 75 76 77 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 73 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
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/oneview-sdk/resource/logical_interconnect_group.rb', line 82 def update(attributes = {}) set_all(attributes) = { 'If-Match' => @data.delete('eTag'), 'Body' => @data } response = @client.rest_put(@data['uri'], , @api_version) body = @client.response_handler(response) set_all(body) end |