Skip to content

Commit eade0a9

Browse files
author
Ritwick DSouza
committed
[raspbian] Fix py2-ipaddress related unicode bug
1 parent e582248 commit eade0a9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

netjsonconfig/backends/raspbian/converters/interfaces.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from ipaddress import IPv4Interface, ip_network
22

3+
import six
4+
35
from ....utils import get_copy
46
from .base import RaspbianConverter
57

@@ -58,7 +60,7 @@ def _get_address(self, interface):
5860
if address.get('family') == 'ipv4':
5961

6062
address_mask = str(address.get('address')) + '/' + str(address.get('mask'))
61-
address['netmask'] = IPv4Interface(address_mask).with_netmask.split('/')[1]
63+
address['netmask'] = IPv4Interface(six.text_type(address_mask)).with_netmask.split('/')[1]
6264
del address['mask']
6365
if address.get('family') == 'ipv6':
6466
address['netmask'] = address['mask']
@@ -68,14 +70,14 @@ def _get_address(self, interface):
6870
def _get_route(self, routes):
6971
result = []
7072
for route in routes:
71-
if ip_network(route.get('next')).version == 4:
73+
if ip_network(six.text_type(route.get('next'))).version == 4:
7274
route['version'] = 4
73-
destination = IPv4Interface(route['destination']).with_netmask
75+
destination = IPv4Interface(six.text_type(route['destination'])).with_netmask
7476
dest, dest_mask = destination.split('/')
7577
route['dest'] = dest
7678
route['dest_mask'] = dest_mask
7779
del route['destination']
78-
elif ip_network(route.get('next')).version == 6:
80+
elif ip_network(six.text_type(route.get('next'))).version == 6:
7981
route['version'] = 6
8082
result.append(route)
8183
return routes

0 commit comments

Comments
 (0)