Skip to content

Commit

Permalink
Merge pull request #469 from HewlettPackard/API2000_Interconnects
Browse files Browse the repository at this point in the history
API2000 support for LI and Interconnects
  • Loading branch information
VenkateshRavula committed Sep 11, 2020
2 parents 165ef9a + af072fe commit 88c02af
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/shared_samples/interconnect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# NOTE: You'll need to add an interconnect with state Configured and a port linked.
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000

# Supoported Variants
# C7000, Synergy
Expand Down
44 changes: 20 additions & 24 deletions examples/shared_samples/logical_interconnect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
# Example: Explores functionalities of Logical Interconnects
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800
# - 200, 300, 500, 600, 800, 1000, 1200, 1600, 1800 and 2000

# Supported Variants:
# - C7000, Synergy

# for example, if api_version = 800 & variant = C7000 then, resource that can be created will be in form
# OneviewSDK::API800::C7000::LogicalInterconnect

variant = 'Synergy'

# Resource Class used in this sample
logical_interconnect_class = OneviewSDK.resource_named('LogicalInterconnect', @client.api_version)

Expand Down Expand Up @@ -102,39 +104,25 @@

# Updating Ethernet Settings
puts "\nUpdating Ethernet Settings"
puts 'Current:'
puts "igmpIdleTimeoutInterval: #{item['ethernetSettings']['igmpIdleTimeoutInterval']}"
puts "macRefreshInterval: #{item['ethernetSettings']['macRefreshInterval']}"

# Backing up
eth_set_backup = {}
eth_set_backup['igmpIdleTimeoutInterval'] = item['ethernetSettings']['igmpIdleTimeoutInterval']
eth_set_backup['macRefreshInterval'] = item['ethernetSettings']['macRefreshInterval']

item['ethernetSettings']['igmpIdleTimeoutInterval'] = 222
item['ethernetSettings']['macRefreshInterval'] = 15

puts "\nChanging:"
puts "igmpIdleTimeoutInterval to #{item['ethernetSettings']['igmpIdleTimeoutInterval']}"
puts "macRefreshInterval to #{item['ethernetSettings']['macRefreshInterval']}"
if variant == 'C7000'
eth_set_backup['macRefreshInterval'] = item['ethernetSettings']['macRefreshInterval']
item['ethernetSettings']['macRefreshInterval'] = 15
else
eth_set_backup['stormControlPollingInterval'] = item['ethernetSettings']['stormControlPollingInterval']
item['ethernetSettings']['stormControlPollingInterval'] = 15
end

puts "\nUpdating internet settings"
item.update_ethernet_settings
item.retrieve! # Retrieving to guarantee the remote is updated

puts "\nNew Ethernet Settings:"
puts "igmpIdleTimeoutInterval: #{item['ethernetSettings']['igmpIdleTimeoutInterval']}"
puts "macRefreshInterval: #{item['ethernetSettings']['macRefreshInterval']}"
item.retrieve!

# Rolling back
puts "\nRolling back..."
eth_set_backup.each do |k, v|
item['ethernetSettings'][k] = v
end
item.update_ethernet_settings
item.retrieve! # Retrieving to guarantee the remote is updated
puts "igmpIdleTimeoutInterval: #{item['ethernetSettings']['igmpIdleTimeoutInterval']}"
puts "macRefreshInterval: #{item['ethernetSettings']['macRefreshInterval']}"
item.retrieve!

# Gets igmp settings of LI
puts "\nGets igmp settings of LI "
Expand All @@ -148,6 +136,14 @@
item.retrieve!
puts "Updated igmpIdleTimeoutInterval: #{item['igmpSettings']['igmpIdleTimeoutInterval']}"

# Gets the consolidated inconsistency report for bulk update
if @client.api_version >= 2000 && variant == 'Synergy'
puts "\nGets the consolidated inconsistency report for bulk update"
item['logicalInterconnectUris'] = [item['uri']]
report = item.bulk_inconsistency_validate
puts "\nValidation report:\n #{report['logicalInterconnectsReport']}"
end

# Gets a collection of uplink ports eligibles for assignment to an analyzer port
puts "\nGets a collection of uplink ports eligibles for assignment to an analyzer port "
item.retrieve!
Expand Down
26 changes: 26 additions & 0 deletions lib/oneview-sdk/resource/api2000/c7000/interconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require_relative '../../api1800/c7000/interconnect'

module OneviewSDK
module API2000
module C7000
# Interconnect resource implementation on API2000 C7000
class Interconnect < OneviewSDK::API1800::C7000::Interconnect
include OneviewSDK::ResourceHelper::ConfigurationOperation
def self.api_version
2000
end
end
end
end
end
33 changes: 33 additions & 0 deletions lib/oneview-sdk/resource/api2000/c7000/logical_interconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require_relative '../../api1800/c7000/logical_interconnect'

module OneviewSDK
module API2000
module C7000
# Logical interconnect resource implementation for API2000 C7000
class LogicalInterconnect < OneviewSDK::API1800::C7000::LogicalInterconnect
# Validates the bulk update from group operation and gets the consolidated inconsistency report
def bulk_inconsistency_validate
raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to validate' unless @data['uri']
options = {
'logicalInterconnectUris' => @data['logicalInterconnectUris']
}
response = @client.rest_post("#{BASE_URI}/bulk-inconsistency-validation", { 'body' => options }, @api_version)
body = @client.response_handler(response)
set_all(body)
end

end
end
end
end
25 changes: 25 additions & 0 deletions lib/oneview-sdk/resource/api2000/synergy/interconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require_relative '../../api1800/synergy/interconnect'

module OneviewSDK
module API2000
module Synergy
# Interconnect resource implementation on API2000 Synergy
class Interconnect < OneviewSDK::API1800::Synergy::Interconnect
def self.api_version
2000
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api2000/synergy/logical_interconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require_relative '../../api2000/c7000/logical_interconnect'

module OneviewSDK
module API2000
module Synergy
# Logical interconnect resource implementation for API2000 Synergy
class LogicalInterconnect < OneviewSDK::API2000::C7000::LogicalInterconnect
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"/rest/interconnects/d3eb1592-f078-4b16-951e-04f6e47ad6f0"
],
"stackingHealth": "BiConnected",
"logicalInterconnectUris": [],
"telemetryConfiguration": {
"type": "telemetry-configuration",
"enableTelemetry": true,
Expand Down
19 changes: 19 additions & 0 deletions spec/unit/resource/api2000/c7000/interconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
require 'spec_helper'

RSpec.describe OneviewSDK::API2000::C7000::Interconnect do
include_context 'shared context'

it 'inherits from OneviewSDK::API1800::C7000::Interconnect' do
expect(described_class).to be < OneviewSDK::API1800::C7000::Interconnect
end
end
40 changes: 40 additions & 0 deletions spec/unit/resource/api2000/c7000/logical_interconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

require 'spec_helper'

RSpec.describe OneviewSDK::API2000::C7000::LogicalInterconnect do
include_context 'shared context'

let(:fixture_path) { 'spec/support/fixtures/unit/resource/logical_interconnect_default.json' }
let(:log_int) { OneviewSDK::API2000::C7000::LogicalInterconnect.from_file(@client_2000, fixture_path) }

it 'inherits from OneviewSDK::API1800::C7000::LogicalInterconnect' do
expect(described_class).to be < OneviewSDK::API1800::C7000::LogicalInterconnect
end

describe '#bulk_inconsistency_validate' do
it 'requires the uri to be set' do
expect { OneviewSDK::API2000::C7000::LogicalInterconnect.new(@client_2000).bulk_inconsistency_validate }
.to raise_error(OneviewSDK::IncompleteResource, /Please retrieve the Logical Interconnect before trying to validate/)
end

it 'gets the inconsistency report for bulk update' do
item = log_int
uri = item.class::BASE_URI + '/bulk-inconsistency-validation'
options = {
'logicalInterconnectUris' => []
}
expect(@client_2000).to receive(:rest_post).with(uri, { 'body' => options }, item.api_version).and_return(FakeResponse.new)
item.bulk_inconsistency_validate
end
end
end
19 changes: 19 additions & 0 deletions spec/unit/resource/api2000/synergy/interconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
require 'spec_helper'

RSpec.describe OneviewSDK::API2000::Synergy::Interconnect do
include_context 'shared context'

it 'inherits from OneviewSDK::API1800::Synergy::Interconnect' do
expect(described_class).to be < OneviewSDK::API1800::Synergy::Interconnect
end
end
20 changes: 20 additions & 0 deletions spec/unit/resource/api2000/synergy/logical_interconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

require 'spec_helper'

RSpec.describe OneviewSDK::API2000::Synergy::LogicalInterconnect do
include_context 'shared context'

it 'inherits from OneviewSDK::API2000::C7000::LogicalInterconnect' do
expect(described_class).to be < OneviewSDK::API2000::C7000::LogicalInterconnect
end
end

0 comments on commit 88c02af

Please sign in to comment.