Change in vdsm[master]: models: remove __nonzero__ from IPv4 and IPv6
osvoboda at redhat.com
osvoboda at redhat.com
Thu May 28 14:53:21 UTC 2015
Ondřej Svoboda has uploaded a new change for review.
Change subject: models: remove __nonzero__ from IPv4 and IPv6
......................................................................
models: remove __nonzero__ from IPv4 and IPv6
As an intermediate step it was useful but let's follow the "explicit is
better than implicit" paradigm and let both classes act as expected in
a boolean context.
__nonzero__ is also replaced by __bool__ in Python 3 so this increases
compatibility as well.
Change-Id: Ice7607b7259ec8291dd9e75d77d0371ae64a848b
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M vdsm/network/configurators/iproute2.py
M vdsm/network/configurators/pyroute_two.py
M vdsm/network/models.py
3 files changed, 4 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/41588/1
diff --git a/vdsm/network/configurators/iproute2.py b/vdsm/network/configurators/iproute2.py
index 9c72f80..00eb1ac 100644
--- a/vdsm/network/configurators/iproute2.py
+++ b/vdsm/network/configurators/iproute2.py
@@ -220,7 +220,6 @@
class ConfigApplier(object):
-
def _setIpConfig(self, iface):
ipv4 = iface.ipv4
ipv6 = iface.ipv6
@@ -264,7 +263,7 @@
dhclient.shutdown()
def setIfaceConfigAndUp(self, iface):
- if iface.ipv4 or iface.ipv6:
+ if iface.ipv4.address or iface.ipv6.address or iface.ipv6.ipv6autoconf:
self._setIpConfig(iface)
if iface.mtu:
self.setIfaceMtu(iface.name, iface.mtu)
diff --git a/vdsm/network/configurators/pyroute_two.py b/vdsm/network/configurators/pyroute_two.py
index 211c91b..554c95c 100644
--- a/vdsm/network/configurators/pyroute_two.py
+++ b/vdsm/network/configurators/pyroute_two.py
@@ -102,7 +102,7 @@
dhclient.shutdown()
def setIfaceConfigAndUp(self, iface):
- if iface.ipv4 or iface.ipv6:
+ if iface.ipv4.address or iface.ipv6.address or iface.ipv6.ipv6autoconf:
self._setIpConfig(iface)
if iface.mtu:
self.setIfaceMtu(iface.name, iface.mtu)
diff --git a/vdsm/network/models.py b/vdsm/network/models.py
index 9aa519e..5281d28 100644
--- a/vdsm/network/models.py
+++ b/vdsm/network/models.py
@@ -33,8 +33,8 @@
def __init__(self, name, configurator, ipv4=None, ipv6=None,
blockingdhcp=False, mtu=None):
self.name = name
- self.ipv4 = ipv4 if ipv4 is not None else IPv4()
- self.ipv6 = ipv6 if ipv6 is not None else IPv6()
+ self.ipv4 = ipv4 or IPv4()
+ self.ipv6 = ipv6 or IPv6()
self.blockingdhcp = blockingdhcp
self.mtu = mtu
self.configurator = configurator
@@ -388,9 +388,6 @@
self.defaultRoute = defaultRoute
self.bootproto = bootproto
- def __nonzero__(self):
- return bool(self.address or self.bootproto)
-
def __repr__(self):
return 'IPv4(%s, %s, %s, %s, %s)' % (self.address, self.netmask,
self.gateway, self.defaultRoute,
@@ -445,9 +442,6 @@
self.defaultRoute = defaultRoute
self.ipv6autoconf = ipv6autoconf
self.dhcpv6 = dhcpv6
-
- def __nonzero__(self):
- return bool(self.address or self.ipv6autoconf or self.dhcpv6)
def __repr__(self):
return 'IPv6(%s, %s, %s, %s, %s)' % (
--
To view, visit https://gerrit.ovirt.org/41588
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice7607b7259ec8291dd9e75d77d0371ae64a848b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
More information about the vdsm-patches
mailing list