"--resource-metadata" is unavailable in sample-create

Bug #1324759 reported by Liusheng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-ceilometerclient
Fix Released
Undecided
Liusheng

Bug Description

When I use following commands try to create a sample with resource medatada:

ceilometer --debug sample-create -r resource1 -m meter1 --meter-type delta --meter-unit unit1 --sample-volume 1 --resource-metadata abc=abc

CLI will raise an ValueError with the traceback:
Traceback (most recent call last):
  File "/usr/local/bin/ceilometer", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/python-ceilometerclient/ceilometerclient/shell.py", line 335, in main
    CeilometerShell().main(args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/shell.py", line 289, in main
    args.func(client, args)
  File "/opt/stack/python-ceilometerclient/ceilometerclient/v2/shell.py", line 161, in do_sample_create
    fields[k] = json.loads(v)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Liusheng (liusheng)
Changed in python-ceilometerclient:
assignee: nobody → Liusheng (liusheng)
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

oops, there is no test code for this scenarios

Changed in python-ceilometerclient:
status: New → Confirmed
Revision history for this message
Liusheng (liusheng) wrote :

@ZhiQiang, the right way to use the resource-metadata in sample-create is:

ceilometer --debug sample-create -r resource1 -m meter1 --meter-type delta --meter-unit unit1 --sample-volume 1 --resource-metadata '{"abc":"abc"}'

but unlike other metadata commands in openstack, is the usage a little weird?

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

at least, the error message is not quite useful for end users, we need a good example in help string, or in test code (I always try to find example use case in test code)

Revision history for this message
Liusheng (liusheng) wrote :

agree, the error message and the help string unreasonable or change the usage of --resource-metadata to allowing user specifying key value pairs in CLI like nova or cinder CLI :)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ceilometerclient (master)

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

Changed in python-ceilometerclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ceilometerclient (master)

Reviewed: https://review.openstack.org/97674
Committed: https://git.openstack.org/cgit/openstack/python-ceilometerclient/commit/?id=67183f76b692d74fb255151e682ad7ce0171a01e
Submitter: Jenkins
Branch: master

commit 67183f76b692d74fb255151e682ad7ce0171a01e
Author: liu-sheng <email address hidden>
Date: Wed Jun 4 10:46:44 2014 +0800

    Provide explicit help string of resource-metadata

    Currently, the "--resource-metadata" in ceilometer sample-create command
    is not easy to use. For compatibility, this patch just provides an
    explicit help string for the parameter.

    Change-Id: I6d68d5b653c3b33808cba6f9a781301fba9b44e3
    Closes-Bug: #1324759

Changed in python-ceilometerclient:
status: In Progress → Fix Committed
Changed in python-ceilometerclient:
milestone: none → 1.3.0
status: Fix Committed → Fix Released
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.