Re: [PATCH rhel6-branch] Fix prototype of getIPAddresses (#605659)

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

 



Ack.

On 06/30/2010 09:53 AM, Radek Vykydal wrote:
Return only ipv4 addresses (by default) or ipv6 addresses, never
both.
---
  isys/isys.py |   14 +++++++-------
  1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/isys/isys.py b/isys/isys.py
index 55c7165..449ba5c 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -511,10 +511,9 @@ def isWireless(dev):
          return False

  # Get IP addresses for a network device.
-# Returns list of ipv4 and ipv6 addresses.
-# With version=4 returns only ipv4 addresses,
-# with version=6 returns only ipv6 addresses.
-def getIPAddresses(dev, version=None):
+# Returns list of ipv4 or ipv6 addresses, depending
+# on version parameter. ipv4 is default.
+def getIPAddresses(dev, version=4):
      if dev == '' or dev is None:
         return None

@@ -526,7 +525,7 @@ def getIPAddresses(dev, version=None):

      addresses = []

-    if not version == 6:
+    if version == 4:
          ip4_config_path = device_props_iface.Get(NM_DEVICE_IFACE, 'Ip4Config')
          if ip4_config_path != '/':
              ip4_config_obj = bus.get_object(NM_SERVICE, ip4_config_path)
@@ -542,8 +541,7 @@ def getIPAddresses(dev, version=None):
                  except ValueError as e:
                      log.debug("Exception caught trying to convert IP address %s: %s" %
                      (addr, e))
-
-    if not version == 4:
+    elif version == 6:
          ip6_config_path = device_props_iface.Get(NM_DEVICE_IFACE, 'Ip6Config')
          if ip6_config_path != '/':
              ip6_config_obj = bus.get_object(NM_SERVICE, ip6_config_path)
@@ -560,6 +558,8 @@ def getIPAddresses(dev, version=None):
                  except ValueError as e:
                      log.debug("Exception caught trying to convert IP address %s: %s" %
                      (addr, e))
+    else:
+        raise ValueError, "invalid IP version %d" % version

      return addresses


_______________________________________________
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