diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2021-05-18 20:09:58 +0200 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2021-05-18 20:11:22 +0200 |
commit | bca76a767316a689d59dfd4974dcb7bfb04db1e8 (patch) | |
tree | db451bd134255dac41aeb2e13cc32920d2d17b55 /modules/luci-mod-network | |
parent | a90115cd82372eaaa0ed531800b568387e200c97 (diff) |
luci-mod-network: add bridge interface migration
LuCI now supports the updated UCI syntax for bridges that requires:
1. device section for L2
2. interface section for L3
Check for legacy syntax usage and offser user a migration to allow
changing network config.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'modules/luci-mod-network')
-rw-r--r-- | modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index 7de1e04ac2..4eccc0beb5 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -298,7 +298,52 @@ return view.extend({ ]); }, + interfaceWithIfnameSections: function() { + return uci.sections('network', 'interface').filter(function(ns) { + return ns.type == 'bridge' && !ns.ports && ns.ifname; + }); + }, + + handleMigration: function(ev) { + var interfaces = this.interfaceWithIfnameSections(); + var tasks = []; + + interfaces.forEach(function(ns) { + var device_name = 'br-' + ns['.name']; + + tasks.push(uci.callAdd('network', 'device', null, { + 'name': device_name, + 'type': 'bridge', + 'ports': L.toArray(ns.ifname) + })); + + tasks.push(uci.callSet('network', ns['.name'], { + 'type': '', + 'ifname': device_name + })); + }); + + return Promise.all(tasks) + .then(L.bind(ui.changes.init, ui.changes)) + .then(L.bind(ui.changes.apply, ui.changes)); + }, + + renderMigration: function() { + ui.showModal(_('Network bridge configuration migration'), [ + E('p', _('The existing network configuration needs to be changed for LuCI to function properly.')), + E('p', _('Upon pressing "Continue", bridges configuration will be moved from "interface" sections to "device" sections the network will be restarted to apply the updated configuration.')), + E('div', { 'class': 'right' }, + E('button', { + 'class': 'btn cbi-button-action important', + 'click': ui.createHandlerFn(this, 'handleMigration') + }, _('Continue'))) + ]); + }, + render: function(data) { + if (this.interfaceWithIfnameSections().length) + return this.renderMigration(); + var dslModemType = data[0], netDevs = data[1], m, s, o; |