Merge pull request #67 from ifupdown-ng/feature/create-destroy

create/destroy phases for interfaces
This commit is contained in:
Ariadne Conill 2020-09-09 14:41:52 -06:00 committed by GitHub
commit bdc66bcba9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -12,7 +12,7 @@ protocol documented in this man page.
# PHASES # PHASES
Executors are run to react to seven different phases and are not Executors are run to react to nine different phases and are not
required to take any specific action. These phases are: required to take any specific action. These phases are:
*depend* *depend*
@ -24,6 +24,10 @@ required to take any specific action. These phases are:
any dependencies, it may simply exit 0 without doing any dependencies, it may simply exit 0 without doing
anything. anything.
*create*
Called before *pre-up*, to explicitly allow for interface
creation if necessary.
*pre-up* *pre-up*
Called before the interface is going to be brought up. Called before the interface is going to be brought up.
@ -42,6 +46,10 @@ required to take any specific action. These phases are:
*post-down* *post-down*
Called after the interface was successfully taken down. Called after the interface was successfully taken down.
*destroy*
Called after *post-down* to allow for explicitly
destroying an interface if necessary.
# ENVIRONMENT # ENVIRONMENT
Executors are guaranteed to run with a core set of environment Executors are guaranteed to run with a core set of environment

View file

@ -352,6 +352,9 @@ lif_lifecycle_run(const struct lif_execute_opts *opts, struct lif_interface *ifa
* but, right now neither debian ifupdown or busybox ifupdown do any recovery, * but, right now neither debian ifupdown or busybox ifupdown do any recovery,
* so we wont right now. * so we wont right now.
*/ */
if (!lif_lifecycle_run_phase(opts, iface, "create", lifname, up))
return false;
if (!lif_lifecycle_run_phase(opts, iface, "pre-up", lifname, up)) if (!lif_lifecycle_run_phase(opts, iface, "pre-up", lifname, up))
return false; return false;
@ -376,6 +379,9 @@ lif_lifecycle_run(const struct lif_execute_opts *opts, struct lif_interface *ifa
if (!lif_lifecycle_run_phase(opts, iface, "post-down", lifname, up)) if (!lif_lifecycle_run_phase(opts, iface, "post-down", lifname, up))
return false; return false;
if (!lif_lifecycle_run_phase(opts, iface, "destroy", lifname, up))
return false;
/* when going up, dependents go down last. */ /* when going up, dependents go down last. */
if (!handle_dependents(opts, iface, collection, state, up)) if (!handle_dependents(opts, iface, collection, state, up))
return false; return false;