Python 3: specify a bytes to an argument for a format type 's' of struct.pack()
In python 3, a format type 's' of struct.pack() requires a bytes object to an argument. Change-Id: Ia4640b31c31b5b7454cd1582af46562fb1885726 Blueprint: neutron-python3
This commit is contained in:
parent
75c1500b67
commit
9744ef78e6
|
@ -33,6 +33,7 @@ from oslo_log import log as logging
|
|||
from oslo_log import loggers
|
||||
from oslo_rootwrap import client
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
from six.moves import http_client as httplib
|
||||
|
||||
from neutron.agent.common import config
|
||||
|
@ -149,8 +150,10 @@ def get_interface_mac(interface):
|
|||
MAC_START = 18
|
||||
MAC_END = 24
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
info = fcntl.ioctl(s.fileno(), 0x8927,
|
||||
struct.pack('256s', interface[:constants.DEVICE_NAME_MAX_LEN]))
|
||||
dev = interface[:constants.DEVICE_NAME_MAX_LEN]
|
||||
if isinstance(dev, six.text_type):
|
||||
dev = dev.encode('utf-8')
|
||||
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', dev))
|
||||
return ''.join(['%02x:' % ord(char)
|
||||
for char in info[MAC_START:MAC_END]])[:-1]
|
||||
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -208,6 +208,7 @@ commands = python -m testtools.run \
|
|||
neutron.tests.unit.agent.linux.test_bridge_lib \
|
||||
neutron.tests.unit.agent.linux.test_ip_link_support \
|
||||
neutron.tests.unit.agent.linux.test_interface \
|
||||
neutron.tests.unit.agent.linux.test_utils \
|
||||
neutron.tests.unit.agent.dhcp.test_agent \
|
||||
neutron.tests.unit.test_manager \
|
||||
neutron.tests.unit.test_service \
|
||||
|
|
Loading…
Reference in New Issue