class OneviewSDK::API200::LogicalInterconnectGroup
Logical interconnect group resource implementation
Constants
- BASE_URI
Attributes
Public Class Methods
Get the logical interconnect group default settings @param [OneviewSDK::Client] client The client object for the OneView appliance @return [Hash] The logical interconnect group settings
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 40 def self.get_default_settings(client) response = client.rest_get(BASE_URI + '/defaultSettings', {}, client.api_version) client.response_handler(response) end
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.
OneviewSDK::Resource::new
# 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'] ||= [] end
Public Instance Methods
Adds an interconnect @param [Fixnum] bay Bay number @param [String] type Interconnect
type @raise [OneviewSDK::NotFound] if an invalid type is given
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 49 def add_interconnect(bay, type) interconnect_type = OneviewSDK::Interconnect.get_type(@client, type) unless interconnect_type list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] } raise OneviewSDK::NotFound, "Interconnect type #{type} not found! Supported types: #{list}" end entry_already_present = false @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry| entry['logicalLocation']['locationEntries'].each do |location| if location['type'] == 'Bay' && location['relativeValue'] == bay entry['permittedInterconnectTypeUri'] = interconnect_type['uri'] entry_already_present = true end end end return if entry_already_present new_entry = new_interconnect_entry_template(bay, interconnect_type['uri']) @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << new_entry end
Adds an uplink set @param [OneviewSDK::LIGUplinkSet] uplink_set
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 73 def add_uplink_set(uplink_set) @data['uplinkSets'] << uplink_set.data end
Create the resource on OneView using the current data @note Calls the refresh method to set additional data @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client is not set @raise [StandardError] if the resource creation fails @return [Resource] self
OneviewSDK::Resource#create
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 91 def create(header = {}) verify_interconnects_before_save! super(DEFAULT_REQUEST_HEADER.merge(header)) end
Gets the logical interconnect group settings @return [Hash] The logical interconnect group settings
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 79 def get_settings get_uri = @data['uri'] + '/settings' response = @client.rest_get(get_uri, {}, @api_version) @client.response_handler(response) end
Set data and save to OneView @param [Hash] attributes The attributes to add/change for this resource (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set @raise [StandardError] if the resource save fails @return [Resource] self
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 101 def update(attributes = {}) set_all(attributes) ensure_client && ensure_uri verify_interconnects_before_save! 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
Private Instance Methods
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 121 def new_interconnect_entry_template(bay = 1, interconnect_type_uri = nil) { 'logicalLocation' => { 'locationEntries' => [ { 'relativeValue' => bay, 'type' => 'Bay' }, { 'relativeValue' => 1, 'type' => 'Enclosure' } ] }, 'permittedInterconnectTypeUri' => interconnect_type_uri } end
# File lib/oneview-sdk/resource/api200/logical_interconnect_group.rb, line 116 def verify_interconnects_before_save! return unless @data['interconnectMapTemplate']['interconnectMapEntryTemplates'].empty? @data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << new_interconnect_entry_template end