Class: OneviewSDK::API200::LogicalInterconnectGroup
- Defined in:
- lib/oneview-sdk/resource/api200/logical_interconnect_group.rb
Overview
Logical interconnect group resource implementation
Direct Known Subclasses
Constant Summary collapse
- BASE_URI =
'/rest/logical-interconnect-groups'.freeze
Constants inherited from Resource
Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS
Instance Attribute Summary collapse
-
#bay_count ⇒ Object
readonly
Returns the value of attribute bay_count.
Attributes inherited from Resource
#api_version, #client, #data, #logger
Class Method Summary collapse
-
.get_default_settings(client) ⇒ Hash
Get the logical interconnect group default settings.
Instance Method Summary collapse
-
#add_interconnect(bay, type) ⇒ Object
Adds an interconnect.
-
#add_uplink_set(uplink_set) ⇒ Object
Adds an uplink set.
-
#create(header = {}) ⇒ Resource
Create the resource on OneView using the current data.
-
#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 = {}) ⇒ Resource
Set data and save to OneView.
Methods inherited from Resource
#==, #[], #[]=, build_query, #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
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ LogicalInterconnectGroup
Create a resource object, associate it with a client, and set its properties.
26 27 28 29 30 31 32 33 34 35 |
# 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 |
Instance Attribute Details
#bay_count ⇒ Object (readonly)
Returns the value of attribute bay_count.
20 21 22 |
# File 'lib/oneview-sdk/resource/api200/logical_interconnect_group.rb', line 20 def bay_count @bay_count end |
Class Method Details
.get_default_settings(client) ⇒ Hash
Get the logical interconnect group default settings
40 41 42 43 |
# 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 |
Instance Method Details
#add_interconnect(bay, type) ⇒ Object
Adds an interconnect
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 |
#add_uplink_set(uplink_set) ⇒ Object
Adds an uplink set
73 74 75 |
# 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(header = {}) ⇒ Resource
Calls the refresh method to set additional data
Create the resource on OneView using the current data
91 92 93 94 |
# 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 |
#get_settings ⇒ Hash
Gets the logical interconnect group settings
79 80 81 82 83 |
# 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 |
#update(attributes = {}) ⇒ Resource
Set data and save to OneView
101 102 103 104 105 106 107 108 109 110 111 112 |
# 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! = { 'If-Match' => @data.delete('eTag'), 'Body' => @data } response = @client.rest_put(@data['uri'], , @api_version) body = @client.response_handler(response) set_all(body) end |