Bug 1403828

Summary: Failed to specify attribute of 'number' type for custom resource type
Product: Red Hat OpenStack Reporter: Yurii Prokulevych <yprokule>
Component: python-gnocchiclientAssignee: Mehdi ABAAKOUK <mabaakou>
Status: CLOSED ERRATA QA Contact: Sasha Smolyak <ssmolyak>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 10.0 (Newton)CC: apevec, jdanjou, jjoyce, jschluet, lhh, mabaakou, pkilambi
Target Milestone: z3Keywords: Triaged, ZStream
Target Release: 10.0 (Newton)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-gnocchiclient-2.8.2-2.el7ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-28 15:27:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yurii Prokulevych 2016-12-12 12:50:04 UTC
Description of problem:
-----------------------
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)


Version-Release number of selected component (if applicable):
-------------------------------------------------------------
python-gnocchiclient-2.6.0-1.el7ost.noarch

Steps to Reproduce:
-------------------
1. Create new resource type:

 gnocchi resource-type create \
  --attribute my_name:string:true \
  --attribute my_age:number:false:min=18 rhbz

2. Create a resource with:

  gnocchi resource create \
  --type rhbz --attribute my_name:rhbz-test \
  --attribute my-age:19 37ad7aad-6ca1-4344-b8a9-b71cd3f2f531

Comment 1 Mehdi ABAAKOUK 2017-04-12 09:25:50 UTC
gnocchiclient 2.6.1 have been release with this fix.

Comment 2 Mehdi ABAAKOUK 2017-04-12 09:33:12 UTC
Rdo have switch newton branch to 2.8.2 that have the fix too.

Next downstream rebase from 2.8.2 or 2.6.1 will fixes this BZ

Comment 4 Sasha Smolyak 2017-06-15 06:54:33 UTC
The latest puddle of rhos10 is for now of 2017-06-09.1 and the version is
python-gnocchiclient-2.6.0-1.el7ost.noarch
So the bug is not ON_QA yet

Comment 5 Mehdi ABAAKOUK 2017-06-15 07:04:56 UTC
The package is in brew https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=560272 and tagged rhos-10.0-rhel-7-candidate the 25/05/2017, I'm surprise it's not part of the puddle created the 09/06/2017.

Comment 7 Sasha Smolyak 2017-06-26 11:35:17 UTC
The package is updated, the bug is fixed in it

Comment 9 errata-xmlrpc 2017-06-28 15:27:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1587