Exemple #1
0
def read_yaml_file_section(control_console, file_path, section):
    sections, err = helpers.read_yaml_file(control_console, file_path)
    if err is not None:
        return None, err

    if section not in sections:
        return None, 'File {} does not contain section: {}'.format(
            file_path, section)

    return sections[section], None
Exemple #2
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