Re: [PATCH rhel6-branch] Account for ipv6 addresses too (#594090)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Lumens wrote:
-# Get the IP address for a network device.
-def getIPAddress(dev):
+# Get the IP addresses for a network device.
+# returns dict of lists with keys 'ipv4' and 'ipv6'
+def getIPAddresses(dev):
     if dev == '' or dev is None:
        return None

You return a dict of two lists, but in the two places getIPAddresses is
called, you only use the concatenation of those two lists.  It looks to
me like it makes more sense to always return a single list.  We can
always figure out if an address is IPv6 or not later, should we care.

In one of the places, the order is important and the caller
code seems more readable to me with getIPAddresses returning
the dict because suggested list would require to detect type and sort
addresses in the list (I don't like the idea of having another
function/code doing this), or it would have to rely on assumption
of order addresses returned in the list.

How about having a parameter version='ipv4' to return ipv4 addresses
only, 'ipv6' to return ipv6 addresses and None to return list as
you suggested?

The caller code would be then:

ips = (isys.getIPAddresses(devname, version='ipv4') +
      isys.getIPAddresses(devname, version='ipv6'))

... of course we could rely on implicit order ipv4, ipv6, but I like
to be more explicit for code reader.

Radek

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux