v1Client.update_image fails when image attribute value is not string

Bug #1032798 reported by Alessandro Pilotti
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Alessandro Pilotti

Bug Description

By running:

            (glance_client, image_id) = self._glance.get_glance_client(context, name)
            image_metadata = {"is_public": False,
                      "disk_format": "vhd",
                      "container_format": "bare",
                      "properties": {}}
            f = open(image_vhd_path, 'rb')
            LOG.debug(_("Updating Glance image %s with content from merged disk %s"), image_id, image_vhd_path)
            glance_client.update_image(image_id, image_meta=image_metadata, image_data=f)

I get the following exception:

TypeError: sequence item 0: expected string, long found

File:

..\Python27\lib\site-packages\glance\common\client.py

Line:

542

The issue can be solved by changing at line 542:

c.putheader(header, value)

with

c.putheader(header, str(value))

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Good catch, do you want to propose a fix for this through Gerrit?

Changed in glance:
status: New → Triaged
importance: Undecided → Medium
milestone: none → folsom-3
summary: - update_image HTTP headers issue
+ v1Client.update_image fails when image attribute value is not string
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/11162

Changed in glance:
assignee: nobody → Alessandro Pilotti (alexpilotti)
status: Triaged → In Progress
Thierry Carrez (ttx)
Changed in glance:
milestone: folsom-3 → folsom-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/11162
Committed: http://github.com/openstack/glance/commit/07b72c388289c8e89b4dd2dd342a7f8147c438aa
Submitter: Jenkins
Branch: master

commit 07b72c388289c8e89b4dd2dd342a7f8147c438aa
Author: Alessandro Pilotti <email address hidden>
Date: Fri Aug 10 18:01:48 2012 +0300

    Fixes issue with non string header values in glance client

    Fixes bug 1032798

    By using Glance client on Windows the following exception is raised:

    TypeError: sequence item 0: expected string, long found

    Details on how to reproduce the error are available in the bug description

    Change-Id: Ib4528702b11aabdf939c6358f92ad7ff9c3ff20d

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: folsom-rc1 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.