Skip to content

Commit

Permalink
fixes #11124 - Interface compute attributes not merged from API reque…
Browse files Browse the repository at this point in the history
…st over compute profile
  • Loading branch information
timogoebel authored and dLobatog committed Oct 23, 2015
1 parent 01f0b23 commit 85e82d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/interface_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run(interfaces, compute_attrs)
private

def merge(nic, vm_nic, compute_attrs)
nic.compute_attributes = vm_nic
nic.compute_attributes = vm_nic.merge(nic.compute_attributes)
nic.compute_attributes['from_profile'] = compute_attrs.compute_profile.name
nic
end
Expand Down
10 changes: 10 additions & 0 deletions test/unit/interface_merge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def expected_attrs(num)
assert_equal 'eth2', interfaces[2].identifier
end

test "it does not overwrite compute attributes already set" do
interfaces = [
FactoryGirl.build(:nic_managed, :identifier => 'eth0', :compute_attributes => {'attr' => 9}),
]
@merge.run(interfaces, @attributes)

assert_equal expected_attrs(9), interfaces[0].compute_attributes
assert_equal 'eth0', interfaces[0].identifier
end

test "it creates NICs when there aren't any" do
interfaces = []
@merge.run(interfaces, @attributes)
Expand Down

0 comments on commit 85e82d0

Please sign in to comment.