Merge "libvirt: move checking CONF.my_ip to init_host()" into stable/queens
This commit is contained in:
commit
6212da3f57
|
@ -1535,6 +1535,9 @@ class FakeLibvirtFixture(fixtures.Fixture):
|
||||||
# NOTE(mdbooth): The strange incantation below means 'this module'
|
# NOTE(mdbooth): The strange incantation below means 'this module'
|
||||||
self.useFixture(fixtures.MonkeyPatch(i, sys.modules[__name__]))
|
self.useFixture(fixtures.MonkeyPatch(i, sys.modules[__name__]))
|
||||||
|
|
||||||
|
self.useFixture(
|
||||||
|
fixtures.MockPatch('nova.compute.utils.get_machine_ips'))
|
||||||
|
|
||||||
disable_event_thread(self)
|
disable_event_thread(self)
|
||||||
|
|
||||||
if self.stub_os_vif:
|
if self.stub_os_vif:
|
||||||
|
|
|
@ -806,6 +806,8 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
|
self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
|
||||||
imagebackend.Image._get_driver_format)
|
imagebackend.Image._get_driver_format)
|
||||||
|
|
||||||
|
self.stub_out('nova.compute.utils.get_machine_ips', lambda: [])
|
||||||
|
|
||||||
self.useFixture(fakelibvirt.FakeLibvirtFixture())
|
self.useFixture(fakelibvirt.FakeLibvirtFixture())
|
||||||
self.test_instance = _create_test_instance()
|
self.test_instance = _create_test_instance()
|
||||||
self.test_image_meta = {
|
self.test_image_meta = {
|
||||||
|
@ -12930,16 +12932,22 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
||||||
|
|
||||||
@mock.patch.object(libvirt_driver.LOG, 'warning')
|
@mock.patch.object(libvirt_driver.LOG, 'warning')
|
||||||
@mock.patch('nova.compute.utils.get_machine_ips')
|
@mock.patch('nova.compute.utils.get_machine_ips')
|
||||||
def test_get_host_ip_addr_failure(self, mock_ips, mock_log):
|
def test_check_my_ip(self, mock_ips, mock_log):
|
||||||
mock_ips.return_value = ['8.8.8.8', '75.75.75.75']
|
mock_ips.return_value = ['8.8.8.8', '75.75.75.75']
|
||||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||||
drvr.get_host_ip_addr()
|
drvr._check_my_ip()
|
||||||
mock_log.assert_called_once_with(u'my_ip address (%(my_ip)s) was '
|
mock_log.assert_called_once_with(u'my_ip address (%(my_ip)s) was '
|
||||||
u'not found on any of the '
|
u'not found on any of the '
|
||||||
u'interfaces: %(ifaces)s',
|
u'interfaces: %(ifaces)s',
|
||||||
{'ifaces': '8.8.8.8, 75.75.75.75',
|
{'ifaces': '8.8.8.8, 75.75.75.75',
|
||||||
'my_ip': mock.ANY})
|
'my_ip': mock.ANY})
|
||||||
|
|
||||||
|
def test_init_host_checks_ip(self):
|
||||||
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||||
|
with mock.patch.object(drvr, '_check_my_ip') as mock_check:
|
||||||
|
drvr.init_host('fake-host')
|
||||||
|
mock_check.assert_called_once_with()
|
||||||
|
|
||||||
def test_conn_event_handler(self):
|
def test_conn_event_handler(self):
|
||||||
self.mox.UnsetStubs()
|
self.mox.UnsetStubs()
|
||||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||||
|
@ -19940,6 +19948,8 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(set([uuids.mdev1]),
|
self.assertEqual(set([uuids.mdev1]),
|
||||||
drvr._get_existing_mdevs_not_assigned())
|
drvr._get_existing_mdevs_not_assigned())
|
||||||
|
|
||||||
|
@mock.patch('nova.compute.utils.get_machine_ips',
|
||||||
|
new=mock.Mock(return_value=[]))
|
||||||
@mock.patch.object(nova.privsep.libvirt, 'create_mdev')
|
@mock.patch.object(nova.privsep.libvirt, 'create_mdev')
|
||||||
@mock.patch.object(libvirt_driver.LibvirtDriver,
|
@mock.patch.object(libvirt_driver.LibvirtDriver,
|
||||||
'_get_mdev_capable_devices')
|
'_get_mdev_capable_devices')
|
||||||
|
|
|
@ -889,6 +889,7 @@ class LibvirtConnTestCase(_VirtDriverTestCase, test.TestCase):
|
||||||
# will try to execute some commands which hangs tests so let's just
|
# will try to execute some commands which hangs tests so let's just
|
||||||
# stub out the unplug call to os-vif since we don't care about it.
|
# stub out the unplug call to os-vif since we don't care about it.
|
||||||
self.stub_out('os_vif.unplug', lambda a, kw: None)
|
self.stub_out('os_vif.unplug', lambda a, kw: None)
|
||||||
|
self.stub_out('nova.compute.utils.get_machine_ips', lambda: [])
|
||||||
|
|
||||||
def _fake_admin_context(self, *args, **kwargs):
|
def _fake_admin_context(self, *args, **kwargs):
|
||||||
return self.ctxt
|
return self.ctxt
|
||||||
|
|
|
@ -500,6 +500,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
|
|
||||||
self._set_multiattach_support()
|
self._set_multiattach_support()
|
||||||
|
|
||||||
|
self._check_my_ip()
|
||||||
|
|
||||||
if (CONF.libvirt.virt_type == 'lxc' and
|
if (CONF.libvirt.virt_type == 'lxc' and
|
||||||
not (CONF.libvirt.uid_maps and CONF.libvirt.gid_maps)):
|
not (CONF.libvirt.uid_maps and CONF.libvirt.gid_maps)):
|
||||||
LOG.warning("Running libvirt-lxc without user namespaces is "
|
LOG.warning("Running libvirt-lxc without user namespaces is "
|
||||||
|
@ -621,6 +623,13 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
'versions of QEMU and libvirt. QEMU must be less than '
|
'versions of QEMU and libvirt. QEMU must be less than '
|
||||||
'2.10 or libvirt must be greater than or equal to 3.10.')
|
'2.10 or libvirt must be greater than or equal to 3.10.')
|
||||||
|
|
||||||
|
def _check_my_ip(self):
|
||||||
|
ips = compute_utils.get_machine_ips()
|
||||||
|
if CONF.my_ip not in ips:
|
||||||
|
LOG.warning('my_ip address (%(my_ip)s) was not found on '
|
||||||
|
'any of the interfaces: %(ifaces)s',
|
||||||
|
{'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)})
|
||||||
|
|
||||||
def _prepare_migration_flags(self):
|
def _prepare_migration_flags(self):
|
||||||
migration_flags = 0
|
migration_flags = 0
|
||||||
|
|
||||||
|
@ -3226,11 +3235,6 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
return self._get_console_output_file(instance, console_log)
|
return self._get_console_output_file(instance, console_log)
|
||||||
|
|
||||||
def get_host_ip_addr(self):
|
def get_host_ip_addr(self):
|
||||||
ips = compute_utils.get_machine_ips()
|
|
||||||
if CONF.my_ip not in ips:
|
|
||||||
LOG.warning('my_ip address (%(my_ip)s) was not found on '
|
|
||||||
'any of the interfaces: %(ifaces)s',
|
|
||||||
{'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)})
|
|
||||||
return CONF.my_ip
|
return CONF.my_ip
|
||||||
|
|
||||||
def get_vnc_console(self, context, instance):
|
def get_vnc_console(self, context, instance):
|
||||||
|
|
Loading…
Reference in New Issue