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 the equivalent deprecated "glance add" command.
The fix consists in setting the streams in binary mode in both cases:
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
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 the equivalent deprecated "glance add" command.
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:
fields[ 'data'] = open(args.file, 'rb')
msvcrt. setmode( sys.stdin. fileno( ), os.O_BINARY)
fields[ 'data'] = sys.stdin
if args.file:
else:
if os.name == 'nt':