我一直在尝试使用 python-openstack sdk 建立与 Openstack 云的简单连接。但没有成功。有人能告诉我哪里出错了吗?我可以看到标头发送的是完全不同的东西,而不是身份验证令牌,但我不知道如何更改它。以下是代码:
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)
以下是响应:
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
如果你看一下。你会看到“header”发送的是“agent-..”而不是凭证:{username:...,pass:} 更多详细信息:城市云有自己的 api,我知道它使用令牌进行身份验证-版本 3。我曾经能够使用他们的 API 做到这一点,但在使用 openstack api 时遇到了困难。谢谢