update to setparams check to avoid python3 errors, and fix to ipprefix

This commit is contained in:
bharnden 2019-06-02 22:53:39 -07:00
parent 40176e861d
commit db9d13aff8
2 changed files with 5 additions and 2 deletions

View file

@ -141,8 +141,11 @@ class CoreInterface(object):
:return: True if parameter changed, False otherwise
"""
# treat None and 0 as unchanged values
if value is None or value <= 0:
return False
current_value = self._params.get(key)
if value is None or current_value == value or current_value <= 0 and value <= 0:
if current_value is not None and current_value == value:
return False
self._params[key] = value

View file

@ -236,7 +236,7 @@ class IpPrefix(object):
self.prefixlen = int(tmp[1])
else:
self.prefixlen = self.addrlen
self.prefix = socket.inet_pton(self.af, tmp[0]).decode("ISO-8859-1")
self.prefix = socket.inet_pton(self.af, tmp[0])
if self.addrlen > self.prefixlen:
addrbits = self.addrlen - self.prefixlen
netmask = ((1 << self.prefixlen) - 1) << addrbits