Sha256: 14c63a0c79c35c381f5dc7ed2f5af6aed206119d7421228db743693ca8c82db2
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Facter::NetMask def self.get_netmask netmask = nil; ipregex = %r{(\d{1,3}\.){3}\d{1,3}} ops = nil case Facter.value(:kernel) when 'Linux' ops = { :ifconfig => '/sbin/ifconfig', :regex => %r{\s+ inet\saddr: #{Facter.ipaddress} .*? Mask: (#{ipregex})}x, :munge => nil, } when 'SunOS' ops = { :ifconfig => '/usr/sbin/ifconfig -a', :regex => %r{\s+ inet\s+? #{Facter.ipaddress} \+? mask (\w{8})}x, :munge => Proc.new { |mask| mask.scan(/../).collect do |byte| byte.to_i(16) end.join('.') } } end %x{#{ops[:ifconfig]}}.split(/\n/).collect do |line| matches = line.match(ops[:regex]) if !matches.nil? if ops[:munge].nil? netmask = matches[1] else netmask = ops[:munge].call(matches[1]) end end end netmask end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facter-1.5.6 | lib/facter/util/netmask.rb |
facter-1.5.3 | lib/facter/util/netmask.rb |
facter-1.5.4 | lib/facter/util/netmask.rb |
facter-1.5.5 | lib/facter/util/netmask.rb |