コード例 #1
0
def patch_file_clusterwide(control_console, file_path):
    file_ext = os.path.splitext(file_path)[1]
    assert file_ext in [
        '.yml', '.yaml'
    ], "Impossible to use '%s' file in patch clusterwide function" % file_ext

    new_sections, err = helpers.read_yaml_file(control_console, file_path)
    assert err is None, err

    old_sections, err = helpers.get_clusterwide_config(control_console)
    assert err is None, err

    for section, value in old_sections.items():
        new_sections[section] = new_sections.get(section)

    changed, err = helpers.patch_clusterwide_config(control_console,
                                                    new_sections)
    assert err is None, err
    return changed
コード例 #2
0
def config_app(params):
    control_console = helpers.get_control_console(params['console_sock'])
    config = params['app_config']

    new_sections = {}
    for section_name, section in config.items():
        if section_is_deleted(section):
            new_sections[section_name] = None
        else:
            new_sections[section_name] = section.get('body')

    helpers.set_twophase_options_from_params(control_console, params)

    changed, err = helpers.patch_clusterwide_config(control_console,
                                                    new_sections)
    if err is not None:
        return helpers.ModuleRes(failed=True, msg=err)

    return helpers.ModuleRes(changed=changed)