Ejemplo n.º 1
0
def get_cached_image(context, instance):
    base_disk_path = pathutils.base_disk_path(instance)

    for disk_format in constants.ALL_DISK_FORMATS:
        test_path = base_disk_path + '.' + disk_format.lower()
        if os.path.exists(test_path):
            return test_path

    sync = utils.synchronized(base_disk_path)
    synchronized_fetch_image = sync(_fetch_image)
    disk_path = synchronized_fetch_image(context, instance, base_disk_path)

    return disk_path
Ejemplo n.º 2
0
def get_cached_image(context, instance):
    base_disk_path = pathutils.base_disk_path(instance)

    for disk_format in constants.ALL_DISK_FORMATS:
        test_path = base_disk_path + '.' + disk_format.lower()
        if os.path.exists(test_path):
            return test_path

    sync = utils.synchronized(base_disk_path)
    synchronized_fetch_image = sync(_fetch_image)
    disk_path = synchronized_fetch_image(context, instance, base_disk_path)

    return disk_path
Ejemplo n.º 3
0
def _lock_for_refresh(base_file):
    lock_name = 'refresh-%s' % os.path.split(base_file)[-1]
    return utils.synchronized(lock_name, external=True,
                              lock_path=_get_lock_path())