summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-07 20:52:38 +0000
committerGerrit Code Review <review@openstack.org>2016-06-07 20:52:39 +0000
commit7495bbeadbe61a6b96bd0f39514651d819d16189 (patch)
treed0e44420f8b5d11530d5c9610d0731836b2e7de8
parent10ab31b625ca64cda7924ad61ca5369ad2e26243 (diff)
parente4f550455e71b5132c451171f7bf14ec386dbf9c (diff)
downloadnova-7495bbeadbe61a6b96bd0f39514651d819d16189.tar.gz
Merge "Fall back to raw config drive if not found in rbd" into stable/liberty
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py30
-rw-r--r--nova/virt/libvirt/driver.py9
2 files changed, 39 insertions, 0 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index 47b53e7cfb..daf4c128d9 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -12309,6 +12309,36 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self._test_get_guest_config_parallels_volume(vm_mode.EXE, 4)
self._test_get_guest_config_parallels_volume(vm_mode.HVM, 6)
+ def test_get_guest_disk_config_rbd_older_config_drive_fall_back(self):
+ # New config drives are stored in rbd but existing instances have
+ # config drives in the old location under the instances path.
+ # Test that the driver falls back to 'raw' for config drive if it
+ # doesn't exist in rbd.
+ self.flags(images_type='rbd', group='libvirt')
+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
+ drvr.image_backend = mock.Mock()
+ mock_rbd_image = mock.Mock()
+ mock_raw_image = mock.Mock()
+ mock_raw_image.libvirt_info.return_value = mock.sentinel.diskconfig
+ drvr.image_backend.image.side_effect = [mock_rbd_image,
+ mock_raw_image]
+ mock_rbd_image.check_image_exists.return_value = False
+ instance = objects.Instance()
+ disk_mapping = {'disk.config': {'bus': 'ide',
+ 'dev': 'hdd',
+ 'type': 'file'}}
+ flavor = objects.Flavor(extra_specs={})
+
+ diskconfig = drvr._get_guest_disk_config(
+ instance, 'disk.config', disk_mapping, flavor,
+ drvr._get_disk_config_image_type())
+
+ self.assertEqual(2, drvr.image_backend.image.call_count)
+ call1 = mock.call(instance, 'disk.config', 'rbd')
+ call2 = mock.call(instance, 'disk.config', 'raw')
+ drvr.image_backend.image.assert_has_calls([call1, call2])
+ self.assertEqual(mock.sentinel.diskconfig, diskconfig)
+
class HostStateTestCase(test.NoDBTestCase):
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 9337e9372c..7e99ba7e48 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -3322,6 +3322,15 @@ class LibvirtDriver(driver.ComputeDriver):
image = self.image_backend.image(instance,
name,
image_type)
+ if (name == 'disk.config' and image_type == 'rbd' and
+ not image.check_image_exists()):
+ # This is likely an older config drive that has not been migrated
+ # to rbd yet. Try to fall back on 'raw' image type.
+ # TODO(melwitt): Add online migration of some sort so we can
+ # remove this fall back once we know all config drives are in rbd.
+ image = self.image_backend.image(instance, name, 'raw')
+ LOG.debug('Config drive not found in RBD, falling back to the '
+ 'instance directory', instance=instance)
disk_info = disk_mapping[name]
return image.libvirt_info(disk_info['bus'],
disk_info['dev'],