From 4cf17bc4505a09d1b166cd93aae6c2c9a32cd68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 30 Jun 2017 13:23:00 +0300 Subject: [PATCH] MXS-1300: Add set and clear commands The manipulation of server status is now possible with the set and clear commands. --- client/maxctrl/lib/clear.js | 28 ++++++++++++++++++++++++++++ client/maxctrl/lib/set.js | 28 ++++++++++++++++++++++++++++ client/maxctrl/maxctrl.js | 2 ++ 3 files changed, 58 insertions(+) create mode 100644 client/maxctrl/lib/clear.js create mode 100644 client/maxctrl/lib/set.js diff --git a/client/maxctrl/lib/clear.js b/client/maxctrl/lib/clear.js new file mode 100644 index 000000000..dd213e313 --- /dev/null +++ b/client/maxctrl/lib/clear.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ +require('../common.js')() + +exports.command = 'clear ' +exports.desc = 'Clear object status' +exports.handler = function() {} +exports.builder = function(yargs) { + yargs + .command('server ', 'Clear server status', {}, function(argv) { + var target = 'servers/' + argv.server + "/clear?status=" + argv.status + doRequest(target, null, {method: "POST"}) + }) + .command('*', 'the default command', {}, () => { + console.log("Unknown command. See output of 'help clear' for a list of commands.") + }) + .help() +} diff --git a/client/maxctrl/lib/set.js b/client/maxctrl/lib/set.js new file mode 100644 index 000000000..b41904cc9 --- /dev/null +++ b/client/maxctrl/lib/set.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ +require('../common.js')() + +exports.command = 'set ' +exports.desc = 'Set object status' +exports.handler = function() {} +exports.builder = function(yargs) { + yargs + .command('server ', 'Set server status', {}, function(argv) { + var target = 'servers/' + argv.server + "/set?status=" + argv.status + doRequest(target, null, {method: "POST"}) + }) + .command('*', 'the default command', {}, () => { + console.log("Unknown command. See output of 'help set' for a list of commands.") + }) + .help() +} diff --git a/client/maxctrl/maxctrl.js b/client/maxctrl/maxctrl.js index cd0185f32..c4e8d0442 100644 --- a/client/maxctrl/maxctrl.js +++ b/client/maxctrl/maxctrl.js @@ -52,6 +52,8 @@ program }) .command(require('./lib/list.js')) .command(require('./lib/show.js')) + .command(require('./lib/set.js')) + .command(require('./lib/clear.js')) .recommendCommands() .help() .demandCommand(1, 'At least one command is required')