diff --git a/CHANGELOG.md b/CHANGELOG.md index c90086a69..2913b6d5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Unreleased Changes + +## Suggested release: v4.0.0 + +#### Breaking changes: +- Fixed issue #93 Logical Switch refresh conflict + #### Design changes: - Architecture for future Image Streamer support. **Unimplemented** features to support in the future: - Artifacts Bundle diff --git a/examples/_client.rb.example b/examples/_client.rb.example index aacbf46b7..55f7c1cab 100644 --- a/examples/_client.rb.example +++ b/examples/_client.rb.example @@ -38,3 +38,8 @@ puts "Connected to OneView appliance at #{@client.url}\n\n" # @sas_interconnect_type = 'Synergy 12Gb SAS Connection Module' # @synergy_enclosure_hostname = 'fe80::2:0:9:1%eth2' # @interconnect_name = '0000A66101, interconnect 3' +# @logical_switch1_ip = '172.18.16.91' +# @logical_switch2_ip = '172.18.16.92' +# @logical_switch_ssh_user = "dcs" +# @logical_switch_ssh_password = "dcs" +# @logical_switch_community_string = "public" diff --git a/examples/api200/logical_switch.rb b/examples/api200/logical_switch.rb index 93f2ba550..4216adcfc 100644 --- a/examples/api200/logical_switch.rb +++ b/examples/api200/logical_switch.rb @@ -12,23 +12,28 @@ require_relative '../_client' # SSH Credential -ssh_credentials = OneviewSDK::LogicalSwitch::CredentialsSSH.new('dcs', 'dcs') +ssh_credentials = OneviewSDK::LogicalSwitch::CredentialsSSH.new(@logical_switch_ssh_user, @logical_switch_ssh_password) # SNMP credentials -snmp_v1 = OneviewSDK::LogicalSwitch::CredentialsSNMPV1.new(161, 'public') -snmp_v1_2 = OneviewSDK::LogicalSwitch::CredentialsSNMPV1.new(161, 'public') +snmp_v1 = OneviewSDK::LogicalSwitch::CredentialsSNMPV1.new(161, @logical_switch_community_string) +snmp_v1_2 = OneviewSDK::LogicalSwitch::CredentialsSNMPV1.new(161, @logical_switch_community_string) +logical_switch_group = OneviewSDK::LogicalSwitchGroup.get_all(@client).first logical_switch = OneviewSDK::LogicalSwitch.new( @client, - name: 'Teste_SDK', - logicalSwitchGroupUri: '/rest/logical-switch-groups/2c5de7f0-7cb6-4897-9423-181e625a614c' + name: 'LogicalSwitch', + logicalSwitchGroupUri: logical_switch_group['uri'] ) # Adding switches credentials -logical_switch.set_switch_credentials('172.16.11.11', ssh_credentials, snmp_v1) -logical_switch.set_switch_credentials('172.16.11.12', ssh_credentials, snmp_v1_2) +logical_switch.set_switch_credentials(@logical_switch1_ip, ssh_credentials, snmp_v1) +logical_switch.set_switch_credentials(@logical_switch2_ip, ssh_credentials, snmp_v1_2) # Creates logical switch for a switch group logical_switch.create puts "Logical switch created with uri=#{logical_switch['uri']}" + +puts 'Reclaiming the top-of-rack switches in a logical switch' +logical_switch.refresh_state +puts 'Action done Successfully!' diff --git a/examples/api300/c7000/logical_switch.rb b/examples/api300/c7000/logical_switch.rb index 49e57fecd..c4afc73ae 100644 --- a/examples/api300/c7000/logical_switch.rb +++ b/examples/api300/c7000/logical_switch.rb @@ -12,22 +12,23 @@ require_relative '../../_client' # SSH Credential -ssh_credentials = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSSH.new('dcs', 'dcs') +ssh_credentials = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSSH.new(@logical_switch_ssh_user, @logical_switch_ssh_password) # SNMP credentials -snmp_v1 = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSNMPV1.new(161, 'admin') -snmp_v1_2 = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSNMPV1.new(161, 'admin') +snmp_v1 = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSNMPV1.new(161, @logical_switch_community_string) +snmp_v1_2 = OneviewSDK::API300::C7000::LogicalSwitch::CredentialsSNMPV1.new(161, @logical_switch_community_string) +logical_switch_group = OneviewSDK::API300::C7000::LogicalSwitchGroup.get_all(@client).first logical_switch = OneviewSDK::API300::C7000::LogicalSwitch.new( @client, - name: 'Test_SDK', - logicalSwitchGroupUri: '/rest/logical-switch-groups/2c5de7f0-7cb6-4897-9423-181e625a614c' + name: 'LogicalSwitch', + logicalSwitchGroupUri: logical_switch_group['uri'] ) # Adding switches credentials -logical_switch.set_switch_credentials('172.16.11.11', ssh_credentials, snmp_v1) -logical_switch.set_switch_credentials('172.16.11.12', ssh_credentials, snmp_v1_2) +logical_switch.set_switch_credentials(@logical_switch1_ip, ssh_credentials, snmp_v1) +logical_switch.set_switch_credentials(@logical_switch2_ip, ssh_credentials, snmp_v1_2) # Creates logical switch for a switch group logical_switch.create @@ -43,3 +44,7 @@ # Retrieves a specific Internal Link Set internal_link_set = OneviewSDK::API300::C7000::LogicalSwitch.get_internal_link_set(@client, 'ils1') puts "Internal Link Set #{internal_link_set['name']} URI=#{internal_link_set['uri']}" + +puts 'Reclaiming the top-of-rack switches in a logical switch' +logical_switch.refresh_state +puts 'Action done Successfully!' diff --git a/lib/oneview-sdk/resource/api200/logical_switch.rb b/lib/oneview-sdk/resource/api200/logical_switch.rb index 4b7325c91..a9df9691e 100644 --- a/lib/oneview-sdk/resource/api200/logical_switch.rb +++ b/lib/oneview-sdk/resource/api200/logical_switch.rb @@ -46,10 +46,8 @@ def create self end - # Updates this object using the data that exists on OneView - # @note Will overwrite any data that differs from OneView - # @return [Resource] self - def refresh + # Reclaims the top-of-rack switches in a logical switch. + def refresh_state response = @client.rest_put(@data['uri'] + '/refresh') @client.response_handler(response) end diff --git a/spec/integration/resource/api200/logical_switch/update_spec.rb b/spec/integration/resource/api200/logical_switch/update_spec.rb index 8256478a2..b42c9c255 100644 --- a/spec/integration/resource/api200/logical_switch/update_spec.rb +++ b/spec/integration/resource/api200/logical_switch/update_spec.rb @@ -8,9 +8,9 @@ @item.retrieve! end - describe '#refresh' do - it 'refresh logical switch' do - @item.refresh + describe '#refresh_state' do + it 'should reclaims the top-of-rack switches in a logical switch' do + expect { @item.refresh_state }.to_not raise_error end end end diff --git a/spec/integration/resource/api300/c7000/logical_switch/update_spec.rb b/spec/integration/resource/api300/c7000/logical_switch/update_spec.rb index bc449e05a..e1eacc87c 100644 --- a/spec/integration/resource/api300/c7000/logical_switch/update_spec.rb +++ b/spec/integration/resource/api300/c7000/logical_switch/update_spec.rb @@ -9,9 +9,9 @@ @item.retrieve! end - describe '#refresh' do - it 'refresh logical switch' do - @item.refresh + describe '#refresh_state' do + it 'should reclaims the top-of-rack switches in a logical switch' do + expect { @item.refresh_state }.to_not raise_error end end end diff --git a/spec/unit/resource/api200/logical_switch_spec.rb b/spec/unit/resource/api200/logical_switch_spec.rb index 8689f69f5..e8655a64c 100644 --- a/spec/unit/resource/api200/logical_switch_spec.rb +++ b/spec/unit/resource/api200/logical_switch_spec.rb @@ -38,11 +38,11 @@ end end - describe '#refresh' do - it 'Refresh' do + describe '#refresh_state' do + it 'Refresh logical switch' do item = OneviewSDK::LogicalSwitch.new(@client, uri: '/rest/fake') expect(@client).to receive(:rest_put).with("#{item['uri']}/refresh").and_return(FakeResponse.new({})) - item.refresh + item.refresh_state end end diff --git a/spec/unit/resource/api300/c7000/logical_switch_spec.rb b/spec/unit/resource/api300/c7000/logical_switch_spec.rb index 0da825d78..160c47050 100644 --- a/spec/unit/resource/api300/c7000/logical_switch_spec.rb +++ b/spec/unit/resource/api300/c7000/logical_switch_spec.rb @@ -61,11 +61,11 @@ end end - describe '#refresh' do - it 'Refresh' do + describe '#refresh_state' do + it 'Refresh logical switch' do item = OneviewSDK::API300::C7000::LogicalSwitch.new(@client_300, uri: '/rest/fake') expect(@client_300).to receive(:rest_put).with("#{item['uri']}/refresh").and_return(FakeResponse.new({})) - item.refresh + item.refresh_state end end