0

I have been trying to make a simple connection to Openstack cloud using python-openstack sdk. With no success. Can someone tell me where I am going wrong? I can see that the header is sending something else entirely instead of the token of authentication, but I don't know how to change that. Here is the code:

import openstack
import sys
conn=connection.Connection(
auth_url='https://fra1.citycloud.com:5000',
project_name="Default Project 39140",
username="vishwa",
password="********",
user_domain_id="99c442651eb84358a515c42e4e6b3acb",
project_domain_id="221c17841e5640f5953c22c28c3872e6")

for servers in conn.compute.servers():
    print(server.name)

and here is the response:

    REQ: curl -g -i -X GET https://fra1.citycloud.com:5000 -H "Accept: application/json" -H "**User-Agent: openstacksdk/0.53.0 keystoneauth1/4.3.0 python-requests/2.25.1 CPython/3.7.0**"
RESP: [300] Connection: close Content-Length: 274 Content-Type: application/json Date: Sun, 28 Feb 2021 03:22:48 GMT Location: https://fra1.citycloud.com:5000/v3/ Server: nginx/1.14.0 (Ubuntu) Vary: X-Auth-Token x-openstack-request-id: req-cf7cfc97-92af-4f26-9afc-e65b72d26f26
RESP BODY: {"versions": {"values": [{"id": "v3.13", "status": "stable", "updated": "2019-07-19T00:00:00Z", "links": [{"rel": "self", "href": "https://fra1.citycloud.com:5000/v3/"}], "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}]}]}}
GET call to https://fra1.citycloud.com:5000/ used request id req-cf7cfc97-92af-4f26-9afc-e65b72d26f26
Making authentication request to https://fra1.citycloud.com:5000/v3/auth/tokens
Request returned failure status: 401

If you look at that. you can see that the "header" is sending 'agent-..' instead of credentials: {username:...,pass:} Some more details: The city cloud has its own api, I know it uses tokens to authenticate-version 3. I had been able to do it with their API, but am struggling with using openstack api. Thanks

  • This question appears to be off topic: We do not accept programming questions. You can get help with debugging your Python code on [so]. – Michael Hampton Feb 28 '21 at 04:40
  • 1
    This is not really a programming question, it's more related to the protocol that OpenStack uses to authenticate users. I think the first response, which is a 300 (redirection), tells you to try authenticating at https://fra1.citycloud.com:5000/v3. You can see clearer by setting the connection parameters in shell variables OS_AUTH_URL etc, then `openstack --debug token issue`. This will show you the precise requests made by the CLI program. – berndbausch Feb 28 '21 at 05:09
  • Generally though, Stackoverflow also has the OpenStack tag. – berndbausch Feb 28 '21 at 05:13
  • The problem is that I had been able to connect using explict mention of username and password using curl and other REST methods. As said in the question, I believe, the problem is that the header part is sending out something else instead of the username and password to get a token. – Vishwa Mithra Tatta Feb 28 '21 at 05:16
  • Perhaps you need to add the region? Also, for security reasons the log may not be complete. To be certain which request is sent, use `tcpcump -vXx host fra1.citycloud.com and port 5000`. – berndbausch Feb 28 '21 at 05:33

0 Answers0