glance_store.multi_backend 模块¶
- glance_store.multi_backend.add(conf, image_id, data, size, backend, context=None, verifier=None)¶
- glance_store.multi_backend.add_with_multihash(conf, image_id, data, size, backend, hashing_algo, scheme=None, context=None, verifier=None)¶
- glance_store.multi_backend.check_location_metadata(val, key='')¶
- glance_store.multi_backend.create_multi_stores(conf=<oslo_config.cfg.ConfigOpts 对象>, reserved_stores=None)¶
注册所有存储模块和给定配置对象中的所有方案。
- 参数:
conf – 一个 oslo_config(或兼容)对象
reserved_stores – 用于消费服务内部使用的存储列表。该列表必须与配置设置
enabled_backends的格式相同。默认值为 None
- 返回值:
配置的存储数量
- 引发:
glance_store.exceptions.BackendException
配置多个后端
要配置的后端预计在
enabled_backends配置变量中找到,该变量位于对象 DEFAULT 组中。该变量的格式是键值对的字典,其中键是任意存储标识符,值是存储类型的标识符。类型标识符必须在 glance_store 的
[entry points]部分的setup.cfg文件中定义为glance_store.drivers配置的值。(有关示例,请参阅默认setup.cfg文件。)当前支持的驱动程序的存储类型标识符已在文件中定义。因此,
enabled_backends的示例值是{'store_one': 'http', 'store_two': 'file', 'store_three': 'rbd'}
如果包含,
reserved_stores参数必须具有相同的格式。从 glance_store 的角度来看,enabled_backends和reserved_stores之间没有区别:保留的存储对于消费服务来说是一种便利,它可能希望以不同的方式处理这两组存储。默认存储
如果您希望设置默认存储,则其存储标识符应定义为
conf参数的glance_store组中的default_backend配置选项的值。存储标识符当然应指定为enabled_backends字典中的一个键。建议设置默认存储。配置单个后端
要配置在
enabled_backends配置选项中提到的每个存储,您必须定义一个选项组,其名称与存储标识符相同。为该后端定义的选项将取决于存储类型;请查阅适当的后端驱动程序的文档以确定这些选项是什么。例如,给定上面的
enabled_backends示例,您将把以下内容放在加载conf对象的配置文件中[DEFAULT] enabled_backends = store_one:rbd,store_two:file,store_three:http [store_one] store_description = "A human-readable string aimed at end users" rbd_store_chunk_size = 8 rbd_store_pool = images rbd_store_user = admin rbd_store_ceph_conf = /etc/ceph/ceph.conf [store_two] store_description = "Human-readable description of this store" filesystem_store_datadir = /opt/stack/data/glance/store_two [store_three] store_description = "A read-only store" https_ca_certificates_file = /opt/stack/certs/gs.cert [glance_store] default_backend = store_two
store_description选项可供消费服务使用。如上所述,此文件还定义了一个默认后端。
- glance_store.multi_backend.delete(uri, backend, context=None)¶
从由 uri 指定的后端删除数据块。
- glance_store.multi_backend.get(uri, backend, offset=0, chunk_size=None, context=None)¶
从由 uri 指定的后端生成数据块。
- glance_store.multi_backend.get_known_schemes_for_multi_store()¶
返回已知方案列表。
- glance_store.multi_backend.get_size_from_uri_and_backend(uri, backend, context=None)¶
从由 uri 指定的后端检索图像大小。
- glance_store.multi_backend.get_store_from_store_identifier(store_identifier)¶
根据标识符确定后端存储。
给定存储标识符,返回适当的存储对象以处理该方案。
- glance_store.multi_backend.get_store_weight(store_identifier)¶
根据标识符确定后端存储权重。
给定存储标识符,从内存中返回存储的适当权重。
- glance_store.multi_backend.register_store_opts(conf, reserved_stores=None)¶
- glance_store.multi_backend.set_acls_for_multi_store(location_uri, backend, public=False, read_tenants=[], write_tenants=None, context=None)¶
- glance_store.multi_backend.store_add_to_backend(image_id, data, size, store, context=None, verifier=None)¶
对每个存储的 add() 方法的调用包装器。
这为 glance 提供了一个通用的位置来检查输出。
- 参数:
image_id – 要添加数据的图像
data – 要存储的数据
size – 数据的大小(以字节为单位)
store – 要添加数据的存储
context – 请求上下文
verifier – 用于验证图像签名的对象
backend – 存储图像的后端
- 返回值:
文件的 url 位置、数据量大小、数据的校验和、存储系统的元数据字典
- glance_store.multi_backend.store_add_to_backend_with_multihash(image_id, data, size, hashing_algo, store, context=None, verifier=None)¶
对每个存储的 add() 方法的调用包装器,该方法需要一个 hashing_algo 标识符,并返回一个 5 元组,其中包括使用指定的 hashing_algo 计算的“multihash”。(这是 store_add_to_backend() 的增强版本,为了向后兼容而保持不变。)
- 参数:
image_id – 要添加数据的图像
data – 要存储的数据
size – 数据的大小(以字节为单位)
store – 要添加数据的存储
hashing_algo – 一个 hashlib 算法标识符(字符串)
context – 请求上下文
verifier – 用于验证图像签名的对象
- 返回值:
文件的 url 位置、数据量大小、数据的校验和、数据的多哈希值、存储系统的元数据字典
- 引发:
glance_store.exceptions.BackendExceptionglance_store.exceptions.UnknownHashingAlgo
- glance_store.multi_backend.verify_store()¶