Skip to content

Commit

Permalink
ifreload: Report ifstatus result
Browse files Browse the repository at this point in the history
  • Loading branch information
wipawel committed Jul 31, 2014
1 parent 51e8f55 commit e9f2a6b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions client/ifreload.c
Expand Up @@ -45,6 +45,7 @@
#include "ifup.h"
#include "ifdown.h"
#include "ifreload.h"
#include "ifstatus.h"

static int
ni_do_ifreload_direct(int argc, char **argv)
Expand Down Expand Up @@ -72,6 +73,7 @@ ni_do_ifreload_direct(int argc, char **argv)
ni_string_array_t opt_ifconfig = NI_STRING_ARRAY_INIT;
ni_ifworker_array_t up_marked = NI_IFWORKER_ARRAY_INIT;
ni_ifworker_array_t down_marked = NI_IFWORKER_ARRAY_INIT;
ni_string_array_t ifnames = NI_STRING_ARRAY_INIT;
ni_ifmatcher_t ifmatch;
ni_bool_t check_prio = TRUE;
ni_bool_t opt_persistent = FALSE;
Expand Down Expand Up @@ -220,6 +222,15 @@ ni_do_ifreload_direct(int argc, char **argv)

/* Getting an array of ifworkers matching arguments */
ni_fsm_get_matching_workers(fsm, &ifmatch, &down_marked);

if (ni_string_eq(ifmatch.name, "all") ||
ni_string_empty(ifmatch.name)) {
ni_string_array_destroy(&ifnames);
break;
}

if (ni_string_array_index(&ifnames, ifmatch.name) == -1)
ni_string_array_append(&ifnames, ifmatch.name);
}

for (i = 0; i < down_marked.count; ++i) {
Expand Down Expand Up @@ -295,6 +306,8 @@ ni_do_ifreload_direct(int argc, char **argv)
/* Execute the down run */
if (ni_fsm_schedule(fsm) != 0)
ni_fsm_mainloop(fsm);

status = ni_ifstatus_display_result(fsm, &ifnames, opt_transient);
}
}
else {
Expand All @@ -314,15 +327,13 @@ ni_do_ifreload_direct(int argc, char **argv)
if (ni_fsm_schedule(fsm) != 0)
ni_fsm_mainloop(fsm);

/* No error if all interfaces were good */
status = ni_fsm_fail_count(fsm) ?
NI_WICKED_RC_ERROR : NI_WICKED_RC_SUCCESS;
status = ni_ifstatus_display_result(fsm, &ifnames, opt_transient);

/* Do not report any transient errors to systemd (e.g. dhcp
* or whatever not ready in time) -- returning an error may
* cause to stop the network completely.
*/
if (!opt_transient)
if (!opt_systemd)
status = NI_LSB_RC_SUCCESS;
}
}
Expand All @@ -331,6 +342,7 @@ ni_do_ifreload_direct(int argc, char **argv)
}

cleanup:
ni_string_array_destroy(&ifnames);
ni_string_array_destroy(&opt_ifconfig);
ni_ifworker_array_destroy(&down_marked);
ni_ifworker_array_destroy(&up_marked);
Expand Down

0 comments on commit e9f2a6b

Please sign in to comment.