User story #10507
closedGeneric method to edit separate parameters in key="values" line
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"