Sha256: f29a5ea48bb53eff6aff584aa541b09a0100023c0f4d678a80c9485f76df454f

Contents?: true

Size: 982 Bytes

Versions: 95

Compression:

Stored size: 982 Bytes

Contents

# Fact: netmask
#
# Purpose: Returns the netmask for the main interfaces.
#
# Resolution: Uses the `facter/util/netmask` library routines.
#
# Caveats:
#

# netmask.rb
# Find the netmask of the primary ipaddress
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# Copyright (C) 2007 Mark 'phips' Phillips
#
# idea and originial source by Mark 'phips' Phillips
#
require 'facter/util/netmask'

Facter.add("netmask") do
  confine :kernel => [ :sunos, :linux, :freebsd, :openbsd, :netbsd, :darwin, :"gnu/kfreebsd", :dragonfly, :AIX ]
  setcode do
    Facter::NetMask.get_netmask
  end
end

Facter.add(:netmask) do
  confine :kernel => :windows
  setcode do
    require 'facter/util/ip/windows'

    mask = nil

    adapters = Facter::Util::IP::Windows.get_preferred_ipv4_adapters
    adapters.find do |nic|
      nic.IPSubnet.any? do |subnet|
        mask = subnet if Facter::Util::IP::Windows.valid_ipv4_address?(subnet)
        mask
      end
    end

    mask
  end
end

Version data entries

95 entries across 95 versions & 2 rubygems

Version Path
facter-2.5.7 lib/facter/netmask.rb
facter-2.5.7-x86-mingw32 lib/facter/netmask.rb
facter-2.5.7-x64-mingw32 lib/facter/netmask.rb
facter-2.5.7-universal-darwin lib/facter/netmask.rb
facter-2.5.6-x86-mingw32 lib/facter/netmask.rb
facter-2.5.6-x64-mingw32 lib/facter/netmask.rb
facter-2.5.6-universal-darwin lib/facter/netmask.rb
facter-2.5.6 lib/facter/netmask.rb
facter-2.5.5-x86-mingw32 lib/facter/netmask.rb
facter-2.5.5-x64-mingw32 lib/facter/netmask.rb
facter-2.5.5-universal-darwin lib/facter/netmask.rb
facter-2.5.5 lib/facter/netmask.rb
facter-2.5.4-x86-mingw32 lib/facter/netmask.rb
facter-2.5.4-x64-mingw32 lib/facter/netmask.rb
facter-2.5.4-universal-darwin lib/facter/netmask.rb
facter-2.5.4 lib/facter/netmask.rb
bolt-0.24.0 vendored/facter/lib/facter/netmask.rb
bolt-0.23.0 vendored/facter/lib/facter/netmask.rb
bolt-0.22.0 vendored/facter/lib/facter/netmask.rb
bolt-0.21.8 vendored/facter/lib/facter/netmask.rb