Skip to content

Commit

Permalink
Add Darwin netmask support on top of Jim's patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Nasrat committed Aug 23, 2009
1 parent 9d846b4 commit 33be9e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/facter/netmask.rb
Expand Up @@ -9,7 +9,7 @@
require 'facter/util/netmask'

Facter.add("netmask") do
confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd ]
confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin ]
setcode do
Facter::NetMask.get_netmask
end
Expand Down
8 changes: 7 additions & 1 deletion lib/facter/util/netmask.rb
Expand Up @@ -14,7 +14,13 @@ def self.get_netmask
when 'SunOS'
ops = {
:ifconfig => '/usr/sbin/ifconfig -a',
:regex => %r{\s+ inet\s+? #{Facter.ipaddress} \+? mask (\w{8})}x,
:regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s (\w{8})}x,
:munge => Proc.new { |mask| mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') }
}
when 'FreeBSD','NetBSD','OpenBSD', 'Darwin'
ops = {
:ifconfig => '/sbin/ifconfig -a',
:regex => %r{\s+ inet \s #{Facter.ipaddress} \s netmask \s 0x(\w{8})}x,
:munge => Proc.new { |mask| mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') }
}
end
Expand Down

0 comments on commit 33be9e0

Please sign in to comment.