将映像文件夹复制到新的数据存储后,必须更新每个映像上的位置设置以反映新的数据存储。
开始之前
确认已将映像文件夹复制到新的数据存储中。
确认新数据存储与以前的数据存储中的映像文件夹名称和相对路径相同。
确认您知道要更新的映像的映像 ID 值。
过程
- 对要迁移的所有映像重复此过程。
- 使用 SSH 以管理员身份登录到 VMware Integrated OpenStack Manager。
- 使用 SSH 登录到 controller01 节点。
- 切换到 root 用户。
sudo su -
- 执行 cloudadmin.rc 文件。
source cloudadmin.rc
- (可选) : 查看映像列表。
glance image-list
- (可选) : 获取某个特定映像的位置。
注:
必须知道映像 ID 才能指定映像。
glance --os-image-api-version 2 image-show <image_id>
映像位置是 locations 参数所指示的 URL。
vsphere://<vcenter_ip>/folder/<image_folder_name>/<image_id>dcPath=<path_to_datacenter>&dsName=<old_datastore_name>
例如:
vsphere://10.20.123.456/folder/images/6c4a7e0d-65e7-4f3c-9dde-0de75f729a0c ?dcPath=Datacenter1&dsName=old_ds
- 更新此映像的位置 URL 以反映目标数据存储,以完成迁移单个映像的过程。
- 将新位置添加到映像配置中。
glance --os-image-api-version 2 location-add <image_id> --url <new_url>
选项
说明
image_id
指定要修改的映像。
new_url
除非 dsName 参数指定新数据存储的名称,否则新 URL 与以前的 URL 相同。
vsphere://<vcenter_ip>/folder/<image_folder_name>/<image_id>dcPath=<path_to_datacenter>&dsName=<new_datastore_name>如果命令返回“400 错误请求: 位置无效 (400 Bad Request: Invalid Location)”消息,请确认目标数据存储中映像的文件路径正确。
- 从映像配置中移除旧位置。
glance --os-image-api-version 2 location-delete <image_id> --url <old_url>
- 再次查看映像信息,确认 locations 参数正确反映了新数据存储。
glance --os-image-api-version 2 image-show <image_id>
至此,映像已成功迁移。
- 将新位置添加到映像配置中。