mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
Add CLI command to test reconfiguration status
Based on patch from Kenth Eriksson <kenth.eriksson@infinera.com>.
This commit is contained in:
parent
8a2cbb88d1
commit
9106a750cd
18
conf/conf.c
18
conf/conf.c
@ -444,6 +444,24 @@ config_undo(void)
|
|||||||
return CONF_PROGRESS;
|
return CONF_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
config_status(void)
|
||||||
|
{
|
||||||
|
if (shutting_down)
|
||||||
|
return CONF_SHUTDOWN;
|
||||||
|
|
||||||
|
if (configuring)
|
||||||
|
return future_cftype ? CONF_QUEUED : CONF_PROGRESS;
|
||||||
|
|
||||||
|
return CONF_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
btime
|
||||||
|
config_timer_status(void)
|
||||||
|
{
|
||||||
|
return tm_active(config_timer) ? tm_remains(config_timer) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
extern void cmd_reconfig_undo_notify(void);
|
extern void cmd_reconfig_undo_notify(void);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -69,6 +69,8 @@ void config_free(struct config *);
|
|||||||
int config_commit(struct config *, int type, uint timeout);
|
int config_commit(struct config *, int type, uint timeout);
|
||||||
int config_confirm(void);
|
int config_confirm(void);
|
||||||
int config_undo(void);
|
int config_undo(void);
|
||||||
|
int config_status(void);
|
||||||
|
btime config_timer_status(void);
|
||||||
void config_init(void);
|
void config_init(void);
|
||||||
void cf_error(const char *msg, ...) NORET;
|
void cf_error(const char *msg, ...) NORET;
|
||||||
void config_add_obstacle(struct config *);
|
void config_add_obstacle(struct config *);
|
||||||
|
@ -18,7 +18,7 @@ static struct log_config *this_log;
|
|||||||
CF_DECLS
|
CF_DECLS
|
||||||
|
|
||||||
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
|
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
|
||||||
CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING)
|
CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS)
|
||||||
|
|
||||||
%type <i> log_mask log_mask_list log_cat cfg_timeout
|
%type <i> log_mask log_mask_list log_cat cfg_timeout
|
||||||
%type <t> cfg_name
|
%type <t> cfg_name
|
||||||
@ -124,6 +124,9 @@ CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate und
|
|||||||
CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
|
CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
|
||||||
{ cmd_reconfig_undo(); } ;
|
{ cmd_reconfig_undo(); } ;
|
||||||
|
|
||||||
|
CF_CLI(CONFIGURE STATUS,,, [[Show configuration status]])
|
||||||
|
{ cmd_reconfig_status(); } ;
|
||||||
|
|
||||||
CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
|
CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
|
||||||
{ cmd_check_config($3); } ;
|
{ cmd_check_config($3); } ;
|
||||||
|
|
||||||
|
@ -339,6 +339,28 @@ cmd_reconfig_undo(void)
|
|||||||
cmd_reconfig_msg(r);
|
cmd_reconfig_msg(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_reconfig_status(void)
|
||||||
|
{
|
||||||
|
int s = config_status();
|
||||||
|
btime t = config_timer_status();
|
||||||
|
|
||||||
|
switch (s)
|
||||||
|
{
|
||||||
|
case CONF_DONE: cli_msg(-3, "Daemon is up and running"); break;
|
||||||
|
case CONF_PROGRESS: cli_msg(-4, "Reconfiguration in progress"); break;
|
||||||
|
case CONF_QUEUED: cli_msg(-5, "Reconfiguration in progress, next one enqueued"); break;
|
||||||
|
case CONF_SHUTDOWN: cli_msg(-6, "Shutdown in progress"); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t >= 0)
|
||||||
|
cli_msg(-22, "Configuration unconfirmed, undo in %t s", t);
|
||||||
|
|
||||||
|
cli_msg(0, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Command-Line Interface
|
* Command-Line Interface
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,7 @@ void cmd_check_config(char *name);
|
|||||||
void cmd_reconfig(char *name, int type, uint timeout);
|
void cmd_reconfig(char *name, int type, uint timeout);
|
||||||
void cmd_reconfig_confirm(void);
|
void cmd_reconfig_confirm(void);
|
||||||
void cmd_reconfig_undo(void);
|
void cmd_reconfig_undo(void);
|
||||||
|
void cmd_reconfig_status(void);
|
||||||
void cmd_shutdown(void);
|
void cmd_shutdown(void);
|
||||||
|
|
||||||
#define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300
|
#define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300
|
||||||
|
Loading…
Reference in New Issue
Block a user