glance add / update / image-create / image-update don't work on Windows

Bug #1050345 reported by Alessandro Pilotti on 2012-09-13
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-glanceclient
High
Alessandro Pilotti

Bug Description

By trying to add an image to Glance on Windows with:

glance image-create --name="Image name" --container-format ovf --disk-format qcow2 --file image.img

or

glance image-create --name="Image name" --container-format ovf --disk-format qcow2 < image.img

the upload will hang if the file contains a byte with value 0x1A (EOF), due to the fact that the file and stdin streams are treated as text and not binary streams.

The same issue applies to "image-update" and the equivalent deprecated "add" and "update" commands.

The fix consists in setting the streams in binary mode in both cases:

File: python-glanceclient\glanceclient\v1\shell.py

    if 'location' not in fields and 'copy_from' not in fields:
        if args.file:
            fields['data'] = open(args.file, 'rb')
        else:
            if os.name == 'nt':
                msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
            fields['data'] = sys.stdin

Changed in python-glanceclient:
assignee: nobody → Alessandro Pilotti (alexpilotti)
summary: - glance add / image-create doesn't work on Windows
+ glance add / update / image-create / image-update don't work on Windows
description: updated

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

Changed in python-glanceclient:
status: New → In Progress
Changed in python-glanceclient:
status: In Progress → Fix Committed
Changed in python-glanceclient:
status: Fix Committed → In Progress
Brian Waldon (bcwaldon) on 2012-09-13
Changed in python-glanceclient:
importance: Undecided → High
Brian Waldon (bcwaldon) on 2012-09-13
Changed in python-glanceclient:
milestone: none → v0.6.0

Reviewed: https://review.openstack.org/12936
Committed: http://github.com/openstack/python-glanceclient/commit/91896ff51861e8d90bdf0f7c54cab0f2b3e3c277
Submitter: Jenkins
Branch: master

commit 91896ff51861e8d90bdf0f7c54cab0f2b3e3c277
Author: Alessandro Pilotti <email address hidden>
Date: Thu Sep 13 14:02:20 2012 +0300

    Fixes glance add / update / image-create / image-update on Windows

    Fixes Bug #1050345

    The image upload hangs if the file contains a byte with value 0x1A (EOF), due to
    the fact that the file or stdin streams are treated as text and not
    binary streams. This fix sets the proper binary mode.

    Change-Id: I3425cb9729a8da4d1b73fbfba06fd6f2c7e8833e

Changed in python-glanceclient:
status: In Progress → Fix Committed
Brian Waldon (bcwaldon) on 2012-11-20
Changed in python-glanceclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers