MXS-2349: Add socket support for maxctrl
A server can now be created with a socket.
This commit is contained in:
@ -83,12 +83,12 @@ exports.builder = function(yargs) {
|
|||||||
describe: 'Link the created server to these monitors',
|
describe: 'Link the created server to these monitors',
|
||||||
type: 'array'
|
type: 'array'
|
||||||
})
|
})
|
||||||
.command('server <name> <host> <port>', 'Create a new server', function(yargs) {
|
.command('server <name> <host|socket> [port]', 'Create a new server', function(yargs) {
|
||||||
return yargs.epilog('The created server will not be used by any services or monitors ' +
|
return yargs.epilog('The created server will not be used by any services or monitors ' +
|
||||||
'unless the --services or --monitors options are given. The list ' +
|
'unless the --services or --monitors options are given. The list ' +
|
||||||
'of servers a service or a monitor uses can be altered with the ' +
|
'of servers a service or a monitor uses can be altered with the ' +
|
||||||
'`link` and `unlink` commands.')
|
'`link` and `unlink` commands.')
|
||||||
.usage('Usage: create server <name> <host> <port>')
|
.usage('Usage: create server <name> <host|socket> [port]')
|
||||||
}, function(argv) {
|
}, function(argv) {
|
||||||
var server = {
|
var server = {
|
||||||
'data': {
|
'data': {
|
||||||
@ -96,8 +96,6 @@ exports.builder = function(yargs) {
|
|||||||
'type': 'servers',
|
'type': 'servers',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'parameters': {
|
'parameters': {
|
||||||
'address': argv.host,
|
|
||||||
'port': argv.port,
|
|
||||||
'protocol': argv.protocol,
|
'protocol': argv.protocol,
|
||||||
'authenticator': argv.authenticator,
|
'authenticator': argv.authenticator,
|
||||||
'authenticator_options': argv.auth_options,
|
'authenticator_options': argv.auth_options,
|
||||||
@ -111,6 +109,13 @@ exports.builder = function(yargs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.host[0] == '/') {
|
||||||
|
server.data.attributes.parameters.socket = argv.host
|
||||||
|
} else {
|
||||||
|
server.data.attributes.parameters.address = argv.host
|
||||||
|
server.data.attributes.parameters.port = argv.port
|
||||||
|
}
|
||||||
|
|
||||||
if (argv.services) {
|
if (argv.services) {
|
||||||
for (i = 0; i < argv.services.length; i++) {
|
for (i = 0; i < argv.services.length; i++) {
|
||||||
_.set(server, 'data.relationships.services.data[' + i + ']', {id: argv.services[i], type: 'services'})
|
_.set(server, 'data.relationships.services.data[' + i + ']', {id: argv.services[i], type: 'services'})
|
||||||
|
@ -104,6 +104,12 @@ describe("Create/Destroy Commands", function() {
|
|||||||
.should.be.rejected
|
.should.be.rejected
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('create and destroy server with socket', function() {
|
||||||
|
return verifyCommand('create server server7 /tmp/server.sock', 'servers/server7')
|
||||||
|
.then(() => doCommand('destroy server server7'))
|
||||||
|
.should.be.fulfilled
|
||||||
|
})
|
||||||
|
|
||||||
it('create listener', function() {
|
it('create listener', function() {
|
||||||
return verifyCommand('create listener RW-Split-Router my-listener 4567',
|
return verifyCommand('create listener RW-Split-Router my-listener 4567',
|
||||||
'services/RW-Split-Router/listeners/my-listener')
|
'services/RW-Split-Router/listeners/my-listener')
|
||||||
|
Reference in New Issue
Block a user