Skip to content

Commit

Permalink
crowbar: Avoid uselessly saving a node on re-allocation of IP
Browse files Browse the repository at this point in the history
If the node already has the info, then no need to save, which is
expensive.

(cherry picked from commit 2013a47)
(cherry picked from commit 85cf951)
  • Loading branch information
vuntz committed Jun 20, 2017
1 parent a061df2 commit e64e4a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crowbar_framework/app/models/network_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ def allocate_ip_by_type(bc_instance, network, range, object, type, suggestion =

if type == :node
# Save the information.
node.crowbar["crowbar"]["network"][network] = net_info
node.save
if node.crowbar["crowbar"]["network"][network] != net_info
node.crowbar["crowbar"]["network"][network] = net_info
node.save
end
end

@logger.info("Network allocate ip for #{type}: Assigned: #{name} #{network} #{range} #{net_info["address"]}")
Expand Down

0 comments on commit e64e4a1

Please sign in to comment.