]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: cli: move "{enable|disable} health" to server.c
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2016 11:51:04 +0000 (12:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2016 15:59:28 +0000 (16:59 +0100)
Also mention that "set server" is preferred now.

src/cli.c
src/server.c

index 50f47ae9106eb323432e6acb93e20fb1565b2eef..1661317ba160e1097c50949e7d5149eaf05eb773 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -675,22 +675,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                        sv->agent.state |= CHK_ST_ENABLED;
                        return 1;
                }
-               else if (strcmp(args[1], "health") == 0) {
-                       struct server *sv;
-
-                       sv = expect_server_admin(s, si, args[2]);
-                       if (!sv)
-                               return 1;
-
-                       if (!(sv->check.state & CHK_ST_CONFIGURED)) {
-                               appctx->ctx.cli.msg = "Health checks are not configured on this server, cannot enable.\n";
-                               appctx->st0 = STAT_CLI_PRINT;
-                               return 1;
-                       }
-
-                       sv->check.state |= CHK_ST_ENABLED;
-                       return 1;
-               }
                else { /* unknown "enable" parameter */
                        appctx->ctx.cli.msg = "'enable' only supports 'agent', 'frontend', 'health', and 'server'.\n";
                        appctx->st0 = STAT_CLI_PRINT;
@@ -708,16 +692,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                        sv->agent.state &= ~CHK_ST_ENABLED;
                        return 1;
                }
-               else if (strcmp(args[1], "health") == 0) {
-                       struct server *sv;
-
-                       sv = expect_server_admin(s, si, args[2]);
-                       if (!sv)
-                               return 1;
-
-                       sv->check.state &= ~CHK_ST_ENABLED;
-                       return 1;
-               }
                else { /* unknown "disable" parameter */
                        appctx->ctx.cli.msg = "'disable' only supports 'agent', 'frontend', 'health', and 'server'.\n";
                        appctx->st0 = STAT_CLI_PRINT;
index 81f345ce5a82a365371e39a1c88f251a77a715e2..57119101f55b370b08b62d747d441b0de8729f8c 100644 (file)
@@ -3583,6 +3583,22 @@ static int cli_parse_set_maxconn_server(char **args, struct appctx *appctx, void
        return 1;
 }
 
+/* parse a "disable health" command. It always returns 1. */
+static int cli_parse_disable_health(char **args, struct appctx *appctx, void *private)
+{
+       struct server *sv;
+
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
+
+       sv = cli_find_server(appctx, args[2]);
+       if (!sv)
+               return 1;
+
+       sv->check.state &= ~CHK_ST_ENABLED;
+       return 1;
+}
+
 /* parse a "disable server" command. It always returns 1. */
 static int cli_parse_disable_server(char **args, struct appctx *appctx, void *private)
 {
@@ -3599,6 +3615,22 @@ static int cli_parse_disable_server(char **args, struct appctx *appctx, void *pr
        return 1;
 }
 
+/* parse a "enable health" command. It always returns 1. */
+static int cli_parse_enable_health(char **args, struct appctx *appctx, void *private)
+{
+       struct server *sv;
+
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
+
+       sv = cli_find_server(appctx, args[2]);
+       if (!sv)
+               return 1;
+
+       sv->check.state |= CHK_ST_ENABLED;
+       return 1;
+}
+
 /* parse a "enable server" command. It always returns 1. */
 static int cli_parse_enable_server(char **args, struct appctx *appctx, void *private)
 {
@@ -3617,7 +3649,9 @@ static int cli_parse_enable_server(char **args, struct appctx *appctx, void *pri
 
 /* register cli keywords */
 static struct cli_kw_list cli_kws = {{ },{
+       { { "disable", "health",  NULL }, "disable health : disable health checks (use 'set server' instead)", cli_parse_disable_health, NULL },
        { { "disable", "server",  NULL }, "disable server : disable a server for maintenance (use 'set server' instead)", cli_parse_disable_server, NULL },
+       { { "enable", "health",  NULL }, "enable health  : enable health checks (use 'set server' instead)", cli_parse_enable_health, NULL },
        { { "enable", "server",  NULL }, "enable server  : enable a disabled server (use 'set server' instead)", cli_parse_enable_server, NULL },
        { { "set", "maxconn", "server",  NULL }, "set maxconn server : change a server's maxconn setting", cli_parse_set_maxconn_server, NULL },
        { { "set", "server", NULL }, "set server     : change a server's state, weight or address",  cli_parse_set_server },