MXS-1300: Take the refactored core into use
The refactored maxctrl function is now in use.
This commit is contained in:
parent
b98b326bba
commit
3255d58e70
@ -52,7 +52,7 @@ module.exports = function() {
|
||||
|
||||
// Request a resource collection and format it as a table
|
||||
this.getCollection = function (host, resource, fields) {
|
||||
doRequest(host, resource, function(res) {
|
||||
return doRequest(host, resource, function(res) {
|
||||
|
||||
var header = []
|
||||
|
||||
@ -84,8 +84,7 @@ module.exports = function() {
|
||||
// Request a part of a resource as a collection
|
||||
this.getSubCollection = function (host, resource, subres, fields) {
|
||||
|
||||
doRequest(host, resource, function(res) {
|
||||
|
||||
return doRequest(host, resource, function(res) {
|
||||
var header = []
|
||||
|
||||
fields.forEach(function(i) {
|
||||
@ -118,7 +117,7 @@ module.exports = function() {
|
||||
// Request a single resource and format it as a key-value list
|
||||
this.getResource = function (host, resource, fields) {
|
||||
|
||||
doRequest(resource, function(res) {
|
||||
return doRequest(host, resource, function(res) {
|
||||
var table = getList()
|
||||
|
||||
fields.forEach(function(i) {
|
||||
@ -141,6 +140,12 @@ module.exports = function() {
|
||||
})
|
||||
}
|
||||
|
||||
this.updateValue = function(host, resource, key, value) {
|
||||
var body = {}
|
||||
_.set(body, key, value)
|
||||
return doRequest(host, resource, null, { method: 'PATCH', body: body })
|
||||
}
|
||||
|
||||
// Helper for converting endpoints to acutal URLs
|
||||
this.getUri = function(host, secure, endpoint) {
|
||||
var base = 'http://'
|
||||
@ -172,10 +177,12 @@ module.exports = function() {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}, function(err) {
|
||||
if (err.response.body) {
|
||||
if (err.response && err.response.body) {
|
||||
logError(JSON.stringify(err.response.body, null, 4))
|
||||
} else {
|
||||
} else if (err.statusCode) {
|
||||
logError('Server responded with ' + err.statusCode)
|
||||
} else {
|
||||
logError('Undefined error: ' + JSON.stringify(err, null, 4))
|
||||
}
|
||||
return Promise.reject()
|
||||
})
|
||||
@ -186,12 +193,6 @@ module.exports = function() {
|
||||
.then(this.argv.resolve, this.argv.reject)
|
||||
}
|
||||
|
||||
this.updateValue = function(host, resource, key, value) {
|
||||
var body = {}
|
||||
_.set(body, key, value)
|
||||
doRequest(host, resource, null, { method: 'PATCH', body: body })
|
||||
}
|
||||
|
||||
this.logError = function(err) {
|
||||
this.logger.error(colors.red('Error:'), err)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ program
|
||||
.option('h', {
|
||||
alias: 'hosts',
|
||||
describe: 'List of MaxScale hosts. The hosts must be in ' +
|
||||
'<hostname>:<port> format and each host must be separated by spaces.',
|
||||
'HOST:PORT format and each value must be separated by spaces.',
|
||||
default: 'localhost:8989',
|
||||
type: 'array'
|
||||
})
|
||||
|
@ -18,24 +18,29 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('server <server> <key> <value>', 'Alter server parameters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('servers/' + argv.server, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'servers/' + argv.server, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.command('monitor <monitor> <key> <value>', 'Alter monitor parameters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('monitors/' + argv.monitor, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'monitors/' + argv.monitor, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.command('service <service> <key> <value>', 'Alter service parameters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('services/' + argv.service, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'services/' + argv.service, 'data.attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.command('logging <key> <value>', 'Alter logging parameters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'attributes.parameters.' + argv.key, argv.value)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.command('maxscale <key> <value>', 'Alter MaxScale parameters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale', 'attributes.parameters.' + argv.key, argv.value)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale', 'attributes.parameters.' + argv.key, argv.value)
|
||||
})
|
||||
})
|
||||
.usage('Usage: alter <command>')
|
||||
.help()
|
||||
|
@ -18,10 +18,9 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('command <module> <command> [parameters...]', 'Call a module command', {}, function(argv) {
|
||||
|
||||
// First we have to find the correct method to use
|
||||
maxctrl(argv)
|
||||
.doRequest('maxscale/modules/' + argv.module + '/', function(resp) {
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'maxscale/modules/' + argv.module + '/', function(resp) {
|
||||
|
||||
// A GET request will return the correct error if the command is not found
|
||||
var verb = 'GET'
|
||||
@ -32,12 +31,12 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
})
|
||||
|
||||
return maxctrl
|
||||
.doAsyncRequest('maxscale/modules/' + argv.module + '/' + argv.command + '?' + argv.parameters.join('&'),
|
||||
function(resp) {
|
||||
logger.log(JSON.stringify(resp, null, 4))
|
||||
}, { method: verb })
|
||||
return doAsyncRequest(host, 'maxscale/modules/' + argv.module + '/' + argv.command + '?' + argv.parameters.join('&'),
|
||||
function(resp) {
|
||||
logger.log(JSON.stringify(resp, null, 4))
|
||||
}, { method: verb })
|
||||
})
|
||||
})
|
||||
})
|
||||
.usage('Usage: call <command>')
|
||||
.help()
|
||||
|
@ -19,8 +19,9 @@ exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('server <server> <state>', 'Clear server state', {}, function(argv) {
|
||||
var target = 'servers/' + argv.server + '/clear?state=' + argv.state
|
||||
maxctrl(argv)
|
||||
.doRequest(target, null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, target, null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: clear <command>')
|
||||
.help()
|
||||
|
@ -71,8 +71,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
maxctrl(argv)
|
||||
.doRequest('servers', null, {method: 'POST', body: server})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'servers', null, {method: 'POST', body: server})
|
||||
})
|
||||
})
|
||||
|
||||
// Create monitor
|
||||
@ -98,8 +99,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
maxctrl(argv)
|
||||
.doRequest('monitors', null, {method: 'POST', body: monitor})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'monitors', null, {method: 'POST', body: monitor})
|
||||
})
|
||||
})
|
||||
|
||||
// Create listener
|
||||
@ -159,8 +161,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
maxctrl(argv)
|
||||
.doRequest('services/' + argv.service + '/listeners', null, {method: 'POST', body: listener})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/' + argv.service + '/listeners', null, {method: 'POST', body: listener})
|
||||
})
|
||||
})
|
||||
.command('user <name> <password>', 'Create a new network user', {}, function(argv) {
|
||||
|
||||
@ -174,8 +177,9 @@ exports.builder = function(yargs) {
|
||||
}
|
||||
}
|
||||
|
||||
maxctrl(argv)
|
||||
.doRequest('users/inet', null, {method: 'POST', body: user})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'users/inet', null, {method: 'POST', body: user})
|
||||
})
|
||||
})
|
||||
|
||||
.usage('Usage: create <command>')
|
||||
|
@ -18,20 +18,24 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('server <name>', 'Destroy an unused server', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('servers/' + argv.name, null, {method: 'DELETE'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'servers/' + argv.name, null, {method: 'DELETE'})
|
||||
})
|
||||
})
|
||||
.command('monitor <name>', 'Destroy an unused monitor', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('monitors/' + argv.name, null, {method: 'DELETE'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'monitors/' + argv.name, null, {method: 'DELETE'})
|
||||
})
|
||||
})
|
||||
.command('listener <service> <name>', 'Destroy an unused listener', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('services/' + argv.service + '/listeners/' + argv.name, null, {method: 'DELETE'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/' + argv.service + '/listeners/' + argv.name, null, {method: 'DELETE'})
|
||||
})
|
||||
})
|
||||
.command('user <name>', 'Remove a network user', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('users/inet/' + argv.name, null, {method: 'DELETE'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'users/inet/' + argv.name, null, {method: 'DELETE'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: destroy <command>')
|
||||
.help()
|
||||
|
@ -26,24 +26,30 @@ 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) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.log_' + argv.log, false)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.log_' + argv.log, false)
|
||||
})
|
||||
} else {
|
||||
maxctrl(argv)
|
||||
.error('Invalid log priority: ' + argv.log);
|
||||
maxctrl(argv, function() {
|
||||
error('Invalid log priority: ' + argv.log)
|
||||
return Promise.reject()
|
||||
})
|
||||
}
|
||||
})
|
||||
.command('maxlog', 'Disable MaxScale logging', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.maxlog', false)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.maxlog', false)
|
||||
})
|
||||
})
|
||||
.command('syslog', 'Disable syslog logging', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.syslog', false)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.syslog', false)
|
||||
})
|
||||
})
|
||||
.command('account <name>', 'Disable a Linux user account from administrative use', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('users/unix/' + argv.name, null, { method: 'DELETE'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'users/unix/' + argv.name, null, { method: 'DELETE'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: disable <command>')
|
||||
.help()
|
||||
|
@ -26,20 +26,25 @@ exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('log-priority <log>', 'Enable log priority [warning|notice|info|debug]', {}, function(argv) {
|
||||
if (log_levels.indexOf(argv.log) != -1) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.log_' + argv.log, true)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.log_' + argv.log, true)
|
||||
})
|
||||
} else {
|
||||
maxctrl(argv)
|
||||
.error('Invalid log priority: ' + argv.log);
|
||||
maxctrl(argv, function() {
|
||||
error('Invalid log priority: ' + argv.log)
|
||||
return Promise.reject()
|
||||
})
|
||||
}
|
||||
})
|
||||
.command('maxlog', 'Enable MaxScale logging', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.maxlog', true)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.maxlog', true)
|
||||
})
|
||||
})
|
||||
.command('syslog', 'Enable syslog logging', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.updateValue('maxscale/logs', 'data.attributes.parameters.syslog', true)
|
||||
maxctrl(argv, function(host) {
|
||||
return updateValue(host, 'maxscale/logs', 'data.attributes.parameters.syslog', true)
|
||||
})
|
||||
})
|
||||
.command('account <name>', 'Activate a Linux user account for administrative use', {}, function(argv) {
|
||||
var req_body = {
|
||||
@ -48,8 +53,9 @@ exports.builder = function(yargs) {
|
||||
type: 'unix'
|
||||
}
|
||||
}
|
||||
maxctrl(argv)
|
||||
.doRequest('users/unix', null, { method: 'POST', body: req_body})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'users/unix', null, { method: 'POST', body: req_body})
|
||||
})
|
||||
})
|
||||
.usage('Usage: enable <command>')
|
||||
.help()
|
||||
|
@ -13,8 +13,8 @@
|
||||
require('../common.js')()
|
||||
|
||||
function addServer(argv, path, targets) {
|
||||
maxctrl(argv)
|
||||
.doRequest(path, function(res) {
|
||||
maxctrl(argv, function(host){
|
||||
return doRequest(host, path, function(res) {
|
||||
var servers =_.get(res, 'data.relationships.servers.data', [])
|
||||
|
||||
targets.forEach(function(i){
|
||||
@ -25,9 +25,9 @@ function addServer(argv, path, targets) {
|
||||
_.set(res, 'data.relationships.servers.data', servers)
|
||||
delete res.data.attributes
|
||||
|
||||
return maxctrl(argv)
|
||||
.doAsyncRequest(path, null, {method: 'PATCH', body: res})
|
||||
return doAsyncRequest(host, path, null, {method: 'PATCH', body: res})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.command = 'link <command>'
|
||||
|
@ -19,70 +19,78 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('servers', 'List servers', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('servers', [
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'servers', [
|
||||
{'Server': 'id'},
|
||||
{'Address': 'attributes.parameters.address'},
|
||||
{'Port': 'attributes.parameters.port'},
|
||||
{'Connections': 'attributes.statistics.connections'},
|
||||
{'State': 'attributes.state'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('services', 'List services', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('services',[
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'services',[
|
||||
{'Service': 'id'},
|
||||
{'Router': 'attributes.router'},
|
||||
{'Connections': 'attributes.connections'},
|
||||
{'Total Connections': 'attributes.total_connections'},
|
||||
{'Servers': 'relationships.servers.data[].id'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('monitors', 'List monitors', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('monitors', [
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'monitors', [
|
||||
{'Monitor': 'id'},
|
||||
{'State': 'attributes.state'},
|
||||
{'Servers': 'relationships.servers.data[].id'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('sessions', 'List sessions', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('sessions',[
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'sessions',[
|
||||
{'Id': 'id'},
|
||||
{'Service': 'relationships.services.data[].id'},
|
||||
{'User': 'attributes.user'},
|
||||
{'Host': 'attributes.remote'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('filters', 'List filters', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('filters', [
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'filters', [
|
||||
{'Filter': 'id'},
|
||||
{'Service': 'relationships.services.data[].id'},
|
||||
{'Module': 'attributes.module'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('modules', 'List loaded modules', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('maxscale/modules',[
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'maxscale/modules',[
|
||||
{'Module':'id'},
|
||||
{'Type':'attributes.module_type'},
|
||||
{'Version': 'attributes.version'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('users', 'List created network users', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('users/inet',[
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'users/inet',[
|
||||
{'Name':'id'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('commands', 'List module commands', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getCollection('maxscale/modules',[
|
||||
maxctrl(argv, function(host) {
|
||||
return getCollection(host, 'maxscale/modules',[
|
||||
{'Module':'id'},
|
||||
{'Commands': 'attributes.commands[].id'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.usage('Usage: list <command>')
|
||||
.help()
|
||||
|
@ -18,8 +18,9 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('logs', 'Rotate log files by closing and reopening the files', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('maxscale/logs/flush/', null, {method: 'POST'})
|
||||
maxctrl(argv, function(host){
|
||||
return doRequest(host, 'maxscale/logs/flush/', null, {method: 'POST'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: rotate <command>')
|
||||
.help()
|
||||
|
@ -19,8 +19,9 @@ exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('server <server> <state>', 'Set server state', {}, function(argv) {
|
||||
var target = 'servers/' + argv.server + '/set?state=' + argv.state
|
||||
maxctrl(argv)
|
||||
.doRequest(target, null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, target, null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: set <command>')
|
||||
.help()
|
||||
|
@ -19,8 +19,8 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('server <server>', 'Show server', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('servers/' + argv.server, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'servers/' + argv.server, [
|
||||
{'Server': 'id'},
|
||||
{'Address': 'attributes.parameters.address'},
|
||||
{'Port': 'attributes.parameters.port'},
|
||||
@ -33,10 +33,11 @@ exports.builder = function(yargs) {
|
||||
{'Statistics': 'attributes.statistics'},
|
||||
{'Parameters': 'attributes.parameters'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('service <service>', 'Show service', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('services/' + argv.service, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'services/' + argv.service, [
|
||||
{'Service': 'id'},
|
||||
{'Router': 'attributes.router'},
|
||||
{'State': 'attributes.state'},
|
||||
@ -47,20 +48,22 @@ exports.builder = function(yargs) {
|
||||
{'Parameters': 'attributes.parameters'},
|
||||
{'Router Diagnostics': 'attributes.router_diagnostics'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('monitor <monitor>', 'Show monitor', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('monitors/' + argv.monitor, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'monitors/' + argv.monitor, [
|
||||
{'Monitor': 'id'},
|
||||
{'State': 'attributes.state'},
|
||||
{'Servers': 'relationships.servers.data[].id'},
|
||||
{'Parameters': 'attributes.parameters'},
|
||||
{'Monitor Diagnostics': 'attributes.monitor_diagnostics'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('session <session>', 'Show session', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('sessions/' + argv.session, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'sessions/' + argv.session, [
|
||||
{'Id': 'id'},
|
||||
{'Service': 'relationships.services.data[].id'},
|
||||
{'State': 'attributes.state'},
|
||||
@ -69,19 +72,21 @@ exports.builder = function(yargs) {
|
||||
{'Connected': 'attributes.connected'},
|
||||
{'Idle': 'attributes.idle'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('filter <filter>', 'Show filter', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('filters/' + argv.filter, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'filters/' + argv.filter, [
|
||||
{'Filter': 'id'},
|
||||
{'Module': 'attributes.module'},
|
||||
{'Services': 'relationships.services.data[].id'},
|
||||
{'Parameters': 'attributes.parameters'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('module <module>', 'Show loaded module', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('maxscale/modules/' + argv.module, [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'maxscale/modules/' + argv.module, [
|
||||
{'Module': 'id'},
|
||||
{'Type': 'attributes.module_type'},
|
||||
{'Version': 'attributes.version'},
|
||||
@ -90,23 +95,26 @@ exports.builder = function(yargs) {
|
||||
{'Parameters': 'attributes.parameters'},
|
||||
{'Commands': 'attributes.commands'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('maxscale', 'Show MaxScale information', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getResource('maxscale', [
|
||||
maxctrl(argv, function(host) {
|
||||
return getResource(host, 'maxscale', [
|
||||
{'Version': 'attributes.version'},
|
||||
{'Commit': 'attributes.commit'},
|
||||
{'Started At': 'attributes.started_at'},
|
||||
{'Uptime': 'attributes.uptime'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.command('commands <module>', 'Show module commands of a module', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.getSubCollection('maxscale/modules/' + argv.module, 'attributes.commands', [
|
||||
maxctrl(argv, function(host) {
|
||||
return getSubCollection(host, 'maxscale/modules/' + argv.module, 'attributes.commands', [
|
||||
{'Command': 'id'},
|
||||
{'Parameters': 'attributes.parameters[].type'},
|
||||
{'Descriptions': 'attributes.parameters[].description'}
|
||||
])
|
||||
})
|
||||
})
|
||||
.usage('Usage: show <command>')
|
||||
.help()
|
||||
|
@ -18,12 +18,14 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('service <name>', 'Start a service', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('services/' + argv.name + '/start', null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/' + argv.name + '/start', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.command('monitor <name>', 'Start a monitor', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('monitors/' + argv.name + '/start', null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'monitors/' + argv.name + '/start', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: start <command>')
|
||||
.help()
|
||||
|
@ -18,12 +18,14 @@ exports.handler = function() {}
|
||||
exports.builder = function(yargs) {
|
||||
yargs
|
||||
.command('service <name>', 'Stop a service', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('services/' + argv.name + '/stop', null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'services/' + argv.name + '/stop', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.command('monitor <name>', 'Stop a monitor', {}, function(argv) {
|
||||
maxctrl(argv)
|
||||
.doRequest('monitors/' + argv.name + '/stop', null, {method: 'PUT'})
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, 'monitors/' + argv.name + '/stop', null, {method: 'PUT'})
|
||||
})
|
||||
})
|
||||
.usage('Usage: stop <command>')
|
||||
.help()
|
||||
|
@ -13,8 +13,8 @@
|
||||
require('../common.js')()
|
||||
|
||||
function removeServer(argv, path, targets) {
|
||||
maxctrl(argv)
|
||||
.doRequest(path, function(res) {
|
||||
maxctrl(argv, function(host) {
|
||||
return doRequest(host, path, function(res) {
|
||||
var servers =_.get(res, 'data.relationships.servers.data', [])
|
||||
|
||||
_.remove(servers, function(i) {
|
||||
@ -25,9 +25,9 @@ function removeServer(argv, path, targets) {
|
||||
_.set(res, 'data.relationships.servers.data', servers)
|
||||
delete res.data.attributes
|
||||
|
||||
return maxctrl(argv)
|
||||
.doAsyncRequest(path, null, {method: 'PATCH', body: res})
|
||||
return doAsyncRequest(host, path, null, {method: 'PATCH', body: res})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.command = 'unlink <command>'
|
||||
|
@ -23,4 +23,12 @@ if (process.argv[0] == process.execPath) {
|
||||
}
|
||||
|
||||
maxctrl.execute(process.argv)
|
||||
.then(function(out) {}, function(out) {})
|
||||
.then(function(out) {
|
||||
if (out) {
|
||||
console.log(out)
|
||||
}
|
||||
}, function(out) {
|
||||
if (out) {
|
||||
console.log(out)
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user