v1Client.update_image fails when image attribute value is not string

Bug #1032798 reported by Alessandro Pilotti on 2012-08-03
This bug affects 2 people
Affects Status Importance Assigned to Milestone
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





The issue can be solved by changing at line 542:

c.putheader(header, value)


c.putheader(header, str(value))

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

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) on 2012-08-14
Changed in glance:
milestone: folsom-3 → folsom-rc1

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) on 2012-09-11
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-09-27
Changed in glance:
milestone: folsom-rc1 → 2012.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers