Skip to content

Commit

Permalink
DRY code (thanks @mvidner)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 12, 2016
1 parent b5fd998 commit daa9755
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/lib/cfa/hosts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,7 @@ def delete_host(ip)
def set_host(ip, canonical, aliases = [])
entries = data.select(ip_matcher(ip))
if entries.empty?
log.info "adding new entry for ip #{ip}"
entry_line = AugeasTree.new
entry_line["ipaddr"] = ip
entry_line["canonical"] = canonical
aliases_col = entry_line.collection("alias")
aliases.each do |a|
aliases_col.add(a)
end
data.add(unique_id, entry_line)
add_host(ip, canonical, aliases)
return
end

Expand Down

0 comments on commit daa9755

Please sign in to comment.