-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from HewlettPackard/API1800LogicalInterconnects
API1800 support Logical Interconnects
- Loading branch information
Showing
8 changed files
with
200 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/oneview-sdk/resource/api1800/c7000/logical_interconnect.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
lib/oneview-sdk/resource/api1800/synergy/logical_interconnect.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
spec/unit/resource/api1800/c7000/logical_interconnect_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
spec/unit/resource/api1800/synergy/logical_interconnect_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |