MXS-1300: Make MaxCtrl more like a library
All invocations into the common helper functions are now done through the `maxctrl` function. This allows the program arguments to be passed to the core as a parameter instead of reading them from global variables. This helps with the implicit initialization that was done when the yargs library was required which caused duplicated output. Refactored the core functions so that they only process the argument vector. The parsing of the argument vector is done in maxctrl.js where it is more appropriate.
This commit is contained in:
@ -26,19 +26,24 @@ exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('log-priority <log>', 'Disable log priority [warning|notice|info|debug]', {}, function(argv) {
|
||||
if (log_levels.indexOf(argv.log) != -1) {
|
||||
updateValue('maxscale/logs', 'data.attributes.parameters.log_' + argv.log, false)
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.log_' + argv.log, false)
|
||||
} else {
|
||||
logError('Invalid log priority: ' + argv.log);
|
||||
maxctrl(argv)
|
||||
.logError('Invalid log priority: ' + argv.log);
|
||||
}
|
||||
})
|
||||
.command('maxlog', 'Disable MaxScale logging', {}, function(argv) {
|
||||
updateValue('maxscale/logs', 'data.attributes.parameters.maxlog', false)
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.maxlog', false)
|
||||
})
|
||||
.command('syslog', 'Disable syslog logging', {}, function(argv) {
|
||||
updateValue('maxscale/logs', 'data.attributes.parameters.syslog', false)
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.syslog', false)
|
||||
})
|
||||
.command('account <name>', 'Disable a Linux user account from administrative use', {}, function(argv) {
|
||||
doRequest('users/unix/' + argv.name, null, { method: 'DELETE'})
|
||||
maxctrl(argv)
|
||||
.doRequest('users/unix/' + argv.name, null, { method: 'DELETE'})
|
||||
})
|
||||
.usage('Usage: disable <command>')
|
||||
.help()
|
||||
|
Reference in New Issue
Block a user