Display facts for aliases in *BSD

* interfaces.rb - aliases on *BSD are iterated over up to their actual count - slightly modified Michelle Sullivan's version
* util/ip.rb - added get_alias_no method to return alias count; method get_interface_value modified by Michelle Sullivan to allow obtaining values for specific aliases

Originated here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190796

Hi,

It is a trimmed copy, so duplication is there. I was thinking about moving
common parts out to a separate method, but didn't want to change the file
too much.

As for ipv4 and ipv6 aliases, they are meant to be separate I believe. One
will be ipaddress_alias and the other ipaddress6_alias and they are
enumerated separately. But I didn't really test ipv6. That sounds intuitive
to me, but that's an opinion.

rc.conf manual specifies:

Aliases should be set by *ifconfig**_*<*interface*>*_**alias*<*n*> with
``inet6'' keyword. For example: ifconfig_ed0_ipv6="inet6 2001:db8:1::1
prefixlen 64" ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64"

which doesn't help in this situation (ipv6 interface is configured
separately to ipv4, but ipv6 aliases use the same keyword as ipv4).

Regards,
Daniel

Regards,
Daniel
 On 22 Jul 2014 20:19, "Adrien Thebo" <notifications@github.com> wrote:

> In lib/facter/util/ip.rb:
>
> >        end
> >      end
> >    end
> >
> >    ##
> > +  # get_alias_no obtains alias count for a specified interface and label
> > +  #
> > +  # @param interface [String] the interface identifier, e.g. "eth0" or "bond0"
> > +  #
> > +  # @param label [String] the attribute of the interface to obtain a value for,
> > +  # e.g. "netmask" or "ipaddress" (note eg. ipaddress and ipaddress6 can have different
> > +  # number of aliases, so label does make sense here)
> > +  #
> > +  # @api private
> > +  #
> > +  # @return [Integer] representing the requested value.  0 is returned if the
> > +  # kernel is not supported by the REGEX_MAP constant and on Windows.
> > +  def self.get_alias_no(interface, label)
>
> Using a regex like /inet/ would match both inet and inet6. My concern is
> that this method looks like it largely duplicates the functionality of
> .get_interface_value, and if there's a lot of overlap I would like to
> know if there's extra code that we can trim from the function.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/puppetlabs/facter/pull/731/files#r15249598>.
>