Fix python3 issues with devstack

etree.tostring() needs to be massaged before calling libvirt's
baselineCPU or we will end up with a problem. This can be easily
recreated using:
http://paste.openstack.org/show/593069/
the fix was tested using:
http://paste.openstack.org/show/593070/

We need to send bytes to Popen.communicate under python3:
https://docs.python.org/3/library/subprocess.html?highlight=communicate#subprocess.Popen.communicate

Change-Id: I0ec47f99be8c3e4cb5ac5a6f7343354cc2de380c
This commit is contained in:
Davanum Srinivas 2016-12-21 16:43:29 -05:00
parent 7ead11ba5d
commit 1a2db4cdc0
3 changed files with 8 additions and 2 deletions

View File

@ -371,7 +371,7 @@ class IptablesManager(object):
all_lines[start:end], table, table_name)
table.dirty = False
self.execute('%s-restore' % (cmd,), '-c', run_as_root=True,
process_input='\n'.join(all_lines),
process_input=six.b('\n'.join(all_lines)),
attempts=5)
LOG.debug("IPTablesManager.apply completed with success")

View File

@ -714,8 +714,11 @@ class Host(object):
if (hasattr(libvirt, 'VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES')
and self._caps.host.cpu.model is not None):
try:
xml_str = self._caps.host.cpu.to_xml()
if six.PY3:
xml_str = xml_str.decode('utf-8')
features = self.get_connection().baselineCPU(
[self._caps.host.cpu.to_xml()],
[xml_str],
libvirt.VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
if features:
cpu = vconfig.LibvirtConfigCPU()

View File

@ -30,6 +30,9 @@ class Dom0IptablesFirewallDriver(firewall.IptablesFirewallDriver):
def _plugin_execute(self, *cmd, **kwargs):
# Prepare arguments for plugin call
args = {}
process_input = kwargs.get('process_input', None)
if process_input is not None and isinstance(process_input, bytes):
kwargs['process_input'] = process_input.decode('utf-8')
args.update(map(lambda x: (x, str(kwargs[x])), kwargs))
args['cmd_args'] = jsonutils.dumps(cmd)
ret = self._session.call_plugin('xenhost.py', 'iptables_config', args)