MXS-1929: Add parameters to maxctrl create monitor

The parameters for the monitor can now be defined when the monitor is
created. This makes the filter, monitor and service creation consistent.
This commit is contained in:
Markus Mäkelä 2018-08-22 22:34:07 +03:00
parent 065ee50d53
commit befb25a14a
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 20 additions and 3 deletions

View File

@ -10,6 +10,12 @@ report at [Jira](https://jira.mariadb.org).
## Changed Features
### MaxCtrl `create monitor`
The `create monitor` command now accepts a list of key-value parameters that are
passed to the monitor as the last argument. This allows creation and
configuration of monitors in one command.
### `query_retries`
The default value of `query_retries` was changed from 0 to 1. This turns

View File

@ -142,10 +142,12 @@ exports.builder = function(yargs) {
describe: 'Password for the monitor user',
type: 'string'
})
.command('monitor <name> <module>', 'Create a new monitor', function(yargs) {
.command('monitor <name> <module> [params...]', 'Create a new monitor', function(yargs) {
return yargs.epilog('The list of servers given with the --servers option should not ' +
'contain any servers that are already monitored by another monitor.')
.usage('Usage: create monitor <name> <module>')
'contain any servers that are already monitored by another monitor. ' +
'The last argument to this command is a list of key=value parameters ' +
'given as the monitor parameters.')
.usage('Usage: create monitor <name> <module> [params...]')
}, function(argv) {
var monitor = {
@ -157,6 +159,15 @@ exports.builder = function(yargs) {
}
}
if (argv.params) {
var err = validateParams(argv, argv.params)
if (err) {
return Promise.reject(err)
}
monitor.data.attributes.parameters = argv.params.reduce(to_obj, {})
}
if (argv.servers) {
for (i = 0; i < argv.servers.length; i++) {
_.set(monitor, 'data.relationships.servers.data[' + i + ']', {id: argv.servers[i], type: 'servers'})