Skip to content

Bug #15001#240

Closed
trlinkin wants to merge 2 commits intopuppetlabs:1.6.xfrom
trlinkin:Bug_#15001
Closed

Bug #15001#240
trlinkin wants to merge 2 commits intopuppetlabs:1.6.xfrom
trlinkin:Bug_#15001

Conversation

@trlinkin
Copy link

I did not want to upstage the previous submitted solution to this problem. However, I did want to submit a change that supported unit testing. I did not fully qualify the 'ip' command since I see 'Facter::Util::Resolution.exec' now supports an internal 'which like' functionality that does not need to fork, and also checks in '/sbin' by default. I'll leave it up to others to convert and write tests for the other kernel types.

@Elwell
Copy link

Elwell commented Jun 14, 2012

Ah excellent - I wasn't aware of Facter::Util::Resolution.exec so I'll use that. As I said in the comments on my patch, I've just reaslised it can be refactored much cleaner if I use the same methodology as the ipv6 variant (stick the regexp in a separate function) - we should be able to get a nice clean solution between these :-)

@trlinkin
Copy link
Author

Sure! I agree, I think the whole thing needs a larger overall reactor. I was trying to leave this patch only in the context of the bug on Linux. Perhaps a refactor ticket should be opened for this fact in all its various forms.

@eshamow
Copy link

eshamow commented Jun 14, 2012

Tom,

Please clean up the commit comment to match the style in the README - take a look at recent commits for an example.

In terms of code, my only concern is whether or not "ip addr" is in fact sufficiently cross-platform. If we can confirm it is (did you run the tests on multiple OSes?) then I think this is good stuff.

@eshamow
Copy link

eshamow commented Jun 14, 2012

Sorry, another comment - I would rebase to make one commit as well.

This commit changes the version of the ipaddress fact that is confined with Linux to use
the 'ip' command.Recent versions of net-tool have stated that ifconfig is obsolete. It
also states to rely on 'ip addr' as a replacement. The output was also changed to be more
like that of the 'ip addr' output.

This commit also changes the fact to use
'Facter::Util::Resolution.exec'. The 'ip' command is left unqualified since the recent
changes to 'Facter::Util::Resolution.exec' include functionality that mimics the 'which'
command but does not need to fork. The switch to 'Facter::Util::Resolution.exec'
also allows for unit tests, which are part of this commit.
@trlinkin
Copy link
Author

Eric, I did the rebase. Also, ifconfig is being made obsolete by iproute2, which has been available (and should have been included in systems) for over a decade.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing Facter::Util::Config.stubs(:is_windows?).returns(false) and Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux') it would be better, and a little safer for testing, just to do Facter.fact(:kernel).stubs(:value).returns("Linux").

This commit changes the stubbing used in the spec test as recommended by Hailee Kenney. This
new stubbing will remove a dependancy on the :kernel fact. Now, if the :kernel fact is broken,
this test will still work for its original purpose, which is to test the :ipaddress fact.
@trlinkin
Copy link
Author

Hkenny, I see exactly what you're talking about. It was dependent on the proper function of the :kernel fact. I've added a commit to change that. Thanks for the advice. This should probably be changed in the :ipaddress6 fact as that is what I based this unit test off of.

@HAIL9000
Copy link

@trlinkin Thanks for making that change! And thanks for pointing out the issue with the ipaddress6 fact, I'll take a look at it.

@slippycheeze
Copy link

From the ticket:

I don't think this can go in as-is. Unfortunately, while the ip tool from iproute2 is decidedly the superior way to get this information, it isn't standard or required on all Linux distributions. Despite the decade of availability. :/

We really need to prefer using it if available, but to fall back to ifconfig parsing when it can't be found.

whopper pushed a commit to whopper/facter that referenced this pull request Mar 18, 2015
…t_update

(CFACT-162) Update uptime regular expressions for additional formats
florindragos pushed a commit that referenced this pull request Jun 15, 2020
* (FACT-2265) Add wildcard legacy facts
* Delete old legacy supression mechanism
* (FACT-2265) Fix rspec
* (FACT-2265) Resolve comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants