Project

General

Profile

Actions

User story #10507

closed

Generic method to edit separate parameters in key="values" line

Added by Nicolas CHARLES over 7 years ago. Updated over 2 years ago.

Status:
Released
Priority:
N/A
Category:
Generic methods
Target version:
UX impact:
Suggestion strength:
User visibility:
Effort required:
Name check:
Fix check:
Regression:

Description

The idea is to develop a generic method, that can ensure that one parameter exists in a list of parameters, on one single line, in the right hand side of a key=value line, where all parameters are separated by a unique character (presumably different than the key-value seperator - '=' in this example, but this may actually not be a limitation). It would look something like this:

file_edit_line_key_value_ensure_parameter_in_list(file_name, key, key_value_separator, parameter, parameter_separator)

Where:
- file_name is a string with the full path to the file to look into ("/etc/default/grub", for example)
- key is a string with the full key name ("GRUB_CMDLINE_XEN" for example)
- key_value_separator is a character used to separate key and value in a key-value line ("=" in example)
- parameter is a string representing the sub-value to ensure is present in the list of parameters that form the value part of that line. If missing, it will be added (probably at the end) ("dom0_max_vcpus=32" in example below)
- parameter_separator is a character used to separate parameters in the list (" " in example)

In file /etc/default/grub
GRUB_CMDLINE_XEN="dom0_mem=16G"
calling the method would result in
GRUB_CMDLINE_XEN="dom0_mem=16G dom0_max_vcpus=32"


Subtasks 2 (0 open2 closed)

User story #10533: adapt reporting for ncf 1.0ReleasedAlexis MoussetActions
Bug #10535: Add missing option to use "space" as a parameter separator in file_ensure_key_value_parameter_in_listReleasedAlexis MoussetActions

Related issues 1 (0 open1 closed)

Related to Rudder - User story #10561: Generic method to remove separate parameters in key="values" lineReleasedAlexis MoussetActions
Actions

Also available in: Atom PDF