Glance详解

一 什么是Glance
Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找,注册和检索等操作。
Glance提供restful API可以查询虚拟机镜像的metadata,并且可以获得镜像。
通过Glance,虚拟机镜像进行可以被存储到多种存储上,比如简单的文件存储或者对象存储。

二 Glance in Openstack

三 基本概念
1 image identifiers
就是Image URI,格式:<Glance Server Location>/images/<ID>
全局唯一
2 Image status
Queued:镜像ID已经被保留,镜像还没有上传
Saving:镜像正在被上传
Active:镜像可以使用了
Killed:镜像损坏或者不可用
Deleted:镜像被删除
3 Disk Format
raw:This is an unstructured disk image format
vhd:VMWare,Xen,Microsoft,VirtualBox
vmdk:common format
vdi:VirtualBox,QEMU emulator
iso:optical disc
qcow2:QEMU emulator
aki:Amazon kernel image
ari:Amazon ramdisk iamge
ami:Amazon machine image
4 Container Format
Bare
ovf
aki
ami
ari

四 基本架构

五模块
Glance API:处理API请求
Glance Registry:处理镜像的metadata存储
Store Adapter:镜像本身的存储

六 Store-Adapter
S3
Swift
FileSystem:默认后端存储
RBD:Ceph的Rados block device(RBD)
HTTP:通过HTTP在Internet上读取可用的虚拟机镜像
其他分布是存储,比如sheepdog等。

七 Glance搭建
1 安装Glance包
2 初始化数据库
3 配置Glance
数据库
Keystone认证信息
4 启动Glance

八 Glance CLI
列出镜像
创建镜像
删除镜像
下载镜像

九 添加镜像
glance image-create --name myimage --disk-format=raw --container-format=bare --file /path/to/file.img  --is-public
glance image-create --name myimage --disk-format=raw --container-format=bare --location <IMAGE_URL> --is-public

十 API实验
1 获取Token
2 使用Token列出镜像
3 使用Token上传,下载镜像
4 获取镜像
5 制作镜像-Linux
6 修改镜像
7 转换镜像格式