gnocchi python client author error

Bug #1682758 reported by yunfeng zhou
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
kolla-ansible
Invalid
Undecided
Unassigned

Bug Description

enable gnocchi in globals.yml and set ceilometer_database_type: 'gnocchi'.

exec: gnocchi --debug resource list

logs:

The request you have made requires authentication. (HTTP 401)
Traceback (most recent call last):
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/cliff/display.py", line 113, in run
    column_names, data = self.take_action(parsed_args)
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/gnocchiclient/v1/resource_cli.py", line 68, in take_action
    **utils.get_pagination_options(parsed_args))
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/gnocchiclient/v1/resource.py", line 46, in list
    return self._get(url).json()
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/gnocchiclient/v1/base.py", line 37, in _get
    return self.client.api.get(*args, **kwargs)
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 222, in get
    return self.request(url, 'GET', **kwargs)
  File "/var/lib/kolla/venv/lib/python2.7/site-packages/gnocchiclient/client.py", line 38, in request
    raise exceptions.from_response(resp, method)
Unauthorized: The request you have made requires authentication. (HTTP 401)

Tags: gnocchi
Revision history for this message
yunfeng zhou (zhouyunfeng) wrote :

ps:

   before use the client api, exec: "source admin-openrc.sh".

tags: added: gnocchi
Revision history for this message
Jeffrey Zhang (jeffrey4l) wrote :

have u tried "openstack metric resource-type list"?

Revision history for this message
yunfeng zhou (zhouyunfeng) wrote :
Download full text (3.6 KiB)

@jeffrey, thanks for your reminding. as follows, "openstack metric resource-type list" works well.

(gnocchi-api)[root@control01 ~]# openstack metric resource-type list
+----------------------------+-------------------------------------------------------------------------------------+
| name | attributes |
+----------------------------+-------------------------------------------------------------------------------------+
| ceph_account | |
| generic | |
| host | - host_name: min_length: 0 , max_length: 255 , type: string , required: True |
| host_disk | - host_name: min_length: 0 , max_length: 255 , type: string , required: True |
| | - device_name: min_length: 0 , max_length: 255 , type: string , required: False |
| host_network_interface | - host_name: min_length: 0 , max_length: 255 , type: string , required: True |
| | - device_name: min_length: 0 , max_length: 255 , type: string , required: False |
| identity | |
| image | - container_format: min_length: 0 , max_length: 255 , type: string , required: True |
| | - disk_format: min_length: 0 , max_length: 255 , type: string , required: True |
| | - name: min_length: 0 , max_length: 255 , type: string , required: True |
| instance | - image_ref: min_length: 0 , max_length: 255 , type: string , required: False |
| | - host: min_length: 0 , max_length: 255 , type: string , required: True |
| | - display_name: min_length: 0 , max_length: 255 , type: string , required: True |
| | - flavor_id: min_length: 0 , max_length: 255 , type: string , required: True |
| | - server_group: min_length: 0 , max_length: 255 , type: string , required: False |
| instance_disk | - instance_id: required: True , type: uuid |
| | - name: min_length: 0 , max_length: 255 , type: string , required: True |
| instance_network_interface | - instance_id: required: True , type: uuid |
| | - name: min_length: 0 , max_length: 255 , type: string , required: True |
| ipmi | |
| network | |
| stack | ...

Read more...

Revision history for this message
Eduardo Gonzalez (egonzalez90) wrote :

Can we mark this bug as invalid? Based on previous comments was missing auth info and using older gnocchi api.

Changed in kolla-ansible:
status: New → Invalid
Revision history for this message
Giang Nguyen (giangnv) wrote :

Hi all,

I have installed ceilometer with gnocchi as backend by following the documents https://docs.openstack.org/project-install-guide/telemetry/ocata/install-base-ubuntu.html and http://gnocchi.xyz/install.html. It seemed work for me with client mode (by using command line) because I can get some outputs when using gnocchi resource list, status, and so on. However, I cannot retrieve the outputs by using curl or web browsers. It results error code 401 "{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}. I am using keystone for authentication of gnocchi. I guess this issue relates to keystone. I have checked gnocchi.conf (keystone section) several times and I used api-paste.ini from https://github.com/openstack/cookbook-openstack-telemetry/blob/master/files/api-paste.ini but I don't know why it still has that problem (which consequently results problem when I integrate Gnocchi with Grafana which is my final goal). Does anyone have idea on this? Many thanks!!!

Another note is that in api-paste.ini config file, I have to change gnocchi+auth => gnocchi+keystone otherwise it will raise error while running gnocchi-api. Does anyone have correct api-paste.ini cofiguration file for Gnocchi?

Revision history for this message
jack Li (juice) wrote :

why the command "openstack metric resource-type list" use "openstack metric" rather than "gnocchi". Is it about authentication?
thanks all.

Revision history for this message
Sachin (sacpatil) wrote :

I encountered similar issue in test packstack environment(RHOSP11). I tried to debug using curl

Throws 401 when using gnocchiclient
~~~
curl -g -i -X GET http://localhost:8041/v1/resource/generic? -H "Authorization: gAAAAABaRDPXlJUNNEoC5-et5_h7wLt1HzL6_w07KQfL6YFKazmKOdi38ny5xi9_-0PonE72bwyBHPHvgJdzv1RorQSZihMoqJQ1pt4VZ2bbVr-Iuq_N87Pacj5iNiRR6vfqD5tlKluhxqSt0o7IV8xwIvLs7zjNZ1wD30KqEMP2aOC0y7QBVVM" -H "Accept: application/json, */*" -H "User-Agent: gnocchi keystoneauth1/2.18.0 python-requests/2.11.1 CPython/2.7.5"
Starting new HTTP connection (1): localhost
"GET /v1/resource/generic HTTP/1.1" 401 114
RESP: [401] Date: Wed, 27 Dec 2017 23:47:37 GMT Server: Apache/2.4.6 (Red Hat Enterprise Linux) WWW-Authenticate: Keystone uri='http://10.74.129.12:5000/v3' Content-Length: 114 Connection: close Content-Type: application/json
RESP BODY: {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}
~~~

Works with openstackclient
~~~
curl -g -i -X GET http://localhost:8041/v1/resource/generic? -H "User-Agent: osc-lib/1.3.0 keystoneauth1/2.18.0 python-requests/2.11.1 CPython/2.7.5" -H "Accept: application/json, */*" -H "X-Auth-Token: gAAAAABaRDPXlJUNNEoC5-et5_h7wLt1HzL6_w07KQfL6YFKazmKOdi38ny5xi9_-0PonE72bwyBHPHvgJdzv1RorQSZihMoqJQ1pt4VZ2bbVr-Iuq_N87Pacj5iNiRR6vfqD5tlKluhxqSt0o7IV8xwIvLs7zjNZ1wD30KqEMP2aOC0y7QBVVM"
HTTP/1.1 200 OK
Date: Wed, 27 Dec 2017 23:59:53 GMT
Server: Apache/2.4.6 (Red Hat Enterprise Linux)
Content-Length: 9960
Vary: Accept-Encoding
Connection: close
Content-Type: application/json; charset=UTF-8

<JSON query skipped>
~~~

If I replace '-H "Authorization:' with '-H "Auth-Token:' it work. This is the only difference I found so far.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on kolla-ansible (master)

Change abandoned by Mark Goddard (<email address hidden>) on branch: master
Review: https://review.opendev.org/456870
Reason: Very old

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.