4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/onetable_terminator/iptables/rules_handler.rb', line 4
def find_redundant_rules(nics)
rules = []
nics.each do |nic|
logger.debug "Validating rules for NIC #{nic.name.inspect}"
sorted_rules = nic.rules.sort { |left, right| right.vm_id <=> left.vm_id }
correct_vm_id = sorted_rules.first.vm_id
logger.debug "Correct VM ID is #{correct_vm_id.inspect}"
redundant_rules = sorted_rules.reject { |rule| rule.vm_id == correct_vm_id }
log_redundant redundant_rules
rules.concat redundant_rules
end
rules
end
|