Skip to content

Commit

Permalink
Merge pull request #449 from HewlettPackard/API1800LogicalInterconnects
Browse files Browse the repository at this point in the history
API1800 support Logical Interconnects
  • Loading branch information
yuvirani committed Jul 17, 2020
2 parents 8ba92e7 + 84c03c4 commit 967b24e
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 31 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ This release extends support to OneView Rest API version 1800 (OneView v5.30) fo
- Hypervisor Cluster Profile
- Hypervisor Manager
- Interconnects
- LIG UplinkSet
- Interconnect Types
- Logical Enclosure
- Logical Interconnect
- LIG UplinkSet
- Logical Interconnect Group
- Network Set
- Scope
Expand Down
58 changes: 30 additions & 28 deletions endpoints-support.md

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion examples/shared_samples/logical_interconnect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# Example: Explores functionalities of Logical Interconnects
#
# Supported APIs:
# - 200, 300, 500, 600, 800, 1000, 1200, 1600
# - 200, 300, 500, 600, 800, 1000, 1200, 1600 and 1800

# Supported Variants:
# - C7000, Synergy

Expand Down Expand Up @@ -135,6 +136,18 @@
puts "igmpIdleTimeoutInterval: #{item['ethernetSettings']['igmpIdleTimeoutInterval']}"
puts "macRefreshInterval: #{item['ethernetSettings']['macRefreshInterval']}"

# Gets igmp settings of LI
puts "\nGets igmp settings of LI "
item.get_igmp_settings
puts "IGMP Settings: #{item['igmpSettings']}"

# Update igmp setting for LI
puts "\nUpdates igmp setting for LI "
item['igmpSettings']['igmpIdleTimeoutInterval'] = 210
item.update_igmp_settings
item.retrieve!
puts "Updated igmpIdleTimeoutInterval: #{item['igmpSettings']['igmpIdleTimeoutInterval']}"

# 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
42 changes: 42 additions & 0 deletions lib/oneview-sdk/resource/api1800/c7000/logical_interconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# (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 '../../api1600/c7000/logical_interconnect'

module OneviewSDK
module API1800
module C7000
# Logical interconnect resource implementation for API1800 C7000
class LogicalInterconnect < OneviewSDK::API1600::C7000::LogicalInterconnect
# Gets igmpSettings of logical interconnect
def get_igmp_settings
ensure_client && ensure_uri
response = @client.rest_get("#{@data['uri']}/igmpSettings")
@client.response_handler(response)
body = @client.response_handler(response)
body['members']
end

# Updates igmpSettings for LI
def update_igmp_settings
raise IncompleteResource, 'Please retrieve the Logical Interconnect before trying to update' unless @data['igmpSettings']
update_options = {
'If-Match' => @data['igmpSettings'].delete('eTag'),
'body' => @data['igmpSettings']
}
response = @client.rest_put("#{@data['uri']}/igmpSettings", update_options, @api_version)
body = @client.response_handler(response)
set_all(body)
end
end
end
end
end
22 changes: 22 additions & 0 deletions lib/oneview-sdk/resource/api1800/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 '../../api1800/c7000/logical_interconnect'

module OneviewSDK
module API1800
module Synergy
# Logical interconnect resource implementation for API1800 Synergy
class LogicalInterconnect < OneviewSDK::API1800::C7000::LogicalInterconnect
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
"type": "EthernetInterconnectSettingsV3",
"interconnectType": "Ethernet",
"enableIgmpSnooping": false,
"igmpIdleTimeoutInterval": 260,
"enableFastMacCacheFailover": true,
"macRefreshInterval": 5,
"enableNetworkLoopProtection": true,
Expand All @@ -114,6 +113,26 @@
"created": "2016-01-25T18:10:37.846Z",
"category": null,
"uri": "/rest/logical-interconnects/77af6337-8c4a-4904-a6a8-ea3bbbb9e49e/ethernetSettings"
},
"igmpSettings": {
"type": "IgmpSettings",
"uri": "/rest/logical-interconnects/77af6337-8c4a-4904-a6a8-ea3bbbb9e49e/igmpSettings",
"category": null,
"eTag": null,
"created": null,
"modified": null,
"id": "16579a56-bdd1-4214-825a-f3607c080642",
"name": "name1106003538-1593864373915",
"enableIgmpSnooping": false,
"enableProxyReporting": true,
"enablePreventFlooding": false,
"dependentResourceUri": "/rest/logical-interconnects/77af6337-8c4a-4904-a6a8-ea3bbbb9e49e",
"igmpIdleTimeoutInterval": 210,
"igmpSnoopingVlanIds": "",
"consistencyChecking": "ExactMatch",
"description": null,
"state": null,
"status": null
},
"internalNetworkUris": [],
"interconnectMap": {
Expand Down
49 changes: 49 additions & 0 deletions spec/unit/resource/api1800/c7000/logical_interconnect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# (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::API1800::C7000::LogicalInterconnect do
include_context 'shared context'

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

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

describe '#get_igmp_settings' do
it 'get_igmp_settings' do
item = log_int
expect(@client_1800).to receive(:rest_get).with("#{item['uri']}/igmpSettings")
.and_return(FakeResponse.new(members: [{ igmpIdleTimeoutInterval: 260 }]))
results = item.get_igmp_settings
expect(results).to_not be_empty
expect(results.first['igmpIdleTimeoutInterval']).to eq(260)
end
end

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

it 'does a PUT to uri/igmpSettings & updates @data' do
item = log_int
expect(@client_1800).to receive(:rest_put).with(item['uri'] + '/igmpSettings', Hash, item.api_version)
.and_return(FakeResponse.new(key: 'val'))
item.update_igmp_settings
expect(item['key']).to eq('val')
end
end
end
20 changes: 20 additions & 0 deletions spec/unit/resource/api1800/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::API1800::Synergy::LogicalInterconnect do
include_context 'shared context'

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

0 comments on commit 967b24e

Please sign in to comment.