我想使用RESTful API,例如
https://nova.rc.nectar.org.au:8774/v1.1/1f283209946f428998e8d3930bb038d1
但无法获取身份验证令牌。
我尝试了以下命令来获取它(我没有管理员权限):
curl -d '{"auth":{"passwordCredentials":{"username": "miranda.zhang", "password": "mypass"}}}' -H "Content-type: application/json" https://keystone.rc.nectar.org.au:5000/v2.0/tokens
但仍然得到
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
我也看过python-keystoneclient 我试着安装它
python setup.py install
但它返回错误
Traceback (most recent call last):
File "setup.py", line 18, in <module>
import setuptools
ImportError: No module named setuptools
这里是openrc.sh file generated by my cloud provider,似乎没有帮助。
#!/bin/bash
# With the addition of Keystone, to use an openstack cloud you should
# authenticate against keystone, which returns a **Token** and **Service
# Catalog**. The catalog contains the endpoint for all services the
# user/tenant has access to - including nova, glance, keystone, swift.
#
# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We
# will use the 1.1 *compute api*
export OS_AUTH_URL=https://keystone.rc.nectar.org.au:5000/v2.0/
# With the addition of Keystone we have standardized on the term **tenant**
# as the entity that owns the resources.
export OS_TENANT_ID=1f283209946f428998e8d3930bb038d1
export OS_TENANT_NAME="pt-1114"
# In addition to the owning entity (tenant), openstack stores the entity
# performing the action as the **user**.
export OS_USERNAME="miranda.zhang"
# With Keystone you pass the keystone password.
echo "Please enter your OpenStack Password: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
参考:
我尝试了巴拉克的建议,包括房客姓名,但仍然得到以下信息:
HTTP/1.1 401 Unauthorized
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 114
Date: Sun, 29 Dec 2013 08:54:28 GMT
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}
我在巴拉克的帮助下安装了keystone客户端:
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install python-keystoneclient
但是像这样使用:
keystone --os-tenant-name pt-1114 --os-username USERNAME --os-password PASSWORD --os-auth-url https://keystone.rc.nectar.org.au:5000/v2.0/tokens -os-identity-api-version 2.0 --debug token-get
我得到了这个错误,而token-get
显然是一个有效的选项。
usage: keystone [--version] [--timeout <seconds>]
[--os-username <auth-user-name>]
[--os-password <auth-password>]
[--os-tenant-name <auth-tenant-name>]
[--os-tenant-id <tenant-id>] [--os-auth-url <auth-url>]
[--os-region-name <region-name>]
[--os-identity-api-version <identity-api-version>]
[--os-token <service-token>]
[--os-endpoint <service-endpoint>]
[--os-cacert <ca-certificate>] [--insecure]
[--os-cert <certificate>] [--os-key <key>] [--os-cache]
[--force-new-token] [--stale-duration <seconds>]
<subcommand> ...
keystone: error: argument <subcommand>: invalid choice: '2.0' (choose from 'catalog', 'ec2-credentials-create', 'ec2-credentials-delete', 'ec2-credentials-get', 'ec2-credentials-list', 'endpoint-create', 'endpoint-delete', 'endpoint-get', 'endpoint-list', 'password-update', 'role-create', 'role-delete', 'role-get', 'role-list', 'service-create', 'service-delete', 'service-get', 'service-list', 'tenant-create', 'tenant-delete', 'tenant-get', 'tenant-list', 'tenant-update', 'token-get', 'user-create', 'user-delete', 'user-get', 'user-list', 'user-password-update', 'user-role-add', 'user-role-list', 'user-role-remove', 'user-update', 'discover', 'bootstrap', 'bash-completion', 'help', 'bash_completion')
我刚刚意识到我现有的登录门户的密码不能作为
To access the Nectar Cloud using the OpenStack API you will need to generate a password. By doing so any existing password will be forgotten. To generate a new password click "Reset Password" button.
问题解决了。
json块中缺少租户名称。下面是一个工作卷曲请求:
我建议您使用pip安装keystone客户端:
然后运行任何带有'--debug'选项的keystone命令来查看实际的json。
以下面的代码为例:
这里使用python-m json.tool以json可读格式打印输出。
相关问题 更多 >
编程相关推荐