'Tests that the xml is logged when enabling hairpin mode for the
domain fails.'

def test_create_domain_enable_hairpin_fails(self):

    self.flags(use_neutron=False)
    fake_xml = '<test>this    is    a    test</test>'
    fake_domain = FakeVirtDomain(fake_xml)
    def fake_execute(*args, **kwargs):
        raise processutils.ProcessExecutionError('error')
    def fake_get_interfaces(*args):
        return ['dev']
    self.log_error_called = False
    def fake_error(msg, *args, **kwargs):
        self.log_error_called = True
        self.assertIn(fake_xml, (msg % args))
    self.stubs.Set(nova.virt.libvirt.guest.LOG, 'error', fake_error)
    self.create_fake_libvirt_mock()
    self.mox.ReplayAll()
    drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
    self.stubs.Set(nova.utils, 'execute', fake_execute)
    self.stubs.Set(nova.virt.libvirt.guest.Guest, 'get_interfaces', fake_get_interfaces)
    self.assertRaises(processutils.ProcessExecutionError, drvr._create_domain, domain=fake_domain, power_on=False)
    self.assertTrue(self.log_error_called)
