Merge "tests: work around malformed serial XML"

This commit is contained in:
Zuul 2020-04-02 18:39:25 +00:00 committed by Gerrit Code Review
commit 7520676b28
2 changed files with 12 additions and 12 deletions

View File

@ -21,6 +21,7 @@ from lxml import etree
from oslo_log import log as logging
from oslo_utils.fixture import uuidsentinel as uuids
from nova import conf
from nova.objects import fields as obj_fields
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.virt.libvirt import config as vconfig
@ -40,6 +41,7 @@ def _reset():
LOG = logging.getLogger(__name__)
CONF = conf.CONF
# virDomainState
VIR_DOMAIN_NOSTATE = 0
@ -1069,6 +1071,12 @@ class Domain(object):
</memory>
''' % vpmem
serial_console = ''
if CONF.serial_console.enabled:
serial_console = """<serial type="tcp">
<source host="-1" service="-1" mode="bind"/>
</serial>"""
return '''<domain type='kvm'>
<name>%(name)s</name>
<uuid>%(uuid)s</uuid>
@ -1096,17 +1104,7 @@ class Domain(object):
function='0x1'/>
</controller>
%(nics)s
<serial type='file'>
<source path='dummy.log'/>
<target port='0'/>
</serial>
<serial type='pty'>
<source pty='/dev/pts/27'/>
<target port='1'/>
</serial>
<serial type='tcp'>
<source host="-1" service="-1" mode="bind"/>
</serial>
%(serial_console)s
<console type='file'>
<source path='dummy.log'/>
<target port='0'/>
@ -1135,7 +1133,8 @@ class Domain(object):
'disks': disks,
'nics': nics,
'hostdevs': hostdevs,
'vpmems': vpmems}
'vpmems': vpmems,
'serial_console': serial_console}
def managedSave(self, flags):
self._connection._mark_not_running(self)

View File

@ -572,6 +572,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
@catch_notimplementederror
def test_get_serial_console(self):
self.flags(enabled=True, group='serial_console')
instance_ref, network_info = self._get_running_instance()
serial_console = self.connection.get_serial_console(self.ctxt,
instance_ref)