验证操作
代码语言:javascript复制[root@controller ~]# echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh #在每个客户端脚本中,配置镜像服务客户端使用2.0的API
export OS_IMAGE_API_VERSION=2
[root@controller ~]# source admin-openrc.sh #获得 admin 凭证来获取只有管理员能执行命令的访问权限
[root@controller ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img #下载测试源镜像
[root@controller ~]# glance image-create --name "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress
#使用 QCOW2 磁盘格式, bare 容器格式上传镜像到镜像服务并设置公共可见,这样所有的项目都可以访问它
[=============================>] 100%
------------------ --------------------------------------
| Property | Value |
------------------ --------------------------------------
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2018-02-04T11:50:48Z |
| disk_format | qcow2 |
| id | 936bce27-085b-4d79-8cce-68cff70d7abd |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 839cdfc946e1491c8004e3b732d17f9a |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2018-02-04T11:50:49Z |
| virtual_size | None |
| visibility | public |
------------------ --------------------------------------
[root@controller ~]# glance image-list #确认镜像的上传并验证属性
-------------------------------------- --------
| ID | Name |
-------------------------------------- --------
| 936bce27-085b-4d79-8cce-68cff70d7abd | cirros |
-------------------------------------- --------