glance add throws: IndexError: tuple index out of range

Bug #956202 reported by Dan Prince on 2012-03-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Dan Prince

Bug Description

Adding glance images now throws the following exception if you run it in a shell without a TTY?

ssh nova1 bash <<-"EOF_BASH"
glance add name="ari-tty" type="ramdisk" disk_format="ari" container_format="ari" is_public=true < /tmp/tty_linux/ramdisk

stty: standard input: Inappropriate ioctl for device
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/site-packages/glance/common/", line 67, in run
  File "/usr/lib/python2.7/site-packages/glance/common/", line 105, in render
    height, width = utils.get_terminal_size()
  File "/usr/lib/python2.7/site-packages/glance/common/", line 369, in get_terminal_size
    return height_width[0], height_width[1]
IndexError: tuple index out of range

Dan Prince (dan-prince) wrote :
Changed in glance:
assignee: nobody → Dan Prince (dan-prince)
status: New → In Progress
importance: Undecided → Medium
Dan Prince (dan-prince) wrote :

The issue seems to be that we just need a little error checking:

        if not height_width:
                p = subprocess.Popen(['stty', 'size'],
                result = p.communicate()
                if p.returncode == 0:
                    return tuple(int(x) for x in result[0].split())

Jay Pipes (jaypipes) on 2012-03-15
Changed in glance:
milestone: none → essex-rc1

Submitter: Jenkins
Branch: master

commit 0a19061141de1fb70c5e3dc1a5e47f11f5b068fe
Author: Dan Prince <email address hidden>
Date: Thu Mar 15 13:28:20 2012 -0400

    Add error checking to get_terminal_size.

    Adds returncode error checking to get_terminal_size so that
    it doesn't spew errors to console when running glance commands
    in a shell without a TTY.

    Fixes LP Bug #956202.

    Change-Id: I42e155d168da1f4f25c0dea9ad9768686bd654ce

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-03-21
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in glance:
milestone: essex-rc1 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers