diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-01-26 01:30:30 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-01-26 01:30:30 +0000 |
commit | cefdf1465353abe0d32c56961820343e439efdb1 (patch) | |
tree | 97b55ae17035a3c184f3ca20496fee490e84c325 | |
parent | 13817b4d9c101b93171561181bcc60b7f5a059a8 (diff) | |
parent | eb58ed4f9a1c3a3e228cb7183d2dd8c1d74fd0c2 (diff) | |
download | nova-cefdf1465353abe0d32c56961820343e439efdb1.tar.gz |
Merge "libvirt: safe_decode domain.XMLDesc(0) for i18n logging" into stable/juno
-rw-r--r-- | nova/tests/virt/libvirt/test_driver.py | 5 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/nova/tests/virt/libvirt/test_driver.py b/nova/tests/virt/libvirt/test_driver.py index f4ca753f46..613943bedc 100644 --- a/nova/tests/virt/libvirt/test_driver.py +++ b/nova/tests/virt/libvirt/test_driver.py @@ -59,6 +59,7 @@ from nova.openstack.common import jsonutils from nova.openstack.common import lockutils from nova.openstack.common import loopingcall from nova.openstack.common import processutils +from nova.openstack.common import strutils from nova.openstack.common import timeutils from nova.openstack.common import units from nova.openstack.common import uuidutils @@ -8974,7 +8975,8 @@ Active: 8381604 kB lookup_mock.assert_called_once_with(instance['name']) @mock.patch.object(fake_libvirt_utils, 'get_instance_path') - def test_create_domain(self, mock_get_inst_path): + @mock.patch.object(strutils, 'safe_decode') + def test_create_domain(self, mock_safe_decode, mock_get_inst_path): conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) mock_domain = mock.MagicMock() mock_instance = mock.MagicMock() @@ -8986,6 +8988,7 @@ Active: 8381604 kB self.assertEqual(mock_domain, domain) mock_get_inst_path.assertHasCalls([mock.call(mock_instance)]) mock_domain.createWithFlags.assertHasCalls([mock.call(0)]) + self.assertEqual(2, mock_safe_decode.call_count) @mock.patch('nova.virt.disk.api.clean_lxc_namespace') @mock.patch('nova.virt.libvirt.driver.LibvirtDriver.get_info') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 541823db03..cec2013631 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -76,6 +76,7 @@ from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common import loopingcall from nova.openstack.common import processutils +from nova.openstack.common import strutils from nova.openstack.common import timeutils from nova.openstack.common import units from nova.openstack.common import xmlutils @@ -4333,12 +4334,14 @@ class LibvirtDriver(driver.ComputeDriver): if power_on: err = _LE('Error launching a defined domain with XML: %s') \ - % domain.XMLDesc(0) + % strutils.safe_decode(domain.XMLDesc(0), + errors='ignore') domain.createWithFlags(launch_flags) if not utils.is_neutron(): err = _LE('Error enabling hairpin mode with XML: %s') \ - % domain.XMLDesc(0) + % strutils.safe_decode(domain.XMLDesc(0), + errors='ignore') self._enable_hairpin(domain.XMLDesc(0)) except Exception: with excutils.save_and_reraise_exception(): |