首页 > 编程语言 > 详细

nova - nova base image id的生成算法

时间:2016-08-15 22:53:05      阅读:645      评论:0      收藏:0      [点我收藏+]

nova spawn instance的时候,会先create_image,下面是获取的base image的函数

def get_cache_fname(images, key):
    """Return a filename based on the SHA1 hash of a given image ID.
    Image files stored in the _base directory that match this pattern
    are considered for cleanup by the image cache manager. The cache
    manager considers the file to be in use if it matches an instance‘s
    image_ref, kernel_id or ramdisk_id property.
    However, in grizzly-3 and before, only the image_ref property was
    considered. This means that it‘s unsafe to store kernel and ramdisk
    images using this pattern until we‘re sure that all compute nodes
    are running a cache manager newer than grizzly-3. For now, we
    require admins to confirm that by setting the remove_unused_kernels
    boolean but, at some point in the future, we‘ll be safely able to
    assume this.
    """
    image_id = str(images[key])
    if ((not CONF.libvirt.remove_unused_kernels and     # remove_unused_kernels默认值是True
         key in [‘kernel_id‘, ‘ramdisk_id‘])):
        return image_id
    else:
        return hashlib.sha1(image_id).hexdigest()       # base image id生成


本文出自 “the-way-to-cloud” 博客,请务必保留此出处http://iceyao.blog.51cto.com/9426658/1838284

nova - nova base image id的生成算法

原文:http://iceyao.blog.51cto.com/9426658/1838284

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!