peers.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. 'use strict';
  2. 'require view';
  3. 'require form';
  4. 'require rpc';
  5. return view.extend({
  6. callHostHints: rpc.declare({
  7. object: 'luci-rpc',
  8. method: 'getHostHints',
  9. expect: { '': {} }
  10. }),
  11. load: function() {
  12. return Promise.all([
  13. this.callHostHints(),
  14. ]);
  15. },
  16. render: function(data) {
  17. var hosts = data[0];
  18. let m, s, o;
  19. m = new form.Map('keepalived');
  20. s = m.section(form.GridSection, 'peer', _('Peers'),
  21. _('Peers can be referenced into Instances cluster and data/config synchronization'));
  22. s.anonymous = true;
  23. s.addremove = true;
  24. s.nodescriptions = true;
  25. o = s.option(form.Value, 'name', _('Name'));
  26. o.optional = false;
  27. o.placeholder = 'name';
  28. o = s.option(form.Value, 'address', _('Peer Address'));
  29. o.optional = false;
  30. o.rmempty = false;
  31. o.datatype = 'ipaddr';
  32. for(var mac in hosts) {
  33. if (hosts[mac]['ipaddrs'] == 'undefined') {
  34. continue;
  35. }
  36. for(var i = 0; i < hosts[mac]['ipaddrs'].length; i++) {
  37. o.value(hosts[mac]['ipaddrs'][i]);
  38. }
  39. }
  40. o = s.option(form.Flag, 'sync', _('Enable Sync'),
  41. _('Auto Synchonize Config/Data files with peer'));
  42. o = s.option(form.ListValue, 'sync_mode', _('Sync Mode'),
  43. _('Current System should act as Sender/Receiver.') + '<br/>' +
  44. _('If peer is backup node, Current system should be sender, If peer is master current system should be receiver'));
  45. o.value('send', _('Sender'));
  46. o.value('receive', _('Receiver'));
  47. o.default = 'send';
  48. o.depends({ 'sync' : '1' });
  49. o = s.option(form.Value, 'ssh_port', _('SSH Port'),
  50. _('If peer runs on non standard ssh port, change to correct ssh port number'));
  51. o.datatype = 'port';
  52. o.default = '22';
  53. o.modalonly = true;
  54. o.depends({ 'sync' : '1', 'sync_mode' : 'send' });
  55. o = s.option(form.Value, 'sync_dir', _('Sync Directory'),
  56. _('Sender will send files to this location of receiver. Must be same on Master/Backup'));
  57. o.default = '/usr/share/keepalived/rsync';
  58. o.optional = false;
  59. o.rmempty = false;
  60. o.modalonly = true;
  61. o.datatype = 'directory';
  62. o.depends({ 'sync' : '1' });
  63. o = s.option(form.FileUpload, 'ssh_key', _('Path to SSH Private Key'),
  64. _('Use SSH key for password less authentication, SSH Key would be used on current system'));
  65. o.root_directory = '/etc/keepalived/keys';
  66. o.enable_upload = true;
  67. o.modalonly = true;
  68. o.datatype = 'file';
  69. o.depends({ 'sync' : '1', 'sync_mode' : 'send' });
  70. o = s.option(form.TextValue, 'ssh_pubkey', _('SSH Public Key'),
  71. _('Authorize ssh public key of peer'));
  72. o.datatype = 'string';
  73. o.modalonly = true;
  74. o.depends({ 'sync' : '1', 'sync_mode' : 'receive' });
  75. o = s.option(form.DynamicList, 'sync_list', _('Sync Files'),
  76. _('Additional files to synchronize, By default it synchronizes sysupgrade backup files'));
  77. o.datatype = 'file';
  78. o.modalonly = true;
  79. o.depends({ 'sync' : '1', 'sync_mode' : 'send' });
  80. return m.render();
  81. }
  82. });