Skip to content
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

Feature: Multiple inet4 address for a single interface #27

Merged
merged 2 commits into from
May 24, 2018

Conversation

lowell80
Copy link
Contributor

This feature branch attempts to resolve #20

This patch adds a new output list called "inet4" which contains all IPv4 addresses listed. The "inet" field is also still present, containing the first IPv4 address encountered. (So for most users, they will see no difference.)

Two new unit tests were added: one for linux and one for Mac OS X.

Known limitation: In the situation where multiple inet4 addresses exist on the same interface using different netmasks an exception will still be thrown. (I wasn't able to find an example test case for this.)
This isn't ideal, but it still supports more configurations then it did before without breaking backwards compatibility.

lowell80 added 2 commits May 22, 2018 21:15
- Adds support for capturing multiple IPv4 addresses via the 'inet4' field.
  The existing 'inet' field is preserved for backwards compatibility by simply
  grabbing the very first 'inet4' address found.  (The previous behavior was to
  raise an exception.)
- All existing 'inet' regex matching groups have been renamed to 'inet4'.
- Added a new MacOSX unit test to validate this new 'inet4' output behavior.
- Updated the README to show the new output field.
Created unit test based on sample data provided by user in issue ftao#20: "ifcfg does not see multiple ip addresses on one interfaces"
@codecov-io
Copy link

Codecov Report

Merging #27 into master will increase coverage by 0.37%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
+ Coverage   88.72%   89.09%   +0.37%     
==========================================
  Files           4        4              
  Lines         204      211       +7     
==========================================
+ Hits          181      188       +7     
  Misses         23       23
Impacted Files Coverage Δ
src/ifcfg/parser.py 86.11% <100%> (+0.7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ae9527...089fcba. Read the comment docs.

@benjaoming
Copy link
Collaborator

Awesome! I like that you added new tests, so we can see that the old single-address tests still work just fine.

Code also looks good, and will make it easy to deprecate inet if ultimately desired (the name is ambiguous anyways.. is it v4 or v6?)

It's fair game that other platforms will have to add their versions of multi-address output. Perhaps the most critical is converntional linux-based ifconfig, recent Debian, Raspbian etc...

Anyways, I'd okay this, as it poses no backwards incompats. @ftao any comments here?

@ftao
Copy link
Owner

ftao commented May 23, 2018

I agree . The code looks good.

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.

ifcfg does not see multiple ip addresses on one interfaces
4 participants