MXS-1300: Add creation/deletion of listeners to cluster sync
New listeners are created and old ones removed. As listeners cannot yet be altered via the REST API, differing listeners are not modified.
This commit is contained in:
@ -145,7 +145,6 @@ exports.builder = function(yargs) {
|
|||||||
})
|
})
|
||||||
.command('sync <target>', 'Synchronize the cluster with target MaxScale server.', {}, function(argv) {
|
.command('sync <target>', 'Synchronize the cluster with target MaxScale server.', {}, function(argv) {
|
||||||
maxctrl(argv, function(host) {
|
maxctrl(argv, function(host) {
|
||||||
// TODO: Create new listeners
|
|
||||||
return getDiffs(argv.target, host)
|
return getDiffs(argv.target, host)
|
||||||
.then(function(diffs) {
|
.then(function(diffs) {
|
||||||
var promises = []
|
var promises = []
|
||||||
@ -198,6 +197,24 @@ exports.builder = function(yargs) {
|
|||||||
})
|
})
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
})
|
})
|
||||||
|
.then(function() {
|
||||||
|
// Add new and delete old listeners
|
||||||
|
var promises = []
|
||||||
|
var all_keys = _.concat(Object.keys(src), Object.keys(dest))
|
||||||
|
var unwanted_keys = _.concat(collections, endpoints)
|
||||||
|
var relevant_keys = _.uniq(_.difference(all_keys, unwanted_keys))
|
||||||
|
|
||||||
|
relevant_keys.forEach(function(i) {
|
||||||
|
getDifference(dest[i].data, src[i].data).forEach(function(j) {
|
||||||
|
promises.push(doAsyncRequest(host, i + '/' + j.id, null, {method: 'DELETE'}))
|
||||||
|
})
|
||||||
|
getDifference(src[i].data, dest[i].data).forEach(function(j) {
|
||||||
|
promises.push(doAsyncRequest(host, i, null, {method: 'POST', body: {data: j}}))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return Promise.all(promises)
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
var promises = []
|
var promises = []
|
||||||
// PATCH all remaining resource collections in src from dest apart from the
|
// PATCH all remaining resource collections in src from dest apart from the
|
||||||
|
Reference in New Issue
Block a user