一 简介
用户可以通过volume transfer
方法,将云盘从一个租户/项目转移到另一个租户/项目。先在原来的租户/项目创建transfer
,并将创建的transfer_id
和auth_key
发给新的租户/项目。新的租户/项目通过transfer_id
和auth_key
接收云盘。
二 操作步骤
1 创建2个domian,分别创建project和user
test_domin/test_project/test@example.org passw0rd
test2_domin/test2_project/test2@example.org passw0rd
2 登录后台,配置鉴权文件
通过命令openstack user show <user>
查询对应用户的project_id
和domain_id
[root@node-1 ~]# openstack user show test
+--------------------+----------------------------------+
| Field | Value |
+--------------------+----------------------------------+
| default_project_id | 493090cdbba4446bb2b97a0f908b9fe6 |
| domain_id | bc394ae4a2404d309d5bf1ebcadd0bee |
| email | test@example.org |
| enabled | True |
| id | efcda6cd847a44b79eedea6fc6641064 |
| name | test |
| user_role | domain_member |
| user_type | individual |
+--------------------+----------------------------------+
[root@node-1 ~]# openstack user show test2
+--------------------+----------------------------------+
| Field | Value |
+--------------------+----------------------------------+
| default_project_id | b3e9689b08a4477087336c0fad852998 |
| domain_id | c2c3ef18b4ae479ca2b60c52208b784f |
| email | test2@example.org |
| enabled | True |
| id | 3bb5c82d762c45ca891067dc60cd4594 |
| name | test2 |
| user_role | domain_member |
| user_type | individual |
+--------------------+----------------------------------+
将OS_PROJECT_ID
, OS_USERNAME
, OS_USER_DOMAIN_ID
, OS_PASSWORD
修改为实际值
[root@node-1 ~]# cat openrc.test
#!/bin/sh
export OS_NO_CACHE='true'
export OS_PROJECT_ID='493090cdbba4446bb2b97a0f908b9fe6'
export OS_USERNAME='test'
export OS_USER_DOMAIN_ID='bc394ae4a2404d309d5bf1ebcadd0bee'
export OS_PASSWORD='passw0rd'
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL='http://192.168.10.2:35357/v3/'
export OS_AUTH_STRATEGY='keystone'
export OS_REGION_NAME='RegionOne'
export CINDER_ENDPOINT_TYPE='publicURL'
export GLANCE_ENDPOINT_TYPE='publicURL'
export KEYSTONE_ENDPOINT_TYPE='publicURL'
export NOVA_ENDPOINT_TYPE='publicURL'
export NEUTRON_ENDPOINT_TYPE='publicURL'
export PYTHONIOENCODING=UTF-8
[root@node-1 ~]# cat openrc.test2
#!/bin/sh
export OS_NO_CACHE='true'
export OS_PROJECT_ID='b3e9689b08a4477087336c0fad852998'
export OS_USERNAME='test2'
export OS_USER_DOMAIN_ID="c2c3ef18b4ae479ca2b60c52208b784f"
export OS_PASSWORD='passw0rd'
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL='http://192.168.10.2:35357/v3/'
export OS_AUTH_STRATEGY='keystone'
export OS_REGION_NAME='RegionOne'
export CINDER_ENDPOINT_TYPE='publicURL'
export GLANCE_ENDPOINT_TYPE='publicURL'
export KEYSTONE_ENDPOINT_TYPE='publicURL'
export NOVA_ENDPOINT_TYPE='publicURL'
export NEUTRON_ENDPOINT_TYPE='publicURL'
export PYTHONIOENCODING=UTF-8
3 登录用户test@example.org
创建镜像盘test_image
和数据盘test_data
。
后台查询云盘信息以及配额使用情况如下:
[root@node-1 ~]# source openrc.test
[root@node-1 ~]# cinder list
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
| 8cba8bad-1254-4797-954f-5b3c7c43fb68 | available | test_image | 1 | - | true | |
| afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0 | available | test_data | 1 | - | false | |
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
[root@node-1 ~]# cinder quota-usage 493090cdbba4446bb2b97a0f908b9fe6
+----------------------+--------+----------+-------+
| Type | In_use | Reserved | Limit |
+----------------------+--------+----------+-------+
| backup_gigabytes | 0 | 0 | 10 |
| backups | 0 | 0 | 10 |
| gigabytes | 2 | 0 | 10 |
| per_volume_gigabytes | 0 | 0 | -1 |
| snapshots | 0 | 0 | 10 |
| volumes | 2 | 0 | 10 |
+----------------------+--------+----------+-------+
4 用户test@example.org
创建transfer
这里需要记录每个transfer
的auth_key
和id
[root@node-1 ~]# cinder transfer-create 8cba8bad-1254-4797-954f-5b3c7c43fb68
+------------+--------------------------------------+
| Property | Value |
+------------+--------------------------------------+
| auth_key | a7d97635a4843354 |
| created_at | 2019-12-19T06:42:00.275421 |
| id | 7b4e4e26-0227-4a0a-b3ec-c11c408648e6 |
| name | None |
| volume_id | 8cba8bad-1254-4797-954f-5b3c7c43fb68 |
+------------+--------------------------------------+
[root@node-1 ~]# cinder transfer-create afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0
+------------+--------------------------------------+
| Property | Value |
+------------+--------------------------------------+
| auth_key | 10b8720d68663506 |
| created_at | 2019-12-19T06:42:11.662866 |
| id | 9a267662-933e-4d2d-a3f6-0ef7dd7fd553 |
| name | None |
| volume_id | afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0 |
+------------+--------------------------------------+
注意: 只能对available的云盘创建transfer
5 用户test2@example.org
接收transfer
需要注意的是, 在接收前需要确认云盘配额足够。
查看当前用户云盘和配额信息如下
[root@node-1 ~]# cinder list
+----+--------+------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+----+--------+------+------+-------------+----------+-------------+
+----+--------+------+------+-------------+----------+-------------+
[root@node-1 ~]# cinder quota-usage b3e9689b08a4477087336c0fad852998
+----------------------+--------+----------+-------+
| Type | In_use | Reserved | Limit |
+----------------------+--------+----------+-------+
| backup_gigabytes | 0 | 0 | 10 |
| backups | 0 | 0 | 10 |
| gigabytes | 0 | 0 | 100 |
| per_volume_gigabytes | 0 | 0 | -1 |
| snapshots | 0 | 0 | 10 |
| volumes | 0 | 0 | 10 |
+----------------------+--------+----------+-------+
接收transfer,参数为上一步中的auth_key
和id
[root@node-1 ~]# cinder transfer-accept 7b4e4e26-0227-4a0a-b3ec-c11c408648e6 a7d97635a4843354
+-----------+--------------------------------------+
| Property | Value |
+-----------+--------------------------------------+
| id | 7b4e4e26-0227-4a0a-b3ec-c11c408648e6 |
| name | None |
| volume_id | 8cba8bad-1254-4797-954f-5b3c7c43fb68 |
+-----------+--------------------------------------+
[root@node-1 ~]# cinder transfer-accept 9a267662-933e-4d2d-a3f6-0ef7dd7fd553 10b8720d68663506
+-----------+--------------------------------------+
| Property | Value |
+-----------+--------------------------------------+
| id | 9a267662-933e-4d2d-a3f6-0ef7dd7fd553 |
| name | None |
| volume_id | afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0 |
+-----------+--------------------------------------+
查看当前用户云盘和配额信息如下
[root@node-1 ~]# cinder list
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
| 8cba8bad-1254-4797-954f-5b3c7c43fb68 | available | test_image | 1 | - | true | |
| afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0 | available | test_data | 1 | - | false | |
+--------------------------------------+-----------+------------+------+-------------+----------+-------------+
[root@node-1 ~]# cinder quota-usage b3e9689b08a4477087336c0fad852998
+----------------------+--------+----------+-------+
| Type | In_use | Reserved | Limit |
+----------------------+--------+----------+-------+
| backup_gigabytes | 0 | 0 | 10 |
| backups | 0 | 0 | 10 |
| gigabytes | 2 | 0 | 100 |
| per_volume_gigabytes | 0 | 0 | -1 |
| snapshots | 0 | 0 | 10 |
| volumes | 2 | 0 | 10 |
+----------------------+--------+----------+-------+
6 验证从transfer云盘创建虚拟机
从云盘test_image
创建虚拟机,然后挂载test_data
,虚拟机可以正常进入系统,删除虚拟机和云盘,正常。
[root@node-1 ~]# nova list
+--------------------------------------+------+--------+------------+-------------+--------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+--------------------------+
| 3c2b8f75-d0af-4a08-8170-afe7fcdd9c69 | test | ACTIVE | - | Running | share_net=192.168.111.17 |
+--------------------------------------+------+--------+------------+-------------+--------------------------+
[root@node-1 ~]# cinder list
+--------------------------------------+--------+------------+------+-------------+----------+--------------------------------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+--------+------------+------+-------------+----------+--------------------------------------+
| 8cba8bad-1254-4797-954f-5b3c7c43fb68 | in-use | test_image | 1 | - | true | 3c2b8f75-d0af-4a08-8170-afe7fcdd9c69 |
| afcfbd53-a8b0-4a0e-9e9d-f38f76679cf0 | in-use | test_data | 1 | - | false | 3c2b8f75-d0af-4a08-8170-afe7fcdd9c69 |
+--------------------------------------+--------+------------+------+-------------+----------+--------------------------------------+