Merge pull request #122 from ifupdown-ng/feature/configure-auto-executor-selection
Feature/configure auto executor selection
This commit is contained in:
commit
d250ab213c
7 changed files with 37 additions and 8 deletions
7
dist/ifupdown-ng.conf.example
vendored
7
dist/ifupdown-ng.conf.example
vendored
|
@ -17,6 +17,13 @@ allow_addon_scripts = 1
|
||||||
# templates. Valid values are 0 and 1, the default is 1.
|
# templates. Valid values are 0 and 1, the default is 1.
|
||||||
allow_any_iface_as_template = 1
|
allow_any_iface_as_template = 1
|
||||||
|
|
||||||
|
# auto_executor_selection:
|
||||||
|
# Automatically determine which executors are needed to bring up an
|
||||||
|
# interface. An admin may choose to disable this setting and explicitly
|
||||||
|
# define which executors to use with `use` statements.
|
||||||
|
# Valid values are 0 and 1, the default is 1.
|
||||||
|
auto_executor_selection = 1
|
||||||
|
|
||||||
# compat_create_interfaces:
|
# compat_create_interfaces:
|
||||||
# Denotes where or not to create interfaces when compat_* settings are
|
# Denotes where or not to create interfaces when compat_* settings are
|
||||||
# active and it would be necessary to create an interface to be fully
|
# active and it would be necessary to create an interface to be fully
|
||||||
|
|
|
@ -60,6 +60,12 @@ Currently the following settings are supported in
|
||||||
in order to require inheritance from specified templates.
|
in order to require inheritance from specified templates.
|
||||||
Valid values are `0` and `1`, the default is `1`.
|
Valid values are `0` and `1`, the default is `1`.
|
||||||
|
|
||||||
|
* `auto_executor_selection`: Automatically select executors based
|
||||||
|
on the presence of their config options. An admin may choose to
|
||||||
|
disable this setting in order to require explicitly enabling
|
||||||
|
executors through `use` statements. Valid values are `0` and `1`,
|
||||||
|
the default is `1`.
|
||||||
|
|
||||||
* `compat_create_interfaces`:
|
* `compat_create_interfaces`:
|
||||||
Denotes where or not to create interfaces when compat\_* settings are
|
Denotes where or not to create interfaces when compat\_* settings are
|
||||||
active and it would be necessary to create an interface to be fully
|
active and it would be necessary to create an interface to be fully
|
||||||
|
|
|
@ -17,6 +17,12 @@ configuration options.
|
||||||
performance improvements in setups where only ifupdown-ng executors
|
performance improvements in setups where only ifupdown-ng executors
|
||||||
are used. Valid values are _0_ and _1_, the default is _1_.
|
are used. Valid values are _0_ and _1_, the default is _1_.
|
||||||
|
|
||||||
|
*auto_executor_selection* _bool_
|
||||||
|
Automatically determine which executors to use. At present, this
|
||||||
|
is done by inserting `use` statements for the namespace a config
|
||||||
|
option has. The namespace is separated from the config option with
|
||||||
|
a dash (`-`). Valid values are _0_ and _1_, the default is _1_.
|
||||||
|
|
||||||
*use_hostname_for_dhcp* _bool_
|
*use_hostname_for_dhcp* _bool_
|
||||||
Automatically learn the hostname property, used for DHCP
|
Automatically learn the hostname property, used for DHCP
|
||||||
configuration by querying the system hostname using uname(2).
|
configuration by querying the system hostname using uname(2).
|
||||||
|
|
|
@ -108,9 +108,9 @@ the system will only respond to certain keywords by default:
|
||||||
configuration data from _object_. Normally _object_
|
configuration data from _object_. Normally _object_
|
||||||
must be a *template*.
|
must be a *template*.
|
||||||
|
|
||||||
*use* _option_
|
*use* _executor_
|
||||||
Designates that an option should be used. See _OPTIONS_
|
Designates that an executor should be used. See _EXECUTORS_
|
||||||
section for more information on options.
|
section for more information on executors.
|
||||||
|
|
||||||
*pre-down* _command_
|
*pre-down* _command_
|
||||||
Runs _command_ before taking the interface down.
|
Runs _command_ before taking the interface down.
|
||||||
|
@ -133,11 +133,11 @@ the system will only respond to certain keywords by default:
|
||||||
Additional packages such as *bonding*, *bridge*, *tunnel*, *vrf* and
|
Additional packages such as *bonding*, *bridge*, *tunnel*, *vrf* and
|
||||||
*vxlan* add additional keywords to this vocabulary.
|
*vxlan* add additional keywords to this vocabulary.
|
||||||
|
|
||||||
# OPTIONS
|
# EXECUTORS
|
||||||
|
|
||||||
The *use* keyword designates that an _option_ should be used.
|
The *use* keyword designates that an _executor_ should be used.
|
||||||
This system is extendable by additional packages, but the
|
This system is extendable by additional packages, but the
|
||||||
most common options are:
|
most common executors are:
|
||||||
|
|
||||||
*batman*
|
*batman*
|
||||||
The interface is a B.A.T.M.A.N. adv. mesh interface.
|
The interface is a B.A.T.M.A.N. adv. mesh interface.
|
||||||
|
@ -181,8 +181,12 @@ most common options are:
|
||||||
*wireguard*
|
*wireguard*
|
||||||
The interface is a Wireguard VPN tunnel endpoint.
|
The interface is a Wireguard VPN tunnel endpoint.
|
||||||
|
|
||||||
Check *interfaces-<option>(5)* for further informaton about a given
|
Check *interfaces-<executor>(5)* for further informaton about a given
|
||||||
option and available configuration parameters.
|
executor and available configuration parameters.
|
||||||
|
|
||||||
|
If the _auto\_executor\_selection_ ifupdown-ng.conf option is enabled,
|
||||||
|
*use* statements will automatically be added for executors when their
|
||||||
|
configuration statements are present in the interfaces file.
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
struct lif_config_file lif_config = {
|
struct lif_config_file lif_config = {
|
||||||
.allow_addon_scripts = true,
|
.allow_addon_scripts = true,
|
||||||
.allow_any_iface_as_template = true,
|
.allow_any_iface_as_template = true,
|
||||||
|
.auto_executor_selection = true,
|
||||||
.compat_create_interfaces = true,
|
.compat_create_interfaces = true,
|
||||||
.compat_ifupdown2_bridge_ports_inherit_vlans = true,
|
.compat_ifupdown2_bridge_ports_inherit_vlans = true,
|
||||||
.implicit_template_conversion = true,
|
.implicit_template_conversion = true,
|
||||||
|
@ -49,6 +50,7 @@ set_bool_value(const char *key, const char *value, void *opaque)
|
||||||
static struct lif_config_handler handlers[] = {
|
static struct lif_config_handler handlers[] = {
|
||||||
{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts},
|
{"allow_addon_scripts", set_bool_value, &lif_config.allow_addon_scripts},
|
||||||
{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template},
|
{"allow_any_iface_as_template", set_bool_value, &lif_config.allow_any_iface_as_template},
|
||||||
|
{"auto_executor_selection", set_bool_value, &lif_config.auto_executor_selection},
|
||||||
{"compat_create_interfaces", set_bool_value, &lif_config.compat_create_interfaces},
|
{"compat_create_interfaces", set_bool_value, &lif_config.compat_create_interfaces},
|
||||||
{"compat_ifupdown2_bridge_ports_inherit_vlans", set_bool_value, &lif_config.compat_ifupdown2_bridge_ports_inherit_vlans},
|
{"compat_ifupdown2_bridge_ports_inherit_vlans", set_bool_value, &lif_config.compat_ifupdown2_bridge_ports_inherit_vlans},
|
||||||
{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion},
|
{"implicit_template_conversion", set_bool_value, &lif_config.implicit_template_conversion},
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
struct lif_config_file {
|
struct lif_config_file {
|
||||||
bool allow_addon_scripts;
|
bool allow_addon_scripts;
|
||||||
bool allow_any_iface_as_template;
|
bool allow_any_iface_as_template;
|
||||||
|
bool auto_executor_selection;
|
||||||
bool compat_create_interfaces;
|
bool compat_create_interfaces;
|
||||||
bool compat_ifupdown2_bridge_ports_inherit_vlans;
|
bool compat_ifupdown2_bridge_ports_inherit_vlans;
|
||||||
bool implicit_template_conversion;
|
bool implicit_template_conversion;
|
||||||
|
|
|
@ -216,6 +216,9 @@ handle_generic(struct lif_interface_file_parse_state *state, char *token, char *
|
||||||
|
|
||||||
lif_dict_add(&state->cur_iface->vars, token, strdup(bufp));
|
lif_dict_add(&state->cur_iface->vars, token, strdup(bufp));
|
||||||
|
|
||||||
|
if (!lif_config.auto_executor_selection)
|
||||||
|
return true;
|
||||||
|
|
||||||
/* Check if token looks like <word1>-<word*> and assume <word1> is an addon */
|
/* Check if token looks like <word1>-<word*> and assume <word1> is an addon */
|
||||||
char *word_end = strchr(token, '-');
|
char *word_end = strchr(token, '-');
|
||||||
if (word_end != NULL)
|
if (word_end != NULL)
|
||||||
|
|
Loading…
Reference in a new issue