Add new configuration option live_migration_scheme

This change adds a new configuration option to change scheme that is used
for live migrations. The change also deprecates old live_migration_uri
in favor of two other flags:

* live_migraton_inbound_addr to configure live migration target URI
* live_migration_scheme to change scheme used for live migration

The new configuration option does not break backward compatibility as
it does not override scheme set in live_migration_uri.

Change-Id: I38b3d1d42b2ffc4a2f6d7398061829d3c745b9a1
This commit is contained in:
Pawel Koniszewski 2017-01-11 17:43:40 +01:00
parent 8601b2c496
commit df334b4f41
4 changed files with 66 additions and 4 deletions

View File

@ -259,6 +259,13 @@ Possible values:
# TODO(hieulq): change to URIOpt for validating schemas with next release
# of oslo_config.
cfg.StrOpt('live_migration_uri',
deprecated_for_removal=True,
deprecated_since="15.0.0",
deprecated_reason="""
live_migration_uri is deprecated for removal in favor of two other options that
allow to change live migration scheme and target URI: ``live_migration_scheme``
and ``live_migration_inbound_addr`` respectively.
""",
help="""
Live migration target URI to use.
@ -277,6 +284,23 @@ Related options:
* ``live_migration_inbound_addr``: If ``live_migration_inbound_addr`` value
is not None, the ip/hostname address of target compute node is used instead
of ``live_migration_uri`` as the uri for live migration.
* ``live_migration_scheme``: If ``live_migration_uri`` is not set, the scheme
used for live migration is taken from ``live_migration_scheme`` instead.
"""),
cfg.StrOpt('live_migration_scheme',
help="""
Schema used for live migration.
Override the default libvirt live migration scheme (which is dependant on
virt_type). If this option is set to None, nova will automatically choose a
sensible default based on the hypervisor. It is not recommended that you change
this unless you are very sure that hypervisor supports a particular scheme.
Related options:
* ``virt_type``: This option is meaningful only when ``virt_type`` is set to
`kvm` or `qemu`.
* ``live_migration_uri``: If ``live_migration_uri`` value is not None, the
scheme used for live migration is taken from ``live_migration_uri`` instead.
"""),
cfg.BoolOpt('live_migration_tunnelled',
default=False,

View File

@ -7825,6 +7825,21 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.assertEqual(forced_uri % dest, drvr._live_migration_uri(dest))
def test_live_migration_scheme(self):
self.flags(live_migration_scheme='ssh', group='libvirt')
dest = 'destination'
uri = 'qemu+ssh://%s/system'
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.assertEqual(uri % dest, drvr._live_migration_uri(dest))
def test_live_migration_scheme_does_not_override_uri(self):
forced_uri = 'qemu+ssh://%s/system'
self.flags(live_migration_uri=forced_uri, group='libvirt')
self.flags(live_migration_scheme='tcp', group='libvirt')
dest = 'destination'
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.assertEqual(forced_uri % dest, drvr._live_migration_uri(dest))
def test_migrate_uri(self):
hypervisor_uri_map = (
('xen', None),

View File

@ -684,15 +684,25 @@ class LibvirtDriver(driver.ComputeDriver):
# Only Xen and QEMU support live migration, see
# https://libvirt.org/migration.html#scenarios for reference
uris = {
'kvm': 'qemu+tcp://%s/system',
'qemu': 'qemu+tcp://%s/system',
'kvm': 'qemu+%s://%s/system',
'qemu': 'qemu+%s://%s/system',
'xen': 'xenmigr://%s/system',
}
virt_type = CONF.libvirt.virt_type
uri = CONF.libvirt.live_migration_uri or uris.get(virt_type)
# TODO(pkoniszewski): Remove fetching live_migration_uri in Pike
uri = CONF.libvirt.live_migration_uri
if uri:
return uri % dest
uri = uris.get(virt_type)
if uri is None:
raise exception.LiveMigrationURINotAvailable(virt_type=virt_type)
return uri % dest
str_format = (dest,)
if virt_type in ('kvm', 'qemu'):
scheme = CONF.libvirt.live_migration_scheme or 'tcp'
str_format = (scheme, dest)
return uris.get(virt_type) % str_format
@staticmethod
def _migrate_uri(dest):

View File

@ -0,0 +1,13 @@
---
deprecations:
- |
The ``live_migration_uri`` option in the [libvirt] configuration section
is deprecated, and will be removed in a future release. The
``live_migration_scheme`` should be used to change scheme used for live
migration, and ``live_migration_inbound_addr`` should be used to change
target URI.
features:
- |
The libvirt driver now has a ``live_migration_scheme`` configuration
option which should be used where the ``live_migration_uri`` would
previously have been configured with non-default scheme.