← Back to team overview

cloud-init team mailing list archive

Re: use of network utilities


On 19/12/2017 17:05, Robert Schweikert wrote:
On 12/19/2017 10:14 AM, Scott Moser wrote:
The goal is to get off of net-tools (ifconfig and route) and over to 'ip'.
For freebsd and other things that do not have that, we'll have to keep

Ini python3, 'ipaddress'  is built in and we may be able to utilize it, but
I'm not interested in adding the python2 dependency.
Does that imply that as long we support python2 we should shell out,
i.e. use

if util.which('netstat'):
     return _route_info_from_netstat()
elif util.which('ip'):
     return _route_info_from_ip()

Considering your direction - I would go more towards:

if util.which('ip'):
    return _route_info_from_ip()
elif util.which('netstat'):
    return _route_info_from_netstat()

As, imho, you do not want to care if netstat is available UNLESS 'ip' is not available.

And, although it may be more work (initially) - are there library routines that can get the info you are looking for? I doubt it is uuid* family of calls, but there must be ways to call "what the *net*-utils call - rather than spawning subprocesses.
The hopeful upside is that that may be more portable than dealing with each potential distro change to "stdout" information.

which is the direction I am working on now. I have the device
information collection under control, working on the route information now.

This direction would:
   - avoid adding any new dependency for python2
   - having to differentiate dependencies based on python version
   - handle the freebsd case transparently