parse.h¶
Parsing Netplan YAML configuration into NetplanParser data structures.
Functions
-
NetplanParser *netplan_parser_new()¶
Allocate and initialize a new NetplanParser object.
Note
This contains unvalidated Netplan configuration from raw input, like Netplan YAML or NetworkManager keyfile.
- Returns:
An empty NetplanParser
-
void netplan_parser_reset(NetplanParser *npp)¶
Reset a NetplanParser to its initial default values.
Freeing any dynamically allocated parsing data.
- Parameters:
npp -- [in] The NetplanParser to be reset
-
void netplan_parser_clear(NetplanParser **npp)¶
Free a NetplanParser, including any dynamically allocated data.
Similar to netplan_parser_reset, but also free and nullify the object itself.
- Parameters:
npp -- [out] The NetplanParser to free and nullify
-
gboolean netplan_parser_set_flags(NetplanParser *npp, unsigned int flags, NetplanError **error)¶
Set NetplanParser flags.
Parser flags are used to change the default behavior of the parser.
- Parameters:
npp -- [in] The NetplanParser to set the flags.
flags -- [in] The value of the flags. The possible values are defined in NETPLAN_PARSER_FLAGS
error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure
-
unsigned int netplan_parser_get_flags(const NetplanParser *npp)¶
Get NetplanParser flags.
Parser flags are used to change the default behavior of the parser.
- Parameters:
npp -- [in] The NetplanParser to get the flags from.
- Returns:
The current flags set in the parser.
-
unsigned int netplan_parser_get_error_count(const NetplanParser *npp)¶
Get NetplanParser error count.
The number of errors that were ignored when the IGNORE_ERRORS is used.
- Parameters:
npp -- [in] The NetplanParser to get the error count from.
- Returns:
The current error count.
-
gboolean netplan_parser_load_yaml(NetplanParser *npp, const char *filename, NetplanError **error)¶
Parse a given YAML file and create or update the list of NetplanNetDefinition inside
npp
.- Parameters:
npp -- [in] The NetplanParser object that should contain the parsed data
filename -- [in] Full path to a Netplan YAML configuration file
error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure
-
gboolean netplan_parser_load_yaml_from_fd(NetplanParser *npp, int input_fd, NetplanError **error)¶
Parse a given YAML file from a file descriptor and create or update the list of NetplanNetDefinition inside
npp
.- Parameters:
npp -- [in] The NetplanParser object that should contain the parsed data
input_fd -- [in] File descriptor reference to a Netplan YAML configuration file
error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure
-
gboolean netplan_parser_load_yaml_hierarchy(NetplanParser *npp, const char *rootdir, NetplanError **error)¶
Parse a full hierarchy of
/{usr/lib,etc,run}/netplan/\*.yaml
files insiderootdir
and create or update the list of NetplanNetDefinition insidenpp
.Note
Files with “asciibetically” higher names override/append settings from earlier ones (in all Netplan config directories); files in
/run/netplan/
shadow files in/etc/netplan/
, which shadow files in/usr/lib/netplan/
.- Parameters:
npp -- [in] The NetplanParser object that should contain the parsed data
rootdir -- [in] If not
NULL
, parse configuration from this root directory (useful for testing)error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure
-
gboolean netplan_parser_load_nullable_fields(NetplanParser *npp, int input_fd, NetplanError **error)¶
Parse a Netplan YAML configuration file from a file descriptor, containing settings that are about to be deleted (e.g.
some.setting=NULL
).The
NULL
-settings are ignored when parsing subsequent YAML files.- Parameters:
npp -- [in] The NetplanParser object that should contain the parsed data
input_fd -- [in] File descriptor reference to a Netplan YAML configuration file
error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure
-
gboolean netplan_parser_load_nullable_overrides(NetplanParser *npp, int input_fd, const char *constraint, NetplanError **error)¶
Parse a Netplan YAML configuration file from a file descriptor, containing special settings that are to be overriden inside the YAML hierarchy by the resulting “origin-hint” output file.
Global settings (like
renderer
) or NetplanNetDefinition, defined ininput_fd
are ignored in the existing YAML hierarchy because theinput_fd
configuration overrides those settings via the “origin-hint” output file.Note
Those settings are supposed to be parsed from the “origin-hint” output file given in
constraint
only.- Parameters:
npp -- [in] The NetplanParser object that should contain the parsed data
input_fd -- [in] File descriptor reference to a Netplan YAML configuration file, which would become the “origin-hint” output file afterwards
constraint -- [in] Basename of the “origin-hint” output file
error -- [out] Filled with a NetplanError in case of failure
- Returns:
Indication of success or failure