ftao / python-ifcfg

Python cross-platform network interface discovery (ifconfig/ipconfig/ip)
BSD 3-Clause "New" or "Revised" License
55 stars 37 forks source link

net-tools #30

Closed ljonsson closed 6 years ago

ljonsson commented 6 years ago

How about adding support for linux distros (ubuntu 16 and 18, rhel 7, etc.) where net-tools (ifconfig) has been deprecated in favor of iproute (ip)?

benjaoming commented 6 years ago

It's really odd that this isn't visible in the README, nor the Changelog - but it's there!

https://github.com/ftao/python-ifcfg/blob/master/src/ifcfg/parser.py#L285

benjaoming commented 6 years ago

It was added here: https://github.com/ftao/python-ifcfg/pull/3

benjaoming commented 6 years ago

Ah, okay, it is in the Changelog... since 0.10, but a bit obscure: * Support for Unix systems w/o ``ifconfig``, for instance newer Ubuntu/Debian

benjaoming commented 6 years ago

Is there anything about this support that isn't working for you, @ljonsson ?

ljonsson commented 6 years ago

It's not detecting that the ifconfig command isn't present and won't use the UnixIPParser instead.

ljonsson@op> grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 18.04 LTS"

ljonsson@op> python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcfg
2018-07-06 09:32:07,827 IFCFG DEBUG : ifcfg : Distro detected as 'Linux'
2018-07-06 09:32:07,827 IFCFG DEBUG : ifcfg : Using '<class 'ifcfg.parser.LinuxParser'>'
>>> print ifcfg.__version__
0.16
>>> 
benjaoming commented 6 years ago

Oh right, I see, thanks for pointing me to this!

It doesn't work indeed...

$ python -m ifcfg.cli
{}
benjaoming commented 6 years ago

Thanks for fixing this in #32 @ljonsson !

benjaoming commented 6 years ago

Released as 0.17