diff options
author | Zuul <zuul@review.opendev.org> | 2022-08-18 12:31:14 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-08-18 12:31:14 +0000 |
commit | 64995bbe9f4227f7b862deb778358b2996ee5b28 (patch) | |
tree | df8ec8e4efb5440a81b25c0bcc0e61f886aef420 /nova/virt | |
parent | 76528c36df40dbda0e2b8b22aaeb4456b404e1b9 (diff) | |
parent | 184f0074cc5f4609642b52c98a7ccbfc5f892a33 (diff) | |
download | nova-64995bbe9f4227f7b862deb778358b2996ee5b28.tar.gz |
Merge "imagebackend: default by_name image_type to config correctly"
Diffstat (limited to 'nova/virt')
-rw-r--r-- | nova/virt/libvirt/driver.py | 15 | ||||
-rw-r--r-- | nova/virt/libvirt/imagebackend.py | 4 |
2 files changed, 14 insertions, 5 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 5da61e7a3a..d9cf1f203d 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -4804,8 +4804,7 @@ class LibvirtDriver(driver.ComputeDriver): if size == 0 or suffix == '.rescue': size = None - backend = self.image_backend.by_name(instance, 'disk' + suffix, - CONF.libvirt.images_type) + backend = self.image_backend.by_name(instance, 'disk' + suffix) created_disks = not backend.exists() if instance.task_state == task_states.RESIZE_FINISH: @@ -5357,6 +5356,11 @@ class LibvirtDriver(driver.ComputeDriver): self, instance, name, disk_mapping, flavor, image_type=None, boot_order=None, ): + # NOTE(artom) To pass unit tests, wherein the code here is loaded + # *before* any config with self.flags() is done, we need to have the + # default inline in the method, and not in the kwarg declaration. + if image_type is None: + image_type = CONF.libvirt.images_type disk_unit = None disk = self.image_backend.by_name(instance, name, image_type) if (name == 'disk.config' and image_type == 'rbd' and @@ -5381,7 +5385,9 @@ class LibvirtDriver(driver.ComputeDriver): disk_unit=disk_unit, boot_order=boot_order) return conf - def _get_guest_fs_config(self, instance, name, image_type=None): + def _get_guest_fs_config( + self, instance, name, image_type=CONF.libvirt.images_type + ): disk = self.image_backend.by_name(instance, name, image_type) return disk.libvirt_fs_info("/", "ploop") @@ -10730,8 +10736,7 @@ class LibvirtDriver(driver.ComputeDriver): # Creating backing file follows same way as spawning instances. cache_name = os.path.basename(info['backing_file']) - disk = self.image_backend.by_name(instance, instance_disk, - CONF.libvirt.images_type) + disk = self.image_backend.by_name(instance, instance_disk) if cache_name.startswith('ephemeral'): # The argument 'size' is used by image.cache to # validate disk size retrieved from cache against diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index 617adfe030..155267af23 100644 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -1311,6 +1311,10 @@ class Backend(object): :return: An Image object for the disk with given name and instance. :rtype: Image """ + # NOTE(artom) To pass functional tests, wherein the code here is loaded + # *before* any config with self.flags() is done, we need to have the + # default inline in the method, and not in the kwarg declaration. + image_type = image_type or CONF.libvirt.images_type backend = self.backend(image_type) return backend(instance=instance, disk_name=name) |