Merge "Convert live migration uri back to string"
This commit is contained in:
@@ -7824,9 +7824,12 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
addresses = ('127.0.0.1', '127.0.0.1:4444',
|
||||
'0:0:0:0:0:0:0:1', '[0:0:0:0:0:0:0:1]:4444')
|
||||
'0:0:0:0:0:0:0:1', '[0:0:0:0:0:0:0:1]:4444',
|
||||
u'127.0.0.1', u'destination')
|
||||
for dest in addresses:
|
||||
self.assertEqual('tcp://%s' % dest, drvr._migrate_uri(dest))
|
||||
result = drvr._migrate_uri(dest)
|
||||
self.assertEqual('tcp://%s' % dest, result)
|
||||
self.assertIsInstance(result, str)
|
||||
|
||||
def test_update_volume_xml_no_serial(self):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
|
||||
@@ -695,7 +695,13 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
# libvirt build the URI using the remote hostname and the
|
||||
# tcp schema.
|
||||
uri = 'tcp://%s' % dest
|
||||
return uri
|
||||
# Because dest might be of type unicode, here we might return value of
|
||||
# type unicode as well which is not acceptable by libvirt python
|
||||
# binding when Python 2.7 is in use, so let's convert it explicitly
|
||||
# back to string. When Python 3.x is in use, libvirt python binding
|
||||
# accepts unicode type so it is completely fine to do a no-op str(uri)
|
||||
# conversion which will return value of type unicode.
|
||||
return uri and str(uri)
|
||||
|
||||
def instance_exists(self, instance):
|
||||
"""Efficient override of base instance_exists method."""
|
||||
|
||||
Reference in New Issue
Block a user