Skip to content

Commit

Permalink
Using NotFound instead of StantardError in add_interconnect method
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogpsf committed Mar 23, 2017
1 parent a4b56f2 commit aa6b7b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/oneview-sdk/resource/api200/logical_interconnect_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ def self.get_default_settings(client)
# Adds an interconnect
# @param [Fixnum] bay Bay number
# @param [String] type Interconnect type
# @raise [StandardError] if an invalid type is given
# @raise [OneviewSDK::NotFound] if an invalid type is given
def add_interconnect(bay, type)
interconnect_type = OneviewSDK::Interconnect.get_type(@client, type)
raise OneviewSDK::NotFound unless interconnect_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|
Expand All @@ -64,10 +67,6 @@ def add_interconnect(bay, type)
new_entry = new_interconnect_entry_template(bay, interconnect_type['uri'])
@data['interconnectMapTemplate']['interconnectMapEntryTemplates'] << new_entry
end

rescue OneviewSDK::NotFound
list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] }
raise "Interconnect type #{type} not found! Supported types: #{list}"
end

# Adds an uplink set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end

it 'LIG with unrecognized interconnect' do
expect { @item.add_interconnect(1, 'invalid_type') }.to raise_error(/Interconnect type invalid_type/)
expect { @item.add_interconnect(1, 'invalid_type') }.to raise_error(OneviewSDK::NotFound, /Interconnect type invalid_type not found!/)
end

it 'LIG with interconnect of type HP VC FlexFabric-20/40 F8 Module' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end

it 'LIG with unrecognized interconnect' do
expect { @item.add_interconnect(1, 'invalid_type') }.to raise_error(/Interconnect type invalid_type/)
expect { @item.add_interconnect(1, 'invalid_type') }.to raise_error(OneviewSDK::NotFound, /Interconnect type invalid_type not found!/)
end

it 'LIG with interconnect of type HP VC FlexFabric-20/40 F8 Module' do
Expand Down

0 comments on commit aa6b7b7

Please sign in to comment.