]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/libraries/interfaces.rb
67b2bd2373176e2fd69ab93697170d2de6025f77
[chef.git] / cookbooks / networking / libraries / interfaces.rb
1 class Chef
2   class Node
3     def interfaces(options = {}, &block)
4       interfaces = []
5
6       networking = construct_attributes[:networking] || {}
7       networking_interfaces = networking[:interfaces] || []
8
9       networking_interfaces.each_value  do |interface|
10         if options[:role].nil? or interface[:role].to_s == options[:role].to_s
11           if options[:family].nil? or interface[:family].to_s == options[:family].to_s
12             if block.nil?
13               interfaces << interface
14             else
15               block.call(interface)
16             end
17           end
18         end
19       end
20
21       interfaces
22     end
23   end
24 end