Failed to specify attribute of 'number' type for custom resource type

Bug #1649269 reported by Yurii Prokulevych
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-gnocchiclient
Fix Released
Undecided
Mehdi Abaakouk

Bug Description

Attempt to create a resource with specified attribute fails:
    gnocchi --debug resource create --type rhbz --attribute 'my_name:rhbz-test' --attribute my_age:33 37ad7aad-6ca1-4344-b8a9-b71cd3f2f531REQ: curl -g -i -X GET https://[2620:52:0:13b8:5054:ff:fe3e:1]:13000/v2.0 -H "Accept: application/json" -H "User-Agent: gnocchi keystoneauth1/2.12.2 python-requests/2.10.0 CPython/2.7.5"
    Starting new HTTPS connection (1): 2620:52:0:13b8:5054:ff:fe3e:1
    /usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py:303: SubjectAltNameWarning: Certificate for 2620:52:0:13b8:5054:ff:fe3e:1 has no `subjectAltName`, falling back to check for a `commonName
    ` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
      SubjectAltNameWarning
    "GET /v2.0 HTTP/1.1" 200 247
    RESP: [200] Date: Mon, 12 Dec 2016 12:27:39 GMT Server: Apache Vary: X-Auth-Token,Accept-Encoding x-openstack-request-id: req-2733a833-008a-4aeb-9ca6-b54c6024555c Content-Encoding: gzip Content-Length: 247 Conte
    nt-Type: application/json
    RESP BODY: {"version": {"status": "deprecated", "updated": "2016-08-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}], "id": "v2.0", "links": [{
    "href": "https://[2620:52:0:13b8:5054:ff:fe3e:1]:13000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/", "type": "text/html", "rel": "describedby"}]}}

    Making authentication request to https://[2620:52:0:13b8:5054:ff:fe3e:1]:13000/v2.0/tokens
    "POST /v2.0/tokens HTTP/1.1" 200 1130
    REQ: curl -g -i -X POST https://[2620:52:0:13b8:5054:ff:fe3e:1]:13041/v1/resource/rhbz -H "User-Agent: gnocchi keystoneauth1/2.12.2 python-requests/2.10.0 CPython/2.7.5" -H "Content-Type: application/json" -H "A
    ccept: application/json, */*" -H "X-Auth-Token: {SHA1}31fa32feb3f0ca711e04dc482225b01af0d38023" -d '{"my_name": "rhbz-test", "my_age": "33", "id": "37ad7aad-6ca1-4344-b8a9-b71cd3f2f531"}'
    Starting new HTTPS connection (1): 2620:52:0:13b8:5054:ff:fe3e:1
    /usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py:303: SubjectAltNameWarning: Certificate for 2620:52:0:13b8:5054:ff:fe3e:1 has no `subjectAltName`, falling back to check for a `commonName
    ` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
      SubjectAltNameWarning
    "POST /v1/resource/rhbz HTTP/1.1" 400 123
    RESP: [400] Date: Mon, 12 Dec 2016 12:27:39 GMT Server: Apache Content-Length: 123 Content-Type: application/json; charset=UTF-8
    RESP BODY: {"code": 400, "description": "Invalid input: expected Real for dictionary value @ data[u'my_age']", "title": "Bad Request"}
    Invalid input: expected Real for dictionary value @ data[u'my_age'] (HTTP 400)
    Traceback (most recent call last):
      File "/usr/lib/python2.7/site-packages/cliff/app.py", line 387, in run_subcommand
        result = cmd.run(parsed_args)
      File "/usr/lib/python2.7/site-packages/cliff/display.py", line 100, in run
        column_names, data = self.take_action(parsed_args)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/resource_cli.py", line 182, in take_action
        resource_type=parsed_args.resource_type, resource=resource)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/resource.py", line 98, in create
        data=jsonutils.dumps(resource)).json()
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/base.py", line 41, in _post
        return self.client.api.post(*args, **kwargs)
      File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 193, in post
        return self.request(url, 'POST', **kwargs)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/client.py", line 38, in request
        raise exceptions.from_response(resp, method)
    BadRequest: Invalid input: expected Real for dictionary value @ data[u'my_age'] (HTTP 400)
    Traceback (most recent call last):
      File "/bin/gnocchi", line 10, in <module>
        sys.exit(main())
      File "/usr/lib/python2.7/site-packages/gnocchiclient/shell.py", line 223, in main
        return GnocchiShell().run(args)
      File "/usr/lib/python2.7/site-packages/cliff/app.py", line 267, in run
        result = self.run_subcommand(remainder)
      File "/usr/lib/python2.7/site-packages/cliff/app.py", line 387, in run_subcommand
        result = cmd.run(parsed_args)
      File "/usr/lib/python2.7/site-packages/cliff/display.py", line 100, in run
        column_names, data = self.take_action(parsed_args)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/resource_cli.py", line 182, in take_action
        resource_type=parsed_args.resource_type, resource=resource)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/resource.py", line 98, in create
        data=jsonutils.dumps(resource)).json()
      File "/usr/lib/python2.7/site-packages/gnocchiclient/v1/base.py", line 41, in _post
        return self.client.api.post(*args, **kwargs)
      File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 193, in post
        return self.request(url, 'POST', **kwargs)
      File "/usr/lib/python2.7/site-packages/gnocchiclient/client.py", line 38, in request
        raise exceptions.from_response(resp, method)
    gnocchiclient.exceptions.BadRequest: Invalid input: expected Real for dictionary value @ data[u'my_age'] (HTTP 400)

Package:
--------
python-gnocchiclient-2.6.0-1.el7ost.noarch

---
Yurii

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

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

Changed in python-gnocchiclient:
assignee: nobody → Mehdi Abaakouk (sileht)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-gnocchiclient (master)

Reviewed: https://review.openstack.org/416581
Committed: https://git.openstack.org/cgit/openstack/python-gnocchiclient/commit/?id=c77109d8b3c074ddc80daa1513c6b12ce55bac00
Submitter: Jenkins
Branch: master

commit c77109d8b3c074ddc80daa1513c6b12ce55bac00
Author: Mehdi Abaakouk <email address hidden>
Date: Wed Jan 4 16:12:24 2017 +0100

    resource: Set correct attribute type

    Currently all resources attributes are transmitted as string to the
    server. But if the attribute type is a number or a bool, the json must
    have the value as float or bool too.

    This change does that.

    Closes-bug: #1649269
    Change-Id: I0f739f782bf081761d289398bcd4185af3d0e7b4

Changed in python-gnocchiclient:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-gnocchiclient 2.8.0

This issue was fixed in the openstack/python-gnocchiclient 2.8.0 release.

Julien Danjou (jdanjou)
Changed in python-gnocchiclient:
status: Fix Committed → Fix Released
milestone: none → 2.8.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-gnocchiclient (stable/2.6)

Fix proposed to branch: stable/2.6
Review: https://review.openstack.org/450256

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-gnocchiclient (stable/2.6)

Reviewed: https://review.openstack.org/450256
Committed: https://git.openstack.org/cgit/openstack/python-gnocchiclient/commit/?id=8957c54e28e769dff050f0b510f77368b3198408
Submitter: Jenkins
Branch: stable/2.6

commit 8957c54e28e769dff050f0b510f77368b3198408
Author: Mehdi Abaakouk <email address hidden>
Date: Wed Jan 4 16:12:24 2017 +0100

    resource: Set correct attribute type

    Currently all resources attributes are transmitted as string to the
    server. But if the attribute type is a number or a bool, the json must
    have the value as float or bool too.

    This change does that.

    Closes-bug: #1649269
    Change-Id: I0f739f782bf081761d289398bcd4185af3d0e7b4
    (cherry picked from commit c77109d8b3c074ddc80daa1513c6b12ce55bac00)

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.