Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Commit

Permalink
Merge pull request #40 from fanf/bug_4883/deduplicate_ips_for_same_in…
Browse files Browse the repository at this point in the history
…terface

Fixes #4883: Add deduplication logic on IPs for same interface
  • Loading branch information
ncharles committed May 22, 2014
2 parents 0554aea + 89e8015 commit 78ee74f
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,14 @@ class FusionReportUnmarshaller(
* merge them when it's the case.
*/
private[this] def demuxSameInterfaceDifferentIp(report: InventoryReport) : InventoryReport = {
val nets = report.node.networks.groupBy( _.name ).map { case (interface, ips) =>
val referenceInterface = ips.head //we have at least one due to the groupBy

referenceInterface.copy(ifAddresses = ips.flatMap( _.ifAddress ) )
val nets = report.node.networks.groupBy( _.name ).map { case (interface, networks) =>
val referenceInterface = networks.head //we have at least one due to the groupBy
val ips = networks.flatMap( _.ifAddress )
val uniqIps = ips.distinct
if(uniqIps.size < ips.size) {
logger.error(s"Network interface '${interface}' appears several time with same IPs. Taking only the first one, it is likelly a bug in fusion inventory.")
}
referenceInterface.copy(ifAddresses = uniqIps )
}.toSeq

report.copy(node = report.node.copy(networks = nets))
Expand Down

0 comments on commit 78ee74f

Please sign in to comment.