MXS-1300: Add module commands to MaxCtrl
Added inspection of module commands to MaxCtrl. The commands can't be called yet.
This commit is contained in:
@ -53,6 +53,40 @@ module.exports = function() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request a part of a resource as a collection
|
||||||
|
this.getSubCollection = function (resource, subres, fields) {
|
||||||
|
|
||||||
|
doRequest(resource, function(res) {
|
||||||
|
|
||||||
|
var header = []
|
||||||
|
|
||||||
|
fields.forEach(function(i) {
|
||||||
|
header.push(Object.keys(i))
|
||||||
|
})
|
||||||
|
|
||||||
|
var table = getTable(header)
|
||||||
|
|
||||||
|
_.getPath(res.data, subres, []).forEach(function(i) {
|
||||||
|
row = []
|
||||||
|
|
||||||
|
fields.forEach(function(p) {
|
||||||
|
var v = _.getPath(i, p[Object.keys(p)[0]], '')
|
||||||
|
|
||||||
|
if (Array.isArray(v) && typeof(v[0]) != 'object') {
|
||||||
|
v = v.join(', ')
|
||||||
|
} else if (typeof(v) == 'object') {
|
||||||
|
v = JSON.stringify(v, null, 4)
|
||||||
|
}
|
||||||
|
row.push(v)
|
||||||
|
})
|
||||||
|
|
||||||
|
table.push(row)
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(table.toString())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Request a single resource and format it as a key-value list
|
// Request a single resource and format it as a key-value list
|
||||||
this.getResource = function (resource, fields) {
|
this.getResource = function (resource, fields) {
|
||||||
|
|
||||||
|
@ -70,6 +70,12 @@ exports.builder = function(yargs) {
|
|||||||
{'Name':'id'}
|
{'Name':'id'}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
.command('commands', 'List module commands', {}, function() {
|
||||||
|
getCollection('maxscale/modules',[
|
||||||
|
{'Module':'id'},
|
||||||
|
{'Commands': 'attributes.commands[].id'}
|
||||||
|
])
|
||||||
|
})
|
||||||
.usage('Usage: list <command>')
|
.usage('Usage: list <command>')
|
||||||
.help()
|
.help()
|
||||||
.command('*', 'the default command', {}, () => {
|
.command('*', 'the default command', {}, () => {
|
||||||
|
@ -93,6 +93,13 @@ exports.builder = function(yargs) {
|
|||||||
{'Uptime': 'attributes.uptime'}
|
{'Uptime': 'attributes.uptime'}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
.command('commands <module>', 'Show module commands of a module', {}, function(argv) {
|
||||||
|
getSubCollection('maxscale/modules/' + argv.module, 'attributes.commands', [
|
||||||
|
{'Command': 'id'},
|
||||||
|
{'Parameters': 'attributes.parameters[].type'},
|
||||||
|
{'Descriptions': 'attributes.parameters[].description'}
|
||||||
|
])
|
||||||
|
})
|
||||||
.usage('Usage: show <command>')
|
.usage('Usage: show <command>')
|
||||||
.help()
|
.help()
|
||||||
.command('*', 'the default command', {}, () => {
|
.command('*', 'the default command', {}, () => {
|
||||||
|
Reference in New Issue
Block a user