alarm-list crashes if no time_constraints

Bug #1337051 reported by Martin Paulo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-ceilometerclient
New
Undecided
Unassigned

Bug Description

If the client is run against a ceilometer service that doesn't return time_constraint data, the client simply reports "time_constraints".
This is somewhat cryptic...

The stack trace is as follows:
Traceback (most recent call last):
File "/Users/martinpaulo/.virtualenvs/osclt/bin/ceilometer", line 10, in <module> sys.exit(main())
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/shell.py", line 335, in main CeilometerShell().main(args)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/shell.py", line 289, in main args.func(client, args)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/v2/shell.py", line 284, in do_alarm_list 'time_constraints': time_constraints_formatter}, sortby=0)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/common/utils.py", line 65, in print_list sortby_index=sortby)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/openstack/common/cliutils.py", line 154, in print_list row.append(formatters[field](o))
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/v2/shell.py", line 229, in time_constraints_formatter return _display_time_constraints(alarm.time_constraints)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/v2/alarms.py", line 52, in __getattr__ return super(Alarm, self).__getattr__(k)
File "/Users/martinpaulo/.virtualenvs/osclt/lib/python2.7/site-packages/ceilometerclient/openstack/common/apiclient/base.py", line 463, in __getattr__ raise AttributeError(k)
AttributeError: time_constraints

The fix I applied to tide me over was to simply alter the time_constraints_formatter method in shell.py (line 229) to read as follows:

def time_constraints_formatter(alarm):
    if hasattr(alarm, 'time_constraints'):
        return _display_time_constraints(alarm.time_constraints)
    return 'None'

I'm not submitting a patch because I'm not sure that this is the behavior that is actually desired, and also because I don't have time to properly write a test :(

Revision history for this message
Martin Paulo (martin-paulo) wrote :

alarm-show exhibits similar behavior.
The method _display_alarm(alarm) does a 'if alarm.time_constraints:' I've worked around it in a quick and dirty way by changing it to "if hasattr(alarm, 'time_constraints') and alarm.time_constraints:'

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.