(#21954) Add support for Mageia OS to osfamily.rb

The addition of Mageia OS in
https://github.com/puppetlabs/facter/commit/e2f040a5bc4ed7539ecc54a5c3d26f93a9ed6a18
(Ticket #9929) was incomplete.
Mageia is derived from Mandrake and Mandriva, and so is in the same family.
This patch adds support to return osfamily='Mandrake' on a Mageia OS system,
rather than the generic 'Linux' kernel value, as well as adjusting the tests
expecting the kernel fact for the Mageia operating system.
Merge pull request #504 from StephenBrown2/mageia_osfamily

Add support for Mageia to osfamily.rb
Maint: Don't load facts twice during specs

Previously, the spec_helper was prepending facter's lib directory to the
$LOAD_PATH, which had the side-effect of causing the zfs and zpool commands
to be executed 5 times, not 3 (as specified in the comments).

Originally, this was noticed because we were having to add `.at_least_once`
to expectations even though the method should have only been called once.

This commit changes the spec_helper to no longer prepend facter's top-level
lib directory to the LOAD_PATH. In doing so, it causes the virtual fact
resolutions to be evaluated in a different order than the virtual tests
expected. In particular, the tests we're trying to verify the more-specific
resolution, but were actually running with the more generic one.

This commit adds a higher weight to the more specific virtual facts,
since that's the expected behavior, and it ensures the tests reliably
test the resolution they are trying to set their expectations on.

Paired-with: Patrick Carlisle <patrick@puppetlabs.com>
(#16668) Use WMI to collect IPv4 address

Previously, we were calling `IPSocket.getaddress(Socket.gethostname)` to
resolve the `ipaddress` fact on Windows, but using WMI-based methods
to resolve other IP related facts, e.g. interfaces. This led to inconsistent
information -- ipaddress from one interface, netmask from another.

This commit introduces a `get_preferred_network_adapters` method that
returns an ordered list of WIN32OLE objects that wrap
Win32_NetworkAdapterConfiguration objects. The list is ordered by the
IPConnectionMetric. If two interfaces have the same metric, e.g. host with
multiple NICs, then the order is based on the adapter bindings[1].

It is possible for a network adapter configuration to contain IPv4 and/or
IPv6 addresses, but only the former will be considered valid for the
ipaddress fact.

[1] http://support.microsoft.com/kb/894564
(#16668) Use WMI to collect netmask fact

Previously, Windows hosts didn't report the netmask fact.
(#16668) Use WMI to collect macaddress fact

Previously, facter would report on the first macaddress associated
with any interface that had IP enabled. This could easily be an
interface with a high cost metric, or an IPv6 only interface.

This commit refactors the macaddress fact to use the same ordered list
of network adapters as is done for ipaddress, to ensure we return a
consistent set of facts.
(#16668) Use WMI to collect IPv6 address

Previously, we were using netsh.exe to collect the ipaddress6 fact, but it
relied on en_US output that wasn't internationalizable.

This commit uses WMI, like the ipaddress fact, and handles issues like
multiple NICs, both IPv4 and IPv6 IP addresses on a single NIC,
per-interface metrics, and the binding order of interfaces.
(#21518) Use WMI to collect per-interface facts

Previously, we used netsh.exe to collect the interfaces fact, and the
derived per-interface facts on Windows. However, netsh.exe is not
available on plain 2003 servers, and the facts relied on netsh.exe
outputting en_US text.

This commit refactors the method to use WMI instead, which does not
have these issues.
(#16665) Remove references to netsh

We no longer use netsh to collect IP related facts on Windows. This
commit removes references to it.
Maint: Simplify how interfaces are enumerated

Previously, we were enumerating each WIN32OLE object, only to have the
caller append the yielded object to an array and then call Enumerable
methods on the array.

This commit simplifies the method to return an Array of WIN32OLE objects,
so the caller can call Enumerable methods directly on it.
(#16668) Support IPv6 adapter binding order

Previously, if multiple interfaces had the same IP connection metric,
then we would always use the IPv4 specific adapter binding order, which
could be incorrect when reporting IPv6 IP related facts.

This commit adds a method for returning the ordered list of interfaces
supporting IPv6, and updates the various facts to use the appropriate
IPv4 or IPv6 method.
Maint: Update yardocs

Updated yardocs where appropriate. Also changed the predicate methods to
return a boolean instead of String or nil.
(#16668) added windows network spec helper
maint: adding lib to spec path in spec helper

Add the 'spec/lib' directory to the load path so we can load spec
specific code.
(#16668) Only consider NICs that have a binding entry

This ensures that only nics that are in the bindings for ipv4/ipv6 are checked
against the registry bindings.
(#16668) Ipv6 remove warning

If someone does not have ipv6 installed or their machine doesn't have the ipv6
bindings in the registry, we should suppress any messages that result in not
finding that key.
(#16668) Backport WMI changes to per-interface facts

Previously, facter was using WMI for the global interface facts,
e.g. ipaddress, but still using netsh for the per-interface facts.

This commit updates the per-interface facts to use the WMI
methods. This commit is broken out in order to make merging up to
master easier, since the code has been drastically modified there.
Merge branch 'ticket/stable/16668-wmi-ipaddress-facts' into stable
Merge remote-tracking branch 'upstream/stable'

* upstream/stable:
  (#16668) Backport WMI changes to per-interface facts
  (#16668) Ipv6 remove warning
  (#16668) Only consider NICs that have a binding entry
  maint: adding lib to spec path in spec helper
  (#16668) added windows network spec helper
  Maint: Update yardocs
  (#16668) Support IPv6 adapter binding order
  Maint: Simplify how interfaces are enumerated
  (#16665) Remove references to netsh
  (#21518) Use WMI to collect per-interface facts
  (#16668) Use WMI to collect IPv6 address
  (#16668) Use WMI to collect macaddress fact
  (#16668) Use WMI to collect netmask fact
  (#16668) Use WMI to collect IPv4 address
  Maint: Don't load facts twice during specs

Conflicts:
	lib/facter/util/ip.rb
	lib/facter/util/ip/windows.rb
	spec/unit/ec2_spec.rb
	spec/unit/util/ip/windows_spec.rb
	spec/unit/util/ip_spec.rb

Resolved conflicts due to code having been refactored into platform
specific delegate classes.
Maint: Don't output "No facts loaded from" during tests

Previously, running `bundle exec rspec spec/unit/memory_spec.rb` would
output the warning "No facts loaded from ...". The reason was because
the memorytotal fact is defined in a file whose name doesn't match,
and the code that forces facter to load the memory facts was within an
inner describe block.

See #7670 and commit 2255abee7b for more information about facter's
quirky loading behavior.

This commit just moves the `load(:memory)` before each to the
outermost describe block. This ensures that all of the memory-derived
facts are "preloaded" so facter doesn't print a warning that it can't
find them.