glance模块的配置文件glance-api.conf已将default_store设置为file,并且将swift、rbd、s3相关的配置选项全部注释掉了,但启动glance-api的时候控制台依然输出以上错误信息,虽然不影响使用,但看着终归不爽。
追踪代码后发现,glance的wsgi controller(位于glance/glance/api/v1/images.py)中包含了一个名为create_stores()的初始化函数,改函数的实现位于:glance/glance/store/__init__.py中,相关代码如下:
def create_stores(): """ Registers all store modules and all schemes from the given config. Duplicates are not re-registered. """ store_count = 0 store_classes = set() for store_entry in CONF.known_stores: store_entry = store_entry.strip() if not store_entry: continue store_cls = _get_store_class(store_entry) store_instance = store_cls() schemes = store_instance.get_schemes() ... ...
其中known_stores的默认值为:
cfg.ListOpt('known_stores', default=['glance.store.filesystem.Store', 'glance.store.http.Store', 'glance.store.rbd.Store', 'glance.store.s3.Store', 'glance.store.swift.Store', ]),
从中可以看到,通过遍历变量known_stores来依次初始化并加载各个后端。
解决方法很简单了,在glance-api.conf文件中添加如下的配置选项:
known_stores=glance.store.filesystem.Store