When a cinder volume is created from a glance image, the "properties" attached to the glance image are not copied to the cinder volume (in the volume_image_metadata) if the glance V2 API is used. If the glance V1 API is used, the properties are copied correctly.
To illustrate, here is a glance image with a hw_vif_model property defined:
When a volume is created (using glance V1 API) from this image (with "cinder create --image-id 2386997c1a85709759c3d26ba0f11192 --display-name=wrl5-avp-from-volume 1"), the volume_image_metadata for the resulting volume is:
{u'container_format': u'bare', u'min_ram': u'0', u'hw_vif_model': u'avp', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941-cbac-484e-8ef4-5714e01f5c66', u'checksum': u'2386997c1a85709759c3d26ba0f11192', u'min_disk': u'0', u'size': u'507510784'}
When a volume is created using the glance V2 API, the volume_image_metadata is missing the hw_vif_model:
{u'container_format': u'bare', u'min_ram': u'0', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941-cbac-484e-8ef4-5714e01f5c66', u'checksum': u'2386997c1a85709759c3d26ba0f11192', u'min_disk': u'0', u'size': u'507510784'}
With debug logs turned on, the results of the image get from glance are different. For the glance V1 API:
The difference (other than the switch to the json encoding) is that the hw_vif_model is returned as a property in the V1 case and returned as a regular field in the V2 case. From a look at the cinder code, I suspect that the problem happens because the _extract_attributes function (in cinder/image/glance.py) is using a whitelist to copy certain attributes and then copying the "properties" from the image transparently. In the case of the glance V2 API, the hw_vif_model isn't a "property", so it isn't getting copied. Here is the code (from Havana):
When a cinder volume is created from a glance image, the "properties" attached to the glance image are not copied to the cinder volume (in the volume_ image_metadata) if the glance V2 API is used. If the glance V1 API is used, the properties are copied correctly.
To illustrate, here is a glance image with a hw_vif_model property defined:
[root@controller-0 log(keystone_ admin)] # glance image-show wrl5-avp ------- ------- -----+- ------- ------- ------- ------- ------- --+ ------- ------- -----+- ------- ------- ------- ------- ------- --+ 759c3d26ba0f111 92 | 23T15:25: 01.804247 | 3b8e-4cc4- ab9f-c24959492c 22 | 59aa3ec554d62b7 df | 23T15:25: 03.852936 | ------- ------- -----+- ------- ------- ------- ------- ------- --+
+------
| Property | Value |
+------
| Property 'hw_vif_model' | avp |
| checksum | 2386997c1a85709
| container_format | bare |
| created_at | 2014-05-
| deleted | False |
| disk_format | raw |
| id | 78e935d4-
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | wrl5-avp |
| owner | 376000978ffb431
| protected | False |
| size | 507510784 |
| status | active |
| updated_at | 2014-05-
+------
When a volume is created (using glance V1 API) from this image (with "cinder create --image-id 2386997c1a85709 759c3d26ba0f111 92 --display- name=wrl5- avp-from- volume 1"), the volume_ image_metadata for the resulting volume is: format' : u'bare', u'min_ram': u'0', u'hw_vif_model': u'avp', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941- cbac-484e- 8ef4-5714e01f5c 66', u'checksum': u'2386997c1a857 09759c3d26ba0f1 1192', u'min_disk': u'0', u'size': u'507510784'}
{u'container_
When a volume is created using the glance V2 API, the volume_ image_metadata is missing the hw_vif_model: format' : u'bare', u'min_ram': u'0', u'disk_format': u'qcow2', u'image_name': u'wrl5-avp', u'image_id': u'8f1b7941- cbac-484e- 8ef4-5714e01f5c 66', u'checksum': u'2386997c1a857 09759c3d26ba0f1 1192', u'min_disk': u'0', u'size': u'507510784'}
{u'container_
With debug logs turned on, the results of the image get from glance are different. For the glance V1 API:
May 25 12:49:48 localhost 2014-05-25 12:49:48.221 1773 DEBUG glanceclient. common. http [-] HTTP/1.1 200 OK content-length: 0 x-image- meta-status: active x-image-meta-owner: 621793db5e664ca 390af686640b245 43 x-image-meta-name: wrl5-avp x-image- meta-container_ format: bare x-image- meta-created_ at: 2014-05- 22T17:59: 05.446468 etag: 2386997c1a85709 759c3d26ba0f111 92 location: http:// 192.168. 204.2:9292/ v1/images/ 8f1b7941- cbac-484e- 8ef4-5714e01f5c 66 x-image- meta-min_ ram: 0 x-image- meta-updated_ at: 2014-05- 22T17:59: 11.446979 x-image-meta-id: 8f1b7941- cbac-484e- 8ef4-5714e01f5c 66 date: Sun, 25 May 2014 12:49:48 GMT x-openstack- request- id: req-884ad959- fe85-4653- 81e9-97a9205db3 b8 x-image- meta-deleted: False x-image- meta-checksum: 2386997c1a85709 759c3d26ba0f111 92 x-image- meta-property- hw_vif_ model: avp x-image- meta-protected: False x-image- meta-min_ disk: 0 x-image-meta-size: 507510784 x-image- meta-is_ public: True content-type: text/html; charset=UTF-8 x-image- meta-disk_ format: qcow2 log_http_response /usr/lib64/ python2. 7/site- packages/ glanceclient/ common/ http.py: 152
With the glance V2 API:
May 25 12:07:15 localhost 2014-05-25 12:07:15.589 12689 DEBUG glanceclient. common. http [-] HTTP/1.1 200 OK date: Sun, 25 May 2014 12:07:15 GMT content-length: 543 content-type: application/json; charset=UTF-8 x-openstack- request- id: req-5c8b6f6c- 0880-4054- ba03-4fc89326f6 4e {"status": "active", "name": "wrl5-avp", "tags": [], "container_format": "bare", "created_at": "2014-05- 22T17:59: 05Z", "hw_vif_model": "avp", "disk_format": "qcow2", "updated_at": "2014-05- 22T17:59: 11Z", "visibility": "public", "self": "/v2/images/ 8f1b7941- cbac-484e- 8ef4-5714e01f5c 66", "protected": false, "id": "8f1b7941- cbac-484e- 8ef4-5714e01f5c 66", "file": "/v2/images/ 8f1b7941- cbac-484e- 8ef4-5714e01f5c 66/file" , "checksum": "2386997c1a8570 9759c3d26ba0f11 192", "min_disk": 0, "size": 507510784, "min_ram": 0, "schema": "/v2/schemas/ image"} log_http_response /usr/lib64/ python2. 7/site- packages/ glanceclient/ common/ http.py: 152
The difference (other than the switch to the json encoding) is that the hw_vif_model is returned as a property in the V1 case and returned as a regular field in the V2 case. From a look at the cinder code, I suspect that the problem happens because the _extract_attributes function (in cinder/ image/glance. py) is using a whitelist to copy certain attributes and then copying the "properties" from the image transparently. In the case of the glance V2 API, the hw_vif_model isn't a "property", so it isn't getting copied. Here is the code (from Havana):
def _extract_ attributes( image): ATTRIBUTES = ['size', 'disk_format', 'owner',
'container_ format' , 'checksum', 'id',
'name' , 'created_at', 'updated_at',
'deleted_ at', 'deleted', 'status',
'min_ disk', 'min_ram', 'is_public']
output[ attr] = getattr(image, attr, None)
IMAGE_
output = {}
for attr in IMAGE_ATTRIBUTES:
output[ 'properties' ] = getattr(image, 'properties', {})
return output
I don't know why the glance V2 API is returning the properties as regular attributes, but I expect that is what is causing the problem.
I am testing this in Havana, using the Ceph backend, but I don't expect the backend matters here.