public static void Main()
var dbdata = new HostInterface[] {
new HostInterface { HostName = "host-1", InterfaceName = "eth0", IsExternal = 1, IsCluster = 0, IsHidingNat = 1 },
new HostInterface { HostName = "host-1", InterfaceName = "eth0:1", IsExternal = 1, IsCluster = 1, IsHidingNat = 1 },
new HostInterface { HostName = "host-1", InterfaceName = "eth1", IsExternal = 0, IsCluster = 0, IsHidingNat = 0 },
new HostInterface { HostName = "host-1", InterfaceName = "eth1:1", IsExternal = 0, IsCluster = 1, IsHidingNat = 0 },
new HostInterface { HostName = "host-1", InterfaceName = "eth2", IsExternal = 1, IsCluster = 0, IsHidingNat = 1 },
new HostInterface { HostName = "host-2", InterfaceName = "eth0", IsExternal = 1, IsCluster = 0, IsHidingNat = 1 },
new HostInterface { HostName = "host-2", InterfaceName = "eth0:1", IsExternal = 1, IsCluster = 1, IsHidingNat = 1 },
new HostInterface { HostName = "host-2", InterfaceName = "eth2", IsExternal = 0, IsCluster = 0, IsHidingNat = 1 },
var numhosts = (from x in dbdata group x by x.HostName).Count();
var inconsistencies = from iface in dbdata
group iface by iface.InterfaceName into ifaceGroup
group flags by new { flags.IsExternal, flags.IsCluster, flags.IsHidingNat }
) group flagGroup by ifaceGroup.Key
foreach (var ifaces in inconsistencies) {
if (ifaces.First().Count() < numhosts)
if (ifaces.Count() < numhosts)
Console.WriteLine($"Interface {ifaces.Key} does not exist for all hosts");
Console.WriteLine($"Interface {ifaces.Key} flags differ");
Console.WriteLine("Data:");
foreach (var ifaces in inconsistencies) {
Console.WriteLine($"{ifaces.Key}: {ifaces.Count()}");
foreach (var flags in ifaces)
Console.WriteLine($" {flags.Key}: {flags.Count()}");
public string HostName { get; set; }
public string InterfaceName { get; set; }
public int IsExternal { get; set; }
public int IsCluster { get; set; }
public int IsHidingNat { get; set; }