route.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. 'use strict';
  2. 'require view';
  3. 'require ui';
  4. 'require form';
  5. 'require uci';
  6. 'require tools.widgets as widgets';
  7. return view.extend({
  8. load: function() {
  9. return Promise.all([
  10. uci.load('keepalived'),
  11. ]);
  12. },
  13. renderRoute: function(m) {
  14. var s, o;
  15. s = m.section(form.GridSection, 'route', _('Routes'),
  16. _('Routes would be referenced into Static and Virtual Routes of VRRP instances'));
  17. s.anonymous = true;
  18. s.addremove = true;
  19. s.nodescriptions = true;
  20. o = s.option(form.Value, 'name', _('Name'));
  21. o.optional = false;
  22. o.placeholder = 'name';
  23. o = s.option(widgets.DeviceSelect, 'device', _('Device'),
  24. _('Device to use for Routing'));
  25. o.optional = true;
  26. o.noaliases = true;
  27. o = s.option(form.Value, 'address', _('Target/Destination'),
  28. _('Target IP Address of the Route'));
  29. o.optional = true;
  30. o.datatype = 'ipaddr';
  31. o.placeholder = '192.168.1.1';
  32. o = s.option(form.Value, 'src_addr', _('Source Address'),
  33. _('Source Address of the Route'));
  34. o.optional = true;
  35. o.datatype = 'ipaddr';
  36. o.placeholder = '192.168.1.1';
  37. o = s.option(form.Value, 'gateway', _('Gateway'),
  38. _('Gateway to use for the Route'));
  39. o.optional = true;
  40. o.datatype = 'ipaddr';
  41. o.placeholder = '192.168.1.1';
  42. o = s.option(form.Value, 'table', _('Route Table'),
  43. _('System Route Table'));
  44. o.value('default', _('default'));
  45. o.value('Main', _('Main'));
  46. o.optional = true;
  47. o = s.option(form.Flag, 'blackhole', _('Blackhole'));
  48. o.optional = true;
  49. o.placeholder = 'name';
  50. },
  51. renderStaticRoutes: function(m) {
  52. var s, o;
  53. var route;
  54. route = uci.sections('keepalived', 'route');
  55. if (route == '') {
  56. ui.addNotification(null, E('p', _('Routes must be configured for Static Routes')));
  57. }
  58. s = m.section(form.GridSection, 'static_routes', _('Static Routes'),
  59. _('Static Routes are not moved by vrrpd, they stay on the machine.') + '<br/>' +
  60. _('If you already have routes on your machines and your machines can ping each other, you don\'t need this section'));
  61. s.anonymous = true;
  62. s.addremove = true;
  63. s.nodescriptions = true;
  64. o = s.option(form.DynamicList, 'route', _('Route'),
  65. _('List of Route Object'));
  66. for (var i = 0; i < route.length; i++) {
  67. o.value(route[i]['name']);
  68. }
  69. o.optional = true;
  70. },
  71. render: function() {
  72. var m;
  73. m = new form.Map('keepalived');
  74. this.renderRoute(m);
  75. this.renderStaticRoutes(m);
  76. return m.render();
  77. }
  78. });