Default image.size to 0 when extracting v1 image attributes
When we snapshot a non-volume-backed instance, we create an
image in nova.compute.api.API._create_image and set some
values from the instance but 'size' isn't one of them.
Later in the virt driver's snapshot method, at least for
libvirt, it gets the snapshot image from the image API (glance)
and when using glance v1 (use_glance_v1=True) the _extract_attributes
method in nova.image.glance pulls the attributes out of the v1 image
response to the form that nova expects. This code assumes that
the 'size' attribute is set on the image, which for a snapshot image
it might not be (yet anyway). This results in an AttributeError.
This change defaults the size attribute value to 0 if it's not set.
If it is set, but to None, we still use 0 as before.
Reviewed: https:/ /review. openstack. org/347571 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=7a16c754fb4 9615b802e6b8f3d 886847c168bd2a
Committed: https:/
Submitter: Jenkins
Branch: master
commit 7a16c754fb49615 b802e6b8f3d8868 47c168bd2a
Author: Matt Riedemann <email address hidden>
Date: Tue Jul 26 18:27:48 2016 -0400
Default image.size to 0 when extracting v1 image attributes
When we snapshot a non-volume-backed instance, we create an api.API. _create_ image and set some
image in nova.compute.
values from the instance but 'size' isn't one of them.
Later in the virt driver's snapshot method, at least for v1=True) the _extract_attributes
libvirt, it gets the snapshot image from the image API (glance)
and when using glance v1 (use_glance_
method in nova.image.glance pulls the attributes out of the v1 image
response to the form that nova expects. This code assumes that
the 'size' attribute is set on the image, which for a snapshot image
it might not be (yet anyway). This results in an AttributeError.
This change defaults the size attribute value to 0 if it's not set.
If it is set, but to None, we still use 0 as before.
Change-Id: I14b0e44a726823 1c2b19f013b563f 0b8f09c2e88
Closes-Bug: #1606707