[OpenStack] OpenStack之Glance笔记(转载)

Glance项目提供虚拟机镜像的发现,注册,取得服务。

Glance提供restful API可以查询虚拟机镜像的metadata,并且可以获得镜像。

通过Glance,虚拟机镜像可以被存储到多种存储上,比如简单的文件存储或者对象存储(比如OpenStack中swiftx项目)。

Glance,像所有的OpenStack项目一样,遵循以下思想:

1.基于组件的架构      便于快速增加新特性

2.高可用性                  支持大负荷

3.容错性                      独立的进程避免串行错误

4.开放标准                  对社区驱动的API提供参考实现

Glance的几个重要概念:

1.Image identifiers                         Image使用URI作为唯一标识,URL符合以下格式:

<Glance Server Location>/images/<ID>

Glance Server Location是镜像的所在位置, ID是镜像在Glance的唯一标识。

2.Image Statuses                         共四种状态。

queued                                标识该镜像ID已经被保留,但是镜像还未上传。

saving                                  标识镜像正在被上传。

active                                    标识镜像在Glance中完全可用。

killed                                     标识镜像上传过程中出错,镜像完全不可用。

3.Disk and Container format

Disk  Format:raw vhd vmdk vdi iso qcow2 aki ari ami

Container Format: ovf bare aki ari ami

当disk format为aki ari ami时,disk format 和container format一致。

4.Image Registries

使用Glance,镜像metadata可以注册至image registries。

只要为image metadata提供了rest like API,任何web程序可以作为image registries与Glance对接。

当然,Glance也提供了参考实现。

更多信息可以参考on Controlling Servers,来自于Glance提供的Glance registry server。

Glance提供了如下Rest-like API:

GET     /images         Return brief information about public images
GET     /images/detail  Return detailed information about public images
GET     /images/<ID>    Return metadata about an image in HTTP headers
POST    /images         Register metadata about a new image
PUT     /images/<ID>    Update metadata about an existing image
DELETE  /images/<ID>    Remove an image's metadata from the registry

通过 GET /images and GET /images/detail对镜像过滤查询

 
支持以下参数:
  • name=NAME

    Filters images having a name attribute matching NAME.

  • container_format=FORMAT

    Filters images having a container_format attribute matching FORMAT

    For more information, see About Disk and Container Formats

  • disk_format=FORMAT

    Filters images having a disk_format attribute matching FORMAT

    For more information, see About Disk and Container Formats

  • status=STATUS

    Filters images having a status attribute matching STATUS

    For more information, see About Image Statuses

  • size_min=BYTES

    Filters images having a size attribute greater than or equal to BYTES

  • size_max=BYTES

    Filters images having a size attribute less than or equal to BYTES

These two resources also accept sort parameters:

  • sort_key=KEY

    Results will be ordered by the specified image attribute KEY. Accepted values include idnamestatusdisk_format,container_formatsizecreated_at (default) and updated_at.

  • sort_dir=DIR

    Results will be sorted in the direction DIR. Accepted values are asc for ascending or desc (default) for descending.

     
 

POST /images

request的body部分使用json编码,比如以下格式:
{'image':
  {'id': <ID>|None,
   'name': <NAME>,
   'status': <STATUS>,
   'disk_format': <DISK_FORMAT>,
   'container_format': <CONTAINER_FORMAT>,
   'properties': [ ... ]
  }
}
如果输入不满足以下条件,将返回400错误:
  • status must be non-empty, and must be one of activesavingqueued, or killed
  • disk_format must be non-empty, and must be one of ariakiamirawisovhdvdiqcow2, or vmdk
  • container_format must be non-empty, and must be on of ariakiamibare, or ovf
  • If disk_format or container_format is ariakiami, then both disk_format and container_format must be the same.

Glance的架构:

Glance被设计为可以使用多种后端存储。

前端通过API Server向多个Client提供服务。

Glance目前提供的参考实现中Registry Server仅是使用Sql数据库存储metadata

Glance目前支持S3,Swift,简单的文件存储及只读的HTTPS存储。

后续也可能支持其他后端,如分布式存储系统(SheepDog或Ceph)。

Popular Use Cases 

Service Providers  提供IAAS虚拟机镜像注册
Enterprises创造了一个低成本备份平台(DR/BCP)来备份他们的镜像

ISVS提供他们软件的预先设置优化的镜像

Key Features

配置并使用标准命令行和配置选项处理,使用粘贴部署配置
注册数据库支持版本控制,因此可以升级或降级
通过disk format和container format组合,支持EC2等多种镜像格式
全新的命令行,允许用户同镜像服务交互,如增改镜像属性,查看删除镜像
通过checksum确认镜像完整性
独立配置日志功能
提供了功能测试组件,可以启动停止glance服务并执行功能进行测试。可以使用命令行或者CURL

原文地址:https://www.cnblogs.com/licheng/p/2534760.html