Skip to content

Commit

Permalink
ifup: Add ni_ifup_start_policies() for cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wipawel committed Jun 6, 2014
1 parent fa16834 commit e64ff92
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions client/ifup.c
Expand Up @@ -144,6 +144,31 @@ ni_ifup_hire_nanny(ni_ifworker_t *w)
return rv;
}

static ni_bool_t
ni_ifup_start_policies(ni_ifworker_array_t *array, ni_bool_t set_persistent)
{
unsigned int i;
ni_bool_t rv = TRUE;

for (i = 0; i < array->count; i++) {
ni_ifworker_t *w = array->data[i];

if (set_persistent)
ni_cient_state_set_persistent(w->config.node);

if (!ni_ifup_hire_nanny(w)) {
ni_error("%s: unable to apply configuration to nanny", w->name);
rv = FALSE;
}
else
ni_info("%s: configuration applied to nanny", w->name);
}

if (0 == array->count)
printf("ifup: no matching interfaces\n");

return rv;
}

/*
* Wickedd is sending us a signal indicating internal device state change.
Expand Down Expand Up @@ -241,10 +266,9 @@ ni_do_ifup(int argc, char **argv)
ni_ifworker_array_t ifmarked;
ni_string_array_t opt_ifconfig = NI_STRING_ARRAY_INIT;
ni_bool_t check_prio = TRUE, set_persistent = FALSE;
unsigned int i;
ni_fsm_t *fsm;
int c, status = NI_WICKED_RC_USAGE;
unsigned int timeout = 0;
ni_fsm_t *fsm;

fsm = ni_fsm_new();
ni_assert(fsm);
Expand Down Expand Up @@ -411,23 +435,10 @@ ni_do_ifup(int argc, char **argv)
ni_fsm_get_matching_workers(fsm, &ifmatch, &ifmarked);
}

if (0 == ifmarked.count)
printf("ifup: no matching interfaces\n");

for (i = 0; i < ifmarked.count; i++) {
ni_ifworker_t *w = ifmarked.data[i];

if (set_persistent)
ni_cient_state_set_persistent(w->config.node);

if (!ni_ifup_hire_nanny(w)) {
status = NI_WICKED_RC_NOT_CONFIGURED;
ni_error("%s: unable to apply configuration to nanny", w->name);
}
else
ni_info("%s: configuration applied to nanny", w->name);
}
if (!ni_ifup_start_policies(&ifmarked, set_persistent))
status = NI_WICKED_RC_NOT_CONFIGURED;

/* Wait for device-up events */
ni_timer_register(ni_wait_for_interfaces, ni_ifup_timer_expires, &status);
while (status == NI_WICKED_RC_SUCCESS) {
/* status is already success */
Expand Down

0 comments on commit e64ff92

Please sign in to comment.