summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-12-07 16:52:37 +0000
committerGerrit Code Review <review@openstack.org>2017-12-07 16:52:37 +0000
commit81544829d14aebaaa717ffbe6ec33c67a2f11b7f (patch)
tree4fd70936699e8a14642db4043ec22a62536d69e4
parentadc4d4a29d108c87f884c779af5696e4941b9549 (diff)
parent3f8daf080411b84ec0669f0642524ce8a7d19057 (diff)
Merge "libvirt: Re-initialise volumes, encryptors, and vifs on hard reboot"17.0.0.0b2
-rwxr-xr-xnova/tests/unit/virt/libvirt/test_driver.py13
-rw-r--r--nova/virt/libvirt/driver.py19
2 files changed, 16 insertions, 16 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index aa2f0ba..548ef1a 100755
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -12103,16 +12103,15 @@ class LibvirtConnTestCase(test.NoDBTestCase,
12103 mock_hard_reboot.assert_called_once_with(self.context, 12103 mock_hard_reboot.assert_called_once_with(self.context,
12104 instance, [], None) 12104 instance, [], None)
12105 12105
12106 @mock.patch('nova.virt.libvirt.LibvirtDriver._undefine_domain')
12107 @mock.patch('nova.virt.libvirt.LibvirtDriver.get_info') 12106 @mock.patch('nova.virt.libvirt.LibvirtDriver.get_info')
12108 @mock.patch('nova.virt.libvirt.LibvirtDriver._create_domain_and_network') 12107 @mock.patch('nova.virt.libvirt.LibvirtDriver._create_domain_and_network')
12109 @mock.patch('nova.virt.libvirt.LibvirtDriver._get_guest_xml') 12108 @mock.patch('nova.virt.libvirt.LibvirtDriver._get_guest_xml')
12110 @mock.patch('nova.virt.libvirt.LibvirtDriver.' 12109 @mock.patch('nova.virt.libvirt.LibvirtDriver.'
12111 '_get_instance_disk_info_from_config') 12110 '_get_instance_disk_info_from_config')
12112 @mock.patch('nova.virt.libvirt.LibvirtDriver._destroy') 12111 @mock.patch('nova.virt.libvirt.LibvirtDriver.destroy')
12113 def test_hard_reboot(self, mock_destroy, mock_get_disk_info, 12112 def test_hard_reboot(self, mock_destroy, mock_get_disk_info,
12114 mock_get_guest_xml, mock_create_domain_and_network, 12113 mock_get_guest_xml, mock_create_domain_and_network,
12115 mock_get_info, mock_undefine): 12114 mock_get_info):
12116 self.context.auth_token = True # any non-None value will suffice 12115 self.context.auth_token = True # any non-None value will suffice
12117 instance = objects.Instance(**self.test_instance) 12116 instance = objects.Instance(**self.test_instance)
12118 network_info = _fake_network_info(self, 1) 12117 network_info = _fake_network_info(self, 1)
@@ -12160,13 +12159,13 @@ class LibvirtConnTestCase(test.NoDBTestCase,
12160 for name in ('disk', 'disk.local'): 12159 for name in ('disk', 'disk.local'):
12161 self.assertTrue(disks[name].cache.called) 12160 self.assertTrue(disks[name].cache.called)
12162 12161
12163 mock_destroy.assert_called_once_with(instance) 12162 mock_destroy.assert_called_once_with(self.context, instance,
12164 mock_undefine.assert_called_once_with(instance) 12163 network_info, destroy_disks=False,
12164 block_device_info=block_device_info)
12165 12165
12166 mock_create_domain_and_network.assert_called_once_with(self.context, 12166 mock_create_domain_and_network.assert_called_once_with(self.context,
12167 dummyxml, instance, network_info, 12167 dummyxml, instance, network_info,
12168 block_device_info=block_device_info, 12168 block_device_info=block_device_info)
12169 reboot=True, vifs_already_plugged=True)
12170 12169
12171 @mock.patch('oslo_utils.fileutils.ensure_tree') 12170 @mock.patch('oslo_utils.fileutils.ensure_tree')
12172 @mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall') 12171 @mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall')
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 407b9da..33a0f47 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2501,12 +2501,15 @@ class LibvirtDriver(driver.ComputeDriver):
2501 re-creates the domain to ensure the reboot happens, as the guest 2501 re-creates the domain to ensure the reboot happens, as the guest
2502 OS cannot ignore this action. 2502 OS cannot ignore this action.
2503 """ 2503 """
2504 2504 # NOTE(mdbooth): In addition to performing a hard reboot of the domain,
2505 self._destroy(instance) 2505 # the hard reboot operation is relied upon by operators to be an
2506 # Domain XML will be redefined so we can safely undefine it 2506 # automated attempt to fix as many things as possible about a
2507 # from libvirt. This ensure that such process as create serial 2507 # non-functioning instance before resorting to manual intervention.
2508 # console for guest will run smoothly. 2508 # With this goal in mind, we tear down all the aspects of an instance
2509 self._undefine_domain(instance) 2509 # we can here without losing data. This allows us to re-initialise from
2510 # scratch, and hopefully fix, most aspects of a non-functioning guest.
2511 self.destroy(context, instance, network_info, destroy_disks=False,
2512 block_device_info=block_device_info)
2510 2513
2511 # Convert the system metadata to image metadata 2514 # Convert the system metadata to image metadata
2512 # NOTE(mdbooth): This is a workaround for stateless Nova compute 2515 # NOTE(mdbooth): This is a workaround for stateless Nova compute
@@ -2542,9 +2545,7 @@ class LibvirtDriver(driver.ComputeDriver):
2542 # Initialize all the necessary networking, block devices and 2545 # Initialize all the necessary networking, block devices and
2543 # start the instance. 2546 # start the instance.
2544 self._create_domain_and_network(context, xml, instance, network_info, 2547 self._create_domain_and_network(context, xml, instance, network_info,
2545 block_device_info=block_device_info, 2548 block_device_info=block_device_info)
2546 reboot=True,
2547 vifs_already_plugged=True)
2548 self._prepare_pci_devices_for_use( 2549 self._prepare_pci_devices_for_use(
2549 pci_manager.get_instance_pci_devs(instance, 'all')) 2550 pci_manager.get_instance_pci_devs(instance, 'all'))
2550 2551