11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/milc/gcloud/compute/firewall_rules.rb', line 11
def compare(attrs, res)
attrs = attrs.dup
Milc.logger.debug("*" * 100)
[:allow, :source_ranges, :target_tags].each do |k|
attrs[k] = split_sort(attrs[k])
end
res = res.symbolize_keys
res[:allow] = res[:allowed].map{|h|
proto = h["IPProtocol"]
if ports = h["ports"]
ports.map{|port| '%s:%s' % [proto, port] }
else
[proto]
end
}.tap(&:flatten!).sort
{
:sourceRanges => :source_ranges,
:targetTags => :target_tags,
}.each do |k1, k2|
res[k2] = res[k1] ? Array.wrap(res[k1]).sort : nil
end
super(attrs, res)
end
|