我们部署好OPenStack以及Swift后,想使用开放接口对Swift进行对接,但是却找不到入口,下面就一步一步介绍一下如何使用租户,用户名和密码对接Swift。
首先,我们安装好SWIFT后,在命令行执行
nova list和keystone tenant-list都会显示错误,如下图:
是因为,我们还没有导出。
进入OPenStack主页,点Access&Security,右上角有个Download Openstack RC File,点击下载。
下载到部署Openstack的主机上,点击打开。
里面有租户,用户名和密码的内容。修改之。改成以下:
#!/bin/bash
# To use an OpenStack cloud you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/tenant has
# access to - such as Compute, Image Service, Identity, Object Storage, Block
# Storage, and Networking (code-named nova, glance, keystone, swift,
# cinder, and neutron).
#
# *NOTE*: Using the 2.0 *Identity API* does not necessarily mean any other
# OpenStack API is version 2.0. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone.
export OS_AUTH_URL=http://192.168.111.161: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=b69864c4cb0a44cfb98d4281c9739081
export OS_TENANT_NAME="admin"
# In addition to the owning entity (tenant), openstack stores the entity
# performing the action as the **user**.
export OS_USERNAME="admin"
export OS_PASSWORD="swift"
好了,现在你可以登录后台,新建一个文件,然后把上面的内容复制进去,执行久违的source,然后再次运行命令:[root@node-2 ~]# vi ~/openrc
[root@node-2 ~]# source ~/openrc
[root@node-2 ~]# nova list
[root@node-2 ~]# keystone tenant-list
+----------------------------------+----------+---------+
| id | name | enabled |
+----------------------------------+----------+---------+
| 6d0dff68ecd24215bd971a8d1935ba03 | admin | True |
| d1f2d43d358743eda4e37bfd489c1163 | services | True |
+----------------------------------+----------+---------+
[root@node-2 ~]#
ok,搞定,接下来就用curl测试一下吧
成功返回token和URL
成功。
版权声明:本文为bupt073114原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。