Comment 3 for bug 934081

Revision history for this message
Eric Harney (eharney) wrote :

Observed behavior:
$ nova secgroup-list
+---------+-------------+
| Name | Description |
+---------+-------------+
| default | default |
+---------+-------------+
$ nova secgroup-create öa UTFtest
+------+-------------+
| Name | Description |
+------+-------------+
| öa | UTFtest |
+------+-------------+
$ nova secgroup-delete öa
/opt/stack/python-novaclient/novaclient/v1_1/shell.py:1461: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if secgroup == s.name:
ERROR: Secgroup öa not found

The failure occurs because the secgroup name (s.name) inside of _get_secgroup is in Unicode, but the command-line argument is not. A conversion must be done to compare the two.

A fix to novaclient/shell.py is also required because error messages that print Unicode secgroup names cause a UnicodeEncodeError error to be displayed rather than the error message.

For example, if you try to create "öa" twice:
$ nova secgroup-create öa UTFtest
Traceback (most recent call last):
  File "/bin/nova", line 9, in <module>
    load_entry_point('python-novaclient==2.8.0.11', 'console_scripts', 'nova')()
  File "/opt/stack/python-novaclient/novaclient/shell.py", line 536, in main
    print >> sys.stderr, "ERROR: %s" % str(e)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 15: ordinal not in range(128)

With the fix, you will see the normal "ERROR: Security group öa already exists (HTTP 400) (Request-ID: req-...)"

Proposed change at https://review.openstack.org/#/c/12972/ .