HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //lib/python3/dist-packages/cloudinit/config/cc_write_files_deferred.py
# Copyright (C) 2021 Canonical Ltd.
#
# This file is part of cloud-init. See LICENSE file for license information.

"""Defer writing certain files"""

from textwrap import dedent

from cloudinit.config.schema import validate_cloudconfig_schema
from cloudinit import util
from cloudinit.config.cc_write_files import (
    schema as write_files_schema, write_files, DEFAULT_DEFER)


schema = util.mergemanydict([
    {
        'id': 'cc_write_files_deferred',
        'name': 'Write Deferred Files',
        'title': dedent("""\
            write certain files, whose creation as been deferred, during
            final stage
        """),
        'description': dedent("""\
            This module is based on `'Write Files' <write-files>`__, and
            will handle all files from the write_files list, that have been
            marked as deferred and thus are not being processed by the
            write-files module.

            *Please note that his module is not exposed to the user through
            its own dedicated top-level directive.*
        """)
    },
    write_files_schema
])

# Not exposed, because related modules should document this behaviour
__doc__ = None


def handle(name, cfg, _cloud, log, _args):
    validate_cloudconfig_schema(cfg, schema)
    file_list = cfg.get('write_files', [])
    filtered_files = [
        f for f in file_list if util.get_cfg_option_bool(f,
                                                         'defer',
                                                         DEFAULT_DEFER)
    ]
    if not filtered_files:
        log.debug(("Skipping module named %s,"
                   " no deferred file defined in configuration"), name)
        return
    write_files(name, filtered_files)


# vi: ts=4 expandtab