-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display facts for aliases in *BSD #731
Conversation
…l count * 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
@nulldowntime are you the original author of this code? Looking at the FreeBSD ticket indicates that there was code implemented for this earlier and in order to accept this we need a CLA signed from the original author before we can accept it. |
@jasperla could you eyeball this pull request and see if it's suitable to OpenBSD as well? |
# @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) | ||
if Facter.value(:kernel) == 'windows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code guaranteed to be correct on Linux, Solaris, AIX, and other platforms as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux, AIX, Solaris alias interfaces are seen as completely new interfaces, this will not affect any platform that sees an interface alias as a new interface.
eg:
Linux sees: ipaddress_eth0:0
Solaris sees: ipaddress_hme0.1
etc..
Is there an issue on tickets.puppetlabs.com associated with this pull request? |
Hi, I've modified someone else's code, so it's only partially mine (the new Regards,
|
Waiting for CLA signature by @nulldowntime @nulldowntime - We require a Contributor License Agreement (CLA) for people who contribute to Puppet, but we have an easy click-through license with instructions, which is available at https://cla.puppetlabs.com/ Note: if your contribution is trivial and you think it may be exempt from the CLA, please post a short reply to this comment with details. http://docs.puppetlabs.com/community/trivial_patch_exemption.html |
OK, CLA signed. Regards, On 16 July 2014 20:00, puppetcla notifications@github.com wrote:
|
CLA signed by all contributors. |
Ill test this on OpenBSD tomorrow morning. |
Looking at the FreeBSD bug report made me notice this comment:
@nulldowntime did you address this in your patches to the original change? |
My code doesn't iterate from 0 to 9 but uses a new method that returns Regards, On 16 July 2014 22:21, Adrien Thebo notifications@github.com wrote:
|
The sort of race condition where an alias is deleted while interfaces are being enumerated is so unlikely that we don't need to worry about it, thanks for clarifying that! |
# @api private | ||
# | ||
# @return [String] representing the requested value. An empty array is | ||
# returned if the kernel is not supported by the REGEX_MAP constant. | ||
def self.get_interface_value(interface, label) | ||
def self.get_interface_value(interface, label, intalias = -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is -1 used as the starting index of the interface aliases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not "my piece", but I suppose the reason would be that traditionally aliases in FreeBSD are (and have to be) configured in /etc/rc.conf beginning with 0. So alias0 makes sense and corresponds to something that HAS to exist if you're using aliases. It's only an "associative" as ifconfig doesn't actually list "alias0, alias1, alias2", but for anyone comparing facter output with what's configured via /etc/rc.conf it makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, however just for reference - the order of adding ( set in /etc/rc.conf by the numeric suffix of the alias definition ) will result in the alias order (alias 0..n ) .. Whilst specifying _alias0 _alias3 in /etc/rc.conf will work, it's highly frowned on as many scripts reading the config will not process correctly (particularly if they are trying to match to 'live' aliases)
The original author has signed the CLA so we can go ahead with this pull request. |
Seems to be doing the right thing on OpenBSD too:
|
@jasperla thanks for the verification! |
Since I own a FreeBSD's bug that relies on this code being merged, I wonder is there any ETA for merging it and releasing Facter update with that code? |
@bartekrutkowski before we merge this we need to have unit tests added first; I've been working on tests myself but if anyone else is feeling intrepid some help would be appreciated. |
@bartekrutkowski I failed to ask this earlier - do you have a specific time that you need this to be handled or are you just making sure this has forward momentum? |
The reason I am asking is becasue of two things mostly - this functionality is needed in Facter for BSD users and the general policy is to not to maintain our own set of patches if they can be accepted by upstream (in this case, you guys). This means my hands are tied until you accept the patch and release new version so I could update our port of Facter, and I am interested if this is happening, and if it does, then when, because if this is going to be merged in version that's far away from us, it might have some sense to maintain the patch in Ports tree unless the version having it is released. Hope that helps! |
# | ||
# @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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method is simply enumerating the number of addresses defined for a given interface, why do we need to scan for a user specified label? Given output like so:
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
>.......options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
>.......inet 10.0.2.21 netmask 0xffffffff.
>.......inet 10.0.2.22 netmask 0xffffffff.
>.......inet 10.0.2.23 netmask 0xffffffff.
>.......inet 10.0.2.24 netmask 0xffffffff.
>.......inet 10.0.2.25 netmask 0xffffffff.
>.......inet 10.0.2.26 netmask 0xffffffff.
>.......inet 10.0.2.27 netmask 0xffffffff.
>.......inet 10.0.2.28 netmask 0xffffffff.
>.......inet 10.0.2.29 netmask 0xffffffff.
>.......inet 10.0.2.30 netmask 0xffffffff
Can't we just count the number of times inet
is specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
There can be a different number of ip and ipv6 aliases, hence the label is
left there.
Regards,
Daniel
On 22 Jul 2014 20:09, "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)
If this method is simply enumerating the number of addresses defined for a
given interface, why do we need to scan for a user specified label? Given
output like so:.......options=600003 .......inet 10.0.2.21 netmask 0xffffffff. .......inet 10.0.2.22 netmask 0xffffffff. .......inet 10.0.2.23 netmask 0xffffffff. .......inet 10.0.2.24 netmask 0xffffffff. .......inet 10.0.2.25 netmask 0xffffffff. .......inet 10.0.2.26 netmask 0xffffffff. .......inet 10.0.2.27 netmask 0xffffffff. .......inet 10.0.2.28 netmask 0xffffffff. .......inet 10.0.2.29 netmask 0xffffffff. .......inet 10.0.2.30 netmask 0xffffffff Can't we just count the number of times `inet` is specified? — Reply to this email directly or view it on GitHub https://github.com/puppetlabs/facter/pull/731/files#r15248979.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, those are good points. Refactoring into a common method would be good.
@bartekrutkowski this would be released in Facter 2.2.0 which is going to be a couple of months away or so, so it make sense to carry a downstream patch in the meantime. I would like to get test coverage added and reduce the amount of duplication in this change before we pull it in to core, so it's your call as to whether you want to pull in the existing pull request or use the final version that we merge. @nulldowntime I would love to get this pull request merged in sooner rather than later, but it would be a big help if you could take a swing at some of the comments I've left - do you think you'll have time to work on this in the next week or so? |
Hi, I should be able to find some time, yes. Regards,
|
@nulldowntime have you had time to do more work on this? |
Since this hasn't seen an update this month, I'm closing this pull request for the time being; if you would like to continue work on this please comment on this pull request and we can reopen it. |
Did this ever end up in the main code base? |
I would say no |
Originated here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190796